![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/US/BoneSegmentationBaseAlgorithm.h>
Performs bone segmentation on ultrasound images using a machine learning model. More...
Performs bone segmentation on ultrasound images using a machine learning model.
This class provides a concrete implementation of a segmentation pipeline tailored to bone detection in ultrasound images. It integrates machine learning predictions, detection via connected component analysis, and tracking using intensity/gradient-based scanline evaluation.
The algorithm can optionally compare its predictions to labeled ground truth data, computing confidence scores, precision, and recall. It also supports writing detailed evaluation metrics to a configurable statistics file.
A wide range of parameters can be adjusted via the Properties interface, including the model path, segmentation thresholds, smoothing factors, scanline step, and margin widths. These settings allow the algorithm to be adapted to varying image characteristics and use cases.
Additionally, a custom path to the prediction model can be set via the Properties interface.
While the class includes a legacyDetection() method with an empty implementation intended for extension in derived classes, it is not declared as a pure virtual function. Therefore, the class remains fully instantiable and is not abstract.
Classes | |
| struct | PredictionMap |
| struct | DetectionResult |
Public Member Functions | |
| BoneSegmentationBaseAlgorithm (SharedImageSet *images, SharedImageSet *labels=nullptr) | |
| void | configure (const Properties *p) override |
| Configure this object instance by de-serializing the given Properties. | |
| void | configuration (Properties *p) const override |
| Serialize the current object configuration into the given Properties object. | |
| 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(). | |
| virtual bool | useDefaultAlgorithmController () const |
| If you need to use a different controller in a derived class, set this to false. | |
| virtual void | init () |
| Initialize the algorithm. | |
| virtual void | reset () |
| Clears current 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(). | |
| 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 ImFusion::Configurable | |
| 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 |
Static Public Member Functions | |
| static bool | createCompatible (const DataList &data, Algorithm **a=0) |
| 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 | |
| virtual void | updatePrediction () |
| Update prediction using current features. | |
| virtual void | detection () |
| Run detection using ML prediction. | |
| virtual void | legacyDetection () |
| Run legacy algorithm for bone detection. | |
| virtual void | tracking () |
| Run tracking using last detection. | |
| 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 Attributes | |
| SharedImage * | m_curImage |
| std::unique_ptr< SharedImageSet > | m_outImages |
| std::unique_ptr< ImageResamplingAlgorithm > | m_resamplingAlgo |
| std::string | m_statsFile |
| 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. | |
Input | |
| SharedImageSet * | m_images |
| SharedImageSet * | m_labels |
Results | |
| std::shared_ptr< SharedImage > | m_probabilityMap |
| Probability map. | |
| std::vector< vec3 > | m_detectedBone |
| Detection result. | |
| std::vector< vec3 > | m_segmentedBone |
| Segmentation result. | |
| float | m_curConfidenceScore |
| std::vector< double > | m_curBoneClassification |
Parameters for automatic detection | |
| std::string | m_predictionModelPath |
| std::unique_ptr< ML::MachineLearningModel > | m_predictionModel |
| float | m_detectionProbabilityThreshold |
| Threshold on random forest probability for detection heuristic. | |
| float | m_detectionDepthPenalization |
Methods for getting members or results | |
| const std::vector< vec3 > & | detectedBone () const |
| const std::vector< vec3 > & | segmentedBone () const |
| float | confidenceScore () const |
| PredictionMap | computePredictionMap (const SharedImage &curImage) const |
| DetectionResult | computeDetectedBone (const SharedImage &probabilityMap) const |
| std::vector< vec3 > | computeSegmentedBone (const SharedImage &curImage, const std::vector< vec3 > &detectedBone) const |
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... | |
| 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. | |
|
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 |
Serialize the current object configuration into the given Properties object.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from ImFusion::Configurable.
|
overridevirtual |
Execute the algorithm.
Implements ImFusion::Algorithm.
|
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.
Reimplemented from ImFusion::Algorithm.
|
virtual |
Initialize the algorithm.
Load the machine learning model from the configured path, if it has not been loaded previously. If loading fails, a message will be logged.
Reimplemented in ImFusion::US::BoneSegmentationAlgorithm.