From df638fd98f24394c61449816e2348733a90e60e2 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 12 Jan 2025 10:58:35 -0500 Subject: [PATCH] ENH: Slightly simplify frame_indices array construction --- nibabel/nicom/dicomwrappers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nibabel/nicom/dicomwrappers.py b/nibabel/nicom/dicomwrappers.py index 622ab0927..8ef91532b 100755 --- a/nibabel/nicom/dicomwrappers.py +++ b/nibabel/nicom/dicomwrappers.py @@ -756,13 +756,13 @@ def image_shape(self): return (rows, cols) # Initialize array of frame indices try: - frame_indices = np.array( - [frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames] + frame_indices = np.stack( + np.atleast_1d( + *(frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames) + ) ) except AttributeError: raise WrapperError("Can't find frame 'DimensionIndexValues'") - if len(frame_indices.shape) == 1: - frame_indices = frame_indices.reshape(frame_indices.shape + (1,)) # Determine the shape and which indices to use shape = [rows, cols] curr_parts = n_frames