Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitk::Label Class Reference

A data structure describing a label. More...

#include <mitkLabel.h>

Inheritance diagram for mitk::Label:
Collaboration diagram for mitk::Label:

Public Types

enum class  AlgorithmType { Undefined , MANUAL , SEMIAUTOMATIC , AUTOMATIC }
 
typedef unsigned short PixelType
 
- Public Types inherited from mitk::PropertyList
typedef std::map< std::string, BaseProperty::Pointer > PropertyMap
 
typedef std::pair< std::string, BaseProperty::Pointer > PropertyMapElementType
 

Public Member Functions

 mitkClassMacro (Label, mitk::PropertyList)
 
 mitkNewMacro2Param (Self, PixelType, const std::string &)
 
void SetLocked (bool locked)
 
bool GetLocked () const
 
void SetVisible (bool visible)
 
bool GetVisible () const
 
void SetOpacity (float opacity)
 
float GetOpacity () const
 
void SetName (const std::string &name)
 
std::string GetName () const
 
void SetTrackingID (const std::string &trackingID)
 
std::string GetTrackingID () const
 
void SetTrackingUID (const std::string &trackingUID)
 
std::string GetTrackingUID () const
 
void SetDescription (const std::string &description)
 
std::string GetDescription () const
 
mitk::Point3D GetCenterOfMassIndex () const
 
mitk::Point3D GetCenterOfMassCoordinates () const
 
void ResetCenterOfMass ()
 
itk::ModifiedTimeType GetCenterOfMassMTime () const
 
void UpdateCenterOfMass (const mitk::Point3D &index, const mitk::Point3D &coordinates)
 
void SetColor (const mitk::Color &)
 
const mitk::ColorGetColor () const
 
void SetValue (PixelType pixelValue)
 
PixelType GetValue () const
 
void SetAlgorithmType (AlgorithmType algoType)
 
void SetAlgorithmTypeStr (const std::string &algoType)
 
AlgorithmType GetAlgorithmType () const
 
std::string GetAlgorithmTypeStr () const
 
void SetAlgorithmName (const std::string &algoName)
 
std::string GetAlgorithmName () const
 
void AddToolUse (AlgorithmType algoType, const std::string &algoName)
 Helper function to add the usage of multiple tools correctly to the label. Mixture of types always lead to semiautomatic. If the algorithm name is empty, the name will directly set. If it is not empty and algoName is not already a sub string of the current algorithm name, the new algoName will be appended (separated by "|"). More...
 
void SetAnatomicRegion (const DICOMCodeSequenceWithModifiers &code, std::size_t index=0)
 Sets an anatomic region code at the specified index. More...
 
DICOMCodeSequenceWithModifiers GetAnatomicRegion (std::size_t index=0) const
 Gets an anatomic region code at the specified index. More...
 
std::size_t GetAnatomicRegionCount () const
 Gets the number of anatomic region codes stored. More...
 
void RemoveAnatomicRegion (std::size_t index)
 Removes an anatomic region code at the specified index. More...
 
void SetPrimaryAnatomicStructure (const DICOMCodeSequenceWithModifiers &code, std::size_t index=0)
 Sets a primary anatomic structure code at the specified index. More...
 
DICOMCodeSequenceWithModifiers GetPrimaryAnatomicStructure (std::size_t index=0) const
 Gets a primary anatomic structure code at the specified index. More...
 
std::size_t GetPrimaryAnatomicStructureCount () const
 Gets the number of primary anatomic structure codes stored. More...
 
void RemovePrimaryAnatomicStructure (std::size_t index)
 Removes a primary anatomic structure code at the specified index. More...
 
void SetSegmentedPropertyCategory (const DICOMCodeSequence &code)
 Sets the segmented property category code. More...
 
std::optional< DICOMCodeSequenceGetSegmentedPropertyCategory () const
 Gets the segmented property category code. More...
 
void SetSegmentedPropertyType (const DICOMCodeSequenceWithModifiers &code)
 Sets the segmented property type code with optional modifiers. More...
 
std::optional< DICOMCodeSequenceWithModifiersGetSegmentedPropertyType () const
 Gets the segmented property type code with modifiers. More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Add new or change existent property. More...
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Get property by its key. More...
 
BasePropertyGetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Get property by its key. More...
 
void Modified ()
 
void Update (const Label *templateLabel, bool updateLabelValue=false)
 Function updates the property values of a label provided as templates. If a property exists in the destination label only the value will be updated (therefor observers and pointers stay valid). If the property does not exist, it will be cloned and added. No properties will be removed. More...
 
 Label ()
 
 Label (PixelType value, const std::string &name)
 
 ~Label () override
 
- Public Member Functions inherited from mitk::PropertyList
 mitkClassMacroItkParent (PropertyList, itk::Object)
 
Pointer Clone () const
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Query keys of existing properties. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Query names of existing contexts. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Removes a property. If the property does not exist, nothing will be done. More...
 
mitk::BasePropertyGetProperty (const std::string &propertyKey) const
 Get a property by its name. More...
 
void ReplaceProperty (const std::string &propertyKey, BaseProperty *property)
 Set a property object in the list/map by reference. More...
 
void ConcatenatePropertyList (PropertyList *pList, bool replace=false)
 Set a property object in the list/map by reference. More...
 
template<typename T >
bool GetPropertyValue (const char *propertyKey, T &value) const
 Convenience access method for GenericProperty<T> properties (T being the type of the second parameter) More...
 
bool GetBoolProperty (const char *propertyKey, bool &boolValue) const
 Convenience method to access the value of a BoolProperty. More...
 
bool Get (const char *propertyKey, bool &boolValue) const
 ShortCut for the above method. More...
 
void SetBoolProperty (const char *propertyKey, bool boolValue)
 Convenience method to set the value of a BoolProperty. More...
 
void Set (const char *propertyKey, bool boolValue)
 ShortCut for the above method. More...
 
bool GetIntProperty (const char *propertyKey, int &intValue) const
 Convenience method to access the value of an IntProperty. More...
 
bool Get (const char *propertyKey, int &intValue) const
 ShortCut for the above method. More...
 
void SetIntProperty (const char *propertyKey, int intValue)
 Convenience method to set the value of an IntProperty. More...
 
void Set (const char *propertyKey, int intValue)
 ShortCut for the above method. More...
 
bool GetFloatProperty (const char *propertyKey, float &floatValue) const
 Convenience method to access the value of a FloatProperty. More...
 
bool Get (const char *propertyKey, float &floatValue) const
 ShortCut for the above method. More...
 
void SetFloatProperty (const char *propertyKey, float floatValue)
 Convenience method to set the value of a FloatProperty. More...
 
void Set (const char *propertyKey, float floatValue)
 ShortCut for the above method. More...
 
bool GetDoubleProperty (const char *propertyKey, double &doubleValue) const
 Convenience method to access the value of a DoubleProperty. More...
 
bool Get (const char *propertyKey, double &doubleValue) const
 ShortCut for the above method. More...
 
void SetDoubleProperty (const char *propertyKey, double doubleValue)
 Convenience method to set the value of a DoubleProperty. More...
 
void Set (const char *propertyKey, double doubleValue)
 ShortCut for the above method. More...
 
bool GetStringProperty (const char *propertyKey, std::string &stringValue) const
 Convenience method to access the value of a StringProperty. More...
 
bool Get (const char *propertyKey, std::string &stringValue) const
 ShortCut for the above method. More...
 
void SetStringProperty (const char *propertyKey, const char *stringValue)
 Convenience method to set the value of a StringProperty. More...
 
void Set (const char *propertyKey, const char *stringValue)
 ShortCut for the above method. More...
 
void Set (const char *propertyKey, const std::string &stringValue)
 ShortCut for the above method. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the timestamp of the last change of the map or the last change of one of the properties store in the list (whichever is later). More...
 
bool DeleteProperty (const std::string &propertyKey)
 Remove a property from the list/map. More...
 
const PropertyMapGetMap () const
 
bool IsEmpty () const
 
virtual void Clear ()
 
void ToJSON (nlohmann::json &j) const
 Serialize the property list to JSON. More...
 
void FromJSON (const nlohmann::json &j)
 Deserialize the property list from JSON. More...
 
- Public Member Functions inherited from mitk::IPropertyOwner
 ~IPropertyOwner () override
 
virtual bool PropertyIsOwned (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const
 Checks if a certain property exists. More...
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from mitk::PropertyList
static Pointer New ()
 

Static Public Attributes

static const PixelType MAX_LABEL_VALUE
 The maximum value a label can get: Since the value is of type unsigned short MAX_LABEL_VALUE = 65535. More...
 
static constexpr PixelType UNLABELED_VALUE
 

Protected Member Functions

void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
 Label (const Label &other)
 
void SetCenterOfMassIndex (const mitk::Point3D &center)
 
void SetCenterOfMassCoordinates (const mitk::Point3D &center)
 
mitk::BasePropertyGetProperty (const std::string &propertyKey) const
 Get a property by its name. More...
 
- Protected Member Functions inherited from mitk::PropertyList
 PropertyList ()
 
 PropertyList (const PropertyList &other)
 
 ~PropertyList () override
 

Additional Inherited Members

- Protected Attributes inherited from mitk::PropertyList
PropertyMap m_Properties
 Map of properties. More...
 

Detailed Description

A data structure describing a label.

Definition at line 89 of file mitkLabel.h.

Member Typedef Documentation

◆ PixelType

typedef unsigned short mitk::Label::PixelType

Definition at line 94 of file mitkLabel.h.

Member Enumeration Documentation

◆ AlgorithmType

Enumerator
Undefined 

undefined type

MANUAL 

user generated labels with simple tooling (e.g. Add tool)

SEMIAUTOMATIC 

calculated label by user with algorithmic assistance (e.g. nnInteractive)

AUTOMATIC 

fully automatically generated by an algorithm (e.g. nnUnet)

Definition at line 140 of file mitkLabel.h.

Constructor & Destructor Documentation

◆ Label() [1/3]

mitk::Label::Label ( )

◆ Label() [2/3]

mitk::Label::Label ( PixelType  value,
const std::string &  name 
)

◆ ~Label()

mitk::Label::~Label ( )
override

◆ Label() [3/3]

mitk::Label::Label ( const Label other)
protected

Member Function Documentation

◆ AddToolUse()

void mitk::Label::AddToolUse ( AlgorithmType  algoType,
const std::string &  algoName 
)

Helper function to add the usage of multiple tools correctly to the label. Mixture of types always lead to semiautomatic. If the algorithm name is empty, the name will directly set. If it is not empty and algoName is not already a sub string of the current algorithm name, the new algoName will be appended (separated by "|").

◆ GetAlgorithmName()

std::string mitk::Label::GetAlgorithmName ( ) const

◆ GetAlgorithmType()

AlgorithmType mitk::Label::GetAlgorithmType ( ) const

◆ GetAlgorithmTypeStr()

std::string mitk::Label::GetAlgorithmTypeStr ( ) const

◆ GetAnatomicRegion()

DICOMCodeSequenceWithModifiers mitk::Label::GetAnatomicRegion ( std::size_t  index = 0) const

Gets an anatomic region code at the specified index.

Parameters
indexThe index of the code to retrieve (default: 0)
Returns
The DICOMCodeSequenceWithModifiers at the specified index, or an empty code if not found

◆ GetAnatomicRegionCount()

std::size_t mitk::Label::GetAnatomicRegionCount ( ) const

Gets the number of anatomic region codes stored.

Returns
The count of anatomic region codes

◆ GetCenterOfMassCoordinates()

mitk::Point3D mitk::Label::GetCenterOfMassCoordinates ( ) const

◆ GetCenterOfMassIndex()

mitk::Point3D mitk::Label::GetCenterOfMassIndex ( ) const

◆ GetCenterOfMassMTime()

itk::ModifiedTimeType mitk::Label::GetCenterOfMassMTime ( ) const

◆ GetColor()

const mitk::Color& mitk::Label::GetColor ( ) const

◆ GetConstProperty()

BaseProperty::ConstPointer mitk::Label::GetConstProperty ( const std::string &  propertyKey,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = true 
) const
overridevirtual

Get property by its key.

Parameters
[in]propertyKeyKey of property.
[in]contextNameOptional, default is empty string (default context). Search in specified context.
[in]fallBackOnDefaultContextOptional, default is true. Also search in default context if property was not found in given context.
Returns
Found property, nullptr otherwise.

Reimplemented from mitk::PropertyList.

◆ GetDescription()

std::string mitk::Label::GetDescription ( ) const

◆ GetLocked()

bool mitk::Label::GetLocked ( ) const

◆ GetName()

std::string mitk::Label::GetName ( ) const

◆ GetNonConstProperty()

BaseProperty* mitk::Label::GetNonConstProperty ( const std::string &  propertyKey,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = true 
)
overridevirtual

Get property by its key.

Parameters
[in]propertyKeyKey of property.
[in]contextNameOptional, default is empty string (default context). Search in specified context.
[in]fallBackOnDefaultContextOptional, default is true. Also search in default context if property was not found in given context.
Returns
Found property, nullptr otherwise.

Reimplemented from mitk::PropertyList.

◆ GetOpacity()

float mitk::Label::GetOpacity ( ) const

◆ GetPrimaryAnatomicStructure()

DICOMCodeSequenceWithModifiers mitk::Label::GetPrimaryAnatomicStructure ( std::size_t  index = 0) const

Gets a primary anatomic structure code at the specified index.

Parameters
indexThe index of the code to retrieve (default: 0)
Returns
The DICOMCodeSequenceWithModifiers at the specified index, or an empty code if not found

◆ GetPrimaryAnatomicStructureCount()

std::size_t mitk::Label::GetPrimaryAnatomicStructureCount ( ) const

Gets the number of primary anatomic structure codes stored.

Returns
The count of primary anatomic structure codes

◆ GetProperty()

mitk::BaseProperty* mitk::PropertyList::GetProperty
protected

Get a property by its name.

◆ GetSegmentedPropertyCategory()

std::optional<DICOMCodeSequence> mitk::Label::GetSegmentedPropertyCategory ( ) const

Gets the segmented property category code.

Returns
The DICOMCodeSequence representing the segmented property category

◆ GetSegmentedPropertyType()

std::optional<DICOMCodeSequenceWithModifiers> mitk::Label::GetSegmentedPropertyType ( ) const

Gets the segmented property type code with modifiers.

Returns
The DICOMCodeSequenceWithModifiers representing the segmented property type

◆ GetTrackingID()

std::string mitk::Label::GetTrackingID ( ) const

◆ GetTrackingUID()

std::string mitk::Label::GetTrackingUID ( ) const

◆ GetValue()

PixelType mitk::Label::GetValue ( ) const

◆ GetVisible()

bool mitk::Label::GetVisible ( ) const

◆ mitkClassMacro()

mitk::Label::mitkClassMacro ( Label  ,
mitk::PropertyList   
)

◆ mitkNewMacro2Param()

mitk::Label::mitkNewMacro2Param ( Self  ,
PixelType  ,
const std::string &   
)

◆ Modified()

void mitk::Label::Modified ( )
inline

Definition at line 247 of file mitkLabel.h.

◆ New()

static Pointer mitk::Label::New ( )
static

◆ PrintSelf()

void mitk::Label::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

◆ RemoveAnatomicRegion()

void mitk::Label::RemoveAnatomicRegion ( std::size_t  index)

Removes an anatomic region code at the specified index.

Parameters
indexThe index of the code to remove

◆ RemovePrimaryAnatomicStructure()

void mitk::Label::RemovePrimaryAnatomicStructure ( std::size_t  index)

Removes a primary anatomic structure code at the specified index.

Parameters
indexThe index of the code to remove

◆ ResetCenterOfMass()

void mitk::Label::ResetCenterOfMass ( )

◆ SetAlgorithmName()

void mitk::Label::SetAlgorithmName ( const std::string &  algoName)

◆ SetAlgorithmType()

void mitk::Label::SetAlgorithmType ( AlgorithmType  algoType)

◆ SetAlgorithmTypeStr()

void mitk::Label::SetAlgorithmTypeStr ( const std::string &  algoType)

◆ SetAnatomicRegion()

void mitk::Label::SetAnatomicRegion ( const DICOMCodeSequenceWithModifiers code,
std::size_t  index = 0 
)

Sets an anatomic region code at the specified index.

Parameters
codeThe DICOMCodeSequenceWithModifiers representing the anatomic region
indexThe index at which to store the code (default: 0)

◆ SetCenterOfMassCoordinates()

void mitk::Label::SetCenterOfMassCoordinates ( const mitk::Point3D center)
protected

◆ SetCenterOfMassIndex()

void mitk::Label::SetCenterOfMassIndex ( const mitk::Point3D center)
protected

◆ SetColor()

void mitk::Label::SetColor ( const mitk::Color )

◆ SetDescription()

void mitk::Label::SetDescription ( const std::string &  description)

◆ SetLocked()

void mitk::Label::SetLocked ( bool  locked)

◆ SetName()

void mitk::Label::SetName ( const std::string &  name)

◆ SetOpacity()

void mitk::Label::SetOpacity ( float  opacity)

◆ SetPrimaryAnatomicStructure()

void mitk::Label::SetPrimaryAnatomicStructure ( const DICOMCodeSequenceWithModifiers code,
std::size_t  index = 0 
)

Sets a primary anatomic structure code at the specified index.

Parameters
codeThe DICOMCodeSequenceWithModifiers representing the primary anatomic structure
indexThe index at which to store the code (default: 0)

◆ SetProperty()

void mitk::Label::SetProperty ( const std::string &  propertyKey,
BaseProperty property,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = false 
)
overridevirtual

Add new or change existent property.

Parameters
[in]propertyKeyKey of property.
[in]propertyThe actual property.
[in]contextNameOptional, default is empty string (default context). Context in which the property is set.
[in]fallBackOnDefaultContextOptional, default is false. Set property in default context if given context does not exist.
Precondition
If a context is specified by contextName, this context must be known by the owner or fallBackOnDefaultContext must be true. If violated an mitk::Exception is thrown.
propertyKey must be a none empty string. If violated an mitk::Exception is thrown.

Reimplemented from mitk::PropertyList.

◆ SetSegmentedPropertyCategory()

void mitk::Label::SetSegmentedPropertyCategory ( const DICOMCodeSequence code)

Sets the segmented property category code.

Parameters
codeThe DICOMCodeSequence representing the segmented property category

◆ SetSegmentedPropertyType()

void mitk::Label::SetSegmentedPropertyType ( const DICOMCodeSequenceWithModifiers code)

Sets the segmented property type code with optional modifiers.

Parameters
codeThe DICOMCodeSequenceWithModifiers representing the segmented property type

◆ SetTrackingID()

void mitk::Label::SetTrackingID ( const std::string &  trackingID)

◆ SetTrackingUID()

void mitk::Label::SetTrackingUID ( const std::string &  trackingUID)

◆ SetValue()

void mitk::Label::SetValue ( PixelType  pixelValue)

◆ SetVisible()

void mitk::Label::SetVisible ( bool  visible)

◆ Update()

void mitk::Label::Update ( const Label templateLabel,
bool  updateLabelValue = false 
)

Function updates the property values of a label provided as templates. If a property exists in the destination label only the value will be updated (therefor observers and pointers stay valid). If the property does not exist, it will be cloned and added. No properties will be removed.

Parameters
templateLabelLabel instance that provides the new values for properties
updateLabelValueIndicate if also the label value should be updated.

◆ UpdateCenterOfMass()

void mitk::Label::UpdateCenterOfMass ( const mitk::Point3D index,
const mitk::Point3D coordinates 
)

Member Data Documentation

◆ MAX_LABEL_VALUE

const PixelType mitk::Label::MAX_LABEL_VALUE
static

The maximum value a label can get: Since the value is of type unsigned short MAX_LABEL_VALUE = 65535.

Definition at line 100 of file mitkLabel.h.

◆ UNLABELED_VALUE

constexpr PixelType mitk::Label::UNLABELED_VALUE
staticconstexpr

Definition at line 103 of file mitkLabel.h.


The documentation for this class was generated from the following file: