Inverseion of transform is slow

77 views
Skip to first unread message

Neil Horner

unread,
Nov 27, 2020, 3:08:18 AM11/27/20
to elastix-imageregistration

Hi All
I'm doing registration of moving to target image using MI metric. It's quick and it appears to use all available cores on my machine.

However, when I come to invert the transform, as per the instructions in the manual, using (Metric "DisplacementMagnitudePenalty") only one core is used.

Is this a known issue with elastix?

Thanks,
Neil


Forward parameters
---------------------------------
(FixedInternalImagePixelType  "float")
(MovingInternalImagePixelType  "float")
(FixedImageDimension  3)
(MovingImageDimension  3)
(UseDirectionCosines  "true")
(FixedImagePyramid  "FixedSmoothingImagePyramid")
(MovingImagePyramid  "MovingSmoothingImagePyramid")
(ResultImagePixelType  "short")
(ResultImageFormat  "nrrd")
(CompressResultImage  "true")
(Interpolator  "BSplineInterpolator")
(ResampleInterpolator  "FinalBSplineInterpolator")
(Resampler  "DefaultResampler")
(NumberOfHistogramBins  32)
(HowToCombineTransforms  "Compose")
(NewSamplesEveryIteration  "true")
(ImageSampler  "RandomCoordinate")
(FinalBSplineInterpolationOrder  3)
(BSplineInterpolationOrder  3)
(DefaultPixelValue  0)
(WriteTransformParametersEachIteration  "false")
(WriteTransformParametersEachResolution  "true")
(WriteResultImageAfterEachResolution  "true")
(AutomaticScalesEstimation  "true")
(AutomaticTransformInitialization  "true")
(Optimizer  "AdaptiveStochasticGradientDescent")
(UseRandomSampleRegion  "false")
(Registration  "MultiMetricMultiResolutionRegistration")
(NumberOfResolutions  6)
(AutomaticParameterEstimation  "true")
(UseAdaptiveStepSizes  "true")
(Transform  "BSplineTransform")
(Metric  "AdvancedMattesMutualInformation" "TransformBendingEnergyPenalty")
(Metric0Weight  1.0 1.0 1.0 1.0 1.0 1.0)
(Metric1Weight  0.0 0.0 0.0 0.0 50.0 50.0)
(FinalGridSpacingInVoxels  10)
(NumberOfSpatialSamples  10000 10000 10000 10000 50000 50000)
(MaximumNumberOfIterations  800)
(GridSpacingSchedule  9.6 4.8 2.4 1.6 1.2 1.0)
(FixedImagePyramidSchedule  6.0 6.0 6.0 4.0 4.0 4.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)
(MovingImagePyramidSchedule  6.0 6.0 6.0 4.0 4.0 4.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)
(WriteResultImage  "true")


Inverse parameters
-------------------------------
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(FixedImageDimension  3)
(MovingImageDimension  3)
(UseDirectionCosines  "true")
(FixedImagePyramid  "FixedSmoothingImagePyramid")
(MovingImagePyramid  "MovingSmoothingImagePyramid")
(ResultImagePixelType "float")
(ResultImageFormat  "nrrd")
(CompressResultImage  "true")
(Interpolator  "BSplineInterpolator")
(ResampleInterpolator  "FinalBSplineInterpolator")
(Resampler  "DefaultResampler")
(NumberOfHistogramBins  32)
(HowToCombineTransforms  "Compose")
(NewSamplesEveryIteration  "true")
(ImageSampler  "RandomCoordinate")
(FinalBSplineInterpolationOrder 3)
(BSplineInterpolationOrder  3)
(DefaultPixelValue  0)
(WriteTransformParametersEachIteration  "false")
(WriteTransformParametersEachResolution "false")
(WriteResultImageAfterEachResolution "false")
(AutomaticScalesEstimation  "true")
(AutomaticTransformInitialization  "true")
(Optimizer  "AdaptiveStochasticGradientDescent")
(UseRandomSampleRegion  "false")
(Registration  "MultiMetricMultiResolutionRegistration")
(NumberOfResolutions  6)
(AutomaticParameterEstimation  "true")
(UseAdaptiveStepSizes  "true")
(Transform  "BSplineTransform")
(Metric "DisplacementMagnitudePenalty")
(Metric0Weight  1.0 1.0 1.0 1.0 1.0 1.0)
(Metric1Weight  0.0 0.0 0.0 0.0 50.0 50.0)
(FinalGridSpacingInVoxels  10)
(NumberOfSpatialSamples  10000 10000 10000 10000 50000 50000)
(MaximumNumberOfIterations  800)
(GridSpacingSchedule  9.6 4.8 2.4 1.6 1.2 1.0)
(FixedImagePyramidSchedule  6.0 6.0 6.0 4.0 4.0 4.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)
(MovingImagePyramidSchedule  6.0 6.0 6.0 4.0 4.0 4.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)
(WriteResultImage "false")

M.St...@lumc.nl

unread,
Nov 27, 2020, 5:40:53 AM11/27/20
to elastix-imag...@googlegroups.com

Dear Neil,


Looking at the code of this metric, indeed a single threaded implementation is only available:


https://github.com/SuperElastix/elastix/blob/develop/Components/Metrics/DisplacementMagnitudePenalty/itkDisplacementMagnitudePenaltyTerm.hxx


It is possible to make it multi-threaded, similar to what was done for the mean squares metric for example, but that requires some coding.


Best regards, Marius




From: elastix-imag...@googlegroups.com <elastix-imag...@googlegroups.com> on behalf of Neil Horner <horne...@gmail.com>
Sent: 27 November 2020 9:08 AM
To: elastix-imageregistration
Subject: [elastix-imageregistration] Inverseion of transform is slow
 
--
You received this message because you are subscribed to the Google Groups "elastix-imageregistration" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elastix-imageregis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elastix-imageregistration/2186ea60-b70e-464d-af34-20e7646eec91n%40googlegroups.com.

Neil Horner

unread,
Nov 30, 2020, 9:07:53 AM11/30/20
to elastix-imag...@googlegroups.com
Thanks for your reply, Marius.

That would be great if that could be done at some point. I'm afraid that I don't have enough experience with c++ to give it a go.

I was just thinking about how I might speed things up in lieu of a multithreaded DiplacementMagnitidenalty:

Step 1
When I use elastix, I do the forward registration in order to get all the images into the same space to be able to do some voxel-wise statistics.
 A->B

Step 2
I then use the inverse transform as described to automatically segment my moving images with an atlas.

Is there some reason why using the inverse transform method for step 2 could not be replaced by just registering B->A with the same registration parameters?

Best regards,

Neil



M.St...@lumc.nl

unread,
Dec 2, 2020, 5:19:30 AM12/2/20
to elastix-imag...@googlegroups.com

Dear Neil,


So you have the fixed image F and the moving image M, and the  transformation T is defined from the domain of F to that of M. You can use this to pull a moving image segmentation from the domain of M to the domain of F (related to backward mapping,  but in elastix / ITK we directly optimize the 'backward' transformation). This way your fixed image is segmented. So, normally you would choose the moving image as the one having the (manual) segmentation / atlas, and the fixed image as the one needing a segmentation. The manual, sec 2.6, says a few things about this as well.


Best, Marius




Sent: 30 November 2020 3:07 PM
To: elastix-imag...@googlegroups.com
Subject: Re: [elastix-imageregistration] Inverseion of transform is slow
 
--
You received this message because you are subscribed to the Google Groups "elastix-imageregistration" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elastix-imageregis...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages