@@ -473,7 +473,6 @@ def __init__(self, div, sid, ipp, iop):
473
473
frame_slc_indices = np .array (div_seq )[:, slice_dim ]
474
474
uniq_slc_indices = np .unique (frame_slc_indices )
475
475
n_slices = len (uniq_slc_indices )
476
- assert num_of_frames % n_slices == 0
477
476
iop_seq = [(0.0 , 1.0 , 0.0 , 1.0 , 0.0 , 0.0 ) for _ in range (num_of_frames )]
478
477
if ipp_seq is None :
479
478
slc_locs = np .linspace (- 1.0 , 1.0 , n_slices )
@@ -579,6 +578,17 @@ def test_shape(self):
579
578
div_seq = ((1 , 1 , 0 ), (1 , 2 , 0 ), (1 , 1 , 3 ), (1 , 2 , 3 ))
580
579
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
581
580
assert MFW (fake_mf ).image_shape == (32 , 64 , 2 , 2 )
581
+ # Check number of IPP vals match the number of slices or we raise
582
+ frames = fake_mf ['PerFrameFunctionalGroupsSequence' ]
583
+ for frame in frames [1 :]:
584
+ frame .PlanePositionSequence = frames [0 ].PlanePositionSequence [:]
585
+ with pytest .raises (didw .WrapperError ):
586
+ MFW (fake_mf ).image_shape
587
+ # Check we raise on missing slices
588
+ div_seq = ((1 , 1 , 0 ), (1 , 2 , 0 ), (1 , 1 , 1 ))
589
+ fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
590
+ with pytest .raises (didw .WrapperError ):
591
+ MFW (fake_mf ).image_shape
582
592
# check 3D shape when there is no StackID index
583
593
div_seq = ((1 ,), (2 ,), (3 ,), (4 ,))
584
594
sid_seq = (1 , 1 , 1 , 1 )
@@ -614,6 +624,11 @@ def test_shape(self):
614
624
div_seq = ((1 , 1 , 1 ), (2 , 1 , 1 ), (1 , 1 , 2 ), (2 , 1 , 2 ), (1 , 1 , 3 ), (2 , 1 , 3 ))
615
625
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 1 ))
616
626
assert MFW (fake_mf ).image_shape == (32 , 64 , 2 , 3 )
627
+ # Check non-singular dimension preceding slice dim raises
628
+ div_seq = ((1 , 1 , 1 ), (1 , 2 , 1 ), (1 , 1 , 2 ), (1 , 2 , 2 ), (1 , 1 , 3 ), (1 , 2 , 3 ))
629
+ fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 , slice_dim = 2 ))
630
+ with pytest .raises (didw .WrapperError ):
631
+ MFW (fake_mf ).image_shape
617
632
# Test with combo indices, here with the last two needing to be combined into
618
633
# a single index corresponding to [(1, 1), (1, 1), (2, 1), (2, 1), (2, 2), (2, 2)]
619
634
div_seq = (
@@ -655,6 +670,22 @@ def test_shape(self):
655
670
)
656
671
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
657
672
assert MFW (fake_mf ).image_shape == (32 , 64 , 2 , 3 , 2 )
673
+ # Check we only allow one extra spatial dimension with unique val per frame
674
+ div_seq = (
675
+ (1 , 1 , 1 , 6 ),
676
+ (1 , 2 , 2 , 5 ),
677
+ (1 , 1 , 3 , 4 ),
678
+ (1 , 2 , 4 , 3 ),
679
+ (1 , 1 , 5 , 2 ),
680
+ (1 , 2 , 6 , 1 ),
681
+ )
682
+ fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
683
+ with pytest .raises (didw .WrapperError ):
684
+ MFW (fake_mf ).image_shape
685
+ # Check that having unique value per frame works with single volume
686
+ div_seq = ((1 , 1 , 1 ), (1 , 2 , 2 ), (1 , 3 , 3 ))
687
+ fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
688
+ assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
658
689
659
690
def test_iop (self ):
660
691
# Test Image orient patient for multiframe
0 commit comments