Skip to content

Commit df638fd

Browse files
committed
ENH: Slightly simplify frame_indices array construction
1 parent f81f5a7 commit df638fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,13 @@ def image_shape(self):
756756
return (rows, cols)
757757
# Initialize array of frame indices
758758
try:
759-
frame_indices = np.array(
760-
[frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames]
759+
frame_indices = np.stack(
760+
np.atleast_1d(
761+
*(frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames)
762+
)
761763
)
762764
except AttributeError:
763765
raise WrapperError("Can't find frame 'DimensionIndexValues'")
764-
if len(frame_indices.shape) == 1:
765-
frame_indices = frame_indices.reshape(frame_indices.shape + (1,))
766766
# Determine the shape and which indices to use
767767
shape = [rows, cols]
768768
curr_parts = n_frames

0 commit comments

Comments
 (0)