This is a question I asked a while ago and it was resolved. However, that was with a much older version and my script no longer works with the newer versions of slicer that have a different subjecthierarchy organization.
I decided to try and remake it for newer versions. However I am having issues understanding how it works, especially since I am not a strong programmer and very unfamiliar with how the SubjectHierarchy works on the backend.
I started off looking here:
specifically the line:
volumeNode = shNode.GetItemDataNode(exportable.subjectHierarchyItemID)
So the volumeNode it gets is the same as if I were to do
volumeNode = getNode(‘Some_name’)
what I don’t understand is how to get the item ID’s quickly. The first step is
shn = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
and when I look at that I see that there are ID’s. But I don’t see/ know how to get the ID for a volume node. From what I can tell, it seems that all the methods associated with shn need you to know the itemID ahead of time. I am assuming there is some other method to get the ID for a volumeNode but I don’t know where to look.
I am sure it’s right in front of me but spent some time and couldn’t see where. I appreciate any help