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

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:

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:

1 Like

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