Commit cdbcc4ef authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: itkGaussianExponentialDiffeomorphicTransformComponent gets fixed

domain parameters from fixedSource connection
parent d308cfb8
......@@ -30,9 +30,11 @@ namespace selx
template <class InternalComputationValueType, int Dimensionality>
class ItkGaussianExponentialDiffeomorphicTransformComponent :
public Implements<
Accepting< >,
Providing< itkTransformInterface<InternalComputationValueType,Dimensionality>>
>
Accepting< itkImageFixedInterface<Dimensionality, double> >,
Providing< itkTransformInterface<InternalComputationValueType,Dimensionality>,
RunRegistrationInterface
>>
//Should be fixed domain only
{
public:
selxNewMacro(ItkGaussianExponentialDiffeomorphicTransformComponent, ComponentBase);
......@@ -49,14 +51,21 @@ namespace selx
using TransformPointer = typename itkTransformInterface<InternalComputationValueType,Dimensionality>::TransformPointer;
typedef typename itk::GaussianExponentialDiffeomorphicTransform<InternalComputationValueType, Dimensionality> GaussianExponentialDiffeomorphicTransformType;
//Accepting Interfaces:
virtual int Set(itkImageFixedInterface<Dimensionality, double>*) override;
//Providing Interfaces:
virtual TransformPointer GetItkTransform() override;
virtual void RunRegistration() override;
//BaseClass methods
virtual bool MeetsCriterion(const ComponentBase::CriterionType &criterion) override;
//static const char * GetName() { return "ItkGaussianExponentialDiffeomorphicTransform"; } ;
static const char * GetDescription() { return "ItkGaussianExponentialDiffeomorphicTransform Component"; };
private:
typename GaussianExponentialDiffeomorphicTransformType::Pointer m_Transform;
typename itk::Image<double, Dimensionality>::Pointer m_FixedImage;
protected:
/* The following struct returns the string name of computation type */
/* default implementation */
......
......@@ -26,20 +26,7 @@ namespace selx
{
m_Transform = GaussianExponentialDiffeomorphicTransformType::New();
typedef itk::Image<VectorType, Dimensionality> ConstantVelocityFieldType;
typename ConstantVelocityFieldType::Pointer displacementField = ConstantVelocityFieldType::New();
displacementField->CopyInformation(fixedImage);
displacementField->SetRegions(fixedImage->GetBufferedRegion());
displacementField->Allocate();
displacementField->FillBuffer(zeroVector);
typename ConstantVelocityFieldTransformType::Pointer fieldTransform = ConstantVelocityFieldTransformType::New();
fieldTransform->SetGaussianSmoothingVarianceForTheUpdateField(3.0);
fieldTransform->SetGaussianSmoothingVarianceForTheConstantVelocityField(6.0);
fieldTransform->SetConstantVelocityField(displacementField);
fieldTransform->SetCalculateNumberOfIntegrationStepsAutomatically(true);
fieldTransform->IntegrateVelocityField();
//TODO: instantiating the filter in the constructor might be heavy for the use in component selector factory, since all components of the database are created during the selection process.
......@@ -51,12 +38,46 @@ ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueT
{
}
template<class InternalComputationValueType, int Dimensionality>
int ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueType, Dimensionality>
::Set(itkImageFixedInterface<Dimensionality, double>* component)
{
this->m_FixedImage = component->GetItkImageFixed();
auto displacementField = GaussianExponentialDiffeomorphicTransformType::DisplacementFieldType::New();
//auto zeroVector = itk::NumericTraits<GaussianExponentialDiffeomorphicTransformType::DisplacementFieldType::PixelType>::Zero();
auto zeroVector = GaussianExponentialDiffeomorphicTransformType::DisplacementFieldType::PixelType(0.0);
displacementField->CopyInformation(this->m_FixedImage);
displacementField->SetRegions(this->m_FixedImage->GetBufferedRegion());
displacementField->Allocate();
displacementField->FillBuffer(zeroVector);
m_Transform->SetGaussianSmoothingVarianceForTheUpdateField(3.0);
m_Transform->SetGaussianSmoothingVarianceForTheConstantVelocityField(6.0);
m_Transform->SetConstantVelocityField(displacementField);
m_Transform->SetCalculateNumberOfIntegrationStepsAutomatically(true);
m_Transform->IntegrateVelocityField();
return 0;
}
template<class InternalComputationValueType, int Dimensionality>
typename ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueType, Dimensionality>::TransformPointer ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueType, Dimensionality>::GetItkTransform()
{
return (TransformPointer) this->m_Transform;
}
template<class InternalComputationValueType, int Dimensionality>
void ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueType, Dimensionality>::RunRegistration()
{
}
template<class InternalComputationValueType, int Dimensionality>
bool
ItkGaussianExponentialDiffeomorphicTransformComponent< InternalComputationValueType, Dimensionality>
......
......@@ -438,6 +438,7 @@ TEST_F(RegistrationItkv4Test, DisplacementField)
connection5Parameters["NameOfInterface"] = { "itkMetricv4Interface" };
blueprint->AddConnection("Metric", "RegistrationMethod", connection5Parameters);
blueprint->AddConnection("FixedImageSource", "Transform", { {} });
blueprint->AddConnection("Transform", "RegistrationMethod", { {} });
blueprint->AddConnection("Optimizer", "RegistrationMethod", { {} });
blueprint->AddConnection("RegistrationMethod", "TransformDisplacementFilter", { {} });
......@@ -482,6 +483,8 @@ TEST_F(RegistrationItkv4Test, DisplacementField)
EXPECT_NO_THROW(resultImageWriter->Update());
EXPECT_NO_THROW(resultDisplacementWriter->Update());
blueprint->WriteBlueprint(dataManager->GetOutputFile("RegistrationItkv4Test_DisplacementField_network.dot"));
}
} // namespace selx
Supports Markdown
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