ImFusion C++ SDK 4.4.0
ImFusion::ML::LabelsProjectDataReader Class Reference

#include <ImFusionLabels/lib/include/ImFusion/Labels/ML/LabelsProjectDataReader.h>

Data loader for training pipelines that load data directly from a Labels project. More...

Inheritance diagram for ImFusion::ML::LabelsProjectDataReader:

Detailed Description

Data loader for training pipelines that load data directly from a Labels project.

Supports both local and remote ImFusion Labels projects. For remote projects, an access token is required.

The DataItems generated by this loader consist of DataElements that contain the image data (default key 'images', can be changed using the data_name entry) and DataElements from one or more segmentation/keypoint/boundingbox layers (key is the layer name from Labels unless a specific name is defined using the field_name entry). A user defined filter can be used to limit the results to a subset of the datasets in the project.

Validation and Error Handling:

  • Configuration must include at least one layer (throws DataLoaderException if empty or missing)
  • All layer names specified in the configuration must exist in the project (throws DataLoaderException if not found)
  • All label names specified in layer mappings must exist in the corresponding layer (throws DataLoaderException if not found)
  • Field names must be unique across all layers (throws DataLoaderException if duplicated)
  • Field names cannot conflict with the configured data field name (throws DataLoaderException if conflicting)
  • Project type must support the requested layer types (throws DataLoaderException if incompatible)
  • At least one dataset must match the filter criteria (throws DataLoaderException if none available)
  • Detailed mapping summary is logged at INFO level showing all layer configurations

Label Mapping Behavior:

  • For segmentation layers: Labels not specified in the mapping are assigned value 0 (background) in the output
  • For keypoint/landmark layers: Labels not specified in the mapping are omitted from the output (not included in training data)
  • For bounding box layers: Labels not specified in the mapping are omitted from the output (not included in training data)

Sample usage in an IMT training yaml:

sources: {} pipeline:

For remote projects, use the full URL:

path: 'https://server.com/api/v1/projects/123'

access_token: 'your_access_token_here' # Required for remote projects

layers: # define which layers to load yourSegmentLayer: field_name: heart # We can define the field name of the data element (default is the layer name) Heart: 1 # define mapping from labelname to value, required for all layers yourKeypointLayer: # keypoints are supported ventricle: 1 filter: # filter defines which datasets are selected MyBooleanTag: true MyFloatTag: "<10" MyEnumTag: "Blue Red" # space seperated string match: any # keyword for match mode, other option: all invert: false # keyword for filter inversion (like in ImFusionLabels) shuffle: true # internal shuffle is supported crop_to_roi: true # crop images and labels to ROI (default false) data_name: data # default 'images'

Public Member Functions

 LabelsProjectDataReader (std::string projectPath, bool shuffle=false, bool verbose=false)
 LabelsProjectDataReader (const Properties &properties)
 constructor for DataLoaderDecoratorFactory
std::optional< DataItemnext () final
 Advance the loader by one iteration.
std::optional< size_t > size () const final
 Size of the loader, has value only for fixed cardinalities.
void reset () final
 Reset the loader in order to restart the iteration.
Public Member Functions inherited from ImFusion::ML::DataReader
 DataReader (std::string name="", bool verbose=false)
Cardinality cardinality () const override
 Readers have fixed cardinality.
Public Member Functions inherited from ImFusion::ML::DataLoader
 DataLoader (std::string name, bool verbose=false)
 Constructor to be used by DataReaders, as they are the first elements in the chain.
 DataLoader (std::string name, std::unique_ptr< DataLoader > loader, bool verbose=false)
 Constructor to be used by all other derived DataLoaders.
 DataLoader (std::string name, DataLoaderList &&dataLoaders, bool verbose=false)
 Constructor to be used by all other derived DataLoaders.
const std::stringname () const
 Name of the loader.
virtual void reinit ()
 Reinitialize the loader state, cleaning it up if necessary Overload this method if your loader has state that must survive reset (i.e.
DataLoadersingleUnderlyingLoader () const
 Return a single underlying dataloader Expects there to be only one, returns a nullptr otherwise.
std::unique_ptr< DataLoaderextractDataloader ()
 Return a single underlying dataloader Expects there to be only one, throws an exception otherwise.
DataLoaderList & loaders ()
DataLoaderList const & loaders () const
bool verbose () const
virtual void setRandomSeed (unsigned int seed)
virtual Status canBePrefetched () const
 Indicates whether a loader is eligible for prefetching.
const std::stringlogDomain () const
 Log domain for AdvancedParameter.
Public Member Functions inherited from ImFusion::Configurable
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 Attributes

LoaderParam< std::stringp_projectPath = {"path", "", this, ParamRequired::Yes}
LoaderParam< std::stringp_accessToken = {"access_token", "", this, ParamRequired::No}
 Access token for remote projects. Required when path points to a remote project (http/https URL).
LoaderParam< bool > p_shuffle = {"shuffle", false, this, ParamRequired::No}
LoaderParam< std::stringp_dataName = {"data_name", "images", this, ParamRequired::No}
LoaderParam< bool > p_cropToROI = {"crop_to_roi", false, this, ParamRequired::No}
 Whether to crop images and labels to the region of interest (ROI) defined in the dataset descriptor.
LoaderParam< bool > p_internallyUpdateProject = {"internally_update_project", false, this, ParamRequired::No}
 Whether to load labels projects with an old labels version. This may result in files being written to disk, use at your own risk.
Public Attributes inherited from ImFusion::ML::DataLoader
LoaderParam< bool > m_verbose = {"verbose", false, this, ParamRequired::No}
 If enabled, print log messages with extra information like timings.
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.

Additional Inherited Members

Protected Member Functions inherited from ImFusion::Utils::NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
NotCopyable & operator= (NotCopyable &&) noexcept=default
 NotCopyable (const NotCopyable &)=delete
NotCopyable & operator= (const NotCopyable &)=delete
Protected Attributes inherited from ImFusion::ML::DataLoader
std::string m_name
Cardinality m_cardinality = Cardinality::Fixed
Random::Generator m_randGenerator
DataLoaderList m_dataLoaders
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Member Function Documentation

◆ next()

std::optional< DataItem > ImFusion::ML::LabelsProjectDataReader::next ( )
finalvirtual

Advance the loader by one iteration.

The function must pull an item from the underlying node, process it and return it. If the underlyng loader is exhausted, returns an empty optional.

Implements ImFusion::ML::DataLoader.

◆ size()

std::optional< size_t > ImFusion::ML::LabelsProjectDataReader::size ( ) const
finalvirtual

Size of the loader, has value only for fixed cardinalities.

Implements ImFusion::ML::DataLoader.

◆ reset()

void ImFusion::ML::LabelsProjectDataReader::reset ( )
finalvirtual

Reset the loader in order to restart the iteration.

Reimplemented from ImFusion::ML::DataLoader.


The documentation for this class was generated from the following file:
  • ImFusionLabels/lib/include/ImFusion/Labels/ML/LabelsProjectDataReader.h
Search Tab / S to search, Esc to close