Skip to content

Commit

Permalink
BUG: TransformixFilter was not propagating direction
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal committed May 8, 2018
1 parent 5f71ba5 commit 6925e6a
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions Core/Main/elxTransformixFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -265,50 +265,57 @@ void
TransformixFilter< TMovingImage >
::GenerateOutputInformation( void )
{

if( transformParameterObjectPtr->GetNumberOfParameterMaps() == 0 )
{
itkExceptionMacro( "Empty parameter map in parameter object." );
}

// Get pointers to the input and output
const ParameterObjectType * transformParameterObjectPtr = this->GetTransformParameterObject();
OutputImageType * outputPtr = this->GetOutput();
OutputDeformationFieldType * outputOutputDeformationFieldPtr = this->GetOutputDeformationField();

itkAssertInDebugAndIgnoreInReleaseMacro( transformParameterObjectPtr );
itkAssertInDebugAndIgnoreInReleaseMacro( transformParameterObjectPtr != ITK_NULLPTR );
itkAssertInDebugAndIgnoreInReleaseMacro( outputPtr != ITK_NULLPTR );
itkAssertInDebugAndIgnoreInReleaseMacro( outputOutputDeformationFieldPtr != ITK_NULLPTR );

// assuming that transformParameterObjects can have only 1 Map
const ParameterMapType transformParameterObjectMap = transformParameterObjectPtr->GetParameterMap( 0 );
// Get world coordinate system from the last map
const unsigned int lastIndex = transformParameterObjectPtr->GetNumberOfParameterMaps() - 1;
const ParameterMapType transformParameterMap = transformParameterObjectPtr->GetParameterMap( lastIndex );

ParameterMapType::const_iterator spacingMapIter = transformParameterObjectMap.find( "Spacing" );
if( spacingMapIter == transformParameterObjectMap.cend() )
ParameterMapType::const_iterator spacingMapIter = transformParameterMap.find( "Spacing" );
if( spacingMapIter == transformParameterMap.cend() )
{
itkExceptionMacro( "No entry Spacing found in transformParameterObjectMap" );
itkExceptionMacro( "No entry Spacing found in transformParameterMap" );
}
const ParameterValueVectorType spacingStrings = spacingMapIter->second;

ParameterMapType::const_iterator sizeMapIter = transformParameterObjectMap.find( "Size" );
if( sizeMapIter == transformParameterObjectMap.cend() )
ParameterMapType::const_iterator sizeMapIter = transformParameterMap.find( "Size" );
if( sizeMapIter == transformParameterMap.cend() )
{
itkExceptionMacro( "No entry Size found in transformParameterObjectMap" );
itkExceptionMacro( "No entry Size found in transformParameterMap" );
}
const ParameterValueVectorType sizeStrings = sizeMapIter->second;

ParameterMapType::const_iterator indexMapIter = transformParameterObjectMap.find( "Index" );
if( indexMapIter == transformParameterObjectMap.cend() )
ParameterMapType::const_iterator indexMapIter = transformParameterMap.find( "Index" );
if( indexMapIter == transformParameterMap.cend() )
{
itkExceptionMacro( "No entry Index found in transformParameterObjectMap" );
itkExceptionMacro( "No entry Index found in transformParameterMap" );
}
const ParameterValueVectorType indexStrings = indexMapIter->second;

ParameterMapType::const_iterator originMapIter = transformParameterObjectMap.find( "Origin" );
if( originMapIter == transformParameterObjectMap.cend() )
ParameterMapType::const_iterator originMapIter = transformParameterMap.find( "Origin" );
if( originMapIter == transformParameterMap.cend() )
{
itkExceptionMacro( "No entry Origin found in transformParameterObjectMap" );
itkExceptionMacro( "No entry Origin found in transformParameterMap" );
}
const ParameterValueVectorType originStrings = originMapIter->second;

ParameterMapType::const_iterator directionMapIter = transformParameterObjectMap.find( "Direction" );
if( directionMapIter == transformParameterObjectMap.cend() )
ParameterMapType::const_iterator directionMapIter = transformParameterMap.find( "Direction" );
if( directionMapIter == transformParameterMap.cend() )
{
itkExceptionMacro( "No entry Direction found in transformParameterObjectMap" );
itkExceptionMacro( "No entry Direction found in transformParameterMap" );
}
const ParameterValueVectorType directionStrings = directionMapIter->second;

Expand All @@ -334,6 +341,8 @@ TransformixFilter< TMovingImage >
outputOutputDeformationFieldPtr->SetSpacing( outputSpacing );
outputPtr->SetOrigin( outputOrigin );
outputOutputDeformationFieldPtr->SetOrigin( outputOrigin );
outputPtr->SetDirection( outputDirection );
outputOutputDeformationFieldPtr->SetDirection( outputDirection );

// Set region
typename TMovingImage::RegionType outputLargestPossibleRegion;
Expand Down

0 comments on commit 6925e6a

Please sign in to comment.