[ITK-users] [ITK] SimpleITK | Registration in C#
Bradley Lowekamp
blowekamp at mail.nih.gov
Fri Jun 19 19:19:07 EDT 2015
Here is the C# command example:
https://github.com/SimpleITK/SimpleITK/blob/master/Examples/FilterProgressReporting.cs
That with the python registration examples should be enough to write a command to report information at each iteration as needed.
HTH,
Brad
On Jun 19, 2015, at 6:37 PM, Matias Montroull <matimontg at gmail.com> wrote:
> Hi, I have this code so far for doing registration with SimpleITK. I've run it and seems to work ok but the offset and matrix doesn't change so I think I'm missing the command part which I haven't been able to figure out.. I marked in bold what I think needs further code, unfortunately I haven't found any example in C#, all is in Pyton or C++, I was able to kind of translate to C# and figure out but the Command part is a struggle for me so far..
>
> itk.simple.Image Imagen_fija = new itk.simple.Image();
> itk.simple.Image Imagen_flotante = new itk.simple.Image();
>
> ImageSeriesReader reader_fija = new ImageSeriesReader();
> var archivosdcm_fija = ImageSeriesReader.GetGDCMSeriesFileNames(@"C:\TRACKER\Pacientes\ST1_CT\DCM");
> reader_fija.SetFileNames(archivosdcm_fija);
> Imagen_fija = reader_fija.Execute();
>
> ImageSeriesReader reader_flotante = new ImageSeriesReader();
> var archivosdcm_flotante = ImageSeriesReader.GetGDCMSeriesFileNames(@"C:\TRACKER\Pacientes\ST1_RM\DCM");
> reader_flotante.SetFileNames(archivosdcm_flotante);
> Imagen_flotante = reader_flotante.Execute();
>
> CastImageFilter conversorafloat = new CastImageFilter(); conversorafloat.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkFloat32);
> Imagen_fija = conversorafloat.Execute(Imagen_fija);
> Imagen_flotante = conversorafloat.Execute(Imagen_flotante);
>
> ImageRegistrationMethod R = new ImageRegistrationMethod();
> R.SetMetricAsMattesMutualInformation(50); //numberof histogrambins
> R.SetMetricSamplingPercentage(3.0); //Sampling %
> R.SetOptimizerAsRegularStepGradientDescent(16.0, 0.1, 100, 0.99); //max step, min step, iteraciones, relaxation
> R.SetInterpolator(InterpolatorEnum.sitkLinear);
>
> AffineTransform transform = new AffineTransform(3);
> itk.simple.Transform Initial_transform = SimpleITK.CenteredTransformInitializer(Imagen_fija, Imagen_flotante, transform, CenteredTransformInitializerFilter.OperationModeType.GEOMETRY);
> R.SetInitialTransform(Initial_transform);
> ResampleImageFilter resampler_fija = new ResampleImageFilter();
> resampler_fija.SetReferenceImage(Imagen_fija);
> resampler_fija.SetTransform(Initial_transform);
> resampler_fija.SetInterpolator(InterpolatorEnum.sitkLinear);
> Imagen_fija= resampler_fija.Execute(Imagen_fija);
>
> ResampleImageFilter resampler_flotante = new ResampleImageFilter();
> resampler_flotante.SetReferenceImage(Imagen_flotante);
> resampler_flotante.SetTransform(Initial_transform);
> resampler_flotante.SetInterpolator(InterpolatorEnum.sitkLinear);
> Imagen_flotante = resampler_flotante.Execute(Imagen_flotante);
> itk.simple.Command cmd = new Command();
> R.AddCommand(EventEnum.sitkIterationEvent, cmd);
>
> itk.simple.Transform transform_final = R.Execute(Imagen_fija, Imagen_flotante);
> double metrica = R.GetMetricValue();
> --
> Matias
> _____________________________________
> 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
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150619/95a580cc/attachment.html>
More information about the Insight-users
mailing list