[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/insight-users/attachments/20160719/706b36c1/attachment.html>


More information about the Insight-users mailing list