Exporting Dicom programatically

Hello everyone,

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

The method you are looking for is GetItemByDataNode.

Subject hierarchy usage examples:

In general, use the API documentation and examples in script repository and in Slicer core self-tests and Python scripted modules.