[Insight-users] Problem computing final metric value
motes motes
mort.motes at gmail.com
Wed Apr 28 06:33:29 EDT 2010
I have a class Processor looking like this (Processor.h):
template <typename J, typename M, typename I, typename O, typename T>
class Processor {
public:
// ...
// itk types
typedef itk::ImageRegistrationMethod<FixedImageType,
MovingImageType >
RegistrationMethodType;
Processor ();
virtual ~Processor ();
// Setting up the itk componenets
void Start();
double GetFinalMetricValue() {
ParametersType params = registrationMethod->GetLastTransformParameters();
double dd = registrationMethod->GetOptimizer()->GetValue(params);
return dd;
}
private:
typename RegistrationMethodType::Pointer registrationMethod;
};
In Processor.cpp Start() looks like this:
template <typename J, typename M, typename I, typename O, typename T>
void
Processor<J,M,I,O,T>::Start() {
try {
this->registrationMethod->Update();
}
catch( itk::ExceptionObject & err ) {
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
}
ParametersType params = registrationMethod->GetLastTransformParameters();
double value = registrationMethod->GetOptimizer()->GetValue(params);
std::cout << "final val = " << value << std::endl;
}
I then run the processor like:
Processor<......> processor;
processor.Start();
processor.GetFinalMetricValue();
The call:
processor.Start();
works fine but the call:
processor.GetFinalMetricValue();
gives a segmentation error. The problem is this line in GetFinalMetricValue():
double dd = registrationMethod->GetOptimizer()->GetValue(params);
Why is it possible to compute the metric value in Start() but not in
the GetFinalMetricValue() ? Is some of the fields in the Optimizer
dealocated after the Start() call?
More information about the Insight-users
mailing list