Path of data added to slicer

Dear developer,
I only find the command about the path of files of DICOM, how can I find the path of data added to slicer, by the way, I also want to know the command of loaded the generated anatomical tracts into the Slicer.
Here is my code,

# Input file selector
#
with It(qt.QLineEdit()) as w:
    self.inputFileSelector = w
    w.setReadOnly(True)
    w.setToolTip("Select input file")

def selectInputFile():
  inputFile = qt.QFileDialog.getOpenFileName(self.parent, "Select input file")
  if inputFile:
    self.inputFileSelector.setText(inputFile)

def executeTractography():
  storageNode = node.GetStorageNode()
  if storageNode is not None: # loaded via drag-drop
    self.inputFileSelector = storageNode.GetFullNameFromFileName()
  
with It(qt.QPushButton("Browse")) as button:
    button.clicked.connect(selectInputFile)

with It(qt.QPushButton("Execute")) as executeButton:
    executeButton.clicked.connect(executeTractography)

layout = qt.QHBoxLayout()
layout.addWidget(self.inputFileSelector)
layout.addWidget(button)
layout.addWidget(executeButton)

parametersFormLayout.addRow("Input File:", layout)

Best wishes,
Joshua

slicer.mrmlScene.GetRootDirectory() # all nodes are saved relative to this path
slicer.app.temporaryPath # write-able folder, you can use this to store any temporary data
slicer.app.slicerHome # Slicer core binary folder
slicer.app.extensionsInstallPath # Slicer extensions folder
slicer.modules.sampledata.path # path of a scripted module (in this example: Sample Data module)
1 Like

If the data was loaded from disk or saved to disk it will typically have a storage node. From there you can get the path.

>>> slicer.util.getNode("MRHead").GetStorageNode().GetFileName()
'/private/tmp/MRHead.nrrd'
1 Like