Search code examples
pythonpydicom

Positional Argument error with pydicom.dcmread


I have just started playing around with the pydicom module. I've just tried to implement this example in PyCharm : https://pydicom.github.io/pydicom/dev/old/viewing_images.html

However, for some reason I keep getting this error: TypeError: new() missing 1 required positional argument: 'is_raw'.

I assume one of the functions dcmread is missing an output, but that is a bit weird to me since I am also using the same file used in the example. I've also tried using the good old IDLE but same problem.

Any help would be really appreciated!

code:

import matplotlib.pyplot as plt
import pydicom

ds = pydicom.dcmread("C:\\Users\\nicom\\Desktop\\Nico\\AE\\Minor BME\\Opdracht\\CT_small.dcm")
plt.imshow(ds.pixel_array, cmap=plt.cm.bone)

errors :

Traceback (most recent call last):
  File "C:/Users/nicom/PycharmProjects/Opdracht/DICOM readee.py", line 6, in <module>
    ds = pydicom.dcmread("C:\\Users\\nicom\\Desktop\\Nico\\AE\\Minor BME\\Opdracht\\CT_Scans\\EXP1_blind\\1003\\0.dcm")
  File "C:\Users\nicom\PycharmProjects\Opdracht\venv\lib\site-packages\pydicom\filereader.py", line 888, in dcmread
    force=force, specific_tags=specific_tags)
  File "C:\Users\nicom\PycharmProjects\Opdracht\venv\lib\site-packages\pydicom\filereader.py", line 672, in read_partial
    file_meta_dataset = _read_file_meta_info(fileobj)
  File "C:\Users\nicom\PycharmProjects\Opdracht\venv\lib\site-packages\pydicom\filereader.py", line 524, in _read_file_meta_info
    stop_when=_not_group_0002
  File "C:\Users\nicom\PycharmProjects\Opdracht\venv\lib\site-packages\pydicom\filereader.py", line 359, in read_dataset
    raw_data_element = next(de_gen)
  File "C:\Users\nicom\PycharmProjects\Opdracht\venv\lib\site-packages\pydicom\filereader.py", line 206, in data_element_generator
    is_implicit_VR, is_little_endian)
TypeError: __new__() missing 1 required positional argument: 'is_raw'

Solution

  • I think the problem is that default arguments for NamedTuple were only added in Python 3.6.1. If you're using 3.6.0 then I'd upgrade to a newer Python release if possible.