ImFusion C++ SDK 4.5.0
ImFusion::US::BoneSegmentationBaseAlgorithm Class Reference

#include <ImFusion/US/BoneSegmentationBaseAlgorithm.h>

Performs bone segmentation on ultrasound images using a machine learning model. More...

Inheritance diagram for ImFusion::US::BoneSegmentationBaseAlgorithm:

Detailed Description

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.

Note
This is the base class for BoneSegmentationAlgorithm.

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.
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 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

SharedImagem_curImage
std::unique_ptr< SharedImageSetm_outImages
std::unique_ptr< ImageResamplingAlgorithmm_resamplingAlgo
std::string m_statsFile
Protected Attributes inherited from ImFusion::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 ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Input

SharedImageSetm_images
SharedImageSetm_labels

Results

std::shared_ptr< SharedImagem_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

General Parameters

bool m_useLegacyAlgorithm
 Use previous algorithm.
double m_workingResolution
 Spacing for the working images.
int m_frameStep
 Step between predicted frames.
int m_nbSplinePoints
 Number of control points in the final spline.

Parameters for automatic detection

std::string m_predictionModelPath
std::unique_ptr< ML::MachineLearningModelm_predictionModel
float m_detectionProbabilityThreshold
 Threshold on random forest probability for detection heuristic.
float m_detectionDepthPenalization

Parameters for automatic segmentation

double m_marginAroundDetection
 Margin around detection for the mask in mm.
double m_maskSmoothingScale
 Scale for the laplacian in mm.
double m_marginAroundPrevious
 Margin around previous segmentation for the mask in mm.
float m_segmentationThreshold
 Threshold for segmentation extraction.
float m_segmentationGradientFactor
double m_segmentationOffset
int m_segmentationSmoothHalfSize
float m_removeSidePercent
 Total percent of the points to be removed from the sides of each bone (0 1).
double m_qualityThreshold
 Frames having lower tracking quality than this threshold are ignored.
bool m_medianQualityThreshold
 If true, median tracking quality of all frames is used as the threshold.

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.

Member Function Documentation

◆ configure()

void ImFusion::US::BoneSegmentationBaseAlgorithm::configure ( const Properties * p)
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.

See also
configuration() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ configuration()

void ImFusion::US::BoneSegmentationBaseAlgorithm::configuration ( Properties * p) const
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.

See also
configure() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ compute()

void ImFusion::US::BoneSegmentationBaseAlgorithm::compute ( )
overridevirtual

Execute the algorithm.

Implements ImFusion::Algorithm.

◆ takeOutput()

OwningDataList ImFusion::US::BoneSegmentationBaseAlgorithm::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 ImFusion::Algorithm.

◆ init()

virtual void ImFusion::US::BoneSegmentationBaseAlgorithm::init ( )
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.


The documentation for this class was generated from the following file:
  • ImFusion/US/BoneSegmentationBaseAlgorithm.h
Search Tab / S to search, Esc to close