<div dir="ltr">Dear Matias and ITK community,<div><br></div><div>thank you very much for your quick and detailed reply.</div><div><br></div><div>I have tried a little bit of tinkering starting from your suggestion but I didn't overcome the errors. </div><div><br></div><div>I am registering two images using the v4 framework with the following header</div><div><div>#include <itkImageRegistrationMethodv4.h></div><div>#include <itkMeanSquaresImageToImageMetricv4.h></div><div>#include <itkRegularStepGradientDescentOptimizerv4.h></div></div><div><br></div><div>I have initialized the transform with the transform initializer and computed the optimizer parameters with RegistratonParametersFromPhysicalShift and after a little of playing I left the relaxation factor to .5.</div><div><br></div><div><u>The registration process runs <b>correctly </b>at full resolution. </u></div><div><br></div><div>If I choose a multi resolution approach, like </div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="" style="white-space:pre"> </span>const unsigned int numberOfLevels = 3;<br><span class="" style="white-space:pre"> </span>RegistrationType::ShrinkFactorsArrayType shrinkFactorsPerLevel;<br><span class="" style="white-space:pre"> </span>shrinkFactorsPerLevel.SetSize(numberOfLevels);<br><span class="" style="white-space:pre"> </span>shrinkFactorsPerLevel[0] = 4;<br><span class="" style="white-space:pre"> </span>shrinkFactorsPerLevel[1] = 2;<br><span class="" style="white-space:pre"> </span>shrinkFactorsPerLevel[2] = 1;<br><span class="" style="white-space:pre"> </span>RegistrationType::SmoothingSigmasArrayType smoothingSigmasPerLevel;<br><span class="" style="white-space:pre"> </span>smoothingSigmasPerLevel.SetSize(numberOfLevels);<br><span class="" style="white-space:pre"> </span>smoothingSigmasPerLevel[0] = 2;<br><span class="" style="white-space:pre"> </span>smoothingSigmasPerLevel[1] = 1;<br><span class="" style="white-space:pre"> </span>smoothingSigmasPerLevel[2] = 0;</blockquote></div><div><br></div><div>the code stops working properly. </div><div><br></div><div>In fact, I get the following warnings:</div><div><div><ul><li>RegistrationParameterScalesFromPhysicalShift (00000000021F2630): Variation in any parameter won't change a voxel position. The default scales (1.0) are used to avoid division-by-zero.</li><li>WARNING: In f:\libs\insighttoolkit-4.8.2\modules\numerics\optimizersv4\include\itkObjectToObjectMetric.hxx, line 529 MeanSquaresImageToImageMetricv4 (00000000650FCB40): No valid points were found during metric evaluation. For image metrics, verify that the images overlap appropriately. For instance, you can align the image centers by translation. For point-set metrics, verify that the fixed points, once transformed into the virtual domain space, actually lie within the virtual domain.</li></ul></div></div><div>the metric is NaN and the registration process ends before its first step.</div><div><br></div><div>Could you explain me the rationale behind this errors? I am probably overlooking something trivial.</div><div><br></div><div>Best, </div><div><br></div><div>Luigi</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-07 16:06 GMT+01:00 Matias Montroull <span dir="ltr"><<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Actually the min and max steplenght are taken into account, I use these:<div>Min: 0.0001</div><div>Max: 0.1</div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">El lun., 7 de dic. de 2015 a la(s) 12:04, Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Luigi, it could be for various reasons, mailny the transform initializer you use plus the number of samples and translationscale<div>Try this code I have which I've done for MultiResolution and works fine for me:<div><br></div><div>When you enter the parameters, try this:</div><div>Relaxation: 0.99</div><div>Number of Bins: 50</div><div>Samples 3 (this is actually translated to 3% in my code as you will see below)</div><div>maximum and minimum steplenght is not taken into account so you can put 0 and 0</div><div>translation scale 0.0001<br><div><br></div><div><div>#include "itkAffineTransform.h"</div><div>#include "itkRegistrationParameterScalesFromPhysicalShift.h"</div><div>#include "itkCenteredTransformInitializer.h"</div><div>#include "itkLandmarkBasedTransformInitializer.h"</div><div>#include "itkMultiResolutionImageRegistrationMethod.h"</div><div>#include "itkMattesMutualInformationImageToImageMetric.h"</div><div>#include "itkMeanSquaresImageToImageMetric.h"</div><div>#include "itkRegularStepGradientDescentOptimizer.h"</div><div>#include "itkRecursiveMultiResolutionPyramidImageFilter.h"</div><div>#include "itkImage.h"</div><div>#include "itkImageFileReader.h"</div><div>#include "itkImageFileWriter.h"</div><div>#include "itkResampleImageFilter.h"</div><div>#include "itkCastImageFilter.h"</div><div>#include "itkCheckerBoardImageFilter.h"</div><div>#include "itkRescaleIntensityImageFilter.h"</div><div><br></div><div>#include "itkNormalizeImageFilter.h"</div><div><br></div><div>#include "itkCommand.h"</div><div>class CommandIterationUpdate : public itk::Command</div><div>{</div><div>public:</div><div><span style="white-space:pre-wrap"> </span>typedef CommandIterationUpdate Self;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Command Superclass;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::SmartPointer<Self> Pointer;</div><div><span style="white-space:pre-wrap"> </span>itkNewMacro(Self);</div><div>protected:</div><div><span style="white-space:pre-wrap"> </span>CommandIterationUpdate() : m_CumulativeIterationIndex(0) {};</div><div>public:</div><div><span style="white-space:pre-wrap"> </span>typedef itk::RegularStepGradientDescentOptimizer OptimizerType;</div><div><span style="white-space:pre-wrap"> </span>typedef const OptimizerType * OptimizerPointer;</div><div><span style="white-space:pre-wrap"> </span>void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>Execute((const itk::Object *)caller, event);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>void Execute(const itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>OptimizerPointer optimizer = static_cast<OptimizerPointer>(object);</div><div><span style="white-space:pre-wrap"> </span>if (!(itk::IterationEvent().CheckEvent(&event)))</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>return;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>std::cout << optimizer->GetCurrentIteration() << " ";</div><div><span style="white-space:pre-wrap"> </span>std::cout << optimizer->GetValue() << " ";</div><div><span style="white-space:pre-wrap"> </span>std::cout << optimizer->GetCurrentPosition() << " " <<</div><div><span style="white-space:pre-wrap"> </span>m_CumulativeIterationIndex++ << std::endl;</div><div><span style="white-space:pre-wrap"> </span>}</div><div>private:</div><div><span style="white-space:pre-wrap"> </span>unsigned int m_CumulativeIterationIndex;</div><div>};</div><div><br></div><div>template <typename TRegistration></div><div>class RegistrationInterfaceCommand : public itk::Command</div><div>{</div><div>public:</div><div><span style="white-space:pre-wrap"> </span>typedef RegistrationInterfaceCommand Self;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Command Superclass;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::SmartPointer<Self> Pointer;</div><div><span style="white-space:pre-wrap"> </span>itkNewMacro(Self);</div><div>protected:</div><div><span style="white-space:pre-wrap"> </span>RegistrationInterfaceCommand() {};</div><div>public:</div><div><span style="white-space:pre-wrap"> </span>typedef TRegistration RegistrationType;</div><div><span style="white-space:pre-wrap"> </span>typedef RegistrationType * RegistrationPointer;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::RegularStepGradientDescentOptimizer OptimizerType;</div><div><span style="white-space:pre-wrap"> </span>typedef OptimizerType * OptimizerPointer;</div><div><span style="white-space:pre-wrap"> </span>void Execute(itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>if (!(itk::IterationEvent().CheckEvent(&event)))</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>return;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>RegistrationPointer registration = static_cast<RegistrationPointer>(object);</div><div><span style="white-space:pre-wrap"> </span>OptimizerPointer optimizer =</div><div><span style="white-space:pre-wrap"> </span>static_cast<OptimizerPointer>(registration->GetModifiableOptimizer());</div><div><span style="white-space:pre-wrap"> </span>std::cout << "-------------------------------------" << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "MultiResolution Level : "</div><div><span style="white-space:pre-wrap"> </span><< registration->GetCurrentLevel() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << std::endl;</div><div><span style="white-space:pre-wrap"> </span>if (registration->GetCurrentLevel() == 0)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMaximumStepLength(1.0);</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMinimumStepLength(0.001);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>else</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMaximumStepLength(optimizer->GetMaximumStepLength() / 4.0);</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMinimumStepLength(optimizer->GetMinimumStepLength() / 10.0);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>void Execute(const itk::Object *, const itk::EventObject &) ITK_OVERRIDE</div><div><span style="white-space:pre-wrap"> </span>{ return; }</div><div>};</div><div>int main(int argc, char *argv[])</div><div>{</div><div><span style="white-space:pre-wrap"> </span>if (argc < 10)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>std::cerr << "Faltan Parametros " << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cerr << "Uso: " << argv[0];</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " imagenfija imagenflotante ";</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " salida";</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " Iteraciones Relaxation ";</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " NumeroBins Samples%(1/100) ";</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " StepMax(No Habilitado) StepMin(No Habilitado) TranslationFactor";</div><div><span style="white-space:pre-wrap"> </span>std::cerr << " " << std::endl;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>return EXIT_FAILURE;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>const unsigned int Dimension = 3;</div><div><span style="white-space:pre-wrap"> </span>typedef signed short PixelType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Image< PixelType, Dimension > FixedImageType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Image< PixelType, Dimension > MovingImageType;</div><div><span style="white-space:pre-wrap"> </span>typedef float InternalPixelType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Image< InternalPixelType, Dimension > InternalImageType;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef itk::AffineTransform< double, Dimension > TransformType;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef itk::RegularStepGradientDescentOptimizer OptimizerType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::LinearInterpolateImageFunction<</div><div><span style="white-space:pre-wrap"> </span>InternalImageType,</div><div><span style="white-space:pre-wrap"> </span>double > InterpolatorType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::MattesMutualInformationImageToImageMetric<</div><div><span style="white-space:pre-wrap"> </span>InternalImageType,</div><div><span style="white-space:pre-wrap"> </span>InternalImageType > MetricType;</div><div><span style="white-space:pre-wrap"> </span>typedef OptimizerType::ScalesType OptimizerScalesType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::MultiResolutionImageRegistrationMethod<</div><div><span style="white-space:pre-wrap"> </span>InternalImageType,</div><div><span style="white-space:pre-wrap"> </span>InternalImageType > RegistrationType;</div><div><span style="white-space:pre-wrap"> </span>OptimizerType::Pointer optimizer = OptimizerType::New();</div><div><span style="white-space:pre-wrap"> </span>InterpolatorType::Pointer interpolator = InterpolatorType::New();</div><div><span style="white-space:pre-wrap"> </span>RegistrationType::Pointer registration = RegistrationType::New();</div><div><span style="white-space:pre-wrap"> </span>MetricType::Pointer metric = MetricType::New();</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>TransformType::Pointer transform = TransformType::New();</div><div><span style="white-space:pre-wrap"> </span>registration->SetTransform(transform);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;</div><div><span style="white-space:pre-wrap"> </span>FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();</div><div><span style="white-space:pre-wrap"> </span>MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();</div><div><span style="white-space:pre-wrap"> </span>fixedImageReader->SetFileName(argv[1]);</div><div><span style="white-space:pre-wrap"> </span>movingImageReader->SetFileName(argv[2]);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>fixedImageReader->Update();</div><div><span style="white-space:pre-wrap"> </span>movingImageReader->Update();</div><div><br></div><div><span style="line-height:1.5;white-space:pre-wrap"> </span><span style="line-height:1.5">typedef itk::CastImageFilter<</span><br></div><div><span style="white-space:pre-wrap"> </span>FixedImageType, InternalImageType > FixedCastFilterType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::CastImageFilter<</div><div><span style="white-space:pre-wrap"> </span>MovingImageType, InternalImageType > MovingCastFilterType;</div><div><span style="white-space:pre-wrap"> </span>FixedCastFilterType::Pointer fixedCaster = FixedCastFilterType::New();</div><div><span style="white-space:pre-wrap"> </span>MovingCastFilterType::Pointer movingCaster = MovingCastFilterType::New();</div><div><span style="white-space:pre-wrap"> </span>fixedCaster->SetInput(fixedImageReader->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>movingCaster->SetInput(movingImageReader->GetOutput());</div><div><br></div><div><span style="white-space:pre-wrap"> </span>registration->SetFixedImage(fixedCaster->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>registration->SetMovingImage(movingCaster->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>fixedCaster->Update();</div><div><span style="white-space:pre-wrap"> </span>registration->SetFixedImageRegion(fixedCaster->GetOutput()->GetBufferedRegion());</div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef itk::CenteredTransformInitializer<</div><div><span style="white-space:pre-wrap"> </span>TransformType, FixedImageType,</div><div><span style="white-space:pre-wrap"> </span>MovingImageType > TransformInitializerType;</div><div><span style="white-space:pre-wrap"> </span>TransformInitializerType::Pointer initializer</div><div><span style="white-space:pre-wrap"> </span>= TransformInitializerType::New();</div><div><span style="white-space:pre-wrap"> </span>initializer->SetTransform(transform);</div><div><span style="white-space:pre-wrap"> </span>initializer->SetFixedImage(fixedImageReader->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>initializer->SetMovingImage(movingImageReader->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>initializer->GeometryOn();</div><div><span style="white-space:pre-wrap"> </span>initializer->InitializeTransform();</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef TransformType::ParametersType ParametersType;</div><div><span style="white-space:pre-wrap"> </span>const unsigned int numberOfParameters = transform->GetNumberOfParameters();</div><div><span style="white-space:pre-wrap"> </span>ParametersType parameters(numberOfParameters);</div><div><span style="white-space:pre-wrap"> </span>registration->SetInitialTransformParameters(transform->GetParameters());</div><div><br></div><div><span style="white-space:pre-wrap"> </span>OptimizerScalesType optimizerScales(transform->GetNumberOfParameters());</div><div><br></div><div><span style="white-space:pre-wrap"> </span>double translationScale = atof(argv[10]);</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[0] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[1] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[2] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[3] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[4] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[5] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[6] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[7] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[8] = 1.0;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[9] = translationScale;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[10] = translationScale;</div><div><span style="white-space:pre-wrap"> </span>optimizerScales[11] = translationScale;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>optimizer->SetScales(optimizerScales);</div><div><br></div><div><span style="line-height:1.5;white-space:pre-wrap"> </span><span style="line-height:1.5">FixedImageType::RegionType fixedImageRegion = fixedCaster->GetOutput()->GetBufferedRegion();</span><br></div><div><span style="white-space:pre-wrap"> </span>const unsigned int numberOfPixels = fixedImageRegion.GetNumberOfPixels();</div><div><span style="white-space:pre-wrap"> </span>double porcentage_samples = atof(argv[7]);</div><div><span style="white-space:pre-wrap"> </span>const unsigned int numberOfSamples = static_cast<unsigned int>(numberOfPixels * porcentage_samples);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>optimizer->SetNumberOfIterations(atof(argv[4]));</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetRelaxationFactor(atof(argv[5]));</div><div><span style="white-space:pre-wrap"> </span>metric->SetNumberOfHistogramBins(atof(argv[6]));</div><div><span style="white-space:pre-wrap"> </span>metric->SetNumberOfSpatialSamples(numberOfSamples);</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMaximumStepLength(atof(argv[8]));</div><div><span style="white-space:pre-wrap"> </span>optimizer->SetMinimumStepLength(atof(argv[9]));</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>optimizer->MinimizeOn();</div><div><span style="white-space:pre-wrap"> </span>CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();</div><div><span style="white-space:pre-wrap"> </span>optimizer->AddObserver(itk::IterationEvent(), observer);</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef RegistrationInterfaceCommand<RegistrationType> CommandType;</div><div><span style="white-space:pre-wrap"> </span>CommandType::Pointer command = CommandType::New();</div><div><span style="white-space:pre-wrap"> </span>registration->AddObserver(itk::IterationEvent(), command);</div><div><span style="white-space:pre-wrap"> </span>registration->SetNumberOfLevels(1);</div><div><span style="white-space:pre-wrap"> </span>registration->SetOptimizer(optimizer);</div><div><span style="white-space:pre-wrap"> </span>registration->SetInterpolator(interpolator);</div><div><span style="white-space:pre-wrap"> </span>registration->SetMetric(metric);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>FixedImageType::Pointer imagenfija = fixedImageReader->GetOutput();</div><div><span style="white-space:pre-wrap"> </span>MovingImageType::Pointer imagenflotante = movingImageReader->GetOutput();</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef RegistrationType::ParametersType ParametersType;</div><div><span style="white-space:pre-wrap"> </span>ParametersType InitialParameters = registration->GetInitialTransformParameters();</div><div><span style="white-space:pre-wrap"> </span>std::cout << "TranslationScale: " << translationScale << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "MaximumStep: " << optimizer->GetMaximumStepLength() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "MinimunStep: " << optimizer->GetMinimumStepLength() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Number of Bins: " << metric->GetNumberOfHistogramBins() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Number of Samples: " << metric->GetNumberOfSpatialSamples() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Iteraciones: " << optimizer->GetNumberOfIterations() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Relaxation: " << optimizer->GetRelaxationFactor() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Initial Parameters: " << InitialParameters << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Origen Fija: " << imagenfija->GetOrigin() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Origen Flotante: " << imagenflotante->GetOrigin() << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Samples: " << numberOfSamples << std::endl;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>try</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>registration->Update();</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Optimizer stop condition: "</div><div><span style="white-space:pre-wrap"> </span><< registration->GetOptimizer()->GetStopConditionDescription()</div><div><span style="white-space:pre-wrap"> </span><< std::endl;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>catch (itk::ExceptionObject & err)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>std::cout << "ExceptionObject caught !" << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << err << std::endl;</div><div><span style="white-space:pre-wrap"> </span>return EXIT_FAILURE;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>std::cout << "Optimizer Stopping Condition = "</div><div><span style="white-space:pre-wrap"> </span><< optimizer->GetStopCondition() << std::endl;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>ParametersType finalParameters = registration->GetLastTransformParameters();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>double TranslationAlongX = finalParameters[9];</div><div><span style="white-space:pre-wrap"> </span>double TranslationAlongY = finalParameters[10];</div><div><span style="white-space:pre-wrap"> </span>double TranslationAlongZ = finalParameters[11];</div><div><span style="white-space:pre-wrap"> </span>unsigned int numberOfIterations = optimizer->GetCurrentIteration();</div><div><span style="white-space:pre-wrap"> </span>double bestValue = optimizer->GetValue();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>std::cout << "Resultado = " << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << " Traslacion X = " << TranslationAlongX << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << " Traslacion Y = " << TranslationAlongY << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << " Traslacion Z = " << TranslationAlongZ << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << " Iteraciones = " << numberOfIterations << std::endl;</div><div><span style="white-space:pre-wrap"> </span>std::cout << " Metrica = " << bestValue << std::endl;</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>typedef itk::ResampleImageFilter<</div><div><span style="white-space:pre-wrap"> </span>MovingImageType,</div><div><span style="white-space:pre-wrap"> </span>FixedImageType > ResampleFilterType;</div><div><span style="white-space:pre-wrap"> </span>TransformType::Pointer finalTransform = TransformType::New();</div><div><span style="white-space:pre-wrap"> </span>finalTransform->SetParameters(finalParameters);</div><div><span style="white-space:pre-wrap"> </span>finalTransform->SetFixedParameters(transform->GetFixedParameters());</div><div><span style="white-space:pre-wrap"> </span>ResampleFilterType::Pointer resample = ResampleFilterType::New();</div><div><span style="white-space:pre-wrap"> </span>resample->SetTransform(finalTransform);</div><div><span style="white-space:pre-wrap"> </span>resample->SetInput(movingImageReader->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();</div><div><span style="white-space:pre-wrap"> </span>PixelType backgroundGrayLevel = 0; //estaba en 100</div><div><br></div><div><span style="white-space:pre-wrap"> </span>resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize());</div><div><span style="white-space:pre-wrap"> </span>resample->SetOutputOrigin(fixedImage->GetOrigin());</div><div><span style="white-space:pre-wrap"> </span>resample->SetOutputSpacing(fixedImage->GetSpacing());</div><div><span style="white-space:pre-wrap"> </span>resample->SetOutputDirection(fixedImage->GetDirection());</div><div><span style="white-space:pre-wrap"> </span>resample->SetDefaultPixelValue(backgroundGrayLevel);</div><div><span style="white-space:pre-wrap"> </span>typedef signed short OutputPixelType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::Image< OutputPixelType, Dimension > OutputImageType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::CastImageFilter<</div><div><span style="white-space:pre-wrap"> </span>FixedImageType,</div><div><span style="white-space:pre-wrap"> </span>OutputImageType > CastFilterType;</div><div><span style="white-space:pre-wrap"> </span>typedef itk::ImageFileWriter< OutputImageType > WriterType;</div><div><span style="white-space:pre-wrap"> </span>WriterType::Pointer writer = WriterType::New();</div><div><span style="white-space:pre-wrap"> </span>CastFilterType::Pointer caster = CastFilterType::New();</div><div><span style="white-space:pre-wrap"> </span>writer->SetFileName(argv[3]);</div><div><span style="white-space:pre-wrap"> </span>caster->SetInput(resample->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>writer->SetInput(caster->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>writer->Update();</div><div><span style="white-space:pre-wrap"> </span>Sleep(5000);</div><div>/*</div><div><span style="white-space:pre-wrap"> </span>typedef itk::CheckerBoardImageFilter< FixedImageType > CheckerBoardFilterType;</div><div><span style="white-space:pre-wrap"> </span>CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New();</div><div><span style="white-space:pre-wrap"> </span>checker->SetInput1(fixedImage);</div><div><span style="white-space:pre-wrap"> </span>checker->SetInput2(resample->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>caster->SetInput(checker->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>writer->SetInput(caster->GetOutput());</div><div><span style="white-space:pre-wrap"> </span>resample->SetDefaultPixelValue(0);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>resample->SetTransform(finalTransform);</div><div><span style="white-space:pre-wrap"> </span>if (argc > 10)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>writer->SetFileName(argv[11]);</div><div><span style="white-space:pre-wrap"> </span>writer->Update();</div><div><span style="white-space:pre-wrap"> </span>}*/</div><div><span style="white-space:pre-wrap"> </span>return EXIT_SUCCESS;</div><div>}</div></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">El lun., 7 de dic. de 2015 a la(s) 11:43, Luigi Riba <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dear ITK community,</div><div><br></div><div>today I was trying to implement a multi-resolution registration process for 3d images.</div><div><br></div><div>I started from the example in the tutorial. Unfortunately, I've received the following warning:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">WARNING: In f:\libs\insighttoolkit-4.8.2\modules\numerics\optimizersv4\include\itkObjectToObjectMetric.hxx, line 529<br>MeanSquaresImageToImageMetricv4 (000000006506C020): No valid points were found during metric evaluation. For image metrics, verify that the images overlap appropriately. For instance, you can align the image centers by translation. For point-set metrics, verify that the fixed points, once transformed into the virtual domain space, actually lie within the virtual domain.</blockquote></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">These are the parameters I have used for the multi resolution process:<br><span style="white-space:pre-wrap"> </span>const unsigned int numberOfLevels = 3;<br><span style="white-space:pre-wrap"> </span>RegistrationType::ShrinkFactorsArrayType shrinkFactorsPerLevel;<br><span style="white-space:pre-wrap"> </span>shrinkFactorsPerLevel.SetSize(numberOfLevels);<br><span style="white-space:pre-wrap"> </span>shrinkFactorsPerLevel[0] = 4;<br><span style="white-space:pre-wrap"> </span>shrinkFactorsPerLevel[1] = 2;<br><span style="white-space:pre-wrap"> </span>shrinkFactorsPerLevel[2] = 1;<br><span style="white-space:pre-wrap"> </span>RegistrationType::SmoothingSigmasArrayType smoothingSigmasPerLevel;<br><span style="white-space:pre-wrap"> </span>smoothingSigmasPerLevel.SetSize(numberOfLevels);<br><span style="white-space:pre-wrap"> </span>smoothingSigmasPerLevel[0] = 2;<br><span style="white-space:pre-wrap"> </span>smoothingSigmasPerLevel[1] = 1;<br><span style="white-space:pre-wrap"> </span>smoothingSigmasPerLevel[2] = 0;<br><span style="white-space:pre-wrap"> </span>registration->SetNumberOfLevels(numberOfLevels);<br><span style="white-space:pre-wrap"> </span>registration->SetSmoothingSigmasPerLevel(smoothingSigmasPerLevel);<br><span style="white-space:pre-wrap"> </span>registration->SetShrinkFactorsPerLevel(shrinkFactorsPerLevel);</blockquote><div><br></div><div>Could you please me explain what is the meaning of this warning?</div><div><br></div><div>By the way, I am working with affine transformations and I have used the transform initializer.</div><div><br></div><div>Best,</div><div><br></div><div>Luigi </div></div>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div dir="ltr">Matias</div></blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><div dir="ltr">-- <br></div><div dir="ltr">Matias</div>
</font></span></blockquote></div><br></div>