<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:12pt"><div id="yiv1008358354"><div><div style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;" id="yiv1008358354yui_3_2_0_111_132694209626448"><span id="yiv1008358354yui_3_2_0_111_132694209626465">Hi all,</span><span><br></span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264482" style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><br><span id="yiv1008358354yui_3_2_0_111_132694209626465"></span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264483" style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><span id="yiv1008358354yui_3_2_0_111_132694209626465">I am trying to register 2D images (spect modality) witk itk Mattes mutual information.
Visually, offsets between both images are very small (translation of ~ 5 mms). I am initializing transform parameters to 0 for the 3 parameters of euler 2D transform. However, after registration I got a rotation around 90 degres. Plus, when I am observing
optimizer iterations, first iteration is already 1.6 radian for rotation parameter, even if my initial rotation parameter was 0. <br></span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264596" style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><br>Here is the observer:<br><br>MultiResolution Level : 0<br>0 = -0.372419 : [1.7683, -0.0955618, -0.929501]<br>1 = -0.0383217 : [1.92583, -2.08874, -0.978926]<br>2 = -0.0362538 : [1.69325, -1.10031, -2.21542]<br>3 = -0.0377709 : [1.56321, -1.28384, -3.79953]<br>4 = -0.0419196 : [1.66387, -2.53705, -3.55923]<br>141 = -0.042436 : [1.51798, -17.6144, -6.53557]<br>142 = -0.0423536 : [1.52173, -17.635, -6.52587]<br>143 = -0.042424 : [1.51635, -17.6507, -6.54188]<br><br> Iterations = 145<br> Metric value = -0.0424182<br> Stop Condition = RegularStepGradientDescentOptimizer: Step too small after 144<br> iterations. Current step (0.0184467)
is less than minimum step (0.02).<br>Result =<br> Translation X = 17.6507 mm<br> Translation Y = 6.54188 mm<br> Rotation X = -86.8805 degres<br><br>Here is part of the print out of registration:<br> CurrentLevel: 1<br> InitialTransformParameters: [0, 0, 0]<br> InitialTransformParametersOfNextLevel: [0, 0, 0]<br> LastTransformParameters: [1.51635, -17.6507, -6.54188]<br> FixedImageRegion: ImageRegion (103F17EC)<br> Dimension: 2<br> Index: [0, 0]<br> Size: [256, 1024]<br><br> FixedImageRegion at level 0: ImageRegion (04DA4C98)<br> Dimension: 2<br> Index: [0, 0]<br> Size: [128, 512]<br><br> FixedImageRegion at level 1: ImageRegion (04DA4CAC)<br> Dimension: 2<br> Index: [0, 0]<br> Size: [256, 1024]<br><br><br><span id="yiv1008358354yui_3_2_0_111_132694209626465"></span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264611"
style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><span id="yiv1008358354yui_3_2_0_111_132694209626465">It's clear that I am missing something. </span><span id="yiv1008358354yui_3_2_0_111_132694209626465">Please help. Here is my code:</span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264466" style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><span id="yiv1008358354yui_3_2_0_111_132694209626465"><br></span></div><div id="yiv1008358354yui_3_2_0_111_1326942096264467" style="font-family:Courier New, courier, monaco, monospace, sans-serif;"><span id="yiv1008358354yui_3_2_0_111_132694209626465"> ImageType::RegionType fixedImageRegion = fixedImage->GetBufferedRegion();<br> ImageType::RegionType movingImageRegion = movingImage->GetBufferedRegion(); <br id="yiv1008358354yui_3_2_0_111_1326942096264334"></span></div><div style="font-family:Courier New, courier, monaco, monospace,
sans-serif;" id="yiv1008358354yui_3_2_0_111_1326942096264104"><span id="yiv1008358354yui_3_2_0_111_132694209626465"><br></span></div><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;" id="yiv1008358354yui_3_2_0_111_1326942096264105"><span id="yiv1008358354yui_3_2_0_111_132694209626465"> typedef itk::Euler2DTransform< double > TransformType; <br> TransformType::Pointer transform = TransformType::New();<br> registration_->SetTransform(transform);<br><br> // Initialize transform parameters<br> int transformParametersTotal =
registration_->GetTransform()->GetNumberOfParameters();<br> typedef RegistrationType::ParametersType ParametersType;<br> ParametersType initialParameters(transformParametersTotal);<br> initialParameters.Fill(0.0);<br> registration_->SetInitialTransformParameters(initialParameters); <br><br> metric_->SetNumberOfHistogramBins(50);<br> metric_->UseAllPixelsOn();<br><br> registration_->SetFixedImage(fixedImage);<br> registration_->SetMovingImage(movingImage); <br> registration_->SetFixedImageRegion(fixedImageRegion);<br></span></div><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;" id="yiv1008358354yui_3_2_0_111_1326942096264433"><span id="yiv1008358354yui_3_2_0_111_132694209626465"><br></span></div><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;" id="yiv1008358354yui_3_2_0_111_1326942096264444"><span
id="yiv1008358354yui_3_2_0_111_132694209626465">
typedef OptimizerType::ScalesType ScalesType;<br> int transformParametersTotal = registration_->GetTransform()->GetNumberOfParameters();<br> ScalesType parametersScales(transformParametersTotal);<br> parametersScales.Fill( 1.0 );<br><br> for (int j = 1; j < transformParametersTotal; j++ ){<br> parametersScales[j] = 1.0 / 1000;<br> } <br><br> optimizer_->SetScales(parametersScales);<br> <br> // The initial step length is defined with SetMaximumStepLength()<br> optimizer_->SetMaximumStepLength(2.0); <br> optimizer_->SetMinimumStepLength(0.02);<br><br> // Define number of iterations per multi-resolution level<br> optimizer_->SetNumberOfIterations( 200);<br> <br> optimizer_->SetRelaxationFactor(0.8); <br> <br> OptimizerIterationUpdate::Pointer
observer = OptimizerIterationUpdate::New();<br> optimizer_->AddObserver( itk::IterationEvent(), observer );<br><br> typedef RegistrationInterfaceCommand<RegistrationType> CommandType;<br> CommandType::Pointer command = CommandType::New();<br> registration_->AddObserver( itk::IterationEvent(), command );<br> <br> registration_->Update(); <br> // Output parameters<br> ParametersType finalParameters = registration_->GetLastTransformParameters();<br> result[0] = ;<br> result[1] = <br> result[2] = ; <br><br> // Print out results<br> std::cout << "Result = " << std::endl;<br> std::cout
<< " Translation X = " << </span><span id="yiv1008358354yui_3_2_0_111_132694209626465">- finalParameters[1]</span><span id="yiv1008358354yui_3_2_0_111_132694209626465"> << std::endl;<br> std::cout << " Translation Y = " <<</span><span id="yiv1008358354yui_3_2_0_111_132694209626465">- finalParameters[2];</span><span id="yiv1008358354yui_3_2_0_111_132694209626465"> << std::endl;<br> std::cout << " Rotation X = " << -</span><span id="yiv1008358354yui_3_2_0_111_132694209626465"> finalParameters[0] * RAD_TO_DEG</span><span id="yiv1008358354yui_3_2_0_111_132694209626465"> << std::endl; </span></div><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;" id="yiv1008358354yui_3_2_0_111_132694209626451"> </div><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;">Isabelle Renaud<br
id="yiv1008358354yui_3_2_0_111_132694209626456"></div></div></div></div></div></body></html>