![]() |
ImFusion SDK 4.3
|
#include <SpinePlugin/include/ImFusion/Spine/SpineBaseAlgorithm.h>
Spine localisation / classification and segmentation algorithm. More...
Inheritance diagram for SpineBaseAlgorithm: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< SpineData > | takeSpineData () |
| Take ownership of the current SpineData object. | |
| void | setSpineData (std::unique_ptr< SpineData > spineData) |
| Set new SpineData object for the algorithm to work with. | |
| SpineData & | spineData () |
| 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::string > | vertebraTypes () 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< SharedImageSet > | segmentVertebraAsImage (int index) |
| Returns the prediction of the current segmentation model for the vertebra at index 'index'. | |
| std::shared_ptr< SharedImageSet > | cropVertebra (int index) |
| Crop a vertebra region from the source image. | |
| 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. | |
| 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. | |
| std::unique_ptr< SharedImageSet > | vertebraSegmentation () |
| 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< SharedImageSet > | foramenSegmentation () |
| 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. | |
| SharedImageSet * | source () |
| Access current source image. | |
| SharedImageSet * | originalSource () |
| 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< SharedImageSet > | predictSpineMask () |
| 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< 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. | |
| 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. | |
| 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::string > | availableModelNames () const |
| Returns the available model names. | |
| const std::string & | currentModelName () 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< Mesh > | cleanMesh (std::unique_ptr< Mesh > mesh) const |
| Clean a mesh by removing artifacts and improving quality. | |
| std::unique_ptr< Mesh > | smoothMesh (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< Data > | cloneContextPredictionCache () const |
| Clone the current context prediction cache. | |
| AnatomyPlugin::ModelFactory & | modelFactory () |
| ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation. | |
| const AnatomyPlugin::ModelFactory & | modelFactory () const |
| ModelFactory that holds the available model sets used for spine localisation, classification, and segmentation. | |
| std::optional< std::string > | modelPath (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::MachineLearningModel > | createModel (const AnatomyPlugin::ModelFactory::ModelIdentifier &modelIdentifier) const |
| Create an instance of a machine learning model. | |
| std::vector< AnatomyPlugin::ModelFactory::MLEngineName > | enginePreferenceOrder () 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. | |
| Progress * | progress () 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 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 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 Member Functions inherited from 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. | |
Static Public Member Functions | |
| static bool | createCompatible (const DataList &data, Algorithm **a) |
| static const AnatomyPlugin::ModelFactory & | globalModelFactoryInstance () |
| 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::MLEngineName > | p_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< SharedImageSet > | predictKeypoints (SharedImageSet *sis) |
| void | sortVertebrae () |
| SharedImageSet * | getSourceCrop () |
| ClusterResult * | getClusterResult () |
| 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< Mesh > | extractMesh (SharedImageSet *input, OrientedVertebra &vertebra) |
| SharedImageSet * | getTypePrediction () |
| 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 | |
| SharedImageSet * | m_label |
| SharedImageSet * | m_originalSource = nullptr |
| std::unique_ptr< SharedImageSet > | m_source |
| std::unique_ptr< SpineData > | m_spineDataOwned |
| SpineData * | m_spineData = nullptr |
| bool | m_keypointsWereFiltered = false |
| std::unique_ptr< SharedImageSet > | m_output |
| std::vector< std::unique_ptr< Mesh > > | m_meshes |
| std::unique_ptr< SharedImageSet > | m_vertebraSegmentation |
| std::unique_ptr< SharedImageSet > | m_foramenSegmentation |
| std::unique_ptr< SharedImageSet > | m_spineMask |
| std::unique_ptr< SharedImageSet > | m_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::MachineLearningModel > | m_segmentationModelCache |
| std::unique_ptr< SharedImageSet > | m_fullSpineSegmentation |
| std::unique_ptr< SharedImageSet > | m_sacrumSegmentation |
| SpineCache | m_spineCache |
Protected Attributes inherited from 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 Configurable | |
| std::vector< Param > | m_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... | |
|
overridevirtual |
Execute the algorithm.
Implements Algorithm.
|
overridevirtual |
| std::unique_ptr< SpineData > takeSpineData | ( | ) |
| void setSpineData | ( | std::unique_ptr< SpineData > | spineData | ) |
|
inline |
| 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
| 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.
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.
| 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.
| source | New source image set to process |
| label | Optional label image set for supervised processing |
| bodies | Vector of body keypoint positions in world coordinates |
| left | Vector of left pedicle keypoint positions in world coordinates |
| right | Vector of right pedicle keypoint positions in world coordinates |
| loadSegmentationMeshes | If true, loads existing segmentation meshes if available |
| 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.
| skipPrediction | If true, skips neural network prediction and only runs Markov Chain optimization |
| 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
| 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
| 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
| 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
| 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
| std::shared_ptr< SharedImageSet > cropVertebra | ( | int | index | ) |
Crop a vertebra region from the source image.
| index | Index of the vertebra to crop |
| 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()
| 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()
| 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.
| Geometry::AlignedBox predictSpineBounds | ( | ) |
Runs a neural network based Spine prediction on the input image.
Returns the bounds in world coordinates.
|
virtual |
Predict a mask image that forms an area around the spine.
Used to mask out irrelevant information for algorithmic or visualisation purposes.
| void setBounds | ( | Geometry::AlignedBox | bounds, |
| double | scaleFactor = 1.5 ) |
Set the region of interest bounds for spine processing.
| bounds | Aligned bounding box defining the region of interest in world coordinates |
| scaleFactor | Factor to scale the bounds (default 1.5) |
| 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.
| 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.
| std::vector< int > exportTypeIds | ( | ) |
Export the type IDs of all segmented vertebrae.
| Algorithm::Status localizeDiscs | ( | ) |
Localize vertebral discs in the image.
| bool estimateVertebraeFromLabels | ( | bool | useLocalization = false | ) |
Estimate vertebrae keypoints from a label image.
The segmentations of the vertebrae are also processed into per-vertebra-crops
|
inline |
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.
| joinLeftAndRightPelvis | If false, the left and right ilium are segmented separately for models that support it. |
| bool segmentPelvisDetectionSegmentationWorkflow | ( | bool | joinLeftAndRightPelvis = false | ) |
| allowSeparateLeftAndRightPelvis | If true, the left and right ilium are segmented separately for models that support it. |
| bool segmentSacrum | ( | ) |
Segment the sacrum bone.
| 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
| 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.
| out | Output stream to write the state data to |
| bool loadState | ( | std::istream & | in | ) |
Load algorithm state from an input stream.
| in | Input stream to read the state data from |
| bool saveState | ( | std::string | path | ) |
Save the current algorithm state to a file.
| path | File path where to save the state |
| bool loadState | ( | std::string | path | ) |
Load algorithm state from a file.
| path | File path from where to load the state |
| 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
| std::vector< std::string > availableModelNames | ( | ) | const |
Returns the available model names.
| const std::string & currentModelName | ( | ) | const |
Return current modelset name.
| 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.
| void setVertebraMeshes | ( | int | index, |
| std::vector< std::unique_ptr< Mesh > > & | meshes ) |
| std::unique_ptr< Mesh > cleanMesh | ( | std::unique_ptr< Mesh > | mesh | ) | const |
Clean a mesh by removing artifacts and improving quality.
| mesh | Input mesh to clean |
| std::unique_ptr< Mesh > smoothMesh | ( | std::unique_ptr< Mesh > | mesh | ) | const |
Smooth a mesh using surface smoothing algorithms.
| mesh | Input mesh to smooth |
| vec3 projectOnSpline | ( | vec3 | pos, |
| vec3 * | tangent = nullptr ) const |
Project a 3D position onto the spine spline curve.
| pos | 3D position to project |
| tangent | Optional output parameter for the tangent vector at the projection point |
| 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
| std::unique_ptr< Data > cloneContextPredictionCache | ( | ) | const |
Clone the current context prediction cache.
|
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.
|
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.
|
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.
| std::optional< std::string > modelPath | ( | const AnatomyPlugin::ModelFactory::ModelIdentifier & | modelIdentifier | ) | const |
Get the file path for a specific model.
| modelIdentifier | Identifier of the model to get the path for |
| bool hasModel | ( | const AnatomyPlugin::ModelFactory::ModelIdentifier & | modelIdentifier | ) | const |
Check if a specific model is available.
| modelIdentifier | Identifier of the model to check |
| std::unique_ptr< ML::MachineLearningModel > createModel | ( | const AnatomyPlugin::ModelFactory::ModelIdentifier & | modelIdentifier | ) | const |
Create an instance of a machine learning model.
| modelIdentifier | Identifier of the model to create |
| std::vector< AnatomyPlugin::ModelFactory::MLEngineName > enginePreferenceOrder | ( | ) | const |
Get the preferred order of machine learning engines.