<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Tim,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">can you turn this snippet into a runnable example which reproduces the memory leak?</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 5, 2016 at 12:27 PM, Timothee Evain <span dir="ltr"><<a href="mailto:tevain@telecom-paristech.fr" target="_blank">tevain@telecom-paristech.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
<br>
I'm trying a Bspline registration based on the Mutual Information metric (v4) and I'm facing a memory problem.<br>
When running the registration, the memory usage skyrockets in a second until freezing the PC by lack of memory.<br>
I don't know why : this doesn't happen when I'm switching to another metric (e.g. Correlation), the images aren't that big (~400k voxels) and a previous rigid registration phase behaved correctly.<br>
Here is my code snippet, what am I doing wrong ? (Image overlap had been ensured)<br>
<br>
typedef itk::Image<float,3> ImageTypef;<br>
<br>
itk::<wbr>ImageRegistrationMethodv4<<wbr>ImageTypef,ImageTypef>::<wbr>Pointer WarpHelper=<br>
itk::<wbr>ImageRegistrationMethodv4<<wbr>ImageTypef,ImageTypef>::New();<br>
itk::<wbr>MattesMutualInformationImageTo<wbr>ImageMetricv4<ImageTypef,<wbr>ImageTypef>::Pointer MIMetrics=<br>
itk::<wbr>MattesMutualInformationImageTo<wbr>ImageMetricv4<ImageTypef,<wbr>ImageTypef>::New();<br>
itk::BSplineTransform<double,<wbr>3,3>::Pointer BSplineTransform=<br>
itk::BSplineTransform<double,<wbr>3,3>::New();<br>
itk::LBFGSOptimizerv4::Pointer Optimizer=<br>
itk::LBFGSOptimizerv4::New();<br>
<br>
MIMetrics-><wbr>SetNumberOfHistogramBins(50);<br>
MIMetrics-><wbr>SetUseMovingImageGradientFilte<wbr>r(false);<br>
MIMetrics-><wbr>SetUseFixedImageGradientFilter<wbr>(false);<br>
MIMetrics-><wbr>SetUseFixedSampledPointSet(<wbr>false);<br>
MIMetrics-><wbr>SetVirtualDomainFromImage(<wbr>TestIm);<br>
<br>
<br>
WarpHelper->SetFixedImage(<wbr>TestIm);<br>
WarpHelper-><wbr>SetMetricSamplingPercentage(0.<wbr>002);<br>
WarpHelper->SetMovingImage(<wbr>MovIm);<br>
WarpHelper->SetMetric(<wbr>MIMetrics);<br>
//WarpHelper-><wbr>SetMetricSamplingStrategy(<wbr>WarpHelper->RANDOM);<br>
WarpHelper->InPlaceOn();<br>
WarpHelper-><wbr>SetInitialTransform(<wbr>BSplineTransform);<br>
WarpHelper->SetOptimizer(<wbr>Optimizer);<br>
<br>
itk::Array<double> ShrinkFactorPerLevel(1);<br>
ShrinkFactorPerLevel[0]=1;<br>
itk::Array<double> SmoothSigmaPerLevel(1);<br>
SmoothSigmaPerLevel[0]=0;<br>
WarpHelper->SetNumberOfLevels(<wbr>1);<br>
WarpHelper-><wbr>SetSmoothingSigmasPerLevel(<wbr>SmoothSigmaPerLevel);<br>
WarpHelper-><wbr>SetShrinkFactorsPerLevel(<wbr>ShrinkFactorPerLevel);<br>
<br>
/* ----- Initialize the Bspline Transform ----- */<br>
BSplineTransform-><wbr>SetTransformDomainOrigin(<wbr>TestIm->GetOrigin());<br>
BSplineTransform-><wbr>SetTransformDomainDirection(<wbr>TestIm->GetDirection());<br>
<br>
itk::Vector<double,3> PhysicalDim;<br>
for (int dim = 0; dim < 3; dim++)<br>
{<br>
PhysicalDim=(TestIm-><wbr>GetSpacing()[dim])*float((<wbr>TestIm-><wbr>GetLargestPossibleRegion().<wbr>GetSize()[dim])-1);<br>
}<br>
BSplineTransform-><wbr>SetTransformDomainPhysicalDime<wbr>nsions(PhysicalDim);<br>
<br>
itk::Size<3> meshSize;<br>
meshSize.Fill(10-3);// NbGridNodesEachDim-SplineOrder<br>
BSplineTransform-><wbr>SetTransformDomainMeshSize(<wbr>meshSize);<br>
<br>
BSplineTransform->SetIdentity(<wbr>);<br>
<br>
/* ----- Optimizer setup ----- */<br>
itk::Array<double> ScaleBspline(BSplineTransform-<wbr>>GetNumberOfParameters());<br>
ScaleBspline.fill(1);<br>
<br>
Optimizer-><wbr>SetLineSearchAccuracy(0.9);<br>
Optimizer-><wbr>SetDefaultStepLength(1.5);<br>
Optimizer->TraceOn();<br>
Optimizer-><wbr>SetGradientConvergenceToleranc<wbr>e(1e-3);<br>
Optimizer-><wbr>SetMaximumNumberOfFunctionEval<wbr>uations(20);<br>
Optimizer-><wbr>SetDoEstimateScales(false);<br>
Optimizer->SetScales(<wbr>ScaleBspline);<br>
<br>
<br>
try<br>
{<br>
WarpHelper->Update();<br>
}<br>
catch (itk::ExceptionObject &err)<br>
{<br>
std::cerr<<err;<br>
return 0;<br>
}<br>
<br>
Thanks,<br>
<br>
Tim<br>
______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/community</a><br>
</blockquote></div><br></div>