Skip to content

Commit

Permalink
[TEST] iterating over groups f 4 subjects in pipeline_execution_test
Browse files Browse the repository at this point in the history
  • Loading branch information
bclenet committed Jan 29, 2024
1 parent cce2dfe commit 9a10149
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions narps_open/utils/configuration/testing_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ neurovault_naming = true # true if results files are saved using the neurovault
[testing]

[testing.pipelines]
nb_subjects_per_group = 4 # Compute first level analyses by subgroups of N subjects, to avoid lacking of disk and memory
correlation_thresholds = [0.30, 0.70, 0.79, 0.85, 0.93] # Correlation between reproduced hypotheses files and results, respectively for [20, 40, 60, 80, 108] subjects.
40 changes: 24 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ def test_pipeline_execution(
TODO : how to keep intermediate files of the low level for the next numbers of subjects ?
- keep intermediate levels : boolean in PipelineRunner
"""
# A list of number of subject to iterate over
nb_subjects_subgroup = Configuration()['testing']['pipelines']['nb_subjects_per_group']
nb_subjects_list = [s for s in range(nb_subjects_subgroup, nb_subjects, nb_subjects_subgroup)]
nb_subjects_list.append(nb_subjects)

# Initialize the pipeline
runner = PipelineRunner(team_id)
runner.nb_subjects = nb_subjects
runner.pipeline.directories.dataset_dir = Configuration()['directories']['dataset']
runner.pipeline.directories.results_dir = Configuration()['directories']['reproduced_results']
runner.pipeline.directories.set_output_dir_with_team_id(team_id)
Expand All @@ -55,23 +59,27 @@ def test_pipeline_execution(
# TODO : this is a workaround
for _ in range(Configuration()['runner']['nb_trials']):

# Get missing subjects
missing_subjects = set()
for file in runner.get_missing_first_level_outputs():
subject_id = get_subject_id(file)
if subject_id is not None:
missing_subjects.add(subject_id)
for nb_subjects in nb_subjects_list:

# Leave if no missing subjects
if not missing_subjects:
break
runner.nb_subjects = nb_subjects

# Get missing subjects
missing_subjects = set()
for file in runner.get_missing_first_level_outputs():
subject_id = get_subject_id(file)
if subject_id is not None:
missing_subjects.add(subject_id)

# Leave if no missing subjects
if not missing_subjects:
break

# Start pipeline
runner.subjects = missing_subjects
try: # This avoids errors in the workflow to make the test fail
runner.start(True, False)
except(RuntimeError) as err:
print('RuntimeError: ', err)
# Start pipeline
runner.subjects = missing_subjects
try: # This avoids errors in the workflow to make the test fail
runner.start(True, False)
except(RuntimeError) as err:
print('RuntimeError: ', err)

# Check missing files for the last time
missing_files = runner.get_missing_first_level_outputs()
Expand Down

0 comments on commit 9a10149

Please sign in to comment.