Skip to content

Commit

Permalink
ENH: Update slicer.util.updateVolumeFromArray to support 1D NumPy array
Browse files Browse the repository at this point in the history
  • Loading branch information
lassoan authored and jcfr committed Aug 1, 2023
1 parent b8e8faf commit 780f35c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Base/Python/slicer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,16 @@ def updateVolumeFromArray(volumeNode, narray):
"""

vshape = tuple(reversed(narray.shape))
if len(vshape) == 2:
if len(vshape) == 1:
# Line of pixels
vcomponents = 1
# Put the slice into a single-slice 3D volume
import numpy as np
narray3d = np.zeros([1, 1, narray.shape[0]])
narray3d[0, 0, :] = narray
narray = narray3d
vshape = tuple(reversed(narray.shape))
elif len(vshape) == 2:
# Scalar 2D volume
vcomponents = 1
# Put the slice into a single-slice 3D volume
Expand Down

0 comments on commit 780f35c

Please sign in to comment.