Elastix returned non-zero exit status 1

Hello
I also have some problem with this extension. Tried it yesterday twice on different CTs. I’m pasting whole code from python interaction. I think the problem is with elastix, it can’t get the measurements right. If you can help me I’d be grateful.

which elastix:   /Applications/Slicer.app/Contents/Extensions-30893/SlicerElastix/lib/Slicer-5.0/elastix
which elastix:   /Applications/Slicer.app/Contents/Extensions-30893/SlicerElastix/lib/Slicer-5.0/elastix
elastix runs at: Mac-mini-Micha.local
elastix runs at: Mac-mini-Micha.local
  macOS 12.6 (x64), 21G115
  macOS 12.6 (x64), 21G115
  with 8192 MB memory, and 8 cores @ 2400 MHz.
  with 8192 MB memory, and 8 cores @ 2400 MHz.
-------------------------------------------------------------------------
-------------------------------------------------------------------------


Running elastix with parameter file 0: "/Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/Resources/Parameters/Parameters_Rigid.txt".
Running elastix with parameter file 0: "/Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/Resources/Parameters/Parameters_Rigid.txt".


Current time: Sun Oct  2 08:45:18 2022.
Current time: Sun Oct  2 08:45:18 2022.
Reading the elastix parameters from file ...
Reading the elastix parameters from file ...


Installing all components.
Installing all components.
InstallingComponents was successful.
InstallingComponents was successful.


ELASTIX version: 5.0.1
ELASTIX version: 5.0.1
Command line options from ElastixBase:
Command line options from ElastixBase:
-f        /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/fixed.mha
-f        /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/fixed.mha
-m        /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/moving.mha
-m        /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/moving.mha
-fMask    /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/fixedMask.mha
-fMask    /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/fixedMask.mha
-mMask    /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/movingMask.mha
-mMask    /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/input/movingMask.mha
-out      /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/result-transform/
-out      /private/var/folders/l7/h7lnn18d3zdc6vc84b_yvcxc0000gn/T/Slicer-michalkaczmarczyk/Elastix/20221002_084517_248/result-transform/
-p        /Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/Resources/Parameters/Parameters_Rigid.txt
-p        /Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/Resources/Parameters/Parameters_Rigid.txt
-threads  unspecified, so all available threads are used
-threads  unspecified, so all available threads are used
WARNING: The parameter "UseDirectionCosines", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseDirectionCosines", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.


WARNING: The option "UseDirectionCosines" was not found in your parameter file.
WARNING: The option "UseDirectionCosines" was not found in your parameter file.
  From elastix 4.8 it defaults to true!
  From elastix 4.8 it defaults to true!
This may change the behavior of your registrations considerably.
This may change the behavior of your registrations considerably.


Command line options from TransformBase:
Command line options from TransformBase:
-t0       unspecified, so no initial transform used
-t0       unspecified, so no initial transform used


Reading images...
Reading images...
Reading images took 477 ms.
Reading images took 477 ms.


WARNING: the fixed pyramid schedule is not fully specified!
WARNING: the fixed pyramid schedule is not fully specified!
  A default pyramid schedule is used.
  A default pyramid schedule is used.
WARNING: the moving pyramid schedule is not fully specified!
WARNING: the moving pyramid schedule is not fully specified!
  A default pyramid schedule is used.
  A default pyramid schedule is used.
WARNING: The parameter "AutomaticTransformInitializationMethod", requested at entry number 0, does not exist at all.
WARNING: The parameter "AutomaticTransformInitializationMethod", requested at entry number 0, does not exist at all.
  The default value "GeometricalCenter" is used instead.
  The default value "GeometricalCenter" is used instead.
Transform parameters are initialized as: [0, 0, 0, -25.126531652343715, -31.40466437890626, -40.37869225390621]
Transform parameters are initialized as: [0, 0, 0, -25.126531652343715, -31.40466437890626, -40.37869225390621]
Scales are estimated automatically.
Scales are estimated automatically.
Scales for transform parameters are: [3401.561698635128, 3491.2521564018725, 2502.4099204386434, 1, 1, 1]
Scales for transform parameters are: [3401.561698635128, 3491.2521564018725, 2502.4099204386434, 1, 1, 1]
Initialization of all components (before registration) took: 9 ms.
Initialization of all components (before registration) took: 9 ms.
Preparation of the image pyramids took: 2600 ms.
Preparation of the image pyramids took: 2600 ms.


Resolution: 0
Resolution: 0
WARNING: The parameter "ShowExactMetricValue", requested at entry number 0, does not exist at all.
WARNING: The parameter "ShowExactMetricValue", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
WARNING: The parameter "CheckNumberOfSamples", requested at entry number 0, does not exist at all.
WARNING: The parameter "CheckNumberOfSamples", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.
WARNING: The parameter "UseMultiThreadingForMetrics", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseMultiThreadingForMetrics", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.
WARNING: The parameter "ErodeFixedMask", requested at entry number 0, does not exist at all.
WARNING: The parameter "ErodeFixedMask", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
WARNING: The parameter "ErodeMovingMask", requested at entry number 0, does not exist at all.
WARNING: The parameter "ErodeMovingMask", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
Setting the fixed masks took: 1 ms.
Setting the fixed masks took: 1 ms.
Setting the moving masks took: 0 ms.
Setting the moving masks took: 0 ms.
WARNING: The parameter "NumberOfFixedHistogramBins", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfFixedHistogramBins", requested at entry number 0, does not exist at all.
  The default value "32" is used instead.
  The default value "32" is used instead.
WARNING: The parameter "NumberOfMovingHistogramBins", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfMovingHistogramBins", requested at entry number 0, does not exist at all.
  The default value "32" is used instead.
  The default value "32" is used instead.
WARNING: The parameter "FixedLimitRangeRatio", requested at entry number 0, does not exist at all.
WARNING: The parameter "FixedLimitRangeRatio", requested at entry number 0, does not exist at all.
  The default value "0.01" is used instead.
  The default value "0.01" is used instead.
WARNING: The parameter "MovingLimitRangeRatio", requested at entry number 0, does not exist at all.
WARNING: The parameter "MovingLimitRangeRatio", requested at entry number 0, does not exist at all.
  The default value "0.01" is used instead.
  The default value "0.01" is used instead.
WARNING: The parameter "FixedKernelBSplineOrder", requested at entry number 0, does not exist at all.
WARNING: The parameter "FixedKernelBSplineOrder", requested at entry number 0, does not exist at all.
  The default value "0" is used instead.
  The default value "0" is used instead.
WARNING: The parameter "MovingKernelBSplineOrder", requested at entry number 0, does not exist at all.
WARNING: The parameter "MovingKernelBSplineOrder", requested at entry number 0, does not exist at all.
  The default value "3" is used instead.
  The default value "3" is used instead.
WARNING: The parameter "UseFastAndLowMemoryVersion", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseFastAndLowMemoryVersion", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.
WARNING: The parameter "UseJacobianPreconditioning", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseJacobianPreconditioning", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
WARNING: The parameter "FiniteDifferenceDerivative", requested at entry number 0, does not exist at all.
WARNING: The parameter "FiniteDifferenceDerivative", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
WARNING: The parameter "SP_A", requested at entry number 0, does not exist at all.
WARNING: The parameter "SP_A", requested at entry number 0, does not exist at all.
  The default value "20" is used instead.
  The default value "20" is used instead.
WARNING: The parameter "MaximumNumberOfSamplingAttempts", requested at entry number 0, does not exist at all.
WARNING: The parameter "MaximumNumberOfSamplingAttempts", requested at entry number 0, does not exist at all.
  The default value "0" is used instead.
  The default value "0" is used instead.
WARNING: The parameter "SigmoidInitialTime", requested at entry number 0, does not exist at all.
WARNING: The parameter "SigmoidInitialTime", requested at entry number 0, does not exist at all.
  The default value "0" is used instead.
  The default value "0" is used instead.
WARNING: The parameter "MaxBandCovSize", requested at entry number 0, does not exist at all.
WARNING: The parameter "MaxBandCovSize", requested at entry number 0, does not exist at all.
  The default value "192" is used instead.
  The default value "192" is used instead.
WARNING: The parameter "NumberOfBandStructureSamples", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfBandStructureSamples", requested at entry number 0, does not exist at all.
  The default value "10" is used instead.
  The default value "10" is used instead.
WARNING: The parameter "UseAdaptiveStepSizes", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseAdaptiveStepSizes", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.
WARNING: The parameter "AutomaticParameterEstimation", requested at entry number 0, does not exist at all.
WARNING: The parameter "AutomaticParameterEstimation", requested at entry number 0, does not exist at all.
  The default value "true" is used instead.
  The default value "true" is used instead.
WARNING: The parameter "UseConstantStep", requested at entry number 0, does not exist at all.
WARNING: The parameter "UseConstantStep", requested at entry number 0, does not exist at all.
  The default value "false" is used instead.
  The default value "false" is used instead.
WARNING: The parameter "MaximumStepLengthRatio", requested at entry number 0, does not exist at all.
WARNING: The parameter "MaximumStepLengthRatio", requested at entry number 0, does not exist at all.
  The default value "1" is used instead.
  The default value "1" is used instead.
WARNING: The parameter "MaximumStepLength", requested at entry number 0, does not exist at all.
WARNING: The parameter "MaximumStepLength", requested at entry number 0, does not exist at all.
  The default value "0.190429" is used instead.
  The default value "0.190429" is used instead.
WARNING: The parameter "NumberOfGradientMeasurements", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfGradientMeasurements", requested at entry number 0, does not exist at all.
  The default value "0" is used instead.
  The default value "0" is used instead.
WARNING: The parameter "NumberOfJacobianMeasurements", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfJacobianMeasurements", requested at entry number 0, does not exist at all.
  The default value "1000" is used instead.
  The default value "1000" is used instead.
WARNING: The parameter "NumberOfSamplesForExactGradient", requested at entry number 0, does not exist at all.
WARNING: The parameter "NumberOfSamplesForExactGradient", requested at entry number 0, does not exist at all.
  The default value "100000" is used instead.
  The default value "100000" is used instead.
WARNING: The parameter "SigmoidScaleFactor", requested at entry number 0, does not exist at all.
WARNING: The parameter "SigmoidScaleFactor", requested at entry number 0, does not exist at all.
  The default value "0.1" is used instead.
  The default value "0.1" is used instead.
Elastix initialization of all components (for this resolution) took: 2 ms.
Elastix initialization of all components (for this resolution) took: 2 ms.
  Computing the fixed image extrema took 1 ms.
  Computing the fixed image extrema took 1 ms.
  Computing the moving image extrema took 1 ms.
  Computing the moving image extrema took 1 ms.
Initialization of AdvancedMattesMutualInformation metric took: 5 ms.
Initialization of AdvancedMattesMutualInformation metric took: 5 ms.
Starting automatic parameter estimation for AdaptiveStochasticGradientDescent ...
Starting automatic parameter estimation for AdaptiveStochasticGradientDescent ...
WARNING: The parameter "ASGDParameterEstimationMethod", requested at entry number 0, does not exist at all.
WARNING: The parameter "ASGDParameterEstimationMethod", requested at entry number 0, does not exist at all.
  The default value "Original" is used instead.
  The default value "Original" is used instead.
  Computing JacobianTerms ...
  Computing JacobianTerms ...
  Computing the Jacobian terms took 0.001969s
  Computing the Jacobian terms took 0.001969s
  NumberOfGradientMeasurements to estimate sigma_i: 10
  NumberOfGradientMeasurements to estimate sigma_i: 10
  Sampling gradients ...
  Sampling gradients ...


  Progress: 0%Time spent in resolution 0 (ITK initialization and iterating): 0.010 s.
  Progress: 0%Time spent in resolution 0 (ITK initialization and iterating): 0.010 s.
Stopping condition: Error in metric.
Stopping condition: Error in metric.
Settings of AdaptiveStochasticGradientDescent in resolution 0:
Settings of AdaptiveStochasticGradientDescent in resolution 0:
( SP_a 1.000000 )
( SP_a 1.000000 )
( SP_A 20.000000 )
( SP_A 20.000000 )
( SP_alpha 0.602000 )
( SP_alpha 0.602000 )
( SigmoidMax 1.000000 )
( SigmoidMax 1.000000 )
( SigmoidMin -0.800000 )
( SigmoidMin -0.800000 )
( SigmoidScale 0.000000 )
( SigmoidScale 0.000000 )




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




Error occurred during actual registration.
Error occurred during actual registration.




Errors occurred!
Errors occurred!
Error: Command 'elastix' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/ABLTemporalBoneSegmentationModule.py", line 635, in process_transform
    output = function()
  File "/Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/ABLTemporalBoneSegmentationModule.py", line 808, in transform
    return ABLTemporalBoneSegmentationModuleLogic().apply_elastix_rigid_registration(elastix=self.elastixLogic,
  File "/Applications/Slicer.app/Contents/Extensions-30893/ABLTemporalBoneSegmentation/lib/Slicer-5.0/qt-scripted-modules/ABLTemporalBoneSegmentationModule.py", line 1311, in apply_elastix_rigid_registration
    elastix.registerVolumes(
  File "/Applications/Slicer.app/Contents/Extensions-30893/SlicerElastix/lib/Slicer-5.0/qt-scripted-modules/Elastix.py", line 818, in registerVolumes
    self.logProcessOutput(ep)
  File "/Applications/Slicer.app/Contents/Extensions-30893/SlicerElastix/lib/Slicer-5.0/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.

@FUFU @DAT_Minh I’m working on a similar project using this module and experiencing the same command elsatix return to non-zern exit status 1 error.
Could you please elaborate on how to solve this?

This is a very common error, it simply means that the input images must be better aligned. Make sure that you crop any non-overlapping regions from the input images and all transforms are hardened on the input images.

hey @lassoan , i followed your advice that cropped the excessive volumes before registration using the ABL module but I still experience the same error. One interesting thing, I am using the open-ear dataset. I found slicer behaves differently between mac and windows with the same steps on the same data.

Please upload the scene somewhere and post the link here and I can have a look.

If the registration with the same input images and registration parameters consistently converges on one platform then it should converge on all platforms.

If the registration does not converge to a global optimum then even the slightest numerical differences can lead to very different end results, so in these cases it may be normal that you end up getting different results on different platforms.

Thank you for your prompt reply. I uploaded the scene into this one drive. Please let me know if you have any difficulties accessing it.

I also noticed that somehow in the sample data module the text is cutoff

In the scene I only see one volume (PostDentalSurgery) in 3 versions (original, cropped, transformed). Can you share a scene where you have two volumes that you want to register (a moving and a fixed)?

I also noticed that you have a CochleaRegistrationMask. Masking is only intented for specifying a non-rectangular ROI that is only slightly smaller than the image (e.g., to exclude a surgical tool or excised tissue region from the registration). Instead, the mask is much, much smaller than the cropped image:

The area on this slice is 10-20x smaller, so the volume is about 100x smaller. This means that random volumetric sampling will fail 99% of the time, which will cause the registration to fail with “too many samples map outside moving image” error. Instead of using such tiny mask, crop the volume to the size of the mask.

@lassoan, thanks for looking into this for me. I was following the tutorial list here. Using the cropped PostDentalSurgery volume as the input volume in the ABL extension.

Probably cropping the image to the green ROI (instead of using that ROI as mask) would fix the sampling error.

The registration metric is computed by generating random samples. Samples that fall outside the mask are discarded. If the mask is small (volume of mask is smaller than maybe 50% of the image volume) then many samples are discarded. If too many sanples are discarded then you get the sampling error message.

@lassoan thanks, I will give this a try