Hello. I am running into an error processing a medical image DICOM file from The Cancer Imaging Archive. When I call ITKReader.read() on the datapoint, the reader returns an error: KeyError: (<itkCType signed int>, 3).
The python SimpleITK library can load and process the data.
1. itk.imread(image_file)
Dicom file is loaded into an image.
Log from crash
>>> img[0]
'/nvdata/NSCLC-Radiogenomics-Fresh/NSCLC Radiogenomics/R01-041/09-07-1992-CT THORAX WO DYE-33339/4.000000-THIN LUNG WINDOW-58024/1-001.dcm'
>>> itk.imread(img[0])
Traceback (most recent call last):
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkTemplate.py", line 336, in __getitem__
return(self.__template__[tuple(cleanParameters)])
KeyError: (<itkCType signed int>, 3)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkTemplate.py", line 340, in __getitem__
return(self.__template__[tuple(cleanParameters)])
KeyError: (<itkCType signed int>, 3)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkExtras.py", line 645, in imread
reader = TemplateReaderType.New(**kwargs)
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkTemplate.py", line 469, in New
return self._NewImageReader(itk.ImageFileReader, False, 'FileName', *args, **kwargs)
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkTemplate.py", line 579, in _NewImageReader
ImageType = itk.Image[PixelType, dimension]
File "/home/gagan/anaconda3/envs/monai/lib/python3.8/site-packages/itkTemplate.py", line 342, in __getitem__
raise TemplateTypeError(self, tuple(cleanParameters))
itkTemplate.TemplateTypeError: itk.Image is not wrapped for input type `itk.SI, int`.
To limit the size of the package, only a limited number of
types are available in ITK Python. To print the supported
types, run the following command in your python environment:
itk.Image.GetTypes()
Possible solutions:
* If you are an application user:
** Convert your input image into a supported format (see below).
** Contact developer to report the issue.
* If you are an application developer, force input images to be
loaded in a supported pixel type.
e.g.: instance = itk.Image[itk.RGBPixel[itk.UC], int].New(my_input)
* (Advanced) If you are an application developer, build ITK Python yourself and
turned to `ON` the corresponding CMake option to wrap the pixel type or image
dimension you need. When configuring ITK with CMake, you can set
`ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as
`double`). If you need to support images with 4 or 5 dimensions, you can add
these dimensions to the list of dimensions in the CMake variable
`ITK_WRAP_IMAGE_DIMS`.
Supported input types:
I am using CT scan image data from this NSCLC Radiogenomics TCIA dataset. The error happens every time I try to load a file.
Debian Buster, Cmake == 3.16.3, itk == 5.1.1, python == 3.8.3
As the error message says, int is not wrapped by default to keep the package size reasonably small. Can you try reading it in as a larger type, e.g. long or long long?
PixelType = itk.LL
image = itk.imread(input_filename, PixelType)
See more in the quick start guide.
@thewtex I tought that reader and cast filter were wrapped for all the supported pixel types? Or nearly all, at least.
Thank you @dzenanz. I was able to load my images with a different pixeltype.
But my machine did not have itk.LL or itk.L datatypes.
I loaded my images in with itk.D <itkCType double>.