@@ -427,13 +427,6 @@ def fake_shape_dependents(
427
427
generate ipp values so slice location is negatively correlated with slice index
428
428
"""
429
429
430
- class PrintBase :
431
- def __repr__ (self ):
432
- attr_strs = [
433
- f'{ attr } ={ getattr (self , attr )} ' for attr in dir (self ) if attr [0 ].isupper ()
434
- ]
435
- return f"{ self .__class__ .__name__ } ({ ', ' .join (attr_strs )} )"
436
-
437
430
class DimIdxSeqElem (pydicom .Dataset ):
438
431
def __init__ (self , dip = (0 , 0 ), fgp = None ):
439
432
super ().__init__ ()
@@ -444,8 +437,8 @@ def __init__(self, dip=(0, 0), fgp=None):
444
437
class FrmContSeqElem (pydicom .Dataset ):
445
438
def __init__ (self , div , sid ):
446
439
super ().__init__ ()
447
- self .DimensionIndexValues = div
448
- self .StackID = sid
440
+ self .DimensionIndexValues = list ( div )
441
+ self .StackID = str ( sid )
449
442
450
443
class PlnPosSeqElem (pydicom .Dataset ):
451
444
def __init__ (self , ipp ):
@@ -545,17 +538,28 @@ def test_shape(self):
545
538
with pytest .raises (didw .WrapperError ):
546
539
dw .image_shape
547
540
fake_mf .Rows = 32
548
- # No frame data raises WrapperError
541
+ # Single frame doesn't need dimension index values
542
+ assert dw .image_shape == (32 , 64 )
543
+ assert len (dw .frame_order ) == 1
544
+ assert dw .frame_order [0 ] == 0
545
+ # Multiple frames do require dimension index values
546
+ fake_mf .PerFrameFunctionalGroupsSequence = [pydicom .Dataset (), pydicom .Dataset ()]
549
547
with pytest .raises (didw .WrapperError ):
550
- dw .image_shape
548
+ MFW ( fake_mf ) .image_shape
551
549
# check 2D shape with StackID index is 0
552
550
div_seq = ((1 , 1 ),)
553
551
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
554
- assert MFW (fake_mf ).image_shape == (32 , 64 )
552
+ dw = MFW (fake_mf )
553
+ assert dw .image_shape == (32 , 64 )
554
+ assert len (dw .frame_order ) == 1
555
+ assert dw .frame_order [0 ] == 0
555
556
# Check 2D shape with extraneous extra indices
556
557
div_seq = ((1 , 1 , 2 ),)
557
558
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
558
- assert MFW (fake_mf ).image_shape == (32 , 64 )
559
+ dw = MFW (fake_mf )
560
+ assert dw .image_shape == (32 , 64 )
561
+ assert len (dw .frame_order ) == 1
562
+ assert dw .frame_order [0 ] == 0
559
563
# Check 2D plus time
560
564
div_seq = ((1 , 1 , 1 ), (1 , 1 , 2 ), (1 , 1 , 3 ))
561
565
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
@@ -569,7 +573,7 @@ def test_shape(self):
569
573
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
570
574
with pytest .warns (
571
575
UserWarning ,
572
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
576
+ match = 'A multi-stack file was passed without an explicit filter,' ,
573
577
):
574
578
assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
575
579
# No warning if we expclitly select that StackID to keep
@@ -581,7 +585,7 @@ def test_shape(self):
581
585
fake_mf .update (fake_shape_dependents (div_seq , sid_seq = sid_seq ))
582
586
with pytest .warns (
583
587
UserWarning ,
584
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
588
+ match = 'A multi-stack file was passed without an explicit filter,' ,
585
589
):
586
590
assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
587
591
# No warning if we expclitly select that StackID to keep
@@ -599,7 +603,7 @@ def test_shape(self):
599
603
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
600
604
with pytest .warns (
601
605
UserWarning ,
602
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
606
+ match = 'A multi-stack file was passed without an explicit filter,' ,
603
607
):
604
608
with pytest .raises (didw .WrapperError ):
605
609
MFW (fake_mf ).image_shape
@@ -638,7 +642,7 @@ def test_shape(self):
638
642
fake_mf .update (fake_shape_dependents (div_seq , sid_seq = sid_seq ))
639
643
with pytest .warns (
640
644
UserWarning ,
641
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
645
+ match = 'A multi-stack file was passed without an explicit filter,' ,
642
646
):
643
647
with pytest .raises (didw .WrapperError ):
644
648
MFW (fake_mf ).image_shape
@@ -651,7 +655,7 @@ def test_shape(self):
651
655
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 1 ))
652
656
with pytest .warns (
653
657
UserWarning ,
654
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
658
+ match = 'A multi-stack file was passed without an explicit filter,' ,
655
659
):
656
660
assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
657
661
# Make some fake frame data for 4D when StackID index is 1
0 commit comments