Skip to content

Commit 1040c51

Browse files
mgxdeffigies
authored andcommitted
add: warn if frames were altered
1 parent 21af99d commit 1040c51

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,21 +511,23 @@ def image_shape(self):
511511
has_derived = False
512512
if hasattr(first_frame, 'get') and first_frame.get([0x18, 0x9117]):
513513
# DWI image may include derived isotropic, ADC or trace volume
514-
# check and remove
515514
try:
516515
self.frames = Sequence(
517516
frame for frame in self.frames if
518517
frame.MRDiffusionSequence[0].DiffusionDirectionality
519518
!= 'ISOTROPIC'
520519
)
521-
n_frames = len(self.frames)
522-
has_derived = True
520+
if n_frames != len(self.frames):
521+
warnings.warn("Derived images found and removed")
522+
n_frames = len(self.frames)
523+
has_derived = True
523524
except IndexError:
524525
# Sequence tag is found but missing items!
525526
raise WrapperError("Diffusion file missing information")
526527
except AttributeError:
527528
# DiffusionDirectionality tag is not required
528529
pass
530+
529531
assert len(self.frames) == n_frames
530532
frame_indices = np.array(
531533
[frame.FrameContentSequence[0].DimensionIndexValues

0 commit comments

Comments
 (0)