[Insight-users] Mattes Information Metric

Ken Urish ken.urish at gmail.com
Sun Dec 5 10:27:56 EST 2010


Just to follow the thread to conclusion, there was one error in the suggestions.
The itk identity transform does not implement GetParameters. See:
http://www.itk.org/pipermail/insight-users/2008-January/024665.html

Thus, you need to to use any transfrom such as itk translation
transform and call SetIdentity.

Thus, to output the metric value on two images the code looks something like:

  typedef itk::MattesMutualInformationImageToImageMetric<
FixedImageType, MovingImageType > MetricType;
  MetricType::Pointer metric = MetricType::New();
  metric->SetFixedImage( fixedImagePtr );
  metric->SetMovingImage( movingImagePtr );

  typedef itk::TranslationTransform< double, Dimension >  TransformType;
  TransformType::Pointer transform = TransformType::New();
  transform->SetIdentity();
  metric->SetTransform( transform );

  typedef itk::LinearInterpolateImageFunction< MovingImageType,
double> InterpolatorType;
  InterpolatorType::Pointer interpolator  = InterpolatorType::New();
  metric->SetInterpolator( interpolator );

  metric->SetFixedImageRegion( fixedImagePtr->GetBufferedRegion() );
  metric->Initialize();

  double metricValue = metric->GetValue( transform->GetParameters());

Thanks
--Ken--


On Sat, Oct 30, 2010 at 9:19 AM, Karthik Krishnan
<karthik.krishnan at kitware.com> wrote:
> As Cory says, use the identity transform. Also set the interpolator,
> and the fixed image region and finally call Initialize or the metric
> will throw an error.
>
> something like:
>
>   MetricType::Pointer metric = MetricType::New();
>   metric->SetFixedImage( image1 );
>   metric->SetMovingImage( image2 );
>
>   typedef itk::IdentityTransform< double, Dimension >  TransformType;
>   TransformType::Pointer transform = TransformType::New();
>   metric->SetTransform( transform );
>
>  typedef itk::LinearInterpolateImageFunction<
>           ImageType, double > InterpolatorType;
>  InterpolatorType::Pointer interpolator  = InterpolatorType::New();
>  metric->SetInterpolator( interpolator );
>
>  metric->SetFixedImageRegion( image1->GetBufferedRegion() );
>  metric->Initialize();
>  const double metricValue = metric->GetValue( transform->GetParameters()
> );
>
>
>  --
>  karthik
>
> On 10/29/10, Cory Quammen <cquammen at cs.unc.edu> wrote:
>> Ken,
>>
>> When you call GetValue(), the argument you give it is passed to the
>> transform, and the metric is computed over the transformed moving
>> image. If you don't want a transformation on your un-moving image,
>> simply set the transform for the metric to an IdentityTransform. Then
>> simply pass GetValue() a variable of type
>> IdentityTransform::ParametersType. You shouldn't need to initialize
>> the ParametersType variable (it should be a zero-length vector).
>>
>> The code should look something like
>>
>> typedef MattesMutualInformationImageToImageMetric< TFixedImageType,
>> TMovingImageType > MetricType;
>>
>> MetricType::Pointer metric = MetricType::New();
>>
>> typedef IdentityTransform<..., ...> IdentityTransformType;
>> IdentityTransformType::Pointer transform = IdentityTransformType::New();
>> metric->SetTransform(transform);
>>
>> MetricType::ParametersType params;
>> double value = metric->GetValue(params);
>>
>> For what it's worth, there is (I think) an effort underway to separate
>> the transforms from the metrics in ITK v4, which should let you call a
>> parameter-less GetValue() method and avoid this complication
>> altogether.
>>
>> Hope that helps,
>> Cory
>>
>> On Thu, Oct 28, 2010 at 5:56 PM, Ken Urish <ken.urish at gmail.com> wrote:
>>> Simple question but Im getting lost in the code
>>>
>>> Given two images I want to calculate the Mattes Mutual Information
>>> Metric outside of the registration framework. This is easy during
>>> registration as you just need "optimizer->GetValue()". However, I dont
>>> want any transforms or optimizers involved and simply want to call the
>>> metric value directly from:
>>> itkMattesMutualInformationImageToImageMetric given two images. The
>>> GetValue in MattessMutualInformationMetric macro needs a ParameterType
>>> and Im stuck looking through the code what this is?
>>>
>>> Thanks
>>> --Ken--
>>> _____________________________________


More information about the Insight-users mailing list