@@ -23,30 +23,38 @@ def test_update_complex_name():
23
23
# Standard name update
24
24
fn = 'sub-X_ses-Y_task-Z_run-01_sbref'
25
25
metadata = {'ImageType' : ['ORIGINAL' , 'PRIMARY' , 'P' , 'MB' , 'TE3' , 'ND' , 'MOSAIC' ]}
26
- suffix = 3
26
+ file_counter = 3 # This is the third file with the same name
27
27
out_fn_true = 'sub-X_ses-Y_task-Z_run-01_part-phase_sbref'
28
- out_fn_test = update_complex_name (metadata , fn , suffix )
28
+ out_fn_test = update_complex_name (metadata , fn , file_counter )
29
29
assert out_fn_test == out_fn_true
30
30
31
31
# Catch an unsupported type and *do not* update
32
32
fn = 'sub-X_ses-Y_task-Z_run-01_phase'
33
- out_fn_test = update_complex_name (metadata , fn , suffix )
33
+ out_fn_test = update_complex_name (metadata , fn , file_counter )
34
34
assert out_fn_test == fn
35
35
36
36
# Data type is missing from metadata so use suffix
37
37
fn = 'sub-X_ses-Y_task-Z_run-01_sbref'
38
38
metadata = {'ImageType' : ['ORIGINAL' , 'PRIMARY' , 'MB' , 'TE3' , 'ND' , 'MOSAIC' ]}
39
39
out_fn_true = 'sub-X_ses-Y_task-Z_run-01_part-3_sbref'
40
- out_fn_test = update_complex_name (metadata , fn , suffix )
40
+ out_fn_test = update_complex_name (metadata , fn , file_counter )
41
41
assert out_fn_test == out_fn_true
42
42
43
- # Catch existing field with value that *does not match* metadata
44
- # and raise Exception
43
+ # Catch existing field with value (part is already in the filename)
44
+ # that *does not match* metadata and raise Exception
45
45
fn = 'sub-X_ses-Y_task-Z_run-01_part-mag_sbref'
46
46
metadata = {'ImageType' : ['ORIGINAL' , 'PRIMARY' , 'P' , 'MB' , 'TE3' , 'ND' , 'MOSAIC' ]}
47
- suffix = 3
47
+ file_counter = 3
48
48
with pytest .raises (BIDSError ):
49
- assert update_complex_name (metadata , fn , suffix )
49
+ update_complex_name (metadata , fn , file_counter )
50
+
51
+ # Catch existing field with value (part is already in the filename)
52
+ # that *does match* metadata and do not update
53
+ fn = 'sub-X_ses-Y_task-Z_run-01_part-phase_sbref'
54
+ metadata = {'ImageType' : ['ORIGINAL' , 'PRIMARY' , 'P' , 'MB' , 'TE3' , 'ND' , 'MOSAIC' ]}
55
+ file_counter = 3
56
+ out_fn_test = update_complex_name (metadata , fn , file_counter )
57
+ assert out_fn_test == fn
50
58
51
59
52
60
def test_update_multiecho_name ():
0 commit comments