Data file information

I load a bunch of data files into Slicer 3D, including DICOM, STL and others, how can I get the file path and file name information? I cannot see the file information from data structure. I ask this because I have files with the same name from different folders. I’m confused and don’t remember if I loaded the file from the right folder. I want to double-check that.

If you bring up the save dialog the default save will be the directory you loaded from.

Thanks for the tip. Yes, that will tell most of the file path, but I cannot see the DICOM file path. I’m wondering if there is other ways to view the file information easily.

You can get that using a little script, something like this: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#access-tag-of-a-scalar-volume-loaded-from-dicom

> def pathFromNode(node):
>     storageNode = node.GetStorageNode()
>     if storageNode is not None: # loaded via drag-drop
>          filepath = storageNode.GetFullNameFromFileName()
>     else: # Loaded via DICOM browser
>          instanceUIDs = node.GetAttribute(“DICOM.instanceUIDs”).split()
>          filepath = slicer.dicomDatabase.fileForInstance(instUids\[0\])
>      return filepath
> node = slicer.util.getNode(“2025data”)
> path = self.pathFromNode(node)
> print(“DICOM path=%s” % path)

NameError: name ‘self’ is not defined

Did I miss something?

You only use self when you are in a class method. Here you can just call pathFromNode. Otherwise it looks reasonable.

This may be a resonable piece of information to include in the subject hierarchy tooltip. I could add it in the base class (if a node has a storage node with a valid URL, add it to the tooltip). @pieper what do you think?

1 Like

I think that’s a great idea :+1:

1 Like

I created a PR for this: