ImFusion SDK 4.3
SpineBaseAlgorithmImpl Class Reference
+ Inheritance diagram for SpineBaseAlgorithmImpl:

Static Public Member Functions

static bool createCompatible (const DataList &data, Algorithm **a)
 
- Static Public Member Functions inherited from SpineBaseAlgorithm
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.
 

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...
 
- Public Member Functions inherited from SpineBaseAlgorithm
 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.
 
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.
 
- 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.
 
- Public Attributes inherited from SpineBaseAlgorithm
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 inherited from SpineBaseAlgorithm
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 inherited from SpineBaseAlgorithm
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.
 

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