28
28
from .. import fieldmaps as fm
29
29
30
30
31
+ @pytest .fixture (autouse = True )
32
+ def clear_registry ():
33
+ fm .clear_registry ()
34
+ yield
35
+ fm .clear_registry ()
36
+
37
+
31
38
def test_FieldmapFile (dsA_dir ):
32
39
"""Test one existing file."""
33
40
f1 = fm .FieldmapFile (dsA_dir / "sub-01" / "anat" / "sub-01_T1w.nii.gz" )
@@ -45,13 +52,12 @@ def test_FieldmapFile(dsA_dir):
45
52
46
53
47
54
@pytest .mark .parametrize (
48
- "inputfiles,method,nsources,raises " ,
55
+ "inputfiles,method,nsources" ,
49
56
[
50
57
(
51
58
("fmap/sub-01_fieldmap.nii.gz" , "fmap/sub-01_magnitude.nii.gz" ),
52
59
fm .EstimatorType .MAPPED ,
53
60
2 ,
54
- False ,
55
61
),
56
62
(
57
63
(
@@ -62,51 +68,37 @@ def test_FieldmapFile(dsA_dir):
62
68
),
63
69
fm .EstimatorType .PHASEDIFF ,
64
70
4 ,
65
- False ,
66
71
),
67
72
(
68
73
("fmap/sub-01_phase1.nii.gz" , "fmap/sub-01_phase2.nii.gz" ),
69
74
fm .EstimatorType .PHASEDIFF ,
70
75
4 ,
71
- True ,
72
76
),
73
- (("fmap/sub-01_phase2.nii.gz" ,), fm .EstimatorType .PHASEDIFF , 4 , True ),
74
- (("fmap/sub-01_phase1.nii.gz" ,), fm .EstimatorType .PHASEDIFF , 4 , True ),
77
+ (("fmap/sub-01_phase2.nii.gz" ,), fm .EstimatorType .PHASEDIFF , 4 ),
78
+ (("fmap/sub-01_phase1.nii.gz" ,), fm .EstimatorType .PHASEDIFF , 4 ),
75
79
(
76
80
("fmap/sub-01_dir-LR_epi.nii.gz" , "fmap/sub-01_dir-RL_epi.nii.gz" ),
77
81
fm .EstimatorType .PEPOLAR ,
78
82
2 ,
79
- False ,
80
83
),
81
84
(
82
85
("fmap/sub-01_dir-LR_epi.nii.gz" , "dwi/sub-01_dir-RL_sbref.nii.gz" ),
83
86
fm .EstimatorType .PEPOLAR ,
84
87
2 ,
85
- False ,
86
88
),
87
89
(
88
90
("anat/sub-01_T1w.nii.gz" , "dwi/sub-01_dir-RL_sbref.nii.gz" ),
89
91
fm .EstimatorType .ANAT ,
90
92
2 ,
91
- False ,
92
93
),
93
94
],
94
95
)
95
- def test_FieldmapEstimation (dsA_dir , inputfiles , method , nsources , raises ):
96
+ def test_FieldmapEstimation (dsA_dir , inputfiles , method , nsources ):
96
97
"""Test errors."""
97
98
sub_dir = dsA_dir / "sub-01"
98
99
99
100
sources = [sub_dir / f for f in inputfiles ]
100
101
101
- if raises is True :
102
- # Ensure that _estimators is still holding values from previous
103
- # parameter set of this parametrized execution.
104
- with pytest .raises (ValueError ):
105
- fm .FieldmapEstimation (sources )
106
-
107
- # Clean up so this parameter set can be tested.
108
- fm .clear_registry ()
109
-
110
102
fe = fm .FieldmapEstimation (sources )
111
103
assert fe .method == method
112
104
assert len (fe .sources ) == nsources
0 commit comments