[ITK] [ITK-users] simpleITK C# bspline registation

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Mon Jul 18 20:30:33 EDT 2016


Hello Anton,

Yes, likely you are correct. Right now your code initializes using the identity transform and as far as I remember your B-spline grid doesn't physically overlap with your images (maybe it does, but this would be by chance).
What is a bit surprising is that you did not get an error with regard to too many samples outside the domain (indicating no overlap between images - so I am a bit puzzled as it means your images do overlap sufficiently).

This scenario is rare in practice and usually only happens when you are registering temporal data such as 3D volumes from a 4D CT dataset. Please see the following Jupyter Python notebook for an example on setting things up https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/65_Registration_FFD.ipynb . It will be easy for you to translate it to C#.


You will also likely need to initialize your registration by performing a registration using a global transformation (rigid/affine) and only then a local registration (FFD).

One last thing, there is a bug in the code in the line: R.SetMetricSamplingPercentage(30.0);

This is a 300% sampling. The expected values are in (0.0,1.0].


          hope this helps
                  Ziv

________________________________
From: Anton Delehony [anton.delehony at gmail.com]
Sent: Monday, July 18, 2016 5:06 PM
To: insight-users at itk.org
Subject: [ITK-users] simpleITK C# bspline registation

Hi all,

I noticed that the output of my registration is exactly as the moving image, which means that the code below is not correct, but not sure where is the mistake. I think it has to do with the transform initializer....

Thanks,

AD

              // Read input static
             itk.simple.ImageFileReader reader1 = new itk.simple.ImageFileReader();
             reader1.SetFileName(args[0]);
             Image static = reader1.Execute();
             // Read input moving
             itk.simple.ImageFileReader reader2 = new itk.simple.ImageFileReader();
             reader2.SetFileName(args[0]);
             Image moving = reader2.Execute();

            //registation
            itk.simple.ImageRegistrationMethod R = new itk.simple.ImageRegistrationMethod();
            R.SetMetricAsMattesMutualInformation(50);
            R.SetMetricSamplingPercentage(30.0);
            R.SetInterpolator(itk.simple.InterpolatorEnum.sitkLinear);
            R.SetOptimizerAsLBFGSB();
            itk.simple.BSplineTransform transform = new itk.simple.BSplineTransform(3);
            R.SetInitialTransform( transform);
            itk.simple.Transform trans_f = R.Execute(static, moving);
            //resample image
            itk.simple.ResampleImageFilter resample = new itk.simple.ResampleImageFilter();
            resample.SetReferenceImage(static);
            resample.SetTransform(trans_f);
            resample.SetInterpolator(itk.simple.InterpolatorEnum.sitkBSpline);
            itk.simple.Image registered = resample.Execute(moving);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160719/706b36c1/attachment.html>
-------------- next part --------------
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list