-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difficulties with unigradicon-warp #18
Comments
Thank you for the detailed report! We will work on this |
Hi! I have added a test to verify that unigradicon-warp works as expected on labelmaps, see #20 . I haven't been able to replicate your issue on a generic label map, so I need more information on the labelmap that is causing the code to break for you. Could you post the output of this code on your labelmap?
|
Thank you, I am actually working with a NIFTI file. Here it is.
|
Ok! The test now fails, matching your report. It looks like itk doesn't support warping signed int labelmaps, which is surprising but knowing ITK, not that surprising haha. A first pass at a solution is to add a flag for casting int labelmaps to a type that the InterpolateImageFilters support, such as float or double- perhaps with a cast back before saving the image- I will look in to this |
Hi! Your issues should now be fixed in the linked pull request. Until we merge it to main and update the pypi package, you can use it locally with
|
Yes, most likely the spacing, origin and direction of the segmentation mask should match the image- since they appear to have the same Size. Ideally this could be fixed in whatever software produced the mask, as whenever images get separated from their spatial metadata, bugs lurk. However, in this case just copying the image metadata onto the mask should work- just verify that they align after you do this operation, by for example opening both images in 3D Slicer which is a metadata-aware image viewer. to copy the metadata, something like In [8]: mask = itk.imread('mask'), img = itk.imread('img') In [9]: mask.SetOrigin(img.GetOrigin()) In [10]: mask.SetDirection(img.GetDirection()) In [11]: mask.SetSpacing(img.GetSpacing()) In [12]: itk.imwrite(mask, "mask_with_metadata.nrrd") |
Hi, thanks for making uniGradICON.
The instructions look simple enough and unigradicon-register works fine. However I'm having trouble with unigradicon-warp when trying to warp labels.
This works fine:
unigradicon-register --fixed=$fixed_image_file --fixed_modality=mri --moving=$moving_image_file --moving_modality=mri --transform_out=$transform_path --warped_moving_out=$warped_image_path --io_iterations None
This has issues:
unigradicon-warp --fixed $fixed_image_file --moving $moving_label_file --transform $transform_path --warped_moving_out $warped_label_path --nearest_neighbor
Issues:
File "/unigradicon_testing_space/github_pip/uniGradICON/src/unigradicon/init.py", line 312, in wa
rp_command
interpolator = itk.NearestNeighborInterpolateImageFunction.New(moving)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/unigradicon_conda/lib/python3.11/site-packages/itk/support/template_class.py", line 734, in New
raise itk.TemplateTypeError(self, input_type)
itk.support.extras.TemplateTypeError: itk.NearestNeighborInterpolateImageFunction is not wrapped for input type
None
.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:
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.NearestNeighborInterpolateImageFunction[itk.Image[itk.SS,2], itk.D].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 imagedimension you need. When configuring ITK with CMake, you can set
ITK_WRAP_${type}
(replace ${type} with appropriate pixel type such asdouble
). If you need to support images with 4 or 5 dimensions, you can addthese dimensions to the list of dimensions in the CMake variable
ITK_WRAP_IMAGE_DIMS
.Supported input types:
itk.Image[itk.SS,2]
itk.Image[itk.UC,2]
itk.Image[itk.US,2]
itk.Image[itk.F,2]
itk.Image[itk.D,2]
itk.Image[itk.Vector[itk.F,2],2]
itk.Image[itk.CovariantVector[itk.F,2],2]
itk.Image[itk.RGBPixel[itk.UC],2]
itk.Image[itk.RGBAPixel[itk.UC],2]
itk.Image[itk.SS,3]
itk.Image[itk.UC,3]
itk.Image[itk.US,3]
itk.Image[itk.F,3]
itk.Image[itk.D,3]
itk.Image[itk.Vector[itk.F,3],3]
itk.Image[itk.CovariantVector[itk.F,3],3]
itk.Image[itk.RGBPixel[itk.UC],3]
itk.Image[itk.RGBAPixel[itk.UC],3]
itk.Image[itk.SS,4]
itk.Image[itk.UC,4]
itk.Image[itk.US,4]
itk.Image[itk.F,4]
itk.Image[itk.D,4]
itk.Image[itk.Vector[itk.F,4],4]
itk.Image[itk.CovariantVector[itk.F,4],4]
itk.Image[itk.RGBPixel[itk.UC],4]
itk.Image[itk.RGBAPixel[itk.UC],4]
itk.PhasedArray3DSpecialCoordinatesImage[itk.F]
itk.PhasedArray3DSpecialCoordinatesImage[itk.UC]
The text was updated successfully, but these errors were encountered: