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
498583b0
Commit
498583b0
authored
Feb 08, 2017
by
Floris Berendsen
Browse files
ENH: Simplified SuperElastixFilter implementation
parent
d3decaf4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Modules/Components/itkImageRegistrationMethodv4/test/selxRegistrationItkv4Test.cxx
View file @
498583b0
...
...
@@ -476,6 +476,8 @@ TEST_F( RegistrationItkv4Test, FullyConfigured3d )
blueprint
->
SetConnection
(
"ResampleFilter"
,
"Controller"
,
{
{}
}
);
//ReconnectTransformInterface
blueprint
->
SetConnection
(
"TransformDisplacementFilter"
,
"Controller"
,
{
{}
}
);
//ReconnectTransformInterface
blueprint
->
Write
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
));
// Set up the readers and writers
ImageReader3DType
::
Pointer
fixedImageReader
=
ImageReader3DType
::
New
();
fixedImageReader
->
SetFileName
(
dataManager
->
GetInputFile
(
"sphereA3d.mhd"
)
);
...
...
@@ -506,7 +508,6 @@ TEST_F( RegistrationItkv4Test, FullyConfigured3d )
EXPECT_NO_THROW
(
resultImageWriter
->
Update
()
);
EXPECT_NO_THROW
(
resultDisplacementWriter
->
Update
()
);
blueprint
->
Write
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
)
);
}
TEST_F
(
RegistrationItkv4Test
,
FullyConfigured3dAffine
)
{
...
...
@@ -594,6 +595,8 @@ TEST_F( RegistrationItkv4Test, FullyConfigured3dAffine )
blueprint
->
SetConnection
(
"ResampleFilter"
,
"Controller"
,
{
{}
}
);
//ReconnectTransformInterface
blueprint
->
SetConnection
(
"TransformDisplacementFilter"
,
"Controller"
,
{
{}
}
);
//ReconnectTransformInterface
blueprint
->
Write
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
));
// Set up the readers and writers
ImageReader3DType
::
Pointer
fixedImageReader
=
ImageReader3DType
::
New
();
fixedImageReader
->
SetFileName
(
dataManager
->
GetInputFile
(
"sphereA3d.mhd"
)
);
...
...
@@ -623,8 +626,6 @@ TEST_F( RegistrationItkv4Test, FullyConfigured3dAffine )
// Update call on the writers triggers SuperElastix to configure and execute
EXPECT_NO_THROW
(
resultImageWriter
->
Update
()
);
EXPECT_NO_THROW
(
resultDisplacementWriter
->
Update
()
);
blueprint
->
Write
(
dataManager
->
GetOutputFile
(
"RegistrationItkv4Test_DisplacementField_network.dot"
)
);
}
TEST_F
(
RegistrationItkv4Test
,
CompositeTransform
)
...
...
Modules/Core/Filter/include/selxSuperElastixFilter.h
View file @
498583b0
...
...
@@ -67,7 +67,9 @@ public:
itkSetObjectMacro
(
Blueprint
,
BlueprintType
);
// Adding a Blueprint composes SuperElastixFilter' internal blueprint (accessible by Set/Get Blueprint) with the otherBlueprint.
void
AddBlueprint
(
BlueprintPointer
otherBlueprint
);
// void AddBlueprint(BlueprintPointer otherBlueprint);
bool
ParseBlueprint
(
void
);
AnyFileReaderType
::
Pointer
GetInputFileReader
(
const
DataObjectIdentifierType
&
);
...
...
@@ -99,7 +101,7 @@ public:
Superclass
::
SetOutput
(
outputName
,
newOutput
);
this
->
m_OutputConnection
Modified
=
true
;
this
->
Modified
()
;
return
newOutput
;
};
...
...
@@ -122,12 +124,10 @@ private:
//TODO make const correct
BlueprintType
::
Pointer
m_Blueprint
;
bool
m_InputConnectionModified
;
bool
m_OutputConnectionModified
;
bool
m_BlueprintConnectionModified
;
bool
m_IsConnected
;
bool
m_AllUniqueComponents
;
bool
m_IsBlueprintParsedOnce
;
};
}
// namespace elx
...
...
Modules/Core/Filter/src/selxSuperElastixFilter.cxx
View file @
498583b0
...
...
@@ -41,17 +41,16 @@ SuperElastixFilter
//
SuperElastixFilter
::
SuperElastixFilter
(
bool
InitializeEmptyComponentList
)
:
m_InputConnectionModified
(
true
),
m_OutputConnectionModified
(
true
),
m_BlueprintConnectionModified
(
true
),
m_IsConnected
(
false
),
m_AllUniqueComponents
(
false
)
m_AllUniqueComponents
(
false
),
m_IsBlueprintParsedOnce
(
false
)
{
// Disable "Primary" as required input
// TODO: Blueprint should become primary
this
->
SetRequiredInputNames
({});
}
// end Constructor
/*
void
SuperElastixFilter
::AddBlueprint(BlueprintPointer otherBlueprint)
...
...
@@ -60,6 +59,25 @@ SuperElastixFilter
blueprint_internals->ComposeWith(otherBlueprint->Get());
this->m_Blueprint->Set(blueprint_internals);
}
*/
bool
SuperElastixFilter
::
ParseBlueprint
()
{
if
((
!
this
->
m_IsBlueprintParsedOnce
)
||
(
this
->
m_Blueprint
->
GetMTime
()
>
this
->
GetMTime
()))
{
// Was Blueprint modified by Set() or by AddBlueprint?
// delete previous blueprint and start all over with new one
m_NetworkBuilder
=
m_NetworkBuilder
->
ConstructNewDerivedInstance
();
this
->
m_NetworkBuilder
->
AddBlueprint
(
this
->
m_Blueprint
->
Get
());
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
this
->
m_IsBlueprintParsedOnce
=
true
;
this
->
Modified
();
}
return
this
->
m_AllUniqueComponents
;
}
/**
* ********************* GenerateOutputInformation *********************
*/
...
...
@@ -88,19 +106,11 @@ SuperElastixFilter
//TODO: remove this check here by making m_Blueprint primary input
itkExceptionMacro
(
<<
"Setting a Blueprint is required first."
)
}
if
(
this
->
m_Blueprint
->
GetMTime
()
>
this
->
GetMTime
())
{
// Was Blueprint modified by Set() or by AddBlueprint?
// delete previous blueprint and start all over with new one
m_NetworkBuilder
=
m_NetworkBuilder
->
ConstructNewDerivedInstance
();
this
->
m_NetworkBuilder
->
AddBlueprint
(
this
->
m_Blueprint
->
Get
());
}
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
this
->
ParseBlueprint
();
if
(
(
m_InputConnectionModified
==
true
)
||
(
this
->
m_BlueprintConnectionModified
==
true
)
)
{
// Handle inputs:
auto
usedInputs
=
this
->
GetInputNames
();
NetworkBuilderBase
::
SourceInterfaceMapType
sources
=
this
->
m_NetworkBuilder
->
GetSourceInterfaces
();
for
(
const
auto
&
nameAndInterface
:
sources
)
...
...
@@ -128,10 +138,9 @@ SuperElastixFilter
itkExceptionMacro
(
<<
msg
.
str
()
)
//throw std::runtime_error(msg.str());
}
}
if
(
(
m_OutputConnectionModified
==
true
)
||
(
this
->
m_BlueprintConnectionModified
==
true
)
)
{
// Handle outputs:
auto
usedOutputs
=
this
->
GetOutputNames
();
NetworkBuilderBase
::
SinkInterfaceMapType
sinks
=
this
->
m_NetworkBuilder
->
GetSinkInterfaces
();
for
(
const
auto
&
nameAndInterface
:
sinks
)
...
...
@@ -156,22 +165,13 @@ SuperElastixFilter
}
itkExceptionMacro
(
<<
msg
.
str
()
)
}
}
if
(
this
->
m_AllUniqueComponents
==
false
)
// by setting inputs and outputs, settings could be derived to uniquely select the other components
{
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
}
this
->
m_IsConnected
=
this
->
m_NetworkBuilder
->
ConnectComponents
();
if
(
this
->
m_AllUniqueComponents
&&
!
this
->
m_IsConnected
)
{
this
->
m_IsConnected
=
this
->
m_NetworkBuilder
->
ConnectComponents
();
std
::
cout
<<
"Connecting Components: "
<<
(
this
->
m_IsConnected
?
"succeeded"
:
"failed"
)
<<
std
::
endl
<<
std
::
endl
;
}
std
::
cout
<<
"Connecting Components: "
<<
(
this
->
m_IsConnected
?
"succeeded"
:
"failed"
)
<<
std
::
endl
<<
std
::
endl
;
if
(
(
m_OutputConnectionModified
==
true
)
||
(
this
->
m_BlueprintConnectionModified
==
true
)
)
{
NetworkBuilderBase
::
SinkInterfaceMapType
sinks
=
this
->
m_NetworkBuilder
->
GetSinkInterfaces
();
for
(
const
auto
&
nameAndInterface
:
sinks
)
{
// Update information: ask the mini pipeline what the size of the data will be
...
...
@@ -179,11 +179,7 @@ SuperElastixFilter
// Put the information into the Filter's output Objects by grafting
this
->
GetOutput
(
nameAndInterface
.
first
)
->
Graft
(
nameAndInterface
.
second
->
GetMiniPipelineOutput
()
);
}
}
this
->
m_BlueprintConnectionModified
=
false
;
this
->
m_InputConnectionModified
=
false
;
this
->
m_OutputConnectionModified
=
false
;
}
...
...
@@ -223,16 +219,7 @@ SuperElastixFilter
{
//TODO: Before we can get the reader the Blueprint needs to set and applied in the NetworkBuilder.
// This is not like the itk pipeline philosophy
if
(
!
this
->
m_NetworkBuilder
)
{
if
(
!
this
->
m_Blueprint
)
{
itkExceptionMacro
(
<<
"Setting a Blueprint is required first."
)
}
this
->
m_NetworkBuilder
->
AddBlueprint
(
this
->
m_Blueprint
->
Get
());
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
}
if
(
!
this
->
m_AllUniqueComponents
)
if
(
!
this
->
ParseBlueprint
())
{
itkExceptionMacro
(
<<
"Blueprint was not sufficiently specified to build a network."
)
}
...
...
@@ -246,17 +233,7 @@ SuperElastixFilter
{
//TODO: Before we can get the reader the Blueprint needs to set and applied in the NetworkBuilder.
// This is not like the itk pipeline philosophy
if
(
!
this
->
m_NetworkBuilder
)
{
if
(
!
this
->
m_Blueprint
)
{
itkExceptionMacro
(
<<
"Setting a Blueprint is required first."
)
}
this
->
m_NetworkBuilder
->
AddBlueprint
(
this
->
m_Blueprint
->
Get
());
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
}
if
(
!
this
->
m_AllUniqueComponents
)
if
(
!
this
->
ParseBlueprint
())
{
itkExceptionMacro
(
<<
"Blueprint was not sufficiently specified to build a network."
)
}
...
...
@@ -270,7 +247,7 @@ SuperElastixFilter
::
SetInput
(
const
DataObjectIdentifierType
&
inputName
,
itk
::
DataObject
*
input
)
{
Superclass
::
SetInput
(
inputName
,
input
);
this
->
m_InputConnection
Modified
=
true
;
this
->
Modified
()
;
}
...
...
@@ -285,19 +262,12 @@ SuperElastixFilter::OutputDataType
}
else
// otherwise ask the sink component to initialize an output of the right type (the sink knows what type that is).
{
if
(
!
this
->
m_NetworkBuilder
)
if
(
!
this
->
ParseBlueprint
()
)
{
if
(
!
this
->
m_Blueprint
)
// to ask the sink it must be configured by a blueprint.
{
itkExceptionMacro
(
<<
"Setting a Blueprint is required first."
)
}
this
->
m_NetworkBuilder
->
AddBlueprint
(
this
->
m_Blueprint
->
Get
());
this
->
m_AllUniqueComponents
=
this
->
m_NetworkBuilder
->
Configure
();
this
->
m_BlueprintConnectionModified
=
false
;
itkExceptionMacro
(
<<
"Blueprint was not sufficiently specified to build a network."
)
}
OutputDataType
::
Pointer
newOutput
=
this
->
m_NetworkBuilder
->
GetInitializedOutput
(
outputName
);
this
->
m_OutputConnectionModified
=
true
;
this
->
Modified
()
;
Superclass
::
SetOutput
(
outputName
,
newOutput
);
...
...
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