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

**URL:** https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229
**Category:** Development
**Tags:** dicom, multivolume
**Created:** [October 24, 2020, 10:27pm UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229 "2020-10-24T22:27:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cold-pac](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cold-pac/32/8593_2.png) [@cold-pac](https://discourse.slicer.org/u/cold-pac)
#### Post date: [October 24, 2020, 10:27pm UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229/1 "2020-10-24T22:27:51Z")

</div>

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(‘vtkMRML_VolumeNode_’) or slicer.util.getNodes(‘vtkMRML_MultiVolumeNode_’)

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

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [October 25, 2020, 12:12am UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229/2 "2020-10-25T00:12:44Z")

</div>

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](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).

---

<div class="post-metadata">

### Author: ![cold-pac](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cold-pac/32/8593_2.png) [@cold-pac](https://discourse.slicer.org/u/cold-pac)
#### Post date: [October 25, 2020, 3:02am UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229/3 "2020-10-25T03:02:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [October 25, 2020, 3:25am UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229/4 "2020-10-25T03:25:52Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![cold-pac](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cold-pac/32/8593_2.png) [@cold-pac](https://discourse.slicer.org/u/cold-pac)
#### Post date: [October 25, 2020, 8:04am UTC](https://discourse.slicer.org/t/need-help-accessing-the-voxel-array-from-different-frames-in-an-imported-multivolume-python/14229/5 "2020-10-25T08:04:31Z")

</div>

thank you very much!
