long run-time issues medical image registration

I did the test and it works. It took nothing in term of memory…
The different bench of CT I am using are respectively :
443x209x580
485x245x624
536x536x419

The length of series_file_names correspond of the number of CT in the directory

print(len(series_file_names))
580

so i still don t know from where the error come from…

Ok, so it isn’t a memory issue as you were able to allocate an image that has the desired size. What I find interesting is that your CT scans seem to have very strange dimensions in the x and y axes. From commercial machines in clinical use these are usually 512x512, but definitely not 443x209 or 485x245, 536x536.

Were these images processed by some other software and cropped? Possibly something is problematic with one or more of the files
(corrupted for some reason). The next step in debugging is to try and read each of the images independently. Something like:

import glob
import SimpleITK as sitk

file_names = glob.glob('*.dcm')
for f in file_names: 
   sitk.ReadImage(f)

Please let us know if this exposes an issue or provide one of your failing datasets so that we can better identify the problem.

You could also try to read the DICOM series using 3D Slicer, and if it is problematic try DICOM patcher on it.

Ok so let me explain the strange dimensions.
These are indeed images processed from some other software : they are whole Body Phantom made by computer. While making them, we adjusted the size of the field of view to not have some aberrant CT, that s why they are different dimensions in x and y axes. So they are artificial CT

About the code you gave me to try, it works fine; there is no error showing up…
“Process finished with exit code 0”
So apparently, it can read all the 580 CT

Futhermore, i can read all of them on other softwere like 3D slicer or ImageJ or dicompyler
I just don t know why i cannot in my python s code?

Based on the information up to now it looks like none of the files is corrupted, you have enough memory on your machine, SimpleITK is able to read them individually…

The only difference that I can think of is that there is something strange going on with the strings returned by the sitk.ImageSeriesReader.GetGDCMSeriesFileNames. Other than this, we’d need access to the data to figure out what is going on.

Hmmm ok
Do you know an other way to read Dicom data with ITK ?
Like, can you suggest me, or do you have in mind, some other code lines to read my CT series ?

You could read it using Slicer, then save it as .nrrd image. Then your could would not have to deal with DICOM at all.

if I do that, whould I be able to read that .nrrd format with ITK ?

Yes, both ITK and SimpleITK read nrrd.

I saved them in .nrrd format like you said.
How can I read them with sitk ?
By using the function ‘sitk.ReadImage’ ?

Yes.

Will I have to change my code for that ?
Cause I tried it and I get an error…

ERROR:
File “C:/Users/PycharmProjects/sitk registration 2.py”, line 46, in
fixed = sitk.ReadImage(series_file_names, sitk.sitkFloat32)
File “C:\Users\Ibrahima.conda\envs\recalage\lib\site-packages\SimpleITK\SimpleITK.py”, line 8876, in ReadImage
return _SimpleITK.ReadImage(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function ‘ReadImage’.
Possible C/C++ prototypes are:
itk::simple::ReadImage(std::vector< std::string,std::allocator< std::string > > const &,itk::simple::PixelIDValueEnum,std::string const &)
itk::simple::ReadImage(std::string const &,itk::simple::PixelIDValueEnum,std::string const &)

The thing I change in my code above is :
A = “E:/IGR/1 11F06DD_Y5_M6_P50.nrrd”
series_file_names = sitk.ReadImage(A)
B = “E:/IGR/1 11F06DD_Y6_M0_P99.nrrd”
series_file_names2 = sitk.ReadImage(B)

ReadImage returns an image not a file name, just do:

A = “E:/IGR/1 11F06DD_Y5_M6_P50.nrrd”
B = “E:/IGR/1 11F06DD_Y6_M0_P99.nrrd”
fixed = sitk.ReadImage(A, sitk.sitkFloat32)
moving = sitk.ReadImage(B, sitk.sitkFloat32)

thanks ^^

But still having the same issue…
RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_Execute: d:\a\1\work\b\itk-prefix\include\itk-4.13\itkImportImageContainer.hxx:199:
Failed to allocate memory for image.

I am so fed up…

either with DICOM or .nrrd format

Perhaps you are only running 32-bit python? What is the output of:

import platform; print(platform.architecture())
1 Like

print(platform.architecture())
(‘32bit’, ‘WindowsPE’)

You should install 64-bit Python so you can access all of your memory and not be limited to 2-3GB.

I though I was on the good version but seems I wasn t …

Know it works well, thank you

3 posts were split to a new topic: Visualize registered images?