Inconsistency in "Attributes"?

Hi everyone,

I had to implement a check, if a file to import has dicom-data associated.
Hence, I took a look at the example in the script repository.

However, I tried different approaches, which resulted in (for me) unexpected results.

Node:

ID: 2555
DataNode: vtkMRMLScalarVolumeNode
Name (from DataNode): TestName
Parent: 2557
Children: 
OwnerPluginName: Volumes
Expanded: true
UIDs:
  DICOM:2.16.840.1.114033.0.20170412.2476798.0.1
  DICOMInstanceUID:2.16.840.1.114033.0.20170412.2476798.0.1.1
Attributes:
  DICOM.Modality:PT
  DICOM.ReferencedInstanceUIDs:
  DICOM.SeriesNumber:1000

Function:

>> shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)

>>> attribute = shNode.GetItemAttribute(2555, 'DICOM.instanceUIDs')
>>> attribute
''

>>> attribute = shNode.GetItemDataNode(2555).GetAttribute('DICOM.instanceUIDs')
>>> attribute
'2.16.840.1.114033.0.20170412.2476798.0.1.1'

The same applies to attribute names:

>>> names = shNode.GetItemDataNode(2555).GetAttributeNames()
>>> names
('DICOM.instanceUIDs',)

>>> names = shNode.GetItemAttributeNames(2555)
>>> names
('DICOM.Modality', 'DICOM.ReferencedInstanceUIDs', 'DICOM.SeriesNumber')

Hence, the behaviour is as it follows:

  • shNode.GetItemAttribute(id, attribute): returns Attributes
  • node.GetAttribute(attribute): returns UIDs

For me as a user, this was kind of surprising. Is this intended behaviour, did I miss something?

Thanks in advance! :slight_smile:

Subject hierarchy is a hierarchy of data nodes containing items pointing to nodes. Data nodes are MRML nodes containing data. The two contain very different information. Some DICOM info is stored in both for convenience and tracking prevalence.

Learn about subject hierarchy
https://www.slicer.org/wiki/Documentation/Nightly/Modules/Data
https://www.slicer.org/wiki/Documentation/Labs/SubjectHierarchy

Learn about MRML nodes
http://apidocs.slicer.org/master/classvtkMRMLNode.html

1 Like

hi @cpinter,

Thank you for the answer! Okay, I didn’t get the differentiation between item and node… thanks for pointing that out. :slight_smile:

Cheers!

1 Like