SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
509 stars 149 forks source link

Writing DICOM series using SimpleITK doesn't work with the SimpleITK built with SimpleElastix #423

Open sarbabi opened 3 years ago

sarbabi commented 3 years ago

Hi, Actually I was trying to save the results of a registration task, to a DICOM series. This piece of code on SimpleITK should do the job, but it's not working returning the error message:

Traceback (most recent call last):
  File "example.py", line 111, in <module>
    writer.Execute(image_slice)
  File "Python39\lib\site-packages\simpleitk-2.0.0rc2.dev908+g8244e-py3.9-win-amd64.egg\SimpleITK\SimpleITK.py", line 8172, in Execute
    return _SimpleITK.ImageFileWriter_Execute(self, *args)
RuntimeError: Exception thrown in SimpleITK ImageFileWriter_Execute: \SimpleElastix\ITK\Modules\IO\GDCM\src\itkGDCMImageIO.cxx:1154:
itk::ERROR: GDCMImageIO(0000021536F5E630): A Floating point buffer was passed but the stored pixel type was not specified.This is currently not supported

I was wondering what would be the workaround for that?

I tried casting to avoid the type error like:

castFilter = sitk.CastImageFilter()
castFilter.SetOutputPixelType(sitk.sitkInt16)

# Convert floating type image (imgSmooth) to int type (imgFiltered)
filtered_image2 = castFilter.Execute(filtered_image)

but it's still has another issue, that the saved DICOM folder when opened in a DICOM viewer shows as a number of single slice images and not as one multi-slice image.

Best wishes, Saeed

jmaffie commented 1 year ago

I am having the same issue. Did you ever solve this I am having the same problem? Also the cast image filter seems to truncate the float to an integer so all pixels take on an integer value loosing alot of information.