Loading 4D volume as Sequence using python script

Operating system: Windows 10
Slicer version: Slicer 4.11.0
Expected behavior: Load 4D volume nrrd file as sequence using script
Actual behavior: volume is loaded as vtkMRMLMultiVolumeNode

Hi All
I can’t find the right methods to load the 4D volume nrrd file as a Sequence with the vtkMRMLScalarVolumeNode being created in the Subject Hierarchy.

I have the Sequences Extension installed and have saved a multivolume file as a nrrd file. I can load this manually using the Add Data dialog with the “Volume Sequence” option in the description dropdown.

How do I do this using scripting?

Is there a slicer.util.loadSequence function?

Unfortunately there isn’t.

You can use slicer.util.loadNodeFromFile. For example:

sequenceNode = slicer.util.loadNodeFromFile("c:/tmp/something.seq.nrrd", "SequenceFile")

I’ve added a slicer.uitil.loadSequence convenience function to make this easier to figure out.

Typing this into the Python Interactor (as well as my code) gives me a runtime error:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\Carol\AppData\Local\NA-MIC\Slicer 4.11.0-2019-07-15\bin\Python\slicer\util.py”, line 398, in loadNodeFromFile
raise RuntimeError(errorMessage)
RuntimeError: Failed to load node from file: D:\BainesWork…\ImageVolumes\DCE\ShortName.seq.nrrd

Make sure you specify path correctly (using forward-slash, double-backslash, or raw string):

If you still have issues, upgrade to latest Slicer Preview Release.

This does work with the latest nightly version of Slicer.

Thank you.

1 Like