Create new vector volume

Operating system: Windows 10
Slicer version: 4.10.1

I am trying to create a new vector volume (since I need a colour image) and am wondering how to go about coding this.

You can create a new volume node as shown in this example: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create_a_new_volume

For creating a vector volume: use vtkMRMLVectorVolumeNode instead of vtkMRMLScalarVolumeNode and in AllocateScalars use 3 components instead of just 1.

1 Like

Thank you Andras! For some reason when I assign a volume to my new empty vector volume, the image is being rotated 180 degrees. The array of voxels for the volume is correct and so I’m confused why it is appearing as rotated. Let me know if you have any idea of why this is the case!

Expected output:

Actual output:

Slicer uses RAS coordinate system. If your image array is in LPS coordinate system (this is the most common) then you need to set imageDirections = [[-1,0,0], [0,-1,0], [0,0,1]].

Do you load the data from file? Why don’t you load them using standard image loading functions?

1 Like

This works, thank you Andras!

Do you load the data from file? Why can’t you load them using standard image loading functions?

A post was split to a new topic: Combine 3 scalar volumes into a vector

Hi,

Unfortunately the link leads to a dead end and I’m insterested in a similar procedure.

My actual goal is to combine 3 scalar volumes Vx, Vy, and Vz into a vector volume to then compute a new scalar volume corresponding to the magnitude of the vector volume, does that make sense from the 3D slicer point of view?

Thanks in advance,

Pau

The script repository has moved to readthedocs. Here is the direct link to the code snippet: Script repository — 3D Slicer documentation

1 Like