mitk.Label#

class mitk.Label#

Bases: pybind11_object

A single label inside a MultiLabelSegmentation.

Carries the integer pixel value used in the label image, a human-readable name, display attributes (color, opacity, visibility), provenance metadata (algorithm type/name, tracking IDs), and structured DICOM descriptors (anatomic region, primary anatomic structure, segmented property category/type).

Labels expose the same property-owner interface as Image, so the get_property() / set_property() / remove_property() methods used on images work on labels too.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: mitk.Label) -> None

Construct an unnamed label with a default value.

  1. __init__(self: mitk.Label, value: typing.SupportsInt, name: str) -> None

Construct a label with a given pixel value and name.

Parameters:
  • value – Integer pixel value used to mark this label in the label image. Must be in [1, MAX_LABEL_VALUE]; 0 is reserved.

  • name – Human-readable label name.

Methods

__init__(*args, **kwargs)

Overloaded function.

add_tool_use(self, algorithm_type, ...)

Record that a tool/operation contributed to this label.

get_anatomic_region(self[, index])

get_primary_anatomic_structure(self[, index])

get_property(self, key[, raw])

Return the property value for key, or None if not set.

merge_tool_uses(self, other)

Absorb another label's recorded provenance (algorithm type and tool names) into this one.

property_is_owned(self, key)

Return True if the property key is owned (writable) by this object.

remove_anatomic_region(self, index)

remove_primary_anatomic_structure(self, index)

remove_property(self, key)

Remove the property key if it exists.

reset_center_of_mass(self)

set_anatomic_region(self, code[, index])

set_primary_anatomic_structure(self, code[, ...])

set_property(self, key, value)

Set the property key to value.

update(self, template_label[, update_value])

update_center_of_mass(self, index, coordinates)

Attributes

MAX_LABEL_VALUE = 65535#
__eq__(self: mitk.Label, arg0: mitk.Label) bool#
add_tool_use(self: mitk.Label, algorithm_type: object, algorithm_name: str) None#

Record that a tool/operation contributed to this label. An empty algorithm_name is ignored; the reserved separator characters ‘|’ and ‘:’ are sanitized to ‘#’ (a warning is logged).

property algorithm_name#
property algorithm_type#
property algorithm_type_str#
property anatomic_region#
property anatomic_region_count#
property center_of_mass_coordinates#
property center_of_mass_index#
property center_of_mass_mtime#
property color#
property description#
get_anatomic_region(self: mitk.Label, index: SupportsInt = 0) mitk.DICOMCodeSequenceWithModifiers#
get_primary_anatomic_structure(self: mitk.Label, index: SupportsInt = 0) mitk.DICOMCodeSequenceWithModifiers#
get_property(self: mitk.Label, key: str, raw: bool = False) object#

Return the property value for key, or None if not set.

By default returns a coerced Python-native value: bool, int, float, str, or an (r, g, b) tuple for ColorProperty. For types without a known Python equivalent the raw mitk.BaseProperty object is returned.

Parameters:
  • key – Property name.

  • raw – If True, always return the underlying mitk.BaseProperty object (useful to access metadata or to pass to a C++ function that expects one). Defaults to False.

Returns:

The property value, or None if the property is not set.

property has_algorithm_name#
property locked#
merge_tool_uses(self: mitk.Label, other: mitk.Label) None#

Absorb another label’s recorded provenance (algorithm type and tool names) into this one. The source’s type is mixed in (a differing defined type yields SEMIAUTOMATIC) and each recorded tool name is appended (de-duplicated) to this label’s tool chain.

property name#
property opacity#
property primary_anatomic_structure#
property primary_anatomic_structure_count#
property_is_owned(self: mitk.Label, key: str) bool#

Return True if the property key is owned (writable) by this object.

Returns False if the property does not exist or is provided read-only (for example, routed from an internal component like a Label inside a MultiLabelSegmentation).

Parameters:

key – Property name.

property property_keys#

List of all property keys currently set on this object.

remove_anatomic_region(self: mitk.Label, index: SupportsInt) None#
remove_primary_anatomic_structure(self: mitk.Label, index: SupportsInt) None#
remove_property(self: mitk.Label, key: str) None#

Remove the property key if it exists.

Parameters:

key – Property name.

Raises:

PropertyNotOwnedError – If the property is provided read-only and cannot be removed.

reset_center_of_mass(self: mitk.Label) None#
property segmented_property_category#
property segmented_property_type#
set_anatomic_region(self: mitk.Label, code: object, index: SupportsInt = 0) None#
set_primary_anatomic_structure(self: mitk.Label, code: object, index: SupportsInt = 0) None#
set_property(self: mitk.Label, key: str, value: object) None#

Set the property key to value.

The value is auto-wrapped into the appropriate BaseProperty subtype based on its Python type: bool -> BoolProperty, int -> IntProperty, float -> DoubleProperty, str -> StringProperty, 3-tuple -> ColorProperty, or an existing mitk.BaseProperty instance is used as-is.

Parameters:
  • key – Property name.

  • value – Property value (auto-wrapped to a BaseProperty subtype).

Raises:

PropertyNotOwnedError – If the property is provided read-only (not owned) by this object.

property tracking_id#
property tracking_uid#
update(self: mitk.Label, template_label: mitk.Label, update_value: bool = False) None#
update_center_of_mass(self: mitk.Label, index: Annotated[collections.abc.Sequence[SupportsFloat], 'FixedSize(3)'], coordinates: Annotated[collections.abc.Sequence[SupportsFloat], 'FixedSize(3)']) None#
property value#
property visible#