Commit 02c11138 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: initial classes CompositeTransformComponent and

MultiStageTransformInterface
parent 97d5929b
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxItkCompositeTransformComponent_h
#define selxItkCompositeTransformComponent_h
#include "selxComponentBase.h"
#include "selxInterfaces.h"
#include "ItkCompositeTransform.h"
#include <string.h>
#include "selxMacro.h"
namespace selx
{
template< class InternalComputationValueType, int Dimensionality >
class ItkCompositeTransformComponent :
public SuperElastixComponent<
Accepting< >,
Providing< MultiStageTransformInterface< InternalComputationValueType, Dimensionality >>
>
{
public:
selxNewMacro(ItkCompositeTransformComponent, ComponentBase);
//itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
ItkCompositeTransformComponent();
virtual ~ItkCompositeTransformComponent();
/** Type of the optimizer. */
using TransformType = typename MultiStageTransformInterface< InternalComputationValueType, Dimensionality >::TransformBaseType;
typedef typename itk::CompositeTransform< InternalComputationValueType, Dimensionality > CompositeTransformType;
virtual typename TransformType::Pointer GetTransformFixedInitialTransform(int stageIndex) override;
virtual typename TransformType::Pointer GetTransformMovingInitialTransform(int stageIndex) override;
virtual void SetResultTransform(typename TransformType::Pointer resultTransform, int stageIndex) override;
virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
//static const char * GetName() { return "ItkCompositeTransform"; } ;
static const char * GetDescription() { return "ItkCompositeTransform Component"; }
private:
typename CompositeTransformType::Pointer m_CompositeTransform;
protected:
// return the class name and the template arguments to uniquely identify this component.
static inline const std::map< std::string, std::string > TemplateProperties()
{
return { { keys::NameOfClass, "ItkCompositeTransformComponent" }, { keys::InternalComputationValueType, PodString< InternalComputationValueType >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
}
};
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkCompositeTransformComponent.hxx"
#endif
#endif // #define selxItkCompositeTransformComponent_h
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "selxItkCompositeTransformComponent.h"
#include "selxCheckTemplateProperties.h"
namespace selx
{
template< class InternalComputationValueType, int Dimensionality >
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >::ItkCompositeTransformComponent()
{
m_CompositeTransform = CompositeTransformType::New();
//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.
// we could choose to keep the component light weighted (for checking criteria such as names and connections) until the settings are passed to the filter, but this requires an additional initialization step.
}
template< class InternalComputationValueType, int Dimensionality >
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >::~ItkCompositeTransformComponent()
{
}
template< class InternalComputationValueType, int Dimensionality >
typename ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >::TransformType::Pointer
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
::GetTransformFixedInitialTransform(int stageIndex)
{
return nullptr;
}
template< class InternalComputationValueType, int Dimensionality >
typename ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >::TransformType::Pointer
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
::GetTransformMovingInitialTransform(int stageIndex)
{
return nullptr;
}
template< class InternalComputationValueType, int Dimensionality >
void
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
::SetResultTransform(typename TransformType::Pointer resultTransform, int stageIndex)
{
}
template< class InternalComputationValueType, int Dimensionality >
bool
ItkCompositeTransformComponent< InternalComputationValueType, Dimensionality >
::MeetsCriterion( const ComponentBase::CriterionType & criterion )
{
bool hasUndefinedCriteria( false );
bool meetsCriteria( false );
auto status = CheckTemplateProperties( this->TemplateProperties(), criterion );
if( status == CriterionStatus::Satisfied )
{
return true;
}
else if( status == CriterionStatus::Failed )
{
return false;
} // else: CriterionStatus::Unknown
return meetsCriteria;
}
} //end namespace selx
......@@ -44,6 +44,7 @@
#include "selxItkImageSourceMoving.h"
#include "selxRegistrationController.h"
#include "selxItkCompositeTransformComponent.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
......@@ -101,7 +102,8 @@ public:
ItkTransformDisplacementFilterComponent< 3, double, double >,
ItkResampleFilterComponent< 2, float, double >,
ItkResampleFilterComponent< 3, double, double >,
RegistrationControllerComponent< >> RegisterComponents;
RegistrationControllerComponent< >,
ItkCompositeTransformComponent<double, 3> > RegisterComponents;
typedef SuperElastixFilter< RegisterComponents > SuperElastixFilterType;
......
......@@ -195,6 +195,15 @@ struct Properties< itkTransformInterface< InternalComputationValueType, D >>
}
};
template< class InternalComputationValueType, int D >
struct Properties< MultiStageTransformInterface< InternalComputationValueType, D >>
{
static const std::map< std::string, std::string > Get()
{
return{ { keys::NameOfInterface, "MultiStageTransformInterface" }, { keys::Dimensionality, std::to_string(D) } };
}
};
template< class F, class M >
struct Properties< elastixTransformParameterObjectInterface< F, M >>
{
......
......@@ -306,6 +306,16 @@ public:
typedef typename elastix::ElastixFilter< TFixedImage, TMovingImage >::ParameterObjectType elastixTransformParameterObject;
virtual elastixTransformParameterObject * GetTransformParameterObject() = 0;
};
template< class InternalComputationValueType, int Dimensionality >
class MultiStageTransformInterface
{
public:
using TransformBaseType = itk::Transform< InternalComputationValueType, Dimensionality, Dimensionality >;
virtual typename TransformBaseType::Pointer GetTransformFixedInitialTransform(int stageIndex) = 0;
virtual typename TransformBaseType::Pointer GetTransformMovingInitialTransform(int stageIndex) = 0;
virtual void SetResultTransform(typename TransformBaseType::Pointer resultTransform, int stageIndex) = 0;
};
} // end namespace selx
#endif // #define selxInterfaces_h
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