ImFusion C++ SDK 4.4.0
ImFusion::Cranial::FastSurferSegmentationAlgorithm Class Referenceabstract

#include <CranialPlugin/include/ImFusion/Cranial/FastSurferSegmentationAlgorithm.h>

Algorithm wrapping the FastSurfer-based algorithm for brain parcellation. More...

Inheritance diagram for ImFusion::Cranial::FastSurferSegmentationAlgorithm:

Detailed Description

Algorithm wrapping the FastSurfer-based algorithm for brain parcellation.

Runs models from https://github.com/Deep-MI/FastSurfer (Deep Medical Imaging Lab, PI Reuter). This is only an interface because some things like the data processing or the output mapping depends on the application and should be implemented by derived classes.

Public Member Functions

 FastSurferSegmentationAlgorithm (SharedImageSet &input, AnatomicalStructureCollection *asc=nullptr)
SharedImageSetinput () const
 Returns a reference to the input image used for segmentation.
AnatomicalStructureCollectionasc () const
 Returns a pointer to the anatomical structure collection where results are stored.
const SharedImageSetoutputLabelMap () const
 Returns a pointer to the generated label map (this might be null).
const LabelDataComponentlabelDataComponent () const
 Generate the label configuration for all possible labels in the output. This may be a superset of the labels present in the output label map.
Public Member Functions inherited from ImFusion::Algorithm
 Algorithm ()
 Default constructor will registers a single "compute" action that calls compute() and returns status().
virtual void setProgress (Progress *progress)
 Sets a Progress interface the algorithm can use to notify observers about its computing progress.
Progressprogress () const
 Returns the progress interface if set.
virtual int status () const
 Indicates the status of the last call to compute().
const FactoryInfofactoryInfo () const
 Returns the record describing how this Algorithm was instantiated by the AlgorithmFactory.
void setFactoryInfo (const FactoryInfo &value)
 Sets the record describing how this Algorithm was instantiated by the AlgorithmFactory.
Status runAction (const std::string &id)
 Run the action with name id if it exists.
const std::vector< Action > & actions ()
 Get a mapping from Action id to Action as registered in this algorithm.
Public Member Functions inherited from ImFusion::Configurable
virtual void configure (const Properties *p)
 Configure this object instance by de-serializing the given Properties.
virtual void configuration (Properties *p) const
 Serialize the current object configuration into the given Properties object.
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Public Attributes

Parameter< std::stringp_modelPath = {"modelPath", "", this}
 Path to the folder containing the three models (assumed to be called axial_net.yaml, coronal_net.yaml, sagittal_net.yaml).
Parameter< int > p_imageSize = {"imageSize", 256, this}
 Size of the image that will be used internally as model input.
Parameter< double > p_imageSpacing = {"imageSpacing", 1.0, this}
 Spacing of the image that will be used internally as model input.
Parameter< bool > p_runAxial = {"runAxial", true, this}
 Run the model on the axial slices.
Parameter< bool > p_runCoronal = {"runCoronal", true, this}
 Run the model on the coronal slices.
Parameter< bool > p_runSagittal = {"runSagittal", true, this}
 Run the model on the sagittal slices.
Parameter< bool > p_keepLargestComponent = {"keepLargestComponent", true, this}
 Post-process the result to discard all non-connected components.
Parameter< bool > p_resampleToInput = {"resampleToInput", false, this}
 If enabled, make sure the output label map has the same resolution as the input image.
Parameter< bool > p_extractMeshes = {"extractMeshes", false, this}
 If disabled, the algorithm will not extract meshes but instead only save the segmentation images and keypoints.
Parameter< bool > p_exportLabelMap = {"exportLabelMap", true, this}
 If enabled, export the label map as a separate data.
Public Attributes inherited from ImFusion::Algorithm
Signal signalOutputChanged
 Signal should be emitted by Algorithms when their output/result has changed.
Signal signalParametersChanged
 Signal should be emitted by Algorithms when their parameter configuration has changed.
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.

Protected Attributes

SharedImageSetm_inputImage
std::unique_ptr< GenericASCm_ascOwned
AnatomicalStructureCollectionm_asc = nullptr
std::unique_ptr< SharedImageSetm_outputLabelMap
mat4 m_correctionMatrix = mat4::Identity()
Protected Attributes inherited from ImFusion::Algorithm
std::string m_name
 Algorithm name.
Progressm_progress = nullptr
 Non-owing pointer to a progress interface. May be a nullptr.
FactoryInfo m_factoryInfo = {}
 Record describing how this algorithm was instantiated by the AlgorithmFactory.
int m_status = Status::Unknown
 Algorithm status after last call to compute().
std::vector< Actionm_actions
 Map of key given by the id of the action, of the available actions of this algorithm.
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
void compute () override
 Standard methods for the Algorithm interface.
OwningDataList takeOutput () override
 Returns (1) the label map image if flag is enabled, (2) the AnatomicalStructureCollection if it has been created by the algorithm.
bool survivesDataDeletion (const Data *) const override
 Indicates whether the algorithm can handle (partial) deletion of the specified data, by default this checks whether the data is in the input list.
virtual const std::vector< unsigned short > & freesurferLabelsMapping () const =0
 Extra virtual functions to be implemented by derived algorithmsMapping between neural network output channels of the the axial/coronal outputs (indices) to standardized FreeSurfer anatomical indices (values) defined in CranialPluginKeys.
virtual const std::vector< unsigned short > & sagittalChannelsMapping () const =0
 Sagittal slices have a left/right ambiguity so most pairs of labels are collapsed to the same value.
virtual std::string outputStructureIdentifier () const =0
 Key of the anatomical structure collection under which the results will be written.
virtual bool shouldFlipAxialSlices () const
 Models have different pre-processing and orientation so we need to control whether axial slices should be flipped.
std::unique_ptr< SharedImageSetcomputeFastSurfer (const SharedImageSet &inputImage)
 Different steps of the pipelineThis function takes as input the main image and returns an unsigned short label map where structures are represented by a standardized label.
std::unique_ptr< SharedImageSetpreprocess (const SharedImageSet &input)
virtual std::unique_ptr< SharedImageSetsplitImage (SharedImageSet &feature)=0
 This function transforms the pre-processed volume into a series of slices to be fed to the network.
std::unique_ptr< SharedImageSetpredictImage (std::unique_ptr< SharedImageSet >, std::string)
std::unique_ptr< SharedImageSetargmax (std::unique_ptr< SharedImageSet > output)
std::unique_ptr< SharedImageSetrecombineImages (SharedImageSet &predictionSlices, double spacing)
std::unique_ptr< SharedImageSetfusePredictions (std::pair< std::unique_ptr< SharedImageSet >, std::unique_ptr< SharedImageSet > > predictions, float weight, bool sagittalMap)

Additional Inherited Members

Public Types inherited from ImFusion::Algorithm
enum  Status {
  Unknown = -1 , Success = 0 , Error = 1 , InvalidInput ,
  IncompleteInput , OutOfMemoryHost , OutOfMemoryGPU , UnsupportedGPU ,
  UnknownAction , AbortedByUser , User = 1000
}
 Status codes. More...
Static Public Member Functions inherited from ImFusion::Algorithm
static bool createCompatible (const DataList &data, Algorithm **a=nullptr)
 Factory function to check algorithm compatibility with input data and optionally instantiate it.
Protected Member Functions inherited from ImFusion::Algorithm
void loadDefaults ()
void registerAction (const std::string &id, const std::string &guiName, const std::function< Algorithm::Status(void)> &action)
 Register an action to be run via runAction.
template<typename D>
void registerAction (const std::string &id, const std::string &guiName, Algorithm::Status(D::*action)(void))
 Template version of runAction that can be used with a pointer to a member function.
void registerAction (const Action &action)
 Register an action.

Member Function Documentation

◆ compute()

void ImFusion::Cranial::FastSurferSegmentationAlgorithm::compute ( )
overridevirtual

Standard methods for the Algorithm interface.

Implements ImFusion::Algorithm.

◆ takeOutput()

OwningDataList ImFusion::Cranial::FastSurferSegmentationAlgorithm::takeOutput ( )
overridevirtual

Returns (1) the label map image if flag is enabled, (2) the AnatomicalStructureCollection if it has been created by the algorithm.

Reimplemented from ImFusion::Algorithm.

◆ survivesDataDeletion()

bool ImFusion::Cranial::FastSurferSegmentationAlgorithm::survivesDataDeletion ( const Data * ) const
overridevirtual

Indicates whether the algorithm can handle (partial) deletion of the specified data, by default this checks whether the data is in the input list.

Reimplemented from ImFusion::Algorithm.

◆ asc()

AnatomicalStructureCollection * ImFusion::Cranial::FastSurferSegmentationAlgorithm::asc ( ) const
inline

Returns a pointer to the anatomical structure collection where results are stored.

If no ASC was provided in the constructor, this returns the internally created ASC.

◆ freesurferLabelsMapping()

virtual const std::vector< unsigned short > & ImFusion::Cranial::FastSurferSegmentationAlgorithm::freesurferLabelsMapping ( ) const
protectedpure virtual

Extra virtual functions to be implemented by derived algorithmsMapping between neural network output channels of the the axial/coronal outputs (indices) to standardized FreeSurfer anatomical indices (values) defined in CranialPluginKeys.

Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.

◆ sagittalChannelsMapping()

virtual const std::vector< unsigned short > & ImFusion::Cranial::FastSurferSegmentationAlgorithm::sagittalChannelsMapping ( ) const
protectedpure virtual

Sagittal slices have a left/right ambiguity so most pairs of labels are collapsed to the same value.

This mapping brings original axial/coronal label channel indices to the subset of the sagittal label indices. For instance, {0,1,1} means that 0 is mapped to 0, but both labels 1 and 2 are mapped to the second channel of the sagittal label map. The expected size of the mapping is the number of labels in the axial/coronal output, and the number of different values in the mapping is the number of labels in the sagittal output.

Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.

◆ outputStructureIdentifier()

virtual std::string ImFusion::Cranial::FastSurferSegmentationAlgorithm::outputStructureIdentifier ( ) const
protectedpure virtual

Key of the anatomical structure collection under which the results will be written.

Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.

◆ shouldFlipAxialSlices()

virtual bool ImFusion::Cranial::FastSurferSegmentationAlgorithm::shouldFlipAxialSlices ( ) const
inlineprotectedvirtual

Models have different pre-processing and orientation so we need to control whether axial slices should be flipped.

Reimplemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm.

◆ splitImage()

virtual std::unique_ptr< SharedImageSet > ImFusion::Cranial::FastSurferSegmentationAlgorithm::splitImage ( SharedImageSet & feature)
protectedpure virtual

This function transforms the pre-processed volume into a series of slices to be fed to the network.

It is virtual because it might depend on the application.

Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.


The documentation for this class was generated from the following file:
  • CranialPlugin/include/ImFusion/Cranial/FastSurferSegmentationAlgorithm.h
Search Tab / S to search, Esc to close