Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
SuperElastix
Commits
2dde7421
Commit
2dde7421
authored
Aug 23, 2016
by
Floris Berendsen
Browse files
ENH: added Test for AffineTransform Registration
parent
47f4c1b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Modules/Components/itkImageRegistrationMethodv4/include/selxItkAffineTransform.hxx
View file @
2dde7421
...
...
@@ -63,6 +63,17 @@ ItkAffineTransformComponent< InternalComputationValueType, Dimensionality >
}
}
}
else
if
(
criterion
.
first
==
"Dimensionality"
)
//Supports this?
{
meetsCriteria
=
true
;
for
(
auto
const
&
criterionValue
:
criterion
.
second
)
// auto&& preferred?
{
if
(
std
::
stoi
(
criterionValue
)
!=
Dimensionality
)
{
meetsCriteria
=
false
;
}
}
}
return
meetsCriteria
;
}
}
//end namespace selx
Modules/Components/itkImageRegistrationMethodv4/include/selxItkImageRegistrationMethodv4Component.hxx
View file @
2dde7421
...
...
@@ -82,7 +82,7 @@ public:
std
::
cout
<<
" CL Current level: "
<<
currentLevel
<<
std
::
endl
;
std
::
cout
<<
" SF Shrink factor: "
<<
shrinkFactors
<<
std
::
endl
;
std
::
cout
<<
" SS Smoothing sigma: "
<<
smoothingSigmas
[
currentLevel
]
<<
std
::
endl
;
std
::
cout
<<
" RFP Required fixed params: "
<<
adaptors
[
currentLevel
]
->
GetRequiredFixedParameters
()
<<
std
::
endl
;
//
std::cout << " RFP Required fixed params: " << adaptors[ currentLevel ]->GetRequiredFixedParameters() << std::endl;
std
::
cout
<<
" LR Final learning rate: "
<<
optimizer
->
GetLearningRate
()
<<
std
::
endl
;
std
::
cout
<<
" FM Final metric value: "
<<
optimizer
->
GetCurrentMetricValue
()
<<
std
::
endl
;
std
::
cout
<<
" SC Optimizer scales: "
<<
optimizer
->
GetScales
()
<<
std
::
endl
;
...
...
@@ -115,7 +115,7 @@ public:
};
template
<
int
Dimensionality
,
class
TPixel
>
ItkImageRegistrationMethodv4Component
<
Dimensionality
,
TPixel
>::
ItkImageRegistrationMethodv4Component
()
ItkImageRegistrationMethodv4Component
<
Dimensionality
,
TPixel
>::
ItkImageRegistrationMethodv4Component
()
:
m_TransformAdaptorsContainerInterface
(
nullptr
)
{
m_theItkFilter
=
TheItkFilterType
::
New
();
m_theItkFilter
->
InPlaceOn
();
...
...
@@ -237,8 +237,10 @@ ItkImageRegistrationMethodv4Component< Dimensionality, TPixel >::RunRegistration
this
->
m_theItkFilter
->
SetOptimizer
(
optimizer
);
this
->
m_theItkFilter
->
SetTransformParametersAdaptorsPerLevel
(
this
->
m_TransformAdaptorsContainerInterface
->
GetItkTransformParametersAdaptorsContainer
());
if
(
this
->
m_TransformAdaptorsContainerInterface
!=
nullptr
)
{
this
->
m_theItkFilter
->
SetTransformParametersAdaptorsPerLevel
(
this
->
m_TransformAdaptorsContainerInterface
->
GetItkTransformParametersAdaptorsContainer
());
}
typedef
CommandIterationUpdate
<
TheItkFilterType
>
RegistrationCommandType
;
typename
RegistrationCommandType
::
Pointer
registrationObserver
=
RegistrationCommandType
::
New
();
...
...
Modules/Components/itkImageRegistrationMethodv4/test/selxRegistrationItkv4Test.cxx
View file @
2dde7421
...
...
@@ -509,4 +509,127 @@ TEST_F( RegistrationItkv4Test, FullyConfigured3d )
blueprint
->
WriteBlueprint
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
)
);
}
TEST_F
(
RegistrationItkv4Test
,
FullyConfigured3dAffine
)
{
/** make example blueprint configuration */
blueprint
=
Blueprint
::
New
();
blueprint
->
AddComponent
(
"RegistrationMethod"
,
{
{
"NameOfClass"
,
{
"ItkImageRegistrationMethodv4Component"
}
},
{
"Dimensionality"
,
{
"3"
}
},
{
"NumberOfLevels"
,
{
"2"
}
}
});
ParameterMapType
component1Parameters
;
component1Parameters
[
"NameOfClass"
]
=
{
"ItkImageSourceFixedComponent"
};
component1Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the inputs
blueprint
->
AddComponent
(
"FixedImageSource"
,
component1Parameters
);
ParameterMapType
component2Parameters
;
component2Parameters
[
"NameOfClass"
]
=
{
"ItkImageSourceMovingComponent"
};
component2Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the inputs
blueprint
->
AddComponent
(
"MovingImageSource"
,
component2Parameters
);
ParameterMapType
component3Parameters
;
component3Parameters
[
"NameOfClass"
]
=
{
"ItkImageSinkComponent"
};
component3Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the outputs
blueprint
->
AddComponent
(
"ResultImageSink"
,
component3Parameters
);
ParameterMapType
component4Parameters
;
component4Parameters
[
"NameOfClass"
]
=
{
"DisplacementFieldItkImageFilterSinkComponent"
};
component4Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the outputs
blueprint
->
AddComponent
(
"ResultDisplacementFieldSink"
,
component4Parameters
);
ParameterMapType
component5Parameters
;
component5Parameters
[
"NameOfClass"
]
=
{
"ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component"
};
component5Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the inputs
blueprint
->
AddComponent
(
"Metric"
,
component5Parameters
);
ParameterMapType
component6Parameters
;
component6Parameters
[
"NameOfClass"
]
=
{
"ItkTransformDisplacementFilterComponent"
};
component6Parameters
[
"Dimensionality"
]
=
{
"3"
};
// should be derived from the outputs
blueprint
->
AddComponent
(
"TransformDisplacementFilter"
,
component6Parameters
);
ParameterMapType
component7Parameters
;
component7Parameters
[
"NameOfClass"
]
=
{
"ItkGradientDescentOptimizerv4Component"
};
component7Parameters
[
"NumberOfIterations"
]
=
{
"1"
};
blueprint
->
AddComponent
(
"Optimizer"
,
component7Parameters
);
blueprint
->
AddComponent
(
"ResampleFilter"
,
{
{
"NameOfClass"
,
{
"ItkResampleFilterComponent"
}
},
{
"Dimensionality"
,
{
"3"
}
}
});
blueprint
->
AddComponent
(
"Transform"
,
{
{
"NameOfClass"
,
{
"ItkAffineTransformComponent"
}
},
{
"Dimensionality"
,
{
"3"
}
}
});
blueprint
->
AddComponent
(
"Controller"
,
{
{
"NameOfClass"
,
{
"RegistrationControllerComponent"
}
}
});
ParameterMapType
connection1Parameters
;
connection1Parameters
[
"NameOfInterface"
]
=
{
"itkImageFixedInterface"
};
blueprint
->
AddConnection
(
"FixedImageSource"
,
"RegistrationMethod"
,
connection1Parameters
);
ParameterMapType
connection2Parameters
;
connection2Parameters
[
"NameOfInterface"
]
=
{
"itkImageMovingInterface"
};
blueprint
->
AddConnection
(
"MovingImageSource"
,
"RegistrationMethod"
,
connection2Parameters
);
ParameterMapType
connection3Parameters
;
connection3Parameters
[
"NameOfInterface"
]
=
{
"itkImageInterface"
};
blueprint
->
AddConnection
(
"ResampleFilter"
,
"ResultImageSink"
,
connection3Parameters
);
ParameterMapType
connection4Parameters
;
connection4Parameters
[
"NameOfInterface"
]
=
{
"DisplacementFieldItkImageSourceInterface"
};
blueprint
->
AddConnection
(
"TransformDisplacementFilter"
,
"ResultDisplacementFieldSink"
,
connection4Parameters
);
ParameterMapType
connection5Parameters
;
connection5Parameters
[
"NameOfInterface"
]
=
{
"itkMetricv4Interface"
};
blueprint
->
AddConnection
(
"Metric"
,
"RegistrationMethod"
,
connection5Parameters
);
blueprint
->
AddConnection
(
"FixedImageSource"
,
"Transform"
,
{
{}
});
blueprint
->
AddConnection
(
"Transform"
,
"RegistrationMethod"
,
{
{}
});
blueprint
->
AddConnection
(
"Optimizer"
,
"RegistrationMethod"
,
{
{}
});
blueprint
->
AddConnection
(
"RegistrationMethod"
,
"TransformDisplacementFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"FixedImageSource"
,
"TransformDisplacementFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"RegistrationMethod"
,
"ResampleFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"FixedImageSource"
,
"ResampleFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"MovingImageSource"
,
"ResampleFilter"
,
{
{}
});
blueprint
->
AddConnection
(
"RegistrationMethod"
,
"Controller"
,
{
{}
});
//RunRegistrationInterface
blueprint
->
AddConnection
(
"ResampleFilter"
,
"Controller"
,
{
{}
});
//ReconnectTransformInterface
blueprint
->
AddConnection
(
"TransformDisplacementFilter"
,
"Controller"
,
{
{}
});
//ReconnectTransformInterface
// Instantiate SuperElastix
SuperElastixFilterType
::
Pointer
superElastixFilter
;
EXPECT_NO_THROW
(
superElastixFilter
=
SuperElastixFilterType
::
New
());
// Data manager provides the paths to the input and output data for unit tests
DataManagerType
::
Pointer
dataManager
=
DataManagerType
::
New
();
// Set up the readers and writers
ImageReader3DType
::
Pointer
fixedImageReader
=
ImageReader3DType
::
New
();
fixedImageReader
->
SetFileName
(
dataManager
->
GetInputFile
(
"sphereA3d.mhd"
));
ImageReader3DType
::
Pointer
movingImageReader
=
ImageReader3DType
::
New
();
movingImageReader
->
SetFileName
(
dataManager
->
GetInputFile
(
"sphereB3d.mhd"
));
ImageWriter3DType
::
Pointer
resultImageWriter
=
ImageWriter3DType
::
New
();
resultImageWriter
->
SetFileName
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_image.mhd"
));
DisplacementImageWriter3DType
::
Pointer
resultDisplacementWriter
=
DisplacementImageWriter3DType
::
New
();
resultDisplacementWriter
->
SetFileName
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_displacement.mhd"
));
// Connect SuperElastix in an itk pipeline
superElastixFilter
->
SetInput
(
"FixedImageSource"
,
fixedImageReader
->
GetOutput
());
superElastixFilter
->
SetInput
(
"MovingImageSource"
,
movingImageReader
->
GetOutput
());
resultImageWriter
->
SetInput
(
superElastixFilter
->
GetOutput
<
Image3DType
>
(
"ResultImageSink"
));
resultDisplacementWriter
->
SetInput
(
superElastixFilter
->
GetOutput
<
DisplacementImage3DType
>
(
"ResultDisplacementFieldSink"
));
EXPECT_NO_THROW
(
superElastixFilter
->
SetBlueprint
(
blueprint
));
//Optional Update call
//superElastixFilter->Update();
// Update call on the writers triggers SuperElastix to configure and execute
EXPECT_NO_THROW
(
resultImageWriter
->
Update
());
EXPECT_NO_THROW
(
resultDisplacementWriter
->
Update
());
blueprint
->
WriteBlueprint
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
));
}
}
// namespace selx
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment