pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
103 stars 24 forks source link

Error occurence in the process of conducting linear_registration for 2D dicom image #206

Open ShangWeiKuo opened 1 year ago

ShangWeiKuo commented 1 year ago

Hello.

I tried conducting mask registration with two 2D dicom masks.

However. I got the error message which shows that The number of pixels along dimension 2 is less than 4.

How should I do to apply linear_registration to the 2D dicom files ?

This are my codes.

import SimpleITK as sitk
from platipy.imaging.registration.linear import linear_registration

bin_mask_1 = sitk.ReadImage(path_to_dcm_file, sitk.sitkUInt8)
bin_mask_2 = sitk.ReadImage(path_to_dcm_file, sitk.sitkUInt8)

bin_mask_2_reg, tfm = linear_registration(bin_mask_1, bin_mask_2)

This is the error message

RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_Execute: /tmp/SimpleITK-build/ITK-prefix/include/ITK-5.3/itkSmoothingRecursiveGaussianImageFilter.hxx:214:
ITK ERROR: SmoothingRecursiveGaussianImageFilter(0x55a03712d3e0): The number of pixels along dimension 2 is less than 4. This filter requires a minimum of four pixels along the dimension to be processed.

Thank you for your help in advance.

pchlap commented 1 year ago

Hi @ShangWeiKuo, to be honest our code in platipy doesn't support 2D data very well. This is because so far this has been used mostly for radiotherapy projects where we typically have 3D image volumes available.

We could probably amend the linear_registration function to support 2D, however @rnfinnegan and I don't have the capacity for this at the moment. We would be open to contributions from the community though.

This function relies entirely on SimpleITK, so I would recommend taking a look at that for the 2D registration use case. You should be able to get a registration running using SimpleITK directly. The class we use is ImageRegistrationMethod you can find the documentation here: https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html