ImFusion SDK 4.3
SpineBaseAlgorithm Class Reference

#include <SpinePlugin/include/ImFusion/Spine/SpineBaseAlgorithm.h>

Spine localisation / classification and segmentation algorithm. More...

+ Inheritance diagram for SpineBaseAlgorithm:

Detailed Description

Spine localisation / classification and segmentation algorithm.

Takes as input a calibrated CT image, and has an interface to localize, classify and segment each vertebra, as well as the sacrum and ilium.

Classes

struct  ModelIdentifier
 Collection of known model identifiers for the SpineBaseAlgorithm. More...
 
struct  ModelSetMetadataIdentifier
 Collection of known model set metadata identifiers for the SpineBaseAlgorithm. More...
 

Public Member Functions

 SpineBaseAlgorithm (SharedImageSet *source, SharedImageSet *label=nullptr)
 
 SpineBaseAlgorithm (SharedImageSet *source, SpineData *spineData)
 
 SpineBaseAlgorithm (SharedImageSet *source, std::unique_ptr< SpineData > spineData)
 
void compute () override
 Execute the algorithm.
 
OwningDataList takeOutput () override
 Return any new Data that was created by the Algorithm during the last call to compute().
 
std::unique_ptr< SpineDatatakeSpineData ()
 Take ownership of the current SpineData object.
 
void setSpineData (std::unique_ptr< SpineData > spineData)
 Set new SpineData object for the algorithm to work with.
 
SpineDataspineData ()
 Access to the current SpineData object.
 
Algorithm::Status localiseVertebrae ()
 Run vertebra localisation.
 
void addVertebraByBody (vec3 bodyPos, bool rerunClassification=true)
 Add vertebra with a specified body position Uses the localisation prediction to find the closest matching body of a vertebra, and adds corresponding vertebra If rerunClassification is set, the classification of the vertebrae including neural network is run again.
 
Algorithm::Status addVertebraeByMatchingKeypoints (const std::vector< std::tuple< vec3, double > > &bodyKps, const std::vector< std::tuple< vec3, double > > &leftKps, const std::vector< std::tuple< vec3, double > > &rightKps)
 Add a set of vertebrae by providing body, left pedicle, and right pedicle lists.
 
void addVertebraByKeypoints (std::vector< vec3 > keypoints, bool rerunClassification=true)
 Add vertebra explicitly by keypoints Keypoint order is: body, left-keypoint, right-keypoint.
 
void addVertebra (std::unique_ptr< OrientedVertebra > vertebra, bool rerunClassification=true)
 Add an oriented vertebra directly The vertebra automatically gets sorted over the z axis.
 
void deleteVertebra (int index)
 Delete a vertebra at index. Number of vertebrae will decrease and indices of subsequent vertebrae will shift.
 
void clearVertebrae ()
 Clear all vertebrae.
 
void reset ()
 Reset algorithm state to initial state on construction (will still keep pointing to the original input data)
 
void reset (SharedImageSet *source, SharedImageSet *label, const std::vector< vec3 > &bodies, const std::vector< vec3 > &left, const std::vector< vec3 > &right, bool loadSegmentationMeshes=true)
 Reset algorithm state to point to new input data, guess keypoints/classifications based on provided list of body/left/right keypoints If this guessing fails, then classification models are run to reclassify the keypoints.
 
Algorithm::Status classifyVertebraType (bool skipPrediction=false)
 Run deep learning based classification, and subsequent Markov Chain based optimal sequence To only run the Markov Chain optimal sequence, e.g.
 
int nVertebrae () const
 Number of vertebrae.
 
int closestVertebraByBody (vec3 bodyPos) const
 Get the index of the vertebra with the closest body position to bodyPos return index if there are vertebrae present, and -1 if not vertebra exist and there is no possible match.
 
std::vector< vec3 > vertebraBodyPositions () const
 Return a list of detected vertebra body positions; coordinates are in world coordinates.
 
std::vector< vec3 > vertebraCenterPositions () const
 Return a list of centers of the detected vertebrae; coordinates are in world coordinates.
 
std::vector< vec3 > getKeypoints (int index) const
 Return keypoints of vertebra with index 'index'.
 
std::vector< std::stringvertebraTypes () const
 Return types of all vertebrae in string form.
 
void pinVertebraType (std::string sourceName, std::string pinName)
 Pin vertebra type to a known type.
 
void pinVertebraType (int index, std::string pinName)
 Pin vertebra at 'index' to a known type.
 
std::unique_ptr< SharedImageSetsegmentVertebraAsImage (int index)
 Returns the prediction of the current segmentation model for the vertebra at index 'index'.
 
std::shared_ptr< SharedImageSetcropVertebra (int index)
 Crop a vertebra region from the source image.
 
std::unique_ptr< MeshsegmentVertebra (int index, bool highRes=false)
 Return a mesh of vertebra at index 'index' Result is a mesh for the entire vertebra.
 
std::unique_ptr< MeshsegmentVertebraOnly (vec3 center, bool highRes=false)
 Run Segmentation of the vertebra around position 'center' Finds the closest matching vertebra body to 'center' and runs the segmentation and mesh generation there Result is a mesh for the entire vertebra.
 
std::unique_ptr< SharedImageSetvertebraSegmentation ()
 To be used after calling segmentVertebra() or segmentVertebraOnly() Return the corresponding vertebra segmentation as an image and also takes ownership of this segmentation Therefore should be only called once after a call to segmentVertebra()
 
std::unique_ptr< SharedImageSetforamenSegmentation ()
 To be used after calling segmentVertebra() or segmentVertebraOnly() Return the corresponding foramen segmentation as an image and also takes ownership of this segmentation Therefore should be only called once after a call to segmentVertebra()
 
mat4 estimateVertebraMatrix (int vertebraIndex, bool cropMode=false)
 Estimate the orientation matrix corresponding to vertebra at index vertebraIndex localiseVertebrae() must have been called before using this function.
 
std::vector< std::unique_ptr< Mesh > > & meshes ()
 Returns current output meshes, depending on the algorithm used.
 
std::unique_ptr< SharedImageSet > & output ()
 Return general output image, depending on algorithm used.
 
vec3 mainDirection ()
 Find the main direction of the spine (average of all vertebrae)
 
Algorithm::Status segmentAllVertebrae ()
 Run segmentation on all vertebae.
 
SharedImageSetsource ()
 Access current source image.
 
SharedImageSetoriginalSource ()
 Original Source pointer.
 
double sourceVolume ()
 Calculate volume of current image in mm^3.
 
Geometry::AlignedBox predictSpineBounds ()
 Runs a neural network based Spine prediction on the input image.
 
virtual std::unique_ptr< SharedImageSetpredictSpineMask ()
 Predict a mask image that forms an area around the spine.
 
void setBounds (Geometry::AlignedBox bounds, double scaleFactor=1.5)
 Set the region of interest bounds for spine processing.
 
virtual void setSpline (Spline const *spline)
 
std::unique_ptr< SharedImageSetexportLabelMap (bool resampleToSource)
 Exports current segmentations as a label map Optionally resamples the result towards the source image, which is required in case of creating a labeling.
 
std::unique_ptr< SharedImageSetexportLabelMapWithConvertToMultiLabel ()
 Export segmentations as a multi-label image Converts vertebra segmentations to a single multi-label image where each vertebra has a unique label.
 
std::vector< int > exportTypeIds ()
 Export the type IDs of all segmented vertebrae.
 
void getAngles (std::unique_ptr< std::vector< double > > &x_angles, std::unique_ptr< std::vector< double > > &y_angles, std::unique_ptr< std::vector< double > > &z_angles)
 Calculate angles between subsequent vertebrae (deprecated)
 
Algorithm::Status segmentDiscs ()
 Segment vertebral discs in the image.
 
Algorithm::Status localizeDiscs ()
 Localize vertebral discs in the image.
 
const std::vector< std::unique_ptr< OrientedVertebra > > & vertebrae () const
 Direct accessor to vertebra structures.
 
std::vector< std::unique_ptr< OrientedVertebra > > & vertebrae ()
 
bool estimateVertebraeFromLabels (bool useLocalization=false)
 Estimate vertebrae keypoints from a label image.
 
bool hasLabel ()
 Check if the algorithm has a label image associated with it.
 
bool hasSacrum ()
 Check if a sacrum vertebra is present in the current spine data.
 
bool segmentPelvis (bool joinLeftAndRightPelvis=false)
 Segment the pelvis.
 
bool segmentPelvisDetectionSegmentationWorkflow (bool joinLeftAndRightPelvis=false)
 
bool segmentSacrum ()
 Segment the sacrum bone.
 
bool segmentIlium ()
 Segment Ilium, requires positions to be detected by localiseVertebrae.
 
bool predictSacrumKeypoints ()
 Run a dedicated sacrum keypoint model at the position of the current localised sacrum.
 
std::vector< vec3 > detectHipCenters ()
 Detect hip center positions using machine learning model.
 
bool saveState (std::ostream &out)
 Save the current algorithm state to an output stream.
 
bool loadState (std::istream &in)
 Load algorithm state from an input stream.
 
bool saveState (std::string path)
 Save the current algorithm state to a file.
 
bool loadState (std::string path)
 Load algorithm state from a file.
 
std::vector< std::stringavailableModelNames () const
 Returns the available model names.
 
const std::stringcurrentModelName () const
 Return current modelset name.
 
bool setModelByName (const std::string &modelSetVersion)
 Deprecation layer to sets the ModelSet by what was the model name.
 
Algorithm::Status consolidateOverlappingSegmentationsAndMeshes ()
 Run Consolidation process to avoid overlapping segmentations and meshes Requires segmentations to be computed beforehand and stored by setting p_savePredictions.
 
Data::Modality sourceModality () const
 
void clearCache ()
 Clear all cached data including cluster results, type predictions, and context predictions.
 
void clearTypePredictionCache ()
 Clear the cached type prediction results, forcing recomputation on next classification.
 
void clearSegmentationModelCache ()
 Clear the cached segmentation model, forcing model reload on next segmentation.
 
void setVertebraMeshes (int index, std::vector< std::unique_ptr< Mesh > > &meshes)
 
std::unique_ptr< MeshcleanMesh (std::unique_ptr< Mesh > mesh) const
 Clean a mesh by removing artifacts and improving quality.
 
std::unique_ptr< MeshsmoothMesh (std::unique_ptr< Mesh > mesh) const
 Smooth a mesh using surface smoothing algorithms.
 
vec3 projectOnSpline (vec3 pos, vec3 *tangent=nullptr) const
 Project a 3D position onto the spine spline curve.
 
void runContextModel ()
 Force re-calculation of the context model Exposes context model re-calculation to SpineBaseController.
 
std::unique_ptr< DatacloneContextPredictionCache () const
 Clone the current context prediction cache.
 
AnatomyPlugin::ModelFactorymodelFactory ()
 ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation.
 
const AnatomyPlugin::ModelFactorymodelFactory () const
 ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation.
 
std::optional< std::stringmodelPath (const AnatomyPlugin::ModelFactory::ModelIdentifier &modelIdentifier) const
 Get the file path for a specific model.
 
bool hasModel (const AnatomyPlugin::ModelFactory::ModelIdentifier &modelIdentifier) const
 Check if a specific model is available.
 
std::unique_ptr< ML::MachineLearningModelcreateModel (const AnatomyPlugin::ModelFactory::ModelIdentifier &modelIdentifier) const
 Create an instance of a machine learning model.
 
std::vector< AnatomyPlugin::ModelFactory::MLEngineNameenginePreferenceOrder () const
 Get the preferred order of machine learning engines.
 
- Public Member Functions inherited from 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().
 
virtual bool survivesDataDeletion (const Data *) const
 Indicates whether the algorithm can handle (partial) deletion of the specified data, by default this checks whether the data is in the input list.
 
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 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
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (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.
 

Static Public Member Functions

static bool createCompatible (const DataList &data, Algorithm **a)
 
static const AnatomyPlugin::ModelFactoryglobalModelFactoryInstance ()
 Global model factory instance that contains e.g.
 
- Static Public Member Functions inherited from Algorithm
static bool createCompatible (const DataList &data, Algorithm **a=nullptr)
 Factory function to check algorithm compatibility with input data and optionally instantiate it.
 

Public Attributes

Parameter< double > p_keypointSensitivity = {"keypointSensitivity", 0.2, *this}
 
Parameter< double > p_classificationSensitivity = {"classificationSensitivity", 0.2, *this}
 
Parameter< double > p_hipCenterDetectionThreshold = {"hipCenterDetectionThreshold", 0.95, *this}
 
Parameter< bool > p_filterKeypointsByMask = {"filterKeypointsByMask", true, *this}
 
Parameter< SortingStrategy > p_sortingStrategy = {"sortingStrategy", SortingStrategy::Spline, *this}
 
Parameter< bool > p_savePredictions = {"savePredictions", false, *this}
 
Parameter< bool > p_consolidatePredictions = {"consolidatePredictions", false, *this}
 
Parameter< double > p_consolidateThreshold = {"consolidateThreshold", 0.4, *this}
 
Parameter< AnatomyPlugin::ModelFactory::MLEngineNamep_preferredEngine = {"preferredEngine", "", *this}
 
Signal m_spineUpdatedSignal
 
- Public Attributes inherited from 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 Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Protected Member Functions

void setupSource (SharedImageSet *source)
 
void setupModelSets ()
 
Algorithm::Status printError (std::string message)
 
std::unique_ptr< SharedImageSetpredictKeypoints (SharedImageSet *sis)
 
void sortVertebrae ()
 
SharedImageSetgetSourceCrop ()
 
ClusterResultgetClusterResult ()
 
std::vector< vec3 > detectPediclesFromSegmentation (SharedImage *segmentation)
 
void updateSpline ()
 
void fillHoles (SharedImageSet *data)
 
void recenterMesh (Mesh *mesh, mat4 newCenter) const
 
std::vector< std::tuple< vec3, double > > filterPointsByMask (std::vector< std::tuple< vec3, double > > &input)
 
virtual Algorithm::Status localiseVertebrae_3kp ()
 
Algorithm::Status localiseVertebrae_4kp ()
 
std::unique_ptr< SharedImageSet > & fullSpineSegmentation ()
 
std::unique_ptr< MeshextractMesh (SharedImageSet *input, OrientedVertebra &vertebra)
 
SharedImageSetgetTypePrediction ()
 
Algorithm::Status setTypeProbabilitiesFromBlobs ()
 
Algorithm::Status predictAnatomyContext ()
 
Algorithm::Status findCostoVertebralJointCandidates (std::map< std::string, size_t > *jointNameSizeMap=nullptr)
 
Algorithm::Status setTypeProbabilitiesFromContext ()
 
- Protected Member Functions inherited from 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 SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Protected Attributes

SharedImageSetm_label
 
SharedImageSetm_originalSource = nullptr
 
std::unique_ptr< SharedImageSetm_source
 
std::unique_ptr< SpineDatam_spineDataOwned
 
SpineDatam_spineData = nullptr
 
bool m_keypointsWereFiltered = false
 
std::unique_ptr< SharedImageSetm_output
 
std::vector< std::unique_ptr< Mesh > > m_meshes
 
std::unique_ptr< SharedImageSetm_vertebraSegmentation
 
std::unique_ptr< SharedImageSetm_foramenSegmentation
 
std::unique_ptr< SharedImageSetm_spineMask
 
std::unique_ptr< SharedImageSetm_sourceCrop
 
Algorithm::Status m_lastContextPredictionStatus = Algorithm::Status::Unknown
 
vec3 m_ROICenter = vec3::Zero()
 
vec3 m_ROIWidth = vec3::Zero()
 
size_t m_dataHash = 0
 
std::unique_ptr< ML::MachineLearningModelm_segmentationModelCache
 
std::unique_ptr< SharedImageSetm_fullSpineSegmentation
 
std::unique_ptr< SharedImageSetm_sacrumSegmentation
 
SpineCache m_spineCache
 
- Protected Attributes inherited from 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 Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 
bool setCurrentModelSet (const std::string &modelSetName, const std::string &modelSetVersion)
 Functions for choosing models.
 
const std::pair< AnatomyPlugin::ModelFactory::ModelSet::Name, AnatomyPlugin::ModelFactory::ModelSet::Version > & currentModelSet ()
 Return the last model set using setCurrentModelSet().
 
const std::vector< std::pair< AnatomyPlugin::ModelFactory::ModelSet::Name, AnatomyPlugin::ModelFactory::ModelSet::Version > > availableModelSets () const
 
void logRegisteredModelSets (bool currentOnly=false) const
 Log all registered model sets or just the currently active combination of model, version, and engine.
 

Additional Inherited Members

- Public Types inherited from Algorithm
enum  Status {
  Unknown = -1 , Success = 0 , Error = 1 , InvalidInput ,
  IncompleteInput , OutOfMemoryHost , OutOfMemoryGPU , UnsupportedGPU ,
  UnknownAction , AbortedByUser , User = 1000
}
 Status codes. More...
 

Member Function Documentation

◆ compute()

void compute ( )
overridevirtual

Execute the algorithm.

Implements Algorithm.

◆ takeOutput()

OwningDataList takeOutput ( )
overridevirtual

Return any new Data that was created by the Algorithm during the last call to compute().

The default implementation will return an empty list.

Note
Since ownership of the data is transferred, you can call this method only once between calls to compute().

Reimplemented from Algorithm.

◆ takeSpineData()

std::unique_ptr< SpineData > takeSpineData ( )

Take ownership of the current SpineData object.

Returns
Unique pointer to the SpineData, ownership is transferred to caller

◆ setSpineData()

void setSpineData ( std::unique_ptr< SpineData > spineData)

Set new SpineData object for the algorithm to work with.

Parameters
spineDataUnique pointer to SpineData, ownership is transferred to the algorithm

◆ spineData()

SpineData & spineData ( )
inline

Access to the current SpineData object.

Returns
Reference to the current SpineData

◆ localiseVertebrae()

Algorithm::Status localiseVertebrae ( )

Run vertebra localisation.

Resulting Vertebra positions can be queried by vertebraBodyPositions(), vertebraCenterPositions(), getKeypoints(), estimateVertebraMatrix() Number of vertebrae can be queried with nVertebrae() The vertebrae are ordered from head to toe (index = 0 is the highest vertebra). Return: Status value of the algorithm, should be Algorithm::Status::Success

◆ addVertebraeByMatchingKeypoints()

Algorithm::Status addVertebraeByMatchingKeypoints ( const std::vector< std::tuple< vec3, double > > & bodyKps,
const std::vector< std::tuple< vec3, double > > & leftKps,
const std::vector< std::tuple< vec3, double > > & rightKps )

Add a set of vertebrae by providing body, left pedicle, and right pedicle lists.

Warning
A matching between the three vectors is performed, which means that keypoints of different indexes in the lists may be matched

◆ addVertebraByKeypoints()

void addVertebraByKeypoints ( std::vector< vec3 > keypoints,
bool rerunClassification = true )

Add vertebra explicitly by keypoints Keypoint order is: body, left-keypoint, right-keypoint.

The keypoints should be in the center-of-mass of the corresponding areas. If rerunClassification is set, the classification of the vertebrae including neural network is run again.

◆ reset()

void reset ( SharedImageSet * source,
SharedImageSet * label,
const std::vector< vec3 > & bodies,
const std::vector< vec3 > & left,
const std::vector< vec3 > & right,
bool loadSegmentationMeshes = true )

Reset algorithm state to point to new input data, guess keypoints/classifications based on provided list of body/left/right keypoints If this guessing fails, then classification models are run to reclassify the keypoints.

Parameters
sourceNew source image set to process
labelOptional label image set for supervised processing
bodiesVector of body keypoint positions in world coordinates
leftVector of left pedicle keypoint positions in world coordinates
rightVector of right pedicle keypoint positions in world coordinates
loadSegmentationMeshesIf true, loads existing segmentation meshes if available

◆ classifyVertebraType()

Algorithm::Status classifyVertebraType ( bool skipPrediction = false)

Run deep learning based classification, and subsequent Markov Chain based optimal sequence To only run the Markov Chain optimal sequence, e.g.

after setting a pinned vertebra, set skipPrediction = true Subsequent vertebrae types can be queried with vertebraTypes(); Note that in theory the same vertebra type can occur multiple times (e.g. if one somehow more vertebrae are detected than possibly fit), however it is unlikely.

Parameters
skipPredictionIf true, skips neural network prediction and only runs Markov Chain optimization
Returns
Algorithm status indicating success or failure of classification

◆ vertebraBodyPositions()

std::vector< vec3 > vertebraBodyPositions ( ) const

Return a list of detected vertebra body positions; coordinates are in world coordinates.

Index in the vector corresponds to the index of the vertebra

◆ getKeypoints()

std::vector< vec3 > getKeypoints ( int index) const

Return keypoints of vertebra with index 'index'.

There are 3 keypoints for a vertebra: body, left-keypoint, right-keypoint

◆ vertebraTypes()

std::vector< std::string > vertebraTypes ( ) const

Return types of all vertebrae in string form.

Typenames are a letter followed by a number, e.g. 'T12' defines the twelfth thoracic vertebra. C = Cervical, T = Thoracic, L = Lumbar, S = Sacral

◆ pinVertebraType() [1/2]

void pinVertebraType ( std::string sourceName,
std::string pinName )

Pin vertebra type to a known type.

sourceName defined the vertebra by it's current type name, and pinName will be the new type name Typenames are a letter followed by a number, e.g. 'T12' defines the twelfth thoracic vertebra. C = Cervical, T = Thoracic, L = Lumbar, S = Sacral Automatically propagates the result to other vertebrae

◆ pinVertebraType() [2/2]

void pinVertebraType ( int index,
std::string pinName )

Pin vertebra at 'index' to a known type.

Typenames are a letter followed by a number, e.g. 'T12' defines the twelfth thoracic vertebra. C = Cervical, T = Thoracic, L = Lumbar, S = Sacral Automatically propagates the result to other vertebrae

◆ cropVertebra()

std::shared_ptr< SharedImageSet > cropVertebra ( int index)

Crop a vertebra region from the source image.

Parameters
indexIndex of the vertebra to crop
Returns
Shared pointer to the cropped image region, or nullptr if index is invalid

◆ segmentVertebra()

std::unique_ptr< Mesh > segmentVertebra ( int index,
bool highRes = false )

Return a mesh of vertebra at index 'index' Result is a mesh for the entire vertebra.

Can also be called to get the segmentations themselves which can subsequently acquired by vertebraSegmentation() and foramenSegmentation()

◆ segmentVertebraOnly()

std::unique_ptr< Mesh > segmentVertebraOnly ( vec3 center,
bool highRes = false )

Run Segmentation of the vertebra around position 'center' Finds the closest matching vertebra body to 'center' and runs the segmentation and mesh generation there Result is a mesh for the entire vertebra.

Can also be called to get the segmentations themselves which can subsequently acquired by vertebraSegmentation() and foramenSegmentation()

◆ estimateVertebraMatrix()

mat4 estimateVertebraMatrix ( int vertebraIndex,
bool cropMode = false )

Estimate the orientation matrix corresponding to vertebra at index vertebraIndex localiseVertebrae() must have been called before using this function.

The estimated matrix will be centered at the position of the vertebra calculated as position = (leftKeypoint() + rightKeypoint() + 0.3 * body) / 2.3 The forward direction is either a vector from this position to the body keypoint if cropmode is false The cropmode direction ensures that a crop from this matrix will contain the posterior of the vertebra properly, while the non-cropmode direction is more natural for visualization.

◆ predictSpineBounds()

Geometry::AlignedBox predictSpineBounds ( )

Runs a neural network based Spine prediction on the input image.

Returns the bounds in world coordinates.

◆ predictSpineMask()

virtual std::unique_ptr< SharedImageSet > predictSpineMask ( )
virtual

Predict a mask image that forms an area around the spine.

Used to mask out irrelevant information for algorithmic or visualisation purposes.

◆ setBounds()

void setBounds ( Geometry::AlignedBox bounds,
double scaleFactor = 1.5 )

Set the region of interest bounds for spine processing.

Parameters
boundsAligned bounding box defining the region of interest in world coordinates
scaleFactorFactor to scale the bounds (default 1.5)

◆ exportLabelMap()

std::unique_ptr< SharedImageSet > exportLabelMap ( bool resampleToSource)

Exports current segmentations as a label map Optionally resamples the result towards the source image, which is required in case of creating a labeling.

Deprecated
"Use SpineBaseAlgorithm::exportLabelMapWithConvertToMultiLabel instead"

◆ exportLabelMapWithConvertToMultiLabel()

std::unique_ptr< SharedImageSet > exportLabelMapWithConvertToMultiLabel ( )

Export segmentations as a multi-label image Converts vertebra segmentations to a single multi-label image where each vertebra has a unique label.

Returns
Unique pointer to the multi-label image, or nullptr if no segmentations are available

◆ exportTypeIds()

std::vector< int > exportTypeIds ( )

Export the type IDs of all segmented vertebrae.

Returns
Vector of integer type IDs corresponding to each vertebra's anatomical type

◆ localizeDiscs()

Algorithm::Status localizeDiscs ( )

Localize vertebral discs in the image.

Returns
Algorithm status indicating success or failure of disc localization

◆ estimateVertebraeFromLabels()

bool estimateVertebraeFromLabels ( bool useLocalization = false)

Estimate vertebrae keypoints from a label image.

The segmentations of the vertebrae are also processed into per-vertebra-crops

◆ hasLabel()

bool hasLabel ( )
inline

Check if the algorithm has a label image associated with it.

Returns
True if a label image is present, false otherwise

◆ hasSacrum()

bool hasSacrum ( )

Check if a sacrum vertebra is present in the current spine data.

Returns
True if sacrum is detected/segmented, false otherwise

◆ segmentPelvis()

bool segmentPelvis ( bool joinLeftAndRightPelvis = false)

Segment the pelvis.

Parameters
joinLeftAndRightPelvisIf false, the left and right ilium are segmented separately for models that support it.

◆ segmentPelvisDetectionSegmentationWorkflow()

bool segmentPelvisDetectionSegmentationWorkflow ( bool joinLeftAndRightPelvis = false)
Parameters
allowSeparateLeftAndRightPelvisIf true, the left and right ilium are segmented separately for models that support it.

◆ segmentSacrum()

bool segmentSacrum ( )

Segment the sacrum bone.

Returns
True if segmentation was successful, false otherwise

◆ predictSacrumKeypoints()

bool predictSacrumKeypoints ( )

Run a dedicated sacrum keypoint model at the position of the current localised sacrum.

Requires localiseVertebrae to be called firs. Keypoints of the sacrum might get updated by the model, and therefore can change the result of segmentSacrum

◆ detectHipCenters()

std::vector< vec3 > detectHipCenters ( )

Detect hip center positions using machine learning model.

Returns
Vector of 3D positions representing detected hip centers

◆ saveState() [1/2]

bool saveState ( std::ostream & out)

Save the current algorithm state to an output stream.

Parameters
outOutput stream to write the state data to
Returns
True if save was successful, false otherwise

◆ loadState() [1/2]

bool loadState ( std::istream & in)

Load algorithm state from an input stream.

Parameters
inInput stream to read the state data from
Returns
True if load was successful, false otherwise

◆ saveState() [2/2]

bool saveState ( std::string path)

Save the current algorithm state to a file.

Parameters
pathFile path where to save the state
Returns
True if save was successful, false otherwise

◆ loadState() [2/2]

bool loadState ( std::string path)

Load algorithm state from a file.

Parameters
pathFile path from where to load the state
Returns
True if load was successful, false otherwise

◆ setCurrentModelSet()

bool setCurrentModelSet ( const std::string & modelSetName,
const std::string & modelSetVersion )

Functions for choosing models.

Selects the model set by name and version Configures the models to be used, and updates threshold parameters appropriately Sets the currentModelName member if true

Returns
true on success, false otherwise
See also
registerModel

◆ availableModelNames()

std::vector< std::string > availableModelNames ( ) const

Returns the available model names.

Deprecated
"Use availableModelSets instead."

◆ currentModelName()

const std::string & currentModelName ( ) const

Return current modelset name.

Deprecated
"Use currentModelSet instead."

◆ setModelByName()

bool setModelByName ( const std::string & modelSetVersion)

Deprecation layer to sets the ModelSet by what was the model name.

This name now has to match the ModelSet version which needs to be uniquely defined in the available ModelSets.

Deprecated
"Use setCurrentModelSet instead."

◆ setVertebraMeshes()

void setVertebraMeshes ( int index,
std::vector< std::unique_ptr< Mesh > > & meshes )
Deprecated
"setVertebraMeshes() is deprecated, use OrientedVertebra::meshes() directly instead."

◆ cleanMesh()

std::unique_ptr< Mesh > cleanMesh ( std::unique_ptr< Mesh > mesh) const

Clean a mesh by removing artifacts and improving quality.

Parameters
meshInput mesh to clean
Returns
Cleaned mesh with improved topology and reduced artifacts

◆ smoothMesh()

std::unique_ptr< Mesh > smoothMesh ( std::unique_ptr< Mesh > mesh) const

Smooth a mesh using surface smoothing algorithms.

Parameters
meshInput mesh to smooth
Returns
Smoothed mesh with reduced surface roughness

◆ projectOnSpline()

vec3 projectOnSpline ( vec3 pos,
vec3 * tangent = nullptr ) const

Project a 3D position onto the spine spline curve.

Parameters
pos3D position to project
tangentOptional output parameter for the tangent vector at the projection point
Returns
Projected position on the spine spline

◆ runContextModel()

void runContextModel ( )

Force re-calculation of the context model Exposes context model re-calculation to SpineBaseController.

Always forces the inference of context model to be executed, even if it has already been previously cached

◆ cloneContextPredictionCache()

std::unique_ptr< Data > cloneContextPredictionCache ( ) const

Clone the current context prediction cache.

Returns
Unique pointer to a copy of the context prediction cache data

◆ globalModelFactoryInstance()

static const AnatomyPlugin::ModelFactory & globalModelFactoryInstance ( )
static

Global model factory instance that contains e.g.

the standard imfusion models. On construction, algorithms copy this into their local model factory instance that can then be modified without affecting the global instance.

◆ modelFactory() [1/2]

AnatomyPlugin::ModelFactory & modelFactory ( )
inline

ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation.

Choice of a model from this factory is specified using the setCurrentModelSet() function.

◆ modelFactory() [2/2]

const AnatomyPlugin::ModelFactory & modelFactory ( ) const
inline

ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation.

Choice of a model from this factory is specified using the setCurrentModelSet() function.

◆ modelPath()

std::optional< std::string > modelPath ( const AnatomyPlugin::ModelFactory::ModelIdentifier & modelIdentifier) const

Get the file path for a specific model.

Parameters
modelIdentifierIdentifier of the model to get the path for
Returns
Optional string containing the model path, or nullopt if model not found

◆ hasModel()

bool hasModel ( const AnatomyPlugin::ModelFactory::ModelIdentifier & modelIdentifier) const

Check if a specific model is available.

Parameters
modelIdentifierIdentifier of the model to check
Returns
True if the model is available, false otherwise

◆ createModel()

Create an instance of a machine learning model.

Parameters
modelIdentifierIdentifier of the model to create
Returns
Unique pointer to the created model, or nullptr if creation failed

◆ enginePreferenceOrder()

std::vector< AnatomyPlugin::ModelFactory::MLEngineName > enginePreferenceOrder ( ) const

Get the preferred order of machine learning engines.

Returns
Vector of engine names in order of preference

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close