@@ -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
@@ -590,6 +594,17 @@ def test_shape(self):
590
594
# Check for error when explicitly requested StackID is missing
591
595
with pytest .raises (didw .WrapperError ):
592
596
MFW (fake_mf , frame_filters = (didw .FilterMultiStack (3 ),))
597
+ # StackID can be a string
598
+ div_seq = ((1 ,), (2 ,), (3 ,), (4 ,))
599
+ sid_seq = ('a' , 'a' , 'a' , 'b' )
600
+ fake_mf .update (fake_shape_dependents (div_seq , sid_seq = sid_seq ))
601
+ with pytest .warns (
602
+ UserWarning ,
603
+ match = 'A multi-stack file was passed without an explicit filter,' ,
604
+ ):
605
+ assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
606
+ assert MFW (fake_mf , frame_filters = (didw .FilterMultiStack ('a' ),)).image_shape == (32 , 64 , 3 )
607
+ assert MFW (fake_mf , frame_filters = (didw .FilterMultiStack ('b' ),)).image_shape == (32 , 64 )
593
608
# Make some fake frame data for 4D when StackID index is 0
594
609
div_seq = ((1 , 1 , 1 ), (1 , 2 , 1 ), (1 , 1 , 2 ), (1 , 2 , 2 ), (1 , 1 , 3 ), (1 , 2 , 3 ))
595
610
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
@@ -599,7 +614,7 @@ def test_shape(self):
599
614
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 0 ))
600
615
with pytest .warns (
601
616
UserWarning ,
602
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
617
+ match = 'A multi-stack file was passed without an explicit filter,' ,
603
618
):
604
619
with pytest .raises (didw .WrapperError ):
605
620
MFW (fake_mf ).image_shape
@@ -638,7 +653,7 @@ def test_shape(self):
638
653
fake_mf .update (fake_shape_dependents (div_seq , sid_seq = sid_seq ))
639
654
with pytest .warns (
640
655
UserWarning ,
641
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
656
+ match = 'A multi-stack file was passed without an explicit filter,' ,
642
657
):
643
658
with pytest .raises (didw .WrapperError ):
644
659
MFW (fake_mf ).image_shape
@@ -651,7 +666,7 @@ def test_shape(self):
651
666
fake_mf .update (fake_shape_dependents (div_seq , sid_dim = 1 ))
652
667
with pytest .warns (
653
668
UserWarning ,
654
- match = 'A multi-stack file was passed without an explicit filter, just using lowest StackID ' ,
669
+ match = 'A multi-stack file was passed without an explicit filter,' ,
655
670
):
656
671
assert MFW (fake_mf ).image_shape == (32 , 64 , 3 )
657
672
# Make some fake frame data for 4D when StackID index is 1
0 commit comments