Skip to content

Commit

Permalink
🔀 Merge develop into apply-filter-more-broadly
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Jul 21, 2023
2 parents fda6343 + bb4c00c commit 7f87df2
Show file tree
Hide file tree
Showing 20 changed files with 154 additions and 50 deletions.
28 changes: 9 additions & 19 deletions CPAC/func_preproc/func_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,15 @@


@nodeblock(
name="calc_motion_stats",
switch=[["functional_preproc", "run"],
["functional_preproc", "motion_estimates_and_correction",
"motion_estimates", "calculate_motion_after"]],
inputs=[("desc-preproc_bold",
"space-bold_desc-brain_mask",
"max-displacement",
"rels-displacement",
"movement-parameters",
["filtered-movement-parameters", "movement-parameters"],
["filtered-coordinate-transformation",
"coordinate-transformation"]),
"subject",
"scan"],
outputs=["framewise-displacement-power",
"framewise-displacement-jenkinson",
"dvars",
"power-params",
"motion-params"])
name='calc_motion_stats',
switch=[['functional_preproc', 'run'],
['functional_preproc', 'motion_estimates_and_correction', 'run'],
['functional_preproc', 'motion_estimates_and_correction', 'motion_estimates', 'calculate_motion_after']],
inputs=[('desc-preproc_bold', 'space-bold_desc-brain_mask', 'movement-parameters', 'max-displacement',
'rels-displacement', 'coordinate-transformation'), 'subject', 'scan'],
outputs=['framewise-displacement-power', 'framewise-displacement-jenkinson', 'dvars', 'power-params',
'motion-params']
)
def calc_motion_stats(wf, cfg, strat_pool, pipe_num, opt=None):
'''Calculate motion statistics for motion parameters.'''
motion_prov = strat_pool.get_cpac_provenance('movement-parameters')
Expand Down
58 changes: 30 additions & 28 deletions CPAC/func_preproc/func_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,12 @@ def get_idx(in_files, stop_idx=None, start_idx=None):


@nodeblock(
name="func_reorient",
config=["functional_preproc"],
switch=["run"],
inputs=["bold"],
outputs=["desc-preproc_bold", "desc-reorient_bold"])
name='func_reorient',
config=['functional_preproc'],
switch=['run'],
inputs=['bold'],
outputs=['desc-preproc_bold', 'desc-reorient_bold']
)
def func_reorient(wf, cfg, strat_pool, pipe_num, opt=None):

func_deoblique = pe.Node(interface=afni_utils.Refit(),
Expand Down Expand Up @@ -724,9 +725,9 @@ def func_slice_time(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_afni',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='AFNI',
inputs=['desc-preproc_bold'],
outputs={'space-bold_desc-brain_mask':
Expand All @@ -750,9 +751,9 @@ def bold_mask_afni(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_fsl',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='FSL',
inputs=['desc-preproc_bold'],
outputs=['space-bold_desc-brain_mask']
Expand Down Expand Up @@ -903,9 +904,9 @@ def form_thr_string(thr):

@nodeblock(
name='bold_mask_fsl_afni',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='FSL_AFNI',
inputs=[('motion-basefile', 'desc-preproc_bold'), 'FSL-AFNI-bold-ref', 'FSL-AFNI-brain-mask',
'FSL-AFNI-brain-probseg'],
Expand Down Expand Up @@ -1081,9 +1082,9 @@ def bold_mask_fsl_afni(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_anatomical_refined',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='Anatomical_Refined',
inputs=[('bold', 'desc-preproc_bold'),
('desc-brain_T1w', ['space-T1w_desc-brain_mask', 'space-T1w_desc-acpcbrain_mask'])],
Expand Down Expand Up @@ -1200,9 +1201,9 @@ def bold_mask_anatomical_refined(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_anatomical_based',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='Anatomical_Based',
inputs=['desc-preproc_bold', ('desc-brain_T1w', ['desc-preproc_T1w', 'desc-reorient_T1w', 'T1w'])],
outputs=['space-bold_desc-brain_mask']
Expand Down Expand Up @@ -1292,9 +1293,9 @@ def bold_mask_anatomical_based(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_anatomical_resampled',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='Anatomical_Resampled',
inputs=['desc-preproc_bold', 'T1w-template-funcreg', 'space-template_desc-preproc_T1w',
'space-template_desc-T1w_mask'],
Expand Down Expand Up @@ -1361,9 +1362,9 @@ def bold_mask_anatomical_resampled(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_mask_ccs',
config=['functional_preproc'],
switch=['run'],
option_key=['func_masking', 'using'],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run']],
option_key=['functional_preproc', 'func_masking', 'using'],
option_val='CCS_Anatomical_Refined',
inputs=[['desc-motion_bold', 'desc-preproc_bold', 'bold'], 'desc-brain_T1w',
['desc-preproc_T1w', 'desc-reorient_T1w', 'T1w']],
Expand Down Expand Up @@ -1503,8 +1504,9 @@ def bold_mask_ccs(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name='bold_masking',
config=None,
switch=[['functional_preproc', 'run'], ['functional_preproc', 'func_masking', 'apply_func_mask_in_native_space']],
switch=[['functional_preproc', 'run'],
['functional_preproc', 'func_masking', 'run'],
['functional_preproc', 'func_masking', 'apply_func_mask_in_native_space']],
inputs=[('desc-preproc_bold', 'space-bold_desc-brain_mask')],
outputs={'desc-preproc_bold': {'Description': 'The skull-stripped BOLD time-series.', 'SkullStripped': True},
'desc-brain_bold': {'Description': 'The skull-stripped BOLD time-series.', 'SkullStripped': True}}
Expand Down
4 changes: 4 additions & 0 deletions CPAC/pipeline/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def sanitize(filename):
}
},
'func_masking': {
'run': bool1_1,
'using': [In(
['AFNI', 'FSL', 'FSL_AFNI', 'Anatomical_Refined',
'Anatomical_Based', 'Anatomical_Resampled',
Expand Down Expand Up @@ -855,6 +856,9 @@ def sanitize(filename):
'normalize_func': {
'run': bool1_1,
},
'coreg_prep': {
'run': bool1_1,
},
},
'nuisance_corrections': {
'1-ICA-AROMA': {
Expand Down
6 changes: 4 additions & 2 deletions CPAC/registration/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,8 @@ def coregistration_prep_vol(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name="coregistration_prep_mean",
switch=["functional_preproc", "run"],
switch=[["functional_preproc", "run"],
["functional_preproc", "coreg_prep", "run"]],
option_key=[
"registration_workflows",
"functional_registration",
Expand Down Expand Up @@ -2897,7 +2898,8 @@ def coregistration_prep_mean(wf, cfg, strat_pool, pipe_num, opt=None):

@nodeblock(
name="coregistration_prep_fmriprep",
switch=["functional_preproc", "run"],
switch=[["functional_preproc", "run"],
["functional_preproc", "coreg_prep", "run"]],
option_key=[
"registration_workflows",
"functional_registration",
Expand Down
6 changes: 6 additions & 0 deletions CPAC/resources/configs/pipeline_config_abcd-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ functional_preproc:
using: [PhaseDiff, Blip-FSL-TOPUP]

func_masking:
run: On

# Apply functional mask in native space
apply_func_mask_in_native_space: Off
Expand All @@ -313,6 +314,11 @@ functional_preproc:
# Generate mean functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
8 changes: 8 additions & 0 deletions CPAC/resources/configs/pipeline_config_benchmark-ANTS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ functional_preproc:
# run: [On, Off] - this will run both and fork the pipeline
run: [On]

func_masking:
run: On

generate_func_mean:

# Generate mean functional image
Expand All @@ -154,6 +157,11 @@ functional_preproc:
# Normalize functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
8 changes: 8 additions & 0 deletions CPAC/resources/configs/pipeline_config_benchmark-FNIRT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ functional_preproc:
# run: [On, Off] - this will run both and fork the pipeline
run: [On]

func_masking:
run: On

generate_func_mean:

# Generate mean functional image
Expand All @@ -178,6 +181,11 @@ functional_preproc:
# Normalize functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
6 changes: 6 additions & 0 deletions CPAC/resources/configs/pipeline_config_blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ functional_preproc:
fmap_skullstrip_AFNI_threshold: 0.6

func_masking:
run: Off
FSL-BET:

# Set an intensity threshold to improve skull stripping performances of FSL BET on rodent scans.
Expand Down Expand Up @@ -1172,6 +1173,11 @@ functional_preproc:
run: [Off]
space: native

coreg_prep:

# Generate sbref
run: Off

nuisance_corrections:
2-nuisance_regression:

Expand Down
6 changes: 6 additions & 0 deletions CPAC/resources/configs/pipeline_config_ccs-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ functional_preproc:
run: [On]

func_masking:
run: On

# using: ['AFNI', 'FSL', 'FSL_AFNI', 'Anatomical_Refined', 'Anatomical_Based', 'Anatomical_Resampled', 'CCS_Anatomical_Refined']
# FSL_AFNI: fMRIPrep-style BOLD mask. Ref: https://github.com/nipreps/niworkflows/blob/a221f612/niworkflows/func/util.py#L246-L514
Expand Down Expand Up @@ -198,6 +199,11 @@ functional_preproc:
# run: [On, Off] - this will run both and fork the pipeline
run: [On]

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
8 changes: 8 additions & 0 deletions CPAC/resources/configs/pipeline_config_default-deprecated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ functional_preproc:
# run: [On, Off] - this will run both and fork the pipeline
run: [On]

func_masking:
run: On

generate_func_mean:

# Generate mean functional image
Expand All @@ -85,6 +88,11 @@ functional_preproc:
# Normalize functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
6 changes: 5 additions & 1 deletion CPAC/resources/configs/pipeline_config_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ functional_preproc:
regrid: 1

func_masking:

run: On
# using: ['AFNI', 'FSL', 'FSL_AFNI', 'Anatomical_Refined', 'Anatomical_Based', 'Anatomical_Resampled', 'CCS_Anatomical_Refined']

# FSL_AFNI: fMRIPrep-style BOLD mask. Ref: https://github.com/nipreps/niworkflows/blob/a221f612/niworkflows/func/util.py#L246-L514
Expand Down Expand Up @@ -1335,7 +1335,11 @@ functional_preproc:

# Normalize functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:

Expand Down
6 changes: 6 additions & 0 deletions CPAC/resources/configs/pipeline_config_fmriprep-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ functional_preproc:
run: [On]

func_masking:
run: On
FSL_AFNI:
bold_ref: /code/CPAC/resources/templates/tpl-MNI152NLin2009cAsym_res-02_desc-fMRIPrep_boldref.nii.gz
brain_mask: /code/CPAC/resources/templates/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz
Expand All @@ -387,6 +388,11 @@ functional_preproc:
# Generate mean functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
6 changes: 6 additions & 0 deletions CPAC/resources/configs/pipeline_config_monkey-ABCD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ functional_preproc:
using: []

func_masking:
run: On
FSL_AFNI:
brain_mask: /usr/share/fsl/5.0/data/standard/MNI152_T1_${resolution_for_anat}_brain_mask.nii.gz
brain_probseg: /usr/share/fsl/5.0/data/standard/MNI152_T1_${resolution_for_anat}_brain_mask.nii.gz
Expand All @@ -349,6 +350,11 @@ functional_preproc:
# Normalize functional image
run: On

coreg_prep:

# Generate sbref
run: On

nuisance_corrections:
2-nuisance_regression:

Expand Down
Loading

0 comments on commit 7f87df2

Please sign in to comment.