How do access the source filepath(s) of a DICOM image given a `vtkMRMLScalarVolumeNode`

Hello!
I’m making my first Slicer plugin, and my goal is to use the pydicom package to read a DICOM file, i.e. pydicom.read_file(< Path to the .dcm file, whether it was copied or linked during import >)

I am having trouble getting the filepath.

I was following the tutorial in this youtube video: https://www.youtube.com/watch?v=njoTEisxAJ4

I’m using slicer.util.getNode(<name>) to get a vtkMRMLScalarVolumeNode, but to my surprise, when I call _.GetStorageNode(), my storage node is None. It seems the storage node object has a _.GetFileName() property, but I can’t reach it.

I tried to look around for information on why my StorageNode might be None, what I can do to make it initialize properly, or if there’s another way to get the DICOM file path.

Any advice? Thank you!

If the volume was loaded from dicom then the file path can be accessed with this code:

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#access-tag-of-a-volume-loaded-from-dicom-for-example-get-the-patient-position-stored-in-a-volume

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-path-and-filename-of-a-loaded-dicom-volume

1 Like

Worked like a charm!! Thanks. I hadn’t seen the script repository somehow.