Auditory-Biophysics-Lab / Slicer-ABLTemporalBoneSegmentation

3D Slicer extension featuring spacing resampling, fiducial registration, and rigid registration of temporal bone images.
BSD 3-Clause "New" or "Revised" License
16 stars 2 forks source link

Elastix compatibility "Too many samples map outside moving image buffer" #8

Open young-oct opened 1 year ago

young-oct commented 1 year ago

I was excited when I found out about this module, and thank you for all your work. Currently I'm stuck at step 2 and I got the error message saying: "command elsatix return to non-zero exit status 1 error."

Screenshot 2022-11-30 at 14 18 11

Any help is greatly appreciated. @ben-connors @jamesobutler @e-simpson

e-simpson commented 1 year ago

Hi @young-oct,

Thank you for bringing this to my attention. I've tested the module and was able to reproduce this issue.

It seems the Elastix module has changed the way it processes image registrations or the error handling it does since I last worked on this portion of the module. It seems a step has been removed that prevents an error that occurs when images are too far apart. There is a metric that Elastix computes that requires the images to reasonably close. A fiducial registration solves this, as it will register the images so that they are close enough for the rigid registration. Although, that is not working anymore.

I see in the screenshot above that you posted, you began to process the Step 1. Fiducial Registration, but did not Harden the change. In this way, the registration was not applied. Please see that once applied, the Moving Volume's name will have "_fiducial" appended to it. Give this a try.

Otherwise, the code will have to be updated to ensure additional checks or actions are performed before the Rigid Registration takes place.

As a last resort (no programming involved), you could potentially revert Slicer, Elastix Slicer Extension, and this module's primary Python dependencies (vtk, ctk, SimpleITK, and sitkUtils) to the versions that were available on Sep 1. 2020 (the last date I ensured the module was tested and working). To do this, you would need to get a custom python environment going and select the versions using python's PIP as well as installing a local copy of the Elastix slicer extension that was available on that day.

This issue has also been referenced in the following places:

e-simpson commented 1 year ago

Python error:

itk::ExceptionObject (0x600001ec12a0)
Location: "ElastixTemplate - Run()"
File: /Volumes/D/S/S-0-E-b/SlicerElastix-build/elastix/Common/CostFunctions/itkAdvancedImageToImageMetric.hxx
Line: 916
Description: ITK ERROR: AdvancedMattesMutualInformationMetric(0x7fa98701d400): Too many samples map outside moving image buffer: 151 / 1117

Error occurred during actual registration.

Errors occurred!
Error: Command 'elastix' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/Users/Home/Documents/Development/Personal/Slicer/Slicer-ABLTemporalBoneSegmentation/ABLTemporalBoneSegmentationModule/ABLTemporalBoneSegmentationModule.py", line 635, in process_transform
    output = function()
  File "/Users/Home/Documents/Development/Personal/Slicer/Slicer-ABLTemporalBoneSegmentation/ABLTemporalBoneSegmentationModule/ABLTemporalBoneSegmentationModule.py", line 808, in transform
    return ABLTemporalBoneSegmentationModuleLogic().apply_elastix_rigid_registration(elastix=self.elastixLogic,
  File "/Users/Home/Documents/Development/Personal/Slicer/Slicer-ABLTemporalBoneSegmentation/ABLTemporalBoneSegmentationModule/ABLTemporalBoneSegmentationModule.py", line 1324, in apply_elastix_rigid_registration
    elastix.registerVolumes(
  File "/Applications/Slicer.app/Contents/Extensions-31317/SlicerElastix/lib/Slicer-5.2/qt-scripted-modules/Elastix.py", line 818, in registerVolumes
    self.logProcessOutput(ep)
  File "/Applications/Slicer.app/Contents/Extensions-31317/SlicerElastix/lib/Slicer-5.2/qt-scripted-modules/Elastix.py", line 739, in logProcessOutput
    raise subprocess.CalledProcessError(return_code, "elastix")
subprocess.CalledProcessError: Command 'elastix' returned non-zero exit status 1.