Commit bbe1d54b authored by Floris Berendsen's avatar Floris Berendsen

ENH: added optional masks for AntsCorrelationMetric

parent b27a78b5
......@@ -32,7 +32,8 @@ namespace selx
template< int Dimensionality, class TPixel >
class ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component :
public SuperElastixComponent<
Accepting< >,
Accepting< itkImageFixedMaskInterface< Dimensionality, unsigned char >,
itkImageMovingMaskInterface< Dimensionality, unsigned char > >,
Providing< itkMetricv4Interface< Dimensionality, TPixel, double >>
>
{
......@@ -43,7 +44,8 @@ public:
Dimensionality, TPixel
> Self;
typedef SuperElastixComponent<
Accepting< >,
Accepting< itkImageFixedMaskInterface< Dimensionality, unsigned char >,
itkImageMovingMaskInterface< Dimensionality, unsigned char > >,
Providing< itkMetricv4Interface< Dimensionality, TPixel, double >>
> Superclass;
typedef std::shared_ptr< Self > Pointer;
......@@ -59,16 +61,25 @@ public:
typedef itk::Image< PixelType, Dimensionality > MovingImageType;
typedef typename itk::ImageToImageMetricv4< FixedImageType, MovingImageType > ImageToImageMetricv4Type;
//typedef typename ItkMetricv4Interface<Dimensionality, TPixel>::ImageToImageMetricv4Type ImageToImageMetricv4Type;
//typedef ItkMetricv4Interface<Dimensionality, TPixel>::ImageToImageMetricv4Type ItkMetricv4Pointer
typedef typename ImageToImageMetricv4Type::Pointer ItkMetricv4Pointer;
typedef typename itk::ANTSNeighborhoodCorrelationImageToImageMetricv4< FixedImageType, MovingImageType > TheItkFilterType;
// accepting Interfaces:
virtual int Accept(typename itkImageFixedMaskInterface< Dimensionality, unsigned char >::Pointer) override;
virtual int Accept(typename itkImageMovingMaskInterface< Dimensionality, unsigned char >::Pointer) override;
// providing Interfaces:
virtual ItkMetricv4Pointer GetItkMetricv4() override;
// Base class methods:
virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
virtual bool ConnectionsSatisfied() override {return true;} // all of the accepting interfaces are optional
static const char * GetDescription() { return "ItkANTSNeighborhoodCorrelationImageToImageMetricv4 Component"; }
private:
......
......@@ -19,6 +19,7 @@
#include "selxItkANTSNeighborhoodCorrelationImageToImageMetricv4Component.h"
#include "selxCheckTemplateProperties.h"
#include "itkImageMaskSpatialObject.h"
namespace selx
{
......@@ -38,6 +39,30 @@ ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< Dimensionality, TPi
{
}
template< int Dimensionality, class TPixel >
int
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< Dimensionality, TPixel >::Accept(typename itkImageFixedMaskInterface< Dimensionality, unsigned char >::Pointer component)
{
auto fixedMaskImage = component->GetItkImageFixedMask();
// connect the itk pipeline
auto fixedMaskSpatialObject = itk::ImageMaskSpatialObject< Dimensionality >::New();
fixedMaskSpatialObject->SetImage( fixedMaskImage );
this->m_theItkFilter->SetFixedImageMask(fixedMaskSpatialObject);
return 0;
}
template< int Dimensionality, class TPixel >
int
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< Dimensionality, TPixel >::Accept(typename itkImageMovingMaskInterface< Dimensionality, unsigned char >::Pointer component)
{
auto movingMaskImage = component->GetItkImageMovingMask();
// connect the itk pipeline
auto movingMaskSpatialObject = itk::ImageMaskSpatialObject< Dimensionality >::New();
movingMaskSpatialObject->SetImage(movingMaskImage);
this->m_theItkFilter->SetMovingImageMask(movingMaskSpatialObject);
return 0;
}
template< int Dimensionality, class TPixel >
typename ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< Dimensionality, TPixel >::ItkMetricv4Pointer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment