Skip to content

Commit ee734ca

Browse files
committed
♻️ Just turn off FreeSurfer for surface if also on for brain extraction
1 parent ad1a421 commit ee734ca

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

CPAC/pipeline/cpac_pipeline.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
857857
pipeline_blocks += anat_blocks
858858

859859
if not rpool.check_rpool('freesurfer-subject-dir'):
860-
if freesurfer_preproc in pipeline_blocks:
861-
pipeline_blocks[
862-
pipeline_blocks.index(freesurfer_preproc)
863-
] = freesurfer_abcd_preproc
864-
else:
865-
pipeline_blocks += [freesurfer_abcd_preproc]
860+
pipeline_blocks += [freesurfer_abcd_preproc]
866861

867862
# Anatomical T1 brain masking
868863
if not rpool.check_rpool('space-T1w_desc-brain_mask') or \

CPAC/surface/tests/test_config.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
"""
22
Tests for surface configuration
3+
"""
4+
import os
5+
import pkg_resources as p
6+
import pytest
7+
import yaml
8+
9+
from CPAC.pipeline.cpac_pipeline import run_workflow
10+
from CPAC.utils.configuration import Configuration
11+
12+
13+
@pytest.mark.timeout(60)
14+
def test_duplicate_freesurfer():
15+
"""The pipeline should build fast if freesurfer is not self-duplicating"""
16+
c = Configuration(yaml.safe_load('FROM: abcd-options'))
17+
sub_dict = yaml.safe_load(open(p.resource_filename(
18+
"CPAC",
19+
os.path.join(
20+
"resources",
21+
"configs",
22+
"data_config_S3-BIDS-ABIDE.yml"
23+
)
24+
), 'r'))[0]
325

4-
FROM: abcd-options
5-
pipeline_setup:
6-
pipeline_name: ABCD-blip
7-
output_directory:
8-
quality_control:
9-
generate_xcpqc_files: On
10-
functional_preproc:
11-
distortion_correction:
12-
using:
13-
- PhaseDiff
14-
- Blip
15-
"""
26+
run_workflow(sub_dict, c, False, test_config=True)

CPAC/utils/configuration.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ def __init__(self, config_map=None):
117117
regressor['Name'] = f'Regressor-{str(i + 1)}'
118118
# replace spaces with hyphens in Regressor 'Name's
119119
regressor['Name'] = regressor['Name'].replace(' ', '-')
120+
121+
# Don't double-run FreeSurfer
122+
try:
123+
if 'FreeSurfer-ABCD' in config_map['anatomical_preproc'][
124+
'brain_extraction']['using']:
125+
config_map['surface_analysis']['freesurfer']['run'] = False
126+
except TypeError:
127+
pass
128+
120129
config_map = schema(config_map)
121130

122131
# remove 'FROM' before setting attributes now that it's imported

dev/circleci_data/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ spython >= 0.0.81
44
pytest
55
pytest_bdd
66
pytest_click
7+
pytest-timeout
78
pyyaml
89
yamlordereddictloader

dev/docker_data/default_pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ surface_analysis:
170170
# select those 'Freesurfer-' labeled options further below in anatomical_preproc.
171171
freesurfer:
172172

173+
# If anatomical_preproc['brain_extraction']['using'] includes FreeSurfer-ABCD and this switch is On, C-PAC will automatically turn this switch Off to avoid running FreeSurfer twice unnecessarily
173174
run: Off
174175

175176
# Add extra arguments to recon-all command

0 commit comments

Comments
 (0)