Dear All,
I am starting using itk with python, so it might sound silly, but I have the following problem.
I have installed itk using command:
python -m pip install itk
The packages have been successfully installed.
I tried the provided example:
import itk
input_filename = ‘/path_to_my_nifti file/.nii’
output_filename = '/path_to_another_nifti file/.nii’
image = itk.imread(input_filename)
median = itk.MedianImageFilter.New(image, Radius = 2)
itk.imwrite(median, output_filename)
And I am getting such an error:
File “itk_testing.py”, line 11, in
image = itk.imread(input_filename)
File “/home/adam/anaconda3/envs/itk_test_27/lib/python2.7/site-packages/itkExtras.py”, line 449, in imread
reader = itk.ImageFileReader.New(FileName=fileName)
File “/home/adam/anaconda3/envs/itk_test_27/lib/python2.7/site-packages/itkTemplate.py”, line 383, in New
return self._NewImageFileReader(*args, **kwargs)
File “/home/adam/anaconda3/envs/itk_test_27/lib/python2.7/site-packages/itkTemplate.py”, line 433, in _NewImageFileReader
ImageType = itk.Image[PixelType, dimension]
File “/home/adam/anaconda3/envs/itk_test_27/lib/python2.7/site-packages/itkTemplate.py”, line 274, in getitem
(str(parameters), self.name))
KeyError: ‘itkTemplate : No template (, 3) for the itk::Image class’
I tried it in virtual envs with both with python 2.7 and python 3.6.
I do not know if I understood correctly that I do not need to build ITK, and it is enough to pip install the libraries?
I do not have problems with using SimpleITK with python, but it does not have all the libraries that I need to use.
Could you please help me with that?
Cheers,
Adam