Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::SegSourceImageRelationRule Class Reference

Relation rule for referencing a segmentation to a source-image derivations. More...

#include <mitkSegSourceImageRelationRule.h>

Inheritance diagram for mitk::SegSourceImageRelationRule:
Collaboration diagram for mitk::SegSourceImageRelationRule:

Classes

struct  SourceImageRelation
 One seg-source relation as the DICOM SEG writer needs to see it. More...
 

Public Member Functions

 mitkClassMacro (SegSourceImageRelationRule, SourceImageRelationRule)
 
RelationUIDType Connect (MultiLabelSegmentation *seg, const IPropertyProvider *sourceProvider) const
 Connects a segmentation to a source represented as an IPropertyProvider. More...
 
RelationUIDType Connect (MultiLabelSegmentation *seg, TemporoSpatialStringProperty *instanceUIDsPerSlice, TemporoSpatialStringProperty *classUIDsPerSlice, const std::string &sourceSeriesInstanceUID) const
 Connects seg to a source described by its per-slice DICOM UID properties, assembling the intermediate provider PropertyList. More...
 
- Public Member Functions inherited from mitk::SourceImageRelationRule
 mitkClassMacro (SourceImageRelationRule, PropertyRelationRuleBase)
 
 mitkNewMacro1Param (Self, const RuleIDType &)
 
 mitkNewMacro2Param (Self, const RuleIDType &, const std::string &)
 
 mitkNewMacro4Param (Self, const RuleIDType &, const std::string &, const std::string &, const std::string &)
 
RuleIDType GetRuleID () const override
 Return an ID string that identifies the rule class. More...
 
bool IsAbstract () const override
 Return whether this rule is abstract (i.e. has no purpose tag). More...
 
std::string GetDisplayName () const override
 Return a human-readable string describing the rule. Does not need to be unique. More...
 
std::string GetSourceRoleName () const override
 Return a human-readable string describing the role of a source in the context of this rule. More...
 
std::string GetDestinationRoleName () const override
 Return a human-readable string describing the role of a destination in the context of this rule. More...
 
bool IsDestinationCandidate (const IPropertyProvider *owner) const override
 Check whether the given property provider qualifies as a destination for this rule. More...
 
RelationUIDType Connect (Image *source, const Image *destination) const
 Connect two images using this relation rule. More...
 
- Public Member Functions inherited from mitk::PropertyRelationRuleBase
 mitkClassMacroItkParent (PropertyRelationRuleBase, itk::Object)
 
Pointer Clone () const
 
 itkCreateAnotherMacro (Self)
 
virtual bool IsSourceCandidate (const IPropertyProvider *owner) const
 
bool IsSource (const IPropertyProvider *owner) const
 
RelationVectorType GetRelationTypes (const IPropertyProvider *source, const IPropertyProvider *destination) const
 
bool HasRelation (const IPropertyProvider *source, const IPropertyProvider *destination, RelationType requiredRelation=RelationType::None) const
 
RelationUIDVectorType GetExistingRelations (const IPropertyProvider *source, RelationType layer=RelationType::None) const
 
RelationUIDVectorType GetRelationUIDs (const IPropertyProvider *source, const IPropertyProvider *destination) const
 
RelationUIDType GetRelationUID (const IPropertyProvider *source, const IPropertyProvider *destination) const
 
NodePredicateBase::ConstPointer GetSourceCandidateIndicator () const
 
NodePredicateBase::ConstPointer GetDestinationCandidateIndicator () const
 
NodePredicateBase::ConstPointer GetConnectedSourcesDetector () const
 
NodePredicateBase::ConstPointer GetSourcesDetector (const IPropertyProvider *destination, RelationType exclusiveRelation=RelationType::None) const
 
NodePredicateBase::ConstPointer GetDestinationsDetector (const IPropertyProvider *source, RelationType exclusiveRelation=RelationType::None) const
 
NodePredicateBase::ConstPointer GetDestinationDetector (const IPropertyProvider *source, RelationUIDType relationUID) const
 
void Disconnect (IPropertyOwner *source, const IPropertyProvider *destination, RelationType layer=RelationType::Complete) const
 
void Disconnect (IPropertyOwner *source, RelationUIDType relationUID, RelationType layer=RelationType::Complete) const
 
std::vector< PropertyKeyPath > GetRelationPropertyPaths (const IPropertyProvider *source, RelationUIDType relationUID, RelationType layer=RelationType::Data) const
 Get all property key paths relevant for a given relation. More...
 

Static Public Member Functions

static Pointer New ()
 
static const std::string & CanonicalPurposeTag ()
 Returns the canonical DICOM Code Value used in the SEG's Source Image Sequence Purpose Of Reference Code. More...
 
static std::vector< SourceImageRelation > GetSourceImageRelations (const MultiLabelSegmentation *seg)
 Enumerates the seg-source relations established on seg. More...
 
static RelationUIDType Connect (MultiLabelSegmentation *seg, const Image *source_image)
 Static convenience that constructs an instance of this rule and connects seg to source_image. More...
 
- Static Public Member Functions inherited from mitk::SourceImageRelationRule
static Pointer New ()
 
- Static Public Member Functions inherited from mitk::PropertyRelationRuleBase
static PropertyKeyPath GetRootKeyPath ()
 
static PropertyKeyPath GetRIIPropertyKeyPath (const std::string propName, const InstanceIDType &instanceID)
 
static PropertyKeyPath GetRIIRelationUIDPropertyKeyPath (const InstanceIDType &instanceID="")
 
static PropertyKeyPath GetRIIRuleIDPropertyKeyPath (const InstanceIDType &instanceID="")
 
static PropertyKeyPath GetRIIDestinationUIDPropertyKeyPath (const InstanceIDType &instanceID="")
 

Protected Member Functions

 SegSourceImageRelationRule ()
 
 SegSourceImageRelationRule (const SegSourceImageRelationRule &other)
 
void Connect_datalayer (IPropertyOwner *source, const IPropertyProvider *destination, const InstanceIDType &instanceID) const override
 Extends the base data-layer Connect by capturing the source SeriesInstanceUID per relation. More...
 
void Disconnect_datalayer (IPropertyOwner *source, const RelationUIDType &relationUID) const override
 Removes this rule's SourceSeriesInstanceUID extension before delegating to the base. More...
 
 mitkCloneMacro (Self)
 
- Protected Member Functions inherited from mitk::SourceImageRelationRule
 SourceImageRelationRule ()
 Default constructor. Creates an abstract rule with no purpose tag. More...
 
 SourceImageRelationRule (const RuleIDType &purposeTag)
 Construct a rule with a specific purpose tag. More...
 
 SourceImageRelationRule (const RuleIDType &purposeTag, const std::string &displayName)
 Construct a rule with a purpose tag and display name. More...
 
 SourceImageRelationRule (const RuleIDType &purposeTag, const std::string &displayName, const std::string &sourceRole, const std::string &destinationRole)
 Construct a rule with all customizable parameters. More...
 
 ~SourceImageRelationRule () override=default
 
std::vector< std::pair< size_t, std::string > > GetReferenceSequenceIndices (const IPropertyProvider *source, const IPropertyProvider *destination=nullptr, InstanceIDVectorType ignoreInstances={}) const
 Get reference sequence indices from the DICOM Source Image Sequence (0008,2112). More...
 
virtual DataRelationUIDVectorType GetRelationUIDs_DataLayer (const IPropertyProvider *source, const IPropertyProvider *destination, const InstanceIDVectorType &instances_IDLayer) const override
 
bool IsSupportedRuleID (const RuleIDType &ruleID) const override
 
 SourceImageRelationRule (const SourceImageRelationRule &other)
 
 mitkCloneMacro (Self)
 
PropertyKeyPath::ItemSelectionIndex CreateNewSourceImageSequenceItem (IPropertyOwner *source) const
 Prepare a new reference to an image on the data layer. More...
 
std::string GenerateRuleID (const std::string &purpose) const
 Generate a rule ID string from the given purpose tag. More...
 
- Protected Member Functions inherited from mitk::PropertyRelationRuleBase
 PropertyRelationRuleBase ()=default
 
 PropertyRelationRuleBase (const PropertyRelationRuleBase &)
 
 ~PropertyRelationRuleBase () override=default
 
InstanceIDVectorType GetInstanceID_IDLayer (const IPropertyProvider *source, const IPropertyProvider *destination) const
 
RelationUIDType GetRelationUIDByInstanceID (const IPropertyProvider *source, const InstanceIDType &instanceID) const
 
InstanceIDType GetInstanceIDByRelationUID (const IPropertyProvider *source, const RelationUIDType &relationUID) const
 
RelationUIDType Connect (IPropertyOwner *source, const IPropertyProvider *destination) const
 
std::string GetRIIPropertyRegEx (const std::string propName="", const InstanceIDType &instanceID="") const
 
RuleIDType GetRuleIDByInstanceID (const IPropertyProvider *source, const InstanceIDType &instanceID) const
 
std::string GetDestinationUIDByInstanceID (const IPropertyProvider *source, const InstanceIDType &instanceID) const
 
const Identifiable * CastProviderAsIdentifiable (const mitk::IPropertyProvider *provider) const
 

Additional Inherited Members

- Public Types inherited from mitk::SourceImageRelationRule
using RuleIDType = PropertyRelationRuleBase::RuleIDType
 
using RelationUIDType = PropertyRelationRuleBase::RelationUIDType
 
using RelationUIDVectorType = PropertyRelationRuleBase::RelationUIDVectorType
 
- Public Types inherited from mitk::PropertyRelationRuleBase
enum class  RelationType { None , Data , ID , Complete }
 
using RuleIDType = std::string
 
using RelationUIDType = Identifiable::UIDType
 
using RelationUIDVectorType = std::vector< RelationUIDType >
 
using RelationVectorType = std::vector< RelationType >
 
using InstanceIDType = std::string
 
- Protected Types inherited from mitk::SourceImageRelationRule
using InstanceIDType = PropertyRelationRuleBase::InstanceIDType
 
using InstanceIDVectorType = PropertyRelationRuleBase::InstanceIDVectorType
 
using DataRelationUIDVectorType = PropertyRelationRuleBase::DataRelationUIDVectorType
 
- Protected Types inherited from mitk::PropertyRelationRuleBase
using InstanceIDVectorType = std::vector< InstanceIDType >
 
using DataRelationUIDVectorType = std::vector< std::pair< RelationUIDType, RuleIDType > >
 
- Static Protected Member Functions inherited from mitk::PropertyRelationRuleBase
static InstanceIDType NULL_INSTANCE_ID ()
 
static InstanceIDType GetInstanceIDByPropertyName (const std::string propName)
 
static std::vector< std::string > GetPropertyKeys (const IPropertyProvider *owner)
 

Detailed Description

Relation rule for referencing a segmentation to a source-image derivations.

This rule class can be used for relations that reference an image as source for a segmentation.

The ID-layer is supported like for GenericIDRelations, so it can be used for all ID-based relations between PropertyProviders that also implement the Identifiable interface.

In addition, the rule uses the data-layer to deduce/define relations. For this layer it uses properties compliant to DICOM. In addition to the DICOM data used by SourceImageRelationRule this class also adds the source SeriesInstanceUID (0020,000e) to the data captured by the base SourceImageRelationRule. The series UID is stored per-relation on the segmentation (scoped to the relation instance) rather than as a single top-level seg property so a single SEG can cleanly reference multiple source series, mirroring DICOM's ReferencedSeriesSequence (0008,1115) one item per series shape.

The canonical DICOM-SEG-source purpose tag is type-bound: callers acquire an instance via New() and the rule applies the tag itself. This prevents producers from drifting away from the canonical value and lets diagnostic code recover the value by querying the type.

Remarks
PropertyRelationRules and DICOM use the term "source" differently. The DICOM source (image) equals the PropertyRelationRule destination. This is due to an inverted relation direction. In the context of this rule interface, derived data is the source and points to the original image it derives from. In DICOM, this referenced original image would be called the source image (as the name of this class suggests).
See also
SourceImageRelationRule
DICOMSegmentationPropertyHelper

Definition at line 56 of file mitkSegSourceImageRelationRule.h.

Constructor & Destructor Documentation

◆ SegSourceImageRelationRule() [1/2]

mitk::SegSourceImageRelationRule::SegSourceImageRelationRule ( )
protected

◆ SegSourceImageRelationRule() [2/2]

mitk::SegSourceImageRelationRule::SegSourceImageRelationRule ( const SegSourceImageRelationRule &  other)
protected

Member Function Documentation

◆ CanonicalPurposeTag()

static const std::string& mitk::SegSourceImageRelationRule::CanonicalPurposeTag ( )
static

Returns the canonical DICOM Code Value used in the SEG's Source Image Sequence Purpose Of Reference Code.

Used at tag-comparison boundaries (DCMQI, tests, diagnostics) so the canonical value lives in exactly one place rather than as duplicated string literals scattered through callers.

◆ Connect() [1/3]

static RelationUIDType mitk::SegSourceImageRelationRule::Connect ( MultiLabelSegmentation *  seg,
const Image *  source_image 
)
static

Static convenience that constructs an instance of this rule and connects seg to source_image.

Use this from call sites that just want to establish a single relation; the instance method is for callers that already hold a rule and want to make multiple connections through it.

Captures only the relation: per-source SOP Instance / SOP Class / Series Instance UIDs. The seg's own identifying tags (PatientName, StudyInstanceUID, FrameOfReferenceUID, ...) are not touched here. Use DICOMSegmentationPropertyHelper's functions for that.

Precondition
seg and source_image must be valid pointers.

◆ Connect() [2/3]

RelationUIDType mitk::SegSourceImageRelationRule::Connect ( MultiLabelSegmentation *  seg,
const IPropertyProvider *  sourceProvider 
) const

Connects a segmentation to a source represented as an IPropertyProvider.

The base SourceImageRelationRule offers a typed Connect(Image*, Image*) wrapper. The reader path needs to connect against an ad-hoc provider (a PropertyList carrying SOPInstanceUID / SOPClassUID / SeriesInstanceUID synthesized from the SEG file's metadata) that is not an Image, hence this overload. Sources without DICOM identifying tags still establish an ID-layer relation; the data layer is captured only when the provider carries SOP Instance / Class / Series UIDs.

Precondition
seg must be a valid pointer.
sourceProvider must be a valid pointer.

◆ Connect() [3/3]

RelationUIDType mitk::SegSourceImageRelationRule::Connect ( MultiLabelSegmentation *  seg,
TemporoSpatialStringProperty *  instanceUIDsPerSlice,
TemporoSpatialStringProperty *  classUIDsPerSlice,
const std::string &  sourceSeriesInstanceUID 
) const

Connects seg to a source described by its per-slice DICOM UID properties, assembling the intermediate provider PropertyList.

Convenience over Connect(seg, IPropertyProvider*) for the common case where a caller already holds the per-slice SOPInstance (0008,0018) and SOPClass (0008,0016) UID maps (and optionally the source SeriesInstanceUID) and would otherwise have to assemble the DICOM-tag-keyed PropertyList by hand. The series UID is captured only when it is non-empty.

Precondition
seg must be a valid pointer.
instanceUIDsPerSlice and classUIDsPerSlice must be valid pointers.

◆ Connect_datalayer()

void mitk::SegSourceImageRelationRule::Connect_datalayer ( IPropertyOwner *  source,
const IPropertyProvider *  destination,
const InstanceIDType &  instanceID 
) const
overrideprotectedvirtual

Extends the base data-layer Connect by capturing the source SeriesInstanceUID per relation.

Storing the series UID on the relation (rather than as a top-level seg property) keeps Disconnect self-contained: removing a relation removes its series UID through normal virtual dispatch, without the caller having to know the extension exists.

Reimplemented from mitk::SourceImageRelationRule.

◆ Disconnect_datalayer()

void mitk::SegSourceImageRelationRule::Disconnect_datalayer ( IPropertyOwner *  source,
const RelationUIDType &  relationUID 
) const
overrideprotectedvirtual

Removes this rule's SourceSeriesInstanceUID extension before delegating to the base.

The base resolves the instance ID by relation UID, which only works before its own per-relation properties are gone. The extension must therefore be cleaned up first.

Reimplemented from mitk::SourceImageRelationRule.

◆ GetSourceImageRelations()

static std::vector<SourceImageRelation> mitk::SegSourceImageRelationRule::GetSourceImageRelations ( const MultiLabelSegmentation *  seg)
static

Enumerates the seg-source relations established on seg.

Hides the per-relation storage layout from the writer (which would otherwise have to know the rule's MITK.Relations.<instanceID>.* conventions to assemble the writer-side SourceImageRelation entries).

Precondition
seg must be a valid pointer.

◆ mitkClassMacro()

mitk::SegSourceImageRelationRule::mitkClassMacro ( SegSourceImageRelationRule  ,
SourceImageRelationRule   
)

◆ mitkCloneMacro()

mitk::SegSourceImageRelationRule::mitkCloneMacro ( Self  )
protected

◆ New()

static Pointer mitk::SegSourceImageRelationRule::New ( )
static

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