# Create new vector volume

**URL:** https://discourse.slicer.org/t/create-new-vector-volume/9297
**Category:** Support
**Created:** [November 25, 2019, 5:54pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297 "2019-11-25T17:54:05Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![sthirumal](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sthirumal](https://discourse.slicer.org/u/sthirumal)
#### Post date: [November 25, 2019, 5:54pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/1 "2019-11-25T17:54:05Z")

</div>

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.

---

<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: [November 25, 2019, 7:48pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/2 "2019-11-25T19:48:53Z")

</div>

You can create a new volume node as shown in this example: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create\_a\_new\_volume](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.

---

<div class="post-metadata">

### Author: ![sthirumal](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sthirumal](https://discourse.slicer.org/u/sthirumal)
#### Post date: [November 27, 2019, 4:53pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/3 "2019-11-27T16:53:46Z")

</div>

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:

 ![rotated%20-%20expected](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/5/2521c776be2d1f150fc1b2d747b24d4f269d7f2a.png)

Actual output:

 ![rotated%20-%20actual](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/b/bb10d3c7f0c3ae084a456cf2adfa65d648b681f9.png)

---

<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: [November 27, 2019, 4:56pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/4 "2019-11-27T16:56:25Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![sthirumal](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sthirumal](https://discourse.slicer.org/u/sthirumal)
#### Post date: [November 27, 2019, 7:25pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/5 "2019-11-27T19:25:56Z")

</div>

This works, thank you Andras!

---

<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: [November 27, 2019, 8:12pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/6 "2019-11-27T20:12:10Z")

</div>

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

---

<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 15, 2021, 2:48pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/7 "2021-10-15T14:48:34Z")

</div>

A post was split to a new topic: [Combine 3 scalar volumes into a vector](https://discourse.slicer.org/t/combine-3-scalar-volumes-into-a-vector/20172)

---

<div class="post-metadata">

### Author: ![PauRo](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@PauRo](https://discourse.slicer.org/u/PauRo)
#### Post date: [September 2, 2025, 2:32pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/8 "2025-09-02T14:32:47Z")

</div>

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

---

<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: [September 2, 2025, 3:46pm UTC](https://discourse.slicer.org/t/create-new-vector-volume/9297/9 "2025-09-02T15:46:13Z")

</div>

The script repository has moved to readthedocs. Here is the direct link to the code snippet: [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#combine-multiple-volumes-into-one)
