Skip to content

Commit caa6df9

Browse files
mgxdeffigies
authored andcommitted
fix: ensure derived index is removed
1 parent 8e2bd08 commit caa6df9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,15 @@ def image_shape(self):
547547
if stackid_tag in dim_seq:
548548
stackid_dim_idx = dim_seq.index(stackid_tag)
549549
frame_indices = np.delete(frame_indices, stackid_dim_idx, axis=1)
550+
dim_seq.pop(stackid_dim_idx)
550551
if has_derived:
551552
# derived volume is included
552-
frame_indices = np.delete(frame_indices, 1, axis=1)
553+
derived_tag = tag_for_keyword("DiffusionBValue")
554+
if derived_tag not in dim_seq:
555+
raise WrapperError("Missing information, cannot remove indices "
556+
"with confidence.")
557+
derived_dim_idx = dim_seq.index(derived_tag)
558+
frame_indices = np.delete(frame_indices, derived_dim_idx, axis=1)
553559
# account for the 2 additional dimensions (row and column) not included
554560
# in the indices
555561
n_dim = frame_indices.shape[1] + 2

0 commit comments

Comments
 (0)