![]() |
ImFusion C++ SDK 4.5.0
|
#include <CranialPlugin/include/ImFusion/Cranial/FastSurferSegmentationAlgorithm.h>
Algorithm wrapping the FastSurfer-based algorithm for brain segmentation. More...
Algorithm wrapping the FastSurfer-based algorithm for brain segmentation.
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 depend on the application and should be implemented by derived classes.
Public Member Functions | |
| FastSurferSegmentationAlgorithm (SharedImageSet &input, AnatomicalStructureCollection *asc=nullptr) | |
| SharedImageSet & | input () const |
| Returns a reference to the input image used for segmentation. | |
| AnatomicalStructureCollection * | asc () const |
| Returns a pointer to the anatomical structure collection where results are stored. | |
| const SharedImageSet * | outputLabelMap () const |
| Returns a pointer to the generated label map. | |
| const SharedImageSet * | ensembleConfidenceMap () const |
| Confidence score map for the ensemble mixture (null unless p_estimateConfidenceScore is enabled). | |
| const SharedImageSet * | ensembleLabelMap () const |
| Label map from the ensemble mixture (null unless p_estimateConfidenceScore is enabled). | |
| const std::map< uint8_t, float > & | classConfidenceScores () const |
| Mean per-voxel confidence per predicted output label class (empty if p_estimateConfidenceScore is disabled). | |
| const LabelDataComponent * | labelDataComponent () const |
| Generate the label configuration for all possible FastSurfer labels. | |
| bool | checkConfigurationParameters () const |
| Returns whether the parameters are properly set (if not, the algorithm will not produce any output). | |
| 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. | |
| Progress * | progress () const |
| Returns the progress interface if set. | |
| virtual int | status () const |
| Indicates the status of the last call to compute(). | |
| const FactoryInfo & | factoryInfo () 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 | 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 Member Functions inherited from ImFusion::SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Public Attributes | |
| Parameter< std::string > | p_modelSet = {"modelSet", Models::Latest::ModelSetName, this} |
| Model set to use for segmentation. | |
| Parameter< std::string > | p_modelSetVersion = {"modelSetVersion", Models::Latest::ModelSetVersion, this} |
| Version of the model set to use for segmentation. | |
| 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 / confidence maps have the same resolution as the input image. | |
| Parameter< bool > | p_extractMeshes = {"extractMeshes", false, this} |
| If disabled, the algorithm skips mesh extraction and only outputs the segmentation label map. | |
| Parameter< bool > | p_exportLabelMap = {"exportLabelMap", true, this} |
| If enabled, export the label map as a separate data. | |
| Parameter< int > | p_batchSlices = {"batchSlices", 32, this} |
| Number of slices to process in each batch (lower values reduce memory usage). Must be >= 1. | |
| Parameter< bool > | p_estimateConfidenceScore = {"estimateConfidenceScore", false, this} |
| If enabled, compute confidence-score outputs. | |
| 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 | |
| SharedImageSet & | m_inputImage |
| std::unique_ptr< GenericASC > | m_ascOwned |
| AnatomicalStructureCollection * | m_asc = nullptr |
| std::unique_ptr< SharedImageSet > | m_outputLabelMap |
| std::unique_ptr< SharedImageSet > | m_ensembleMixtureConfidence |
| std::unique_ptr< SharedImageSet > | m_ensembleMixtureLabelMap |
| std::map< uint8_t, float > | m_classConfidenceScores |
| mat4 | m_correctionMatrix = mat4::Identity() |
| Protected Attributes inherited from ImFusion::Algorithm | |
| std::string | m_name |
| Algorithm name. | |
| Progress * | m_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< Action > | m_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< Param > | m_params |
| List of all registered Parameter and SubProperty instances. | |
| void | compute () override |
| Standard methods for the Algorithm interface. | |
| void | configure (const Properties *p) override |
| Configure this object instance by de-serializing the given Properties. | |
| 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. | |
| virtual const char * | axialModelIdentifier () const =0 |
| Specify the model identifiers for the axial, coronal, and sagittal slices. | |
| virtual const char * | coronalModelIdentifier () const =0 |
| virtual const char * | sagittalModelIdentifier () const =0 |
| virtual bool | shouldForceModelToCpu (const char *modelIdentifier) const |
| Allows derived algorithms to force selected models to run on CPU. | |
| std::unique_ptr< SharedImageSet > | computeFastSurfer (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< SharedImageSet > | preprocess (const SharedImageSet &input) |
| virtual std::unique_ptr< SharedImageSet > | splitImage (SharedImageSet &feature)=0 |
| This function transforms the pre-processed volume into a series of slices to be fed to the network. | |
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. | |
| Protected Member Functions inherited from ImFusion::SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
|
overridevirtual |
Standard methods for the Algorithm interface.
Implements ImFusion::Algorithm.
|
overridevirtual |
Configure this object instance by de-serializing the given Properties.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from ImFusion::Configurable.
|
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.
|
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.
|
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.
|
inline |
Mean per-voxel confidence per predicted output label class (empty if p_estimateConfidenceScore is disabled).
Only classes present in the main output label map have entries.
| const LabelDataComponent * ImFusion::Cranial::FastSurferSegmentationAlgorithm::labelDataComponent | ( | ) | const |
Generate the label configuration for all possible FastSurfer labels.
| bool ImFusion::Cranial::FastSurferSegmentationAlgorithm::checkConfigurationParameters | ( | ) | const |
Returns whether the parameters are properly set (if not, the algorithm will not produce any output).
This method logs errors for any invalid parameters.
|
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.
|
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.
|
protectedpure virtual |
Key of the anatomical structure collection under which the results will be written.
Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.
|
inlineprotectedvirtual |
Models have different pre-processing and orientation so we need to control whether axial slices should be flipped.
Reimplemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm.
|
protectedpure virtual |
Specify the model identifiers for the axial, coronal, and sagittal slices.
Implemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm, and ImFusion::Cranial::WholeBrainSegmentationAlgorithm.
|
inlineprotectedvirtual |
Allows derived algorithms to force selected models to run on CPU.
Reimplemented in ImFusion::Cranial::HypothalamusSegmentationAlgorithm.
|
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.