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

BUG: Demo configurations did not use generic selxItkImageSource

introduced in:
888e2ac8
and 83d27ecf
parent 24152565
/*=========================================================================
*
* 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 selxItkImageSourceFixedComponent_h
#define selxItkImageSourceFixedComponent_h
#include "selxSuperElastixComponent.h"
#include "selxSinksAndSourcesInterfaces.h"
#include "selxItkObjectInterfaces.h"
#include <string.h>
#include "itkImageFileReader.h"
#include "selxAnyFileReader.h"
#include "selxFileReaderDecorator.h"
namespace selx
{
template< int Dimensionality, class TPixel >
class ItkImageSourceFixedComponent :
public SuperElastixComponent<
Accepting< >,
Providing< SourceInterface,
itkImageFixedInterface< Dimensionality, TPixel >,
itkImageDomainFixedInterface< Dimensionality >>
>
{
public:
/** Standard ITK typedefs. */
typedef ItkImageSourceFixedComponent<
Dimensionality, TPixel
> Self;
typedef SuperElastixComponent<
Accepting< >,
Providing< SourceInterface,
itkImageFixedInterface< Dimensionality, TPixel >,
itkImageDomainFixedInterface< Dimensionality >>
> Superclass;
typedef std::shared_ptr< Self > Pointer;
typedef std::shared_ptr< const Self > ConstPointer;
ItkImageSourceFixedComponent( const std::string & name, LoggerImpl & logger );
virtual ~ItkImageSourceFixedComponent();
typedef typename itkImageFixedInterface< Dimensionality, TPixel >::ItkImageType ItkImageType;
typedef typename itkImageDomainFixedInterface< Dimensionality >::ItkImageDomainType ItkImageDomainType;
typedef typename itk::ImageFileReader< ItkImageType > ItkImageReaderType;
typedef FileReaderDecorator< ItkImageReaderType > DecoratedReaderType;
// providing interfaces
virtual typename ItkImageType::Pointer GetItkImageFixed() override;
virtual void SetMiniPipelineInput( itk::DataObject::Pointer ) override;
virtual AnyFileReader::Pointer GetInputFileReader( void ) override;
virtual typename ItkImageDomainType::Pointer GetItkImageDomainFixed() override;
virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
static const char * GetDescription() { return "ItkImageSourceFixed Component"; }
private:
typename ItkImageType::Pointer m_Image;
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, "ItkImageSourceFixedComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
}
};
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkImageSourceFixedComponent.hxx"
#endif
#endif // #define selxItkImageSourceFixedComponent_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 "selxItkImageSourceFixedComponent.h"
#include "selxCheckTemplateProperties.h"
namespace selx
{
template< int Dimensionality, class TPixel >
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::ItkImageSourceFixedComponent( const std::string & name, LoggerImpl & logger ) : Superclass( name, logger ), m_Image( nullptr )
{
}
template< int Dimensionality, class TPixel >
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::~ItkImageSourceFixedComponent()
{
}
template< int Dimensionality, class TPixel >
typename ItkImageSourceFixedComponent< Dimensionality, TPixel >::ItkImageType::Pointer
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::GetItkImageFixed()
{
if( this->m_Image == nullptr )
{
throw std::runtime_error( "SourceComponent needs to be initialized by SetMiniPipelineInput()" );
}
return this->m_Image;
}
template< int Dimensionality, class TPixel >
void
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::SetMiniPipelineInput( itk::DataObject::Pointer object )
{
this->m_Image = dynamic_cast< ItkImageType * >( object.GetPointer() );
if( this->m_Image == nullptr )
{
throw std::runtime_error( "DataObject passed by the NetworkBuilder is not of the right ImageType or not at all an ImageType" );
}
return;
}
template< int Dimensionality, class TPixel >
typename AnyFileReader::Pointer
ItkImageSourceFixedComponent< Dimensionality, TPixel >::GetInputFileReader()
{
// Instanstiate an image file reader, decorated such that it can be implicitly cast to an AnyFileReaderType
return DecoratedReaderType::New().GetPointer();
}
template< int Dimensionality, class TPixel >
typename ItkImageSourceFixedComponent< Dimensionality, TPixel >::ItkImageDomainType::Pointer
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::GetItkImageDomainFixed()
{
if( this->m_Image == nullptr )
{
throw std::runtime_error( "SourceComponent needs to be initialized by SetMiniPipelineInput()" );
}
return this->m_Image.GetPointer();
}
template< int Dimensionality, class TPixel >
bool
ItkImageSourceFixedComponent< Dimensionality, TPixel >
::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
/*=========================================================================
*
* 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 selxItkImageSourceMovingComponent_h
#define selxItkImageSourceMovingComponent_h
#include "selxSuperElastixComponent.h"
#include "selxSinksAndSourcesInterfaces.h"
#include "selxItkObjectInterfaces.h"
#include <string.h>
#include "itkImageFileReader.h"
#include "selxAnyFileReader.h"
#include "selxFileReaderDecorator.h"
namespace selx
{
template< int Dimensionality, class TPixel >
class ItkImageSourceMovingComponent :
public SuperElastixComponent<
Accepting< >,
Providing< SourceInterface, itkImageMovingInterface< Dimensionality, TPixel >>
>
{
public:
/** Standard ITK typedefs. */
typedef ItkImageSourceMovingComponent<
Dimensionality, TPixel
> Self;
typedef SuperElastixComponent<
Accepting< >,
Providing< SourceInterface, itkImageMovingInterface< Dimensionality, TPixel >>
> Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
ItkImageSourceMovingComponent( const std::string & name, LoggerImpl & logger );
virtual ~ItkImageSourceMovingComponent();
typedef typename itkImageMovingInterface< Dimensionality, TPixel >::ItkImageType ItkImageType;
typedef typename itk::ImageFileReader< ItkImageType > ItkImageReaderType;
typedef FileReaderDecorator< ItkImageReaderType > DecoratedReaderType;
virtual typename ItkImageType::Pointer GetItkImageMoving() override;
virtual void SetMiniPipelineInput( itk::DataObject::Pointer ) override;
virtual AnyFileReader::Pointer GetInputFileReader( void ) override;
virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
static const char * GetDescription() { return "ItkImageSourceMoving Component"; }
private:
typename ItkImageType::Pointer m_Image;
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, "ItkImageSourceMovingComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
}
};
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkImageSourceMovingComponent.hxx"
#endif
#endif // #define selxItkImageSourceMovingComponent_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 "selxItkImageSourceMovingComponent.h"
#include "selxCheckTemplateProperties.h"
namespace selx
{
template< int Dimensionality, class TPixel >
ItkImageSourceMovingComponent< Dimensionality, TPixel >
::ItkImageSourceMovingComponent( const std::string & name, LoggerImpl & logger ) : Superclass( name, logger ), m_Image( nullptr )
{
}
template< int Dimensionality, class TPixel >
ItkImageSourceMovingComponent< Dimensionality, TPixel >
::~ItkImageSourceMovingComponent()
{
}
template< int Dimensionality, class TPixel >
typename ItkImageSourceMovingComponent< Dimensionality, TPixel >::ItkImageType::Pointer
ItkImageSourceMovingComponent< Dimensionality, TPixel >
::GetItkImageMoving()
{
if( this->m_Image == nullptr )
{
throw std::runtime_error( "SourceComponent needs to be initialized by SetMiniPipelineInput()" );
}
return this->m_Image;
}
template< int Dimensionality, class TPixel >
void
ItkImageSourceMovingComponent< Dimensionality, TPixel >
::SetMiniPipelineInput( itk::DataObject::Pointer object )
{
this->m_Image = dynamic_cast< ItkImageType * >( object.GetPointer() );
if( this->m_Image == nullptr )
{
throw std::runtime_error( "DataObject passed by the NetworkBuilder is not of the right ImageType or not at all an ImageType" );
}
return;
}
template< int Dimensionality, class TPixel >
typename AnyFileReader::Pointer
ItkImageSourceMovingComponent< Dimensionality, TPixel >::GetInputFileReader()
{
// Instanstiate an image file reader, decorated such that it can be implicitly cast to an AnyFileReaderType
return DecoratedReaderType::New().GetPointer();
}
template< int Dimensionality, class TPixel >
bool
ItkImageSourceMovingComponent< Dimensionality, TPixel >
::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
......@@ -5,11 +5,11 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "ResultImage",
......
......@@ -10,13 +10,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "ResultImage",
......
......@@ -10,13 +10,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "ResultImage",
......
......@@ -44,12 +44,12 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "3"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "ResultImage",
......
......@@ -8,13 +8,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
......
......@@ -6,13 +6,13 @@
<Component>
<Name>FixedImage</Name>
<NameOfClass>ItkImageSourceFixedComponent</NameOfClass>
<NameOfClass>ItkImageSourceComponent</NameOfClass>
<Dimensionality>2</Dimensionality>
</Component>
<Component>
<Name>MovingImage</Name>
<NameOfClass>ItkImageSourceMovingComponent</NameOfClass>
<NameOfClass>ItkImageSourceComponent</NameOfClass>
<Dimensionality>2</Dimensionality>
</Component>
......
......@@ -8,13 +8,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
......
......@@ -8,13 +8,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
......
......@@ -8,13 +8,13 @@
},
"Component": {
"Name": "FixedImage",
"NameOfClass": "ItkImageSourceFixedComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
"Component": {
"Name": "MovingImage",
"NameOfClass": "ItkImageSourceMovingComponent",
"NameOfClass": "ItkImageSourceComponent",
"Dimensionality": "2",
"PixelType": "float"
},
......
{
"Component": {
"Name": "WarpInputImage",
"NameOfClass": "ItkImageSourceMovingComponent"
"NameOfClass": "ItkImageSourceComponent"
},
"Component": {
"Name": "ImageTransformer",
......
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