17
17
THIS_DIR = Path (__file__ ).parent .resolve ()
18
18
19
19
20
- @settings (suppress_health_check = [HealthCheck .too_slow ], max_examples = 50 , deadline = None )
20
+ @settings (suppress_health_check = [HealthCheck .too_slow ], max_examples = 50 ,
21
+ deadline = None )
21
22
@given (st .integers (min_value = 1 , max_value = 10 ),
22
23
st .floats (allow_nan = False ,
23
24
allow_infinity = False ),
@@ -32,23 +33,16 @@ def test_parse_compliant_dataset(num_subjects,
32
33
repetition_time ,
33
34
echo_train_length ,
34
35
flip_angle )
35
- mrd = import_dataset (fake_ds_dir , config_path = THIS_DIR / 'resources/mri-config.json' ,
36
+ mrd = import_dataset (fake_ds_dir ,
37
+ config_path = THIS_DIR / 'resources/mri-config.json' ,
36
38
output_dir = fake_ds_dir , name = 'test_dataset' )
37
- seq_ids = mrd .get_sequence_ids ()
38
-
39
- for seq_id in seq_ids :
40
- mrd_num_subjects = set ()
41
- for subject , session , run , seq in mrd .traverse_horizontal (seq_id ):
42
- mrd_num_subjects .add (subject )
43
- assert seq ['RepetitionTime' ].get_value () == repetition_time
44
- assert seq ['EchoTrainLength' ].get_value () == echo_train_length
45
- assert seq ['FlipAngle' ].get_value () == flip_angle
46
- assert set (mrd .get_subject_ids (seq_id )) == mrd_num_subjects
39
+ set_parameters (mrd , repetition_time , echo_train_length , flip_angle )
47
40
shutil .rmtree (fake_ds_dir )
48
41
return
49
42
50
43
51
- @settings (suppress_health_check = [HealthCheck .too_slow ], max_examples = 50 , deadline = None )
44
+ @settings (suppress_health_check = [HealthCheck .too_slow ], max_examples = 50 ,
45
+ deadline = None )
52
46
@given (st .integers (min_value = 4 , max_value = 10 ),
53
47
st .floats (allow_nan = False ,
54
48
allow_infinity = False ),
@@ -63,8 +57,14 @@ def test_parse_dataset_no_echo_numbers(num_subjects,
63
57
repetition_time ,
64
58
echo_train_length ,
65
59
flip_angle )
66
- mrd = import_dataset (fake_ds_dir , config_path = THIS_DIR / 'resources/mri-config-2.json' ,
60
+ mrd = import_dataset (fake_ds_dir ,
61
+ config_path = THIS_DIR / 'resources/mri-config-2.json' ,
67
62
output_dir = fake_ds_dir , name = 'test_dataset' )
63
+ set_parameters (mrd , repetition_time , echo_train_length , flip_angle )
64
+ return
65
+
66
+
67
+ def set_parameters (mrd , repetition_time , echo_train_length , flip_angle ):
68
68
seq_ids = mrd .get_sequence_ids ()
69
69
70
70
for seq_id in seq_ids :
@@ -75,8 +75,6 @@ def test_parse_dataset_no_echo_numbers(num_subjects,
75
75
assert seq ['EchoTrainLength' ].get_value () == echo_train_length
76
76
assert seq ['FlipAngle' ].get_value () == flip_angle
77
77
assert set (mrd .get_subject_ids (seq_id )) == mrd_num_subjects
78
- shutil .rmtree (fake_ds_dir )
79
- return
80
78
81
79
82
80
def test_config_dict ():
@@ -94,18 +92,19 @@ def test_empty_folders():
94
92
filepath = subfolder / "test.dcm"
95
93
filepath .touch ()
96
94
97
- mrd = import_dataset (folder_path , config_path = THIS_DIR / 'resources/mri-config.json' ,
95
+ mrd = import_dataset (folder_path ,
96
+ config_path = THIS_DIR / 'resources/mri-config.json' ,
98
97
output_dir = folder_path , name = 'test_dataset' )
99
98
assert len (mrd .get_sequence_ids ()) == 0
100
99
101
100
102
101
def test_invalid_output_dir ():
103
102
fake_ds_dir = make_compliant_test_dataset (1 , 1 , 1 , 1 )
104
103
with pytest .raises (TypeError ):
105
- mrd = import_dataset (fake_ds_dir ,
106
- config_path = THIS_DIR / 'resources/bids-config.json' ,
107
- output_dir = 1 , name = 'test_dataset' ,
108
- ds_format = 'dicom' )
104
+ import_dataset (fake_ds_dir ,
105
+ config_path = THIS_DIR / 'resources/bids-config.json' ,
106
+ output_dir = 1 , name = 'test_dataset' ,
107
+ ds_format = 'dicom' )
109
108
110
109
# def get_csa_props_test():
111
110
# "CSA header looks funny in Pitt 7T (20221130)"
0 commit comments