Skip to content

Commit 1867898

Browse files
committed
Remove default arguments for populate-intended-for functions
(`get_key_info_for_fmap_assignment`, `find_compatible_fmaps_for_run`, `find_compatible_fmaps_for_session` and `populate_intended_for`) Modify unit tests accordingly.
1 parent 0ecd867 commit 1867898

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

heudiconv/bids.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def find_fmap_groups(fmap_dir):
581581
return fmap_groups
582582

583583

584-
def get_key_info_for_fmap_assignment(json_file, matching_parameter='ImagingVolume'):
584+
def get_key_info_for_fmap_assignment(json_file, matching_parameter):
585585
"""
586586
Gets key information needed to assign fmaps to other modalities.
587587
@@ -639,7 +639,7 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter='ImagingVolum
639639
return key_info
640640

641641

642-
def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters=['ImagingVolume']):
642+
def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters):
643643
"""
644644
Finds compatible fmaps for a given run, for populate_intended_for.
645645
@@ -694,7 +694,7 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters=['
694694
return compatible_fmap_groups
695695

696696

697-
def find_compatible_fmaps_for_session(path_to_bids_session, matching_parameters=['ImagingVolume']):
697+
def find_compatible_fmaps_for_session(path_to_bids_session, matching_parameters):
698698
"""
699699
Finds compatible fmaps for all non-fmap runs in a session.
700700
@@ -835,7 +835,7 @@ def select_fmap_from_compatible_groups(json_file, compatible_fmap_groups, criter
835835
return selected_fmap_key
836836

837837

838-
def populate_intended_for(path_to_bids_session, matching_parameters='ImagingVolume', criterion='Closest'):
838+
def populate_intended_for(path_to_bids_session, matching_parameters, criterion):
839839
"""
840840
Adds the 'IntendedFor' field to the fmap .json files in a session folder.
841841
It goes through the session folders and for every json file, it finds

heudiconv/tests/test_bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_get_key_info_for_fmap_assignment(tmpdir):
100100

101101
# 1) Call for a non-existing file should give an error:
102102
with pytest.raises(FileNotFoundError):
103-
assert get_key_info_for_fmap_assignment('foo.json')
103+
assert get_key_info_for_fmap_assignment('foo.json', 'ImagingVolume')
104104

105105
# 2) matching_parameters = 'Shims'
106106
json_name = op.join(TESTS_DATA_PATH, remove_suffix(nifti_file, '.nii.gz') + '.json')

heudiconv/tests/test_main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,13 @@ def test_populate_intended_for(session, expected_folder, capfd):
325325
# Because the function .utils.populate_intended_for already has its own
326326
# tests, here we just test that "process_extra_commands", when 'command'
327327
# is 'populate_intended_for' does what we expect (loop through the list of
328-
# subjects and calls 'populate_intended_for'). We call it using folders
328+
# subjects and calls 'populate_intended_for' using the 'POPULATE_INTENDED_FOR_OPTS'
329+
# defined in the heuristic file 'example.py'). We call it using folders
329330
# that don't exist, and check that the output is the expected.
330331
bids_folder = expected_folder.split('sub-')[0]
331332
subjects = ['1', '2']
332333
process_extra_commands(bids_folder, 'populate-intended-for', [], '',
333-
'', session, subjects, None)
334+
'example', session, subjects, None)
334335
captured_output = capfd.readouterr().err
335336
for s in subjects:
336337
expected_info = 'Adding "IntendedFor" to the fieldmaps in ' + expected_folder.format(sID=s)

0 commit comments

Comments
 (0)