[Insight-users] Helo with bspline/mutual information/gradient descent

J.X.J. wat.a.phony at gmail.com
Sun Aug 9 05:17:31 EDT 2009


Hi Luis,

How can I store the metric value of each iteration into a file or
variable/array within the observer? I've tried using ofstream to output the
metric into a text file but it only stores the final metric value
(optimizer->GetMetric()) after the registration->update() is finished. I've
tried introducing ofstream into the observer but I cannot use the following
command inside the observer (if that makes sense).

std::ofstream infile;
infile.open(argv[4]);
infile<<optimizer->GetMetric();
infile.close;

As for the Levenberg Marquardt Optimizer this is the whole error message
when compiling.

1>BSpline_ITK_DICOMM.cxx
1>.\BSpline_ITK_DICOMM.cxx(242) : error C2664:
'itk::ImageRegistrationMethod<TFixedImage,TMovingImage>::SetOptimizer' :
cannot convert parameter 1 from 'itk::LevenbergMarquardtOptimizer::Pointer'
to 'itk::ImageRegistrationMethod<TFixedImage,TMovingImage>::OptimizerType *'
1>        with
1>        [
1>            TFixedImage=InternalImageType,
1>            TMovingImage=InternalImageType
1>        ]
1>        No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
1>.\BSpline_ITK_DICOMM.cxx(366) : error C2039: 'GetCurrentIteration' : is
not a member of 'itk::LevenbergMarquardtOptimizer'
1>        D:\University -
Engineering\Project\InsightToolkit-3.12.0\Code\Numerics\itkLevenbergMarquardtOptimizer.h(31)
: see declaration of 'itk::LevenbergMarquardtOptimizer'
1>.\BSpline_ITK_DICOMM.cxx(367) : error C2440: 'initializing' : cannot
convert from 'itk::MultipleValuedNonLinearOptimizer::MeasureType' to
'double'
1>        No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called

J.X.J.


Luis Ibanez wrote:
> 
> Hi J.X.J.
> 
> If the Metric is oscillating, this may be a symptom that your optimizer
> is taking jumps that are too large.
> 
> I usually plot the metric values by using GNUPlot, but you could do the
> same with the spreadsheet of OpenOffice, or even with Excel.
> 
> ---
> 
> About the compilation error,  please post also the sentence that
> follows the one that you posted. The next sentence to that one
> tells what the problem is.
> 
> 
>      Thanks
> 
> 
>             Luis
> 
> 
> ----------------------
> On Sat, Aug 8, 2009 at 7:45 PM, J.X.J. <wat.a.phony at gmail.com> wrote:
> 
>>
>> Hi Luis,
>>
>> thanks for your reply. I have added an observe to the code, the metric
>> value
>> output seems to oscillate rather than a general increase for decrease in
>> value. How do you plot the metric values? Is there a way to output the
>> metric value of each iteration into a text or similar file and I could
>> use
>> MATLAB to plot it, or is there a way to do that directly from ITK?
>>
>> Also I've noticed that using Viola and Wells MI is REALLY slow when
>> coupled
>> with BSpline Deformable Transform. I've tried using Mattes MI which is
>> much
>> much faster in comparison in the order of 5-10 fold, why is that the
>> case?
>>
>> And finally (I'm sorry for all the questions, programming in C is not my
>> forte), I tried using Levenberg Marquardt Optimizer but I get this error
>> but
>> I compile the code: error C2664:
>> 'itk::ImageRegistrationMethod<TFixedImage,TMovingImage>::SetOptimizer' :
>> cannot convert parameter 1 from
>> 'itk::LevenbergMarquardtOptimizer::Pointer'
>> to 'itk::ImageRegistrationMethod<TFixedImage,TMovingImage>::OptimizerType
>> *'
>>
>> Any help is appreciated
>> J.X.J.
>>
>>
>> Luis Ibanez wrote:
>> >
>> > Hi J.X.J.
>> >
>> > The first thing that you want to do is to instantiate a
>> Command/Observer
>> > and to print out the values of the Metric at every iteration of the
>> > optimizer.
>> >
>> > Plot this values and/or send the output to the mailing list.
>> >
>> > From the progression of the metric values it will be possible to
>> determine
>> > if parameters of the optimizer need to be adjusted, or whether you may
>> > have to review other components of your registration structure.
>> >
>> > You will find examples on how to use Command Observers in almost
>> > all the files in the directory:
>> >
>> >                     Insight/Examples/Registration
>> >
>> >
>> >     Regards,
>> >
>> >
>> >           Luis
>> >
>> >
>> > --------------------------------------------------------------------
>> > On Sat, Aug 1, 2009 at 6:49 AM, J.X.J. <wat.a.phony at gmail.com> wrote:
>> >
>> >>
>> >> Hi everyone,
>> >>
>> >> I'm current using itk::BSplineDeformableTransform,
>> >> itk::MutualInformationImageToImageMetric and
>> >> itk::GradientDescentOptimizer
>> >> to register 2D MRI images. My problem is that when running 2 phantom
>> >> images
>> >> the output image is almost exactly the same as the original moving
>> image
>> >> (nothing like the fixed image).
>> >>
>> >> I have normalized and smoothed the 2 input images using
>> >> itk::NormalizeImageFilter and itk::DiscreteGaussianImageFilter with
>> >> SetVariance(2.0). For mutual information the standard deviation is
>> 0.4.
>> >> Optimizer learning rate is 10.0, 200 iteration and with maximum on.
>> This
>> >> set
>> >> up is kind of a mixture of a number of deformableregistration examples
>> on
>> >> default (as in I copied and pasted all parameter settings etc
>> directly).
>> >>
>> >> Does anyone know what the problem could be? The code runs all 200
>> >> iterations
>> >> is thats an indication, also the metric value of each iteration is
>> around
>> >> 0.2 - 0.4 if that's any help.
>> >>
>> >> J.X.J.
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Helo-with-bspline-mutual-information-gradient-descent-tp24768056p24768056.html
>> >> Sent from the ITK - Users mailing list archive at Nabble.com.
>> >>
>> >> _____________________________________
>> >> Powered by www.kitware.com
>> >>
>> >> Visit other Kitware open-source projects at
>> >> http://www.kitware.com/opensource/opensource.html
>> >>
>> >> 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://www.itk.org/mailman/listinfo/insight-users
>> >>
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > 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://www.itk.org/mailman/listinfo/insight-users
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Helo-with-bspline-mutual-information-gradient-descent-tp24768056p24883109.html
>> Sent from the ITK - Users mailing list archive at Nabble.com.
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> 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://www.itk.org/mailman/listinfo/insight-users
>>
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> 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://www.itk.org/mailman/listinfo/insight-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Helo-with-bspline-mutual-information-gradient-descent-tp24768056p24885406.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list