Need help accessing the voxel array from different frames in an imported multivolume (Python)

Hi everyone,

I have CT Perfusion data that I can import as a ‘multivolume’ (frames separated by acquisition time).
I can get the MRML node with slicer.util.getNodes(‘vtkMRMLVolumeNode’) or slicer.util.getNodes(‘vtkMRMLMultiVolumeNode’)

this gives me an instance of this class: ‘vtkSlicerMultiVolumeExplorerModuleMRMLPython.vtkMRMLMultiVolumeNode’

Then I can get an array of voxels with slicer.util.arrayFromVolume(node) - but the array is only from 1 frame of the multivolume (i.e. the CT scan at time 0 and not any other time).

If I print out the “vtkMRMLMultiVolumeNode”, I can see that it has all of the dicom files from the whole study as “Attributes”, “MultiVolume.FrameLabels” for each frame, a “LabelArray” - again with each frame time, and “Number of Components” as the number of frames (14)

How do you jump between frames (and get voxel arrays from different ‘acquisition times’)? Do you have to import and use the MultiVolumeExplorer module? - I couldn’t find any documentation on how to use this in Python

Thanks very much

MultiVolume modules can only replay two 4D volume nodes. It is superseded by the more generic Sequences module, which allows replaying, recording, and editing sequences of any nodes - volumes, transforms, segmentations, markups, models, etc. Therefore, I would recommend to use Sequences instead of MultiVolume modules.

If you have a 4D nrrd file then you can load it as a volume sequence (choose “Sequence” in Description column in Add data dialog) and access voxels as a numpy array as shown in these examples in the script repository: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Sequences

If you save your 4D nrrd file using .seq.nrrd file extension then Slicer will automatically load it as volume sequence (no need to manually select “Sequence” in “Add data” window).

thank you this really helps!
is there any way to get the separating value for each frame/node of the Volume Sequence (e.g. Acquisition Time for each frame) using Python? I can see it in the metadata in the DICOM viewer, also I know you can get the .ImageData().GetMTime() of the node but it’s not the same.

You can get the index name, value, and unit from the sequence node:

print("Index value of {0}th item: {1} = {2} {3}".format(
  itemIndex,
  sequenceNode.GetIndexName(),
  sequenceNode.GetNthIndexValue(itemIndex),
  sequenceNode.GetIndexUnit()))

thank you very much!