ImFusion SDK 4.3
BoneSegmentationAlgorithm Class Reference

#include <ImFusion/US/BoneSegmentationAlgorithm.h>

Algorithm which segments bone in an ultrasound sweep. More...

+ Inheritance diagram for BoneSegmentationAlgorithm:

Detailed Description

Algorithm which segments bone in an ultrasound sweep.

This algorithm supports bone detection and segmentation. Many side output parameters can be acquired via the getters.

Classes

class  SweepDetectionResults
 Data structure to store the detections results for a given sweep. More...
 

Public Member Functions

 BoneSegmentationAlgorithm (const std::vector< UltrasoundSweep * > &sweeps)
 
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 computeCompoundedProbability ()
 Execute the detection on whole volume.
 
void computeDetection (int slice)
 Execute only the detection.
 
void computeSegmentation ()
 Execute only the segmentation (assumes that the detection has already been performed)
 
virtual void detectOutliers ()
 Estimate how reliable the segmentations are.
 
void compute () override
 Computes bone segmentation and prepares it for output.
 
OwningDataList takeOutput () override
 Get the calculated results.
 
UltrasoundSweepsweep () const
 
int bestSlice (UltrasoundSweep *sweep) const
 
bool isResultAvailable (int slice, UltrasoundSweep *sweep) const
 
const std::vector< vec3 > & detectedBone (int slice, UltrasoundSweep *sweep) const
 Returns the list of detected bone centerline points for a specific ultrasound slice.
 
const std::vector< vec3 > & segmentedBone (int slice, UltrasoundSweep *sweep) const
 Returns the segmented bone centerline points for a specific ultrasound slice.
 
const std::vector< double > & outlierness (UltrasoundSweep *sweep) const
 
const std::vector< double > & detectionConfidence (UltrasoundSweep *sweep) const
 
const std::vector< std::vector< double > > & boneClassification (UltrasoundSweep *sweep) const
 
std::vector< std::unique_ptr< PointCloud > > extractPointClouds (int exportSkip, double outliernessMaxThreshold, std::vector< double > *outliernessOut) const
 
- Public Member Functions inherited from BoneSegmentationBaseAlgorithm
 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 reset ()
 Clears current output.
 
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
 
- 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 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
 

Static Public Member Functions

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

Protected Member Functions

void init () override
 Clear/resize all vectors of images/results and initialize the algorithm (e.g. load the ML model)
 
bool automaticDetection ()
 Find the best slice and compute its bone detection.
 
int findBestSlice ()
 Compute the probability map on a subset of slices to find the one with the highest confidence.
 
std::shared_ptr< SharedImageboneProbability (int slice)
 Get the bone probability map in a given slice.
 
void computeCompoundedProbabilityImpl (UltrasoundSweep *)
 
- Protected Member Functions inherited from BoneSegmentationBaseAlgorithm
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 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.
 

Input

std::vector< UltrasoundSweep * > m_sweeps
 Input ultrasound sweeps.
 
UltrasoundSweepm_sweep
 Currently analyzed sweep.
 

Output

std::map< UltrasoundSweep *, SweepDetectionResultsm_results
 
std::vector< std::unique_ptr< PointCloud > > m_outPointClouds
 
std::unique_ptr< SharedImagem_compoundedProba
 Compounded probability map for the bone.
 

Configurable Parameters

int m_sliceStep
 Slice step for detection and propagation. Minimum value is 1.
 
bool m_intermediateOutput
 Export intermediate images.
 
bool m_exportPointCloud
 
int m_pointCloudSkip
 The skip step for the exported point cloud.
 
bool m_exportAllRelativePointClouds
 
bool m_exportFrameBasedPointCloud
 

Outliers

Properties m_outlierDetectionProperties
 
double m_pointCloudMaxOutlierness
 

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 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 Attributes inherited from BoneSegmentationBaseAlgorithm
SharedImagem_curImage
 
std::unique_ptr< SharedImageSetm_outImages
 
std::unique_ptr< ImageResamplingAlgorithmm_resamplingAlgo
 
std::string m_statsFile
 
SharedImageSetm_images
 
SharedImageSetm_labels
 
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
 
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.
 
std::string m_predictionModelPath
 
std::unique_ptr< ML::MachineLearningModelm_predictionModel
 
float m_detectionProbabilityThreshold
 Threshold on random forest probability for detection heuristic.
 
float m_detectionDepthPenalization
 
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.
 
- 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.
 

Member Function Documentation

◆ configure()

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

◆ configuration()

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

◆ compute()

void compute ( )
overridevirtual

Computes bone segmentation and prepares it for output.

Performs automatic bone detection on each sweep. If a bone is found, it then computes the segmentation and estimates outliers for it. If the parameter "Export Point Cloud" is set to true, it also exports the point cloud.

Note
Notifies listeners about the output change.

Implements Algorithm.

◆ takeOutput()

OwningDataList takeOutput ( )
overridevirtual

Get the calculated results.

Returns
OwningDataList filled in with up to 3 Data entities:
  1. If the parameter "Intermediate Output" is set, includes the SweepDetectionResults instance for the current sweep.
  2. If the compounded probability map is available (i.e., computeCompoundedProbability() was called successfully), includes a std::unique_ptr to the shared image set with the map.
  3. Includes a std::vector of std::unique_ptr<PointCloud> representing the point clouds.

Reimplemented from Algorithm.

◆ sweep()

UltrasoundSweep * sweep ( ) const
inline
Returns
A pointer to the ultrasound sweep input image.

◆ bestSlice()

int bestSlice ( UltrasoundSweep * sweep) const
inline
Returns
the index of the best slice for the requested sweep.
Parameters
sweep- sweep to look for the best slice for. If equal to nullptr then return the best slice for the current internal sweep.

◆ isResultAvailable()

bool isResultAvailable ( int slice,
UltrasoundSweep * sweep ) const
Returns
true if a segmented bone exists for the specified slice in the given sweep.
Parameters
slice- the index of a slice to look for.
sweep- the sweep to look in. If set nullptr then will look in the currently set internal sweep.

◆ detectedBone()

const std::vector< vec3 > & detectedBone ( int slice,
UltrasoundSweep * sweep ) const
inline

Returns the list of detected bone centerline points for a specific ultrasound slice.

This function provides the 3D points that represent the detected centerline of the bone within a given slice of an ultrasound sweep. If the sweep parameter is nullptr, the currently active internal sweep is used.

Returns
const reference to a std::vector of vec3 points representing the detected bone centerline
Parameters
slice- index of the ultrasound slice.
sweep- pointer to the UltrasoundSweep containing the slice. If nullptr, the internal sweep is used.

◆ segmentedBone()

const std::vector< vec3 > & segmentedBone ( int slice,
UltrasoundSweep * sweep ) const
inline

Returns the segmented bone centerline points for a specific ultrasound slice.

This function retrieves the 3D points representing the segmented bone centerline. for a given slice of an ultrasound sweep. If the sweep parameter is nullptr, the currently active internal sweep is used.

Returns
const reference to a std::vector of vec3 points representing the segmented bone centerline.
Parameters
sliceIndex of the ultrasound slice.
sweepPointer to the UltrasoundSweep containing the slice. If nullptr, the internal sweep is used.

◆ outlierness()

const std::vector< double > & outlierness ( UltrasoundSweep * sweep) const
inline
Returns
the std::vector of outlierness for the slices in the provided sweep.
Parameters
sweep- the sweep to look in. If set nullptr then will look in the currently set internal sweep.

◆ detectionConfidence()

const std::vector< double > & detectionConfidence ( UltrasoundSweep * sweep) const
inline
Returns
the std::vector of confidence scores for each slice in the provided sweep.
Parameters
sweep- the sweep to look in. If set nullptr then will look in the currently set internal sweep.

◆ boneClassification()

const std::vector< std::vector< double > > & boneClassification ( UltrasoundSweep * sweep) const
inline
Returns
the std::vector bone classification for each slice in the provided sweep.
Parameters
sweep- the sweep to look in. If set nullptr then will look in the currently set internal sweep.

◆ init()

void init ( )
overrideprotectedvirtual

Clear/resize all vectors of images/results and initialize the algorithm (e.g. load the ML model)

Reimplemented from BoneSegmentationBaseAlgorithm.


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