[elastix] Error reducing BSpline grid and question about regularization

M.Staring at lumc.nl M.Staring at lumc.nl
Thu Aug 18 11:42:02 CEST 2011

Hi Andres,

1) Memory consumption of the B-spline is a function of the number of parameters which depend on the grid spacing. So, it increases when spacing decreases. You can solve it in several ways:
- use a 64 bit version and stock your pc with suffficient memory
- reduce memory consumption, by using recursive pyramids, using short as the internal pixel type, using another optimizer then the ASGD one (it consumes a lot of memory), using float versions instead of the standard double versions of the interpolators eg (Interpolator "BSplineInterpolatorFloat") and same for the resample interpolator.

2) At the parameter file database you can find example settings on how to use regularization:
For more detailed comments on why you get the same result in your case I need at least also the log file, preferably also the images. But try using the BendingEnergyPenalty term if you only want to constrain the deformation, and not keep it locally rigid.



From: elastix-bounces at bigr.nl [elastix-bounces at bigr.nl] on behalf of Andrés Méndez [andres.mendezg at gmail.com]
Sent: Thursday, August 18, 2011 11:04 AM
To: elastix at bigr.nl
Subject: [elastix] Error reducing BSpline grid and question about regularization

Hello everyone

I'm trying to do a multimodality breast registration  (T1 + DWI) in two stages: first an affine registration to match the general forms and then, using a mask on the fixed image, a B-Spline  registration as a refinement focused on the tumoral area.  I have two issues:

1) I have succesfully tried many BSpline grids, ranging from 4 to 15mm, without problem whatsoever. The problem arises when I try to reduce the grid to 3 or 2 mm, in both cases I get the following error:

 itk::ExceptionObject (00000000009BF8F0)
Location: "ElastixTemplate - Run()"
File: d:\toolkits\itk\3.20.0\insighttoolkit-3.20.0\code\common\itkImportImageContainer.txx
Line: 188
Description: Failed to allocate memory for image.

Error occurred during actual registration.

Do you have any suggestion how to solve it?  I copy the parameter file at the end of the email.

2)The second issue is more an open question. I intend to do tests including a regularization term to limit the ammount of deformation. In the first test I got exactly the same result as without regularization. What default values do you suggest as a starting point (if any)?  The way I use it is as follows (is it correct?):

(Registration "MultiMetricMultiResolutionRegistration")
(Metric  "NormalizedMutualInformation" "TransformRigidityPenalty")
(UseRelativeWeights "true")
(Metric0Weight 1)
(Metric1Weight 0.1)

The rest of the parameters are the same as in the parameter file (just changing the grid size)

Parameter file:

=============== start of ParameterFile: D:\RegistrationIEO\tests\parameters\BSpline_2mm.txt ===============

// ************************** Image Types

(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(FixedImageDimension 3)
(MovingImageDimension 3)

//*************************** Components

(Registration "MultiResolutionRegistration")
(FixedImagePyramid "FixedSmoothingImagePyramid")
(MovingImagePyramid "MovingSmoothingImagePyramid")
(Interpolator "BSplineInterpolator")
(Metric "NormalizedMutualInformation" )
(Optimizer "AdaptiveStochasticGradientDescent")
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(Transform "BSplineTransform")

//*************************** Resolutions

(NumberOfResolutions 4)
(ImagePyramidSchedule 8 8 8 4 4 4  2 2 2  1 1 1 )

// ************************** Transformation

(FinalGridSpacingInPhysicalUnits 2.0 2.0 2.0)
(GridSpacingSchedule 8.0 4.0 2.0 1.0)
(HowToCombineTransforms "Compose")
(BSplineTransformSplineOrder 3)
(AutomaticScalesEstimation "true")
(AutomaticTransformInitialization "true")

// ************************** etc

(NumberOfHistogramBins 32)
(ErodeMask "false" "false" "false" )
(UseDirectionCosines "true")

(WriteResultImage "true")
(ResultImagePixelType "short")
(ResultImageFormat "nii")

// ************************** Optimizer

(MaximumNumberOfIterations 1000)
(AutomaticParameterEstimation "true")
(UseAdaptiveStepSizes "true")

// ************************** Image sampling

(ImageSampler "RandomCoordinate")
(NumberOfSpatialSamples 2048)
(NewSamplesEveryIteration "true")
(MaximumNumberOfSamplingAttempts 30)

// ************************** Interpolation and Resampling

(BSplineInterpolationOrder 1)
(FinalBSplineInterpolationOrder 3)
(DefaultPixelValue 0)


 Thank you very much for your attention. Best regards.

Andrés Méndez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bigr.nl/pipermail/elastix/attachments/20110818/23a84810/attachment.html>

More information about the Elastix mailing list