@@ -80,19 +80,6 @@ class TestNifti1PairHeader(tana.TestAnalyzeHeader, tspm.HeaderScalingMixin):
8080 np .longcomplex ))
8181 tana .add_intp (supported_np_types )
8282
83- def setUp (self ):
84- # Add warning filters for duration of test case
85- self ._wctx = warnings .catch_warnings ()
86- self ._wctx .__enter__ ()
87- warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
88- warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
89- warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
90- UserWarning )
91-
92- def tearDown (self ):
93- # Restore warning filters
94- self ._wctx .__exit__ ()
95-
9683 def test_empty (self ):
9784 tana .TestAnalyzeHeader .test_empty (self )
9885 hdr = self .header_class ()
@@ -728,6 +715,30 @@ def test_recoded_fields(self):
728715 hdr ['slice_code' ] = 4 # alternating decreasing
729716 assert hdr .get_value_label ('slice_code' ) == 'alternating decreasing'
730717
718+ def test_general_init (self ):
719+ with clear_and_catch_warnings () as warns :
720+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
721+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
722+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
723+ UserWarning )
724+ super (TestNifti1PairHeader , self ).test_general_init ()
725+
726+ def test_from_header (self ):
727+ with clear_and_catch_warnings () as warns :
728+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
729+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
730+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
731+ UserWarning )
732+ super (TestNifti1PairHeader , self ).test_from_header ()
733+
734+ def test_data_shape_zooms_affine (self ):
735+ with clear_and_catch_warnings () as warns :
736+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
737+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
738+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
739+ UserWarning )
740+ super (TestNifti1PairHeader , self ).test_data_shape_zooms_affine ()
741+
731742
732743def unshear_44 (affine ):
733744 RZS = affine [:3 , :3 ]
@@ -775,19 +786,6 @@ class TestNifti1Pair(tana.TestAnalyzeImage, tspm.ImageScalingMixin):
775786 image_class = Nifti1Pair
776787 supported_np_types = TestNifti1PairHeader .supported_np_types
777788
778- def setUp (self ):
779- # Add warning filters for duration of test case
780- self ._wctx = warnings .catch_warnings ()
781- self ._wctx .__enter__ ()
782- warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
783- warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
784- warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
785- UserWarning )
786-
787- def tearDown (self ):
788- # Restore warning filters
789- self ._wctx .__exit__ ()
790-
791789 def test_none_qsform (self ):
792790 # Check that affine gets set to q/sform if header is None
793791 img_klass = self .image_class
@@ -1234,6 +1232,14 @@ def test_zooms_edge_cases(self):
12341232 assert_raises (ValueError , img .header .set_zooms , (3 , 3 , 3 , 3.5 ),
12351233 units = 'badparam' )
12361234
1235+ def test_no_finite_values (self ):
1236+ with clear_and_catch_warnings () as warns :
1237+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1238+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1239+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
1240+ UserWarning )
1241+ super (TestNifti1Pair , self ).test_no_finite_values ()
1242+
12371243
12381244class TestNifti1Image (TestNifti1Pair ):
12391245 # Run analyze-flavor spatialimage tests
0 commit comments