The shape will be changed when I turn an array to volume

I use the script slicer.util.arrayFromVolume(volumeNode) get an array.

Then I use the script slicer.util.addVolumeFromArray(array), the volume’s shape is changed as is shown in the picture.

Why? How can I get the original volume from the array.

You can specify the ijkToRAS transform from the source volume, something like this:

ijkToRAS = vtk.vtkMatrix4x4()
segArray = numpy.stack(segmentationArrays)
segNode = slicer.util.addVolumeFromArray(segArray, ijkToRAS=ijkToRAS, name="Segmentation")
1 Like