[Insight-developers] SimpleITK ImageRegistrationMethod straw man

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Jan 2 17:54:50 EST 2014


Happy New Year Folks!

I have continued my rapid prototype/straw man of much needed features in SimpleITK. Not I have a topic which adds callbacks/commands/progress reporting:
https://github.com/blowekamp/SimpleITK/tree/STRAW-SIMPLEITK-441_CallbackPrototype

Along with the other two existing straw topics which have been rebase and updated:
https://github.com/blowekamp/SimpleITK/tree/STRAW-PDERegistration
https://github.com/blowekamp/SimpleITK/tree/STRAW_ImageRegistrationMethod

I have merged them all together here:
https://github.com/blowekamp/SimpleITK/tree/STRAW

Needless to say, they are experimental and the topics will be rebased until the design is finalized, as important common features are extracted.

Here is an example of what things look like in registration now. This code is rather brief, and I think needs a little more verbosity perhaps just with keyword arguments:


def command_iteration(method) :
    print("{0} = {1} : {2}".format(method.GetOptimizerIteration(),
                                   method.GetMetricValue(),
                                   method.GetOptimizerPosition()))

fixedInput = sitk.ReadImage(sys.argv[1])

movingInput = sitk.ReadImage(sys.argv[2])


R = sitk.ImageRegistrationMethod()
R.SetMetricAsMeanSquares()
R.SetOptimizerAsRegularStepGradientDescent(4.0, .01, 200 )
R.SetTransform(sitk.Transform(fixed.GetDimension(), sitk.sitkTranslation))
R.SetInterpolator(sitk.sitkLinear)

R.AddCommand( sitk.sitkIterationEvent, lambda: command_iteration(R) )

outTx = R.Execute(fixed, moving)

And this is the output:

$ "/scratch/blowekamp/build/SimpleITK/SimpleITK-build/Testing/Installation/PythonVirtualenv/bin/python" "/home/blowekamp/src/SimpleITK/Examples/ImageRegistration1.py" "/scratch/blowekamp/build/SimpleITK/SimpleITK-build/../ITK//Examples/Data/BrainProtonDensitySliceBorder20.png" "/scratch/blowekamp/build/SimpleITK/SimpleITK-build/../ITK//Examples/Data/BrainProtonDensitySliceShifted13x17y.png" "/scratch/blowekamp/build/SimpleITK/SimpleITK-build/Testing/Temporary/ImageRegistration1Test.png"
0 = 4499.45303449 : (2.9286959512455848, 2.7244705953923813)
1 = 3860.83625806 : (5.6275095401543647, 5.6768264703372218)
2 = 3450.67752259 : (8.8551550244041568, 8.0395165955973944)
3 = 3139.41514779 : (11.799687371851636, 10.746863868267717)
4 = 2189.97451865 : (13.362815140063773, 14.428796999143961)
5 = 1037.88308322 : (11.291967263350845, 17.851016903170226)
6 = 895.90226716 : (13.160248426976562, 17.137206358528768)
7 = 19.4543370274 : (12.326817932777699, 16.584582063605499)
8 = 236.181016487 : (12.782415987279469, 16.790568501834336)
9 = 38.1330680182 : (13.18325427730521, 17.089447516235214)
10 = 18.7507277013 : (12.949041300626419, 17.002015934096605)
11 = 1.14974579152 : (13.07397264379054, 16.997873531990507)
12 = 2.41322408701 : (13.011491691674189, 16.999416458636308)
13 = 0.058770974297 : (12.949046903335123, 17.002042940939543)
14 = 1.14969751226 : (12.980279306998362, 17.000994388882443)
15 = 0.173006721706 : (13.011502114607094, 16.99969101440513)
16 = 0.0583764039748 : (12.995881389157882, 17.00005647499167)
-------
TranslationTransform (0xa86f00)
  RTTI typeinfo:   itk::TranslationTransform<double, 2u>
  Reference Count: 3
  Modified Time: 1256
  Debug: Off
  Object Name: 
  Observers: 
    none
  Offset: [12.9959, 17.0001]

Optimizer stop condition: ScaledRegularStepGradientDescentOptimizer: Step too small after 17 iterations. Current step (0.0078125) is less than minimum step (0.01).
 Iteration: 16
 Metric value: 0.0583764039748

================
I believe I am going to proceed by implementing some flash IPython-Notebook type demos, and then write of some of the design chooses made in a Wiki page to facilitate community feed back and design review.

Brad


On Dec 28, 2013, at 4:04 PM, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:

> Hello,
> 
> I have hacked away to a  working version of the  ImageRegistationMethod in SimpleITK. This is the 4th SimpleITK registration interface attempted. This one seems about right to me. The branch/commit is available in my github account:
> 
> https://github.com/blowekamp/SimpleITK/tree/STRAW_ImageRegistrationMethod
> 
> Note: this topic will continued to be hacked and rebased/amended/squashed etc....
> 
> Of particular interest is the interface to the method class which encapsulates the metric and optimizer while working with the existing sitk Transform facade:
> 
> https://github.com/blowekamp/SimpleITK/blob/STRAW_ImageRegistrationMethod/Code/Registration/include/sitkImageRegistrationMethod.h
> 
> I ported  several ITK ImageRegistration examples to drive the implementation:
> 
> https://github.com/blowekamp/SimpleITK/blob/STRAW_ImageRegistrationMethod/Examples/ImageRegistration1.py
> https://github.com/blowekamp/SimpleITK/blob/STRAW_ImageRegistrationMethod/Examples/ImageRegistration2.py
> https://github.com/blowekamp/SimpleITK/blob/STRAW_ImageRegistrationMethod/Examples/ImageRegistration15.py
> 
> Also note I have found the scale dependent nature for ITK's RegularStepGradientDecent method un-usable and erratic. So I have use my version which possess sensible parameter scaling properties:
> https://github.com/blowekamp/SimpleITK/blob/STRAW_ImageRegistrationMethod/Code/Registration/include/itkScaledRegularStepGradientDescentOptimizer.h
> 
> 
> ---------------
> So what does this class support...
> 
> --Transforms:  sitkTranslation, sitkScale, sitkScaleLogarithmic, sitkEuler, sitkSimilarity, sitkQuaternionRigid, sitkVersor, sitkVersorRigid, sitkAffine, sitkComposite
> --Metrics: MeansSquares, NormalizedCorrelation, MeanReciprocalSquaredDifference MutualInformation, MatchCardinality, KullbackLeiblerCompareHistogram, MeanSquaresHistogram
> --Optimizers: RegularStepGradientDescent, GradientDescent, ConjugateGradient, OnePlusOneEvolutionary, Exhaustive, Amoeba, LBFS
> --Interpolators:  sitkNearestNeighbor, sitkLinear, sitkBSpline, sitkGaussian, sitkLabelGaussian, sitkHammingWindowedSinc, sitkCosineWindowedSinc, sitkWelchWindowedSinc, sitkLanczosWindowedSinc, sitkBlackmanWindowedSinc
> 
> So that is 4900 combinations.... Ever try a MatchCardinality metric with a LabelGaussian interpolator and a Amoeba optimizer?
> 
> ---------------
> Things still todo and figure out:
> 
> Callbacks and information/interface needed,
> BSpline transfroms.
> Sample masking from images.
> 
> There is a lot that is going to need to be done for testing, and improved parameter checking, verifying defaults, and doing a  different implementation of parameter management. But it is working, and enable easy exploration of registration in a way I have not been able to do before.
> 
> 
> 
> ---------------
> I look forward to suggestions and comments. A long with information regarding the importance of features and things that are missing.
> 
> Thanks,
> Brad
> 
> 
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list