Skip to content

Commit 9cca410

Browse files
committed
adding quick bold masking with automask
1 parent 2df7b30 commit 9cca410

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

CPAC/func_preproc/func_motion.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,19 @@ def calc_motion_stats(wf, cfg, strat_pool, pipe_num, opt=None):
8787
gen_motion_stats,
8888
"inputspec.motion_correct",
8989
)
90-
wf.connect(
91-
*strat_pool.get_data("space-bold_desc-brain_mask"),
92-
gen_motion_stats,
93-
"inputspec.mask",
94-
)
90+
91+
try :
92+
wf.connect(*strat_pool.get_data("space-bold_desc-brain_mask"),
93+
gen_motion_stats,
94+
"inputspec.mask",
95+
)
96+
except :
97+
mask_bold = pe.Node(interface=afni.MaskTool(), name=f"mask_bold_{pipe_num}")
98+
mask_bold.inputs.outputtype = "NIFTI_GZ"
99+
node, out = strat_pool.get_data("desc-preproc_bold")
100+
wf.connect(node, out, mask_bold, "in_file")
101+
wf.connect(mask_bold, "out_file", gen_motion_stats, "inputspec.mask")
102+
95103
wf.connect(
96104
*strat_pool.get_data("desc-movementParameters_motion"),
97105
gen_motion_stats,

CPAC/func_preproc/func_preproc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ def bold_mask_anatomical_resampled(wf, cfg, strat_pool, pipe_num, opt=None):
16111611
16121612
Adapted from `DCAN Lab's BOLD mask method from the ABCD pipeline <https://github.com/DCAN-Labs/DCAN-HCP/blob/1d90814/fMRIVolume/scripts/OneStepResampling.sh#L121-L132>`_.
16131613
"""
1614-
anat_brain_to_func_res = anat_brain_to_bold_res(wf_name="anat_brain_to_bold_res", cfg, pipe_num)
1614+
anat_brain_to_func_res = anat_brain_to_bold_res(wf_name="anat_brain_to_bold_res", cfg=cfg, pipe_num=pipe_num)
16151615

16161616
node, out = strat_pool.get_data("space-template_desc-preproc_T1w")
16171617
wf.connect(

CPAC/pipeline/cpac_pipeline.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
bold_mask_fsl,
100100
bold_mask_fsl_afni,
101101
bold_masking,
102+
template_space_bold_masking,
102103
func_despike,
103104
func_despike_template,
104105
func_mean,
@@ -1401,13 +1402,6 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
14011402
if cfg.voxel_mirrored_homotopic_connectivity["run"]:
14021403
pipeline_blocks += [create_func_to_T1template_symmetric_xfm]
14031404

1404-
# Template space functional masking
1405-
if cfg.functional_preproc["template_space_func_masking"]["run"]:
1406-
if not rpool.check_rpool("space-template_desc-bold_mask"):
1407-
pipeline_blocks += bold_mask_anatomical_resampled,
1408-
if cfg.functional_preproc["template_space_func_masking"]["apply_func_mask_in_template_space"]:
1409-
pipeline_blocks += apply_func_mask_to_template,
1410-
14111405
# Nuisance Correction
14121406
generate_only = (
14131407
True not in cfg["nuisance_corrections", "2-nuisance_regression", "run"]
@@ -1518,6 +1512,13 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
15181512
warp_bold_mask_to_EPItemplate,
15191513
warp_deriv_mask_to_EPItemplate,
15201514
]
1515+
1516+
# Template space functional masking
1517+
if cfg.functional_preproc["template_space_func_masking"]["run"]:
1518+
if not rpool.check_rpool("space-template_desc-bold_mask"):
1519+
pipeline_blocks += bold_mask_anatomical_resampled,
1520+
if cfg.functional_preproc["template_space_func_masking"]["apply_func_mask_in_template_space"]:
1521+
pipeline_blocks += template_space_bold_masking,
15211522

15221523
# Template-space nuisance regression
15231524
nuisance_template = (

CPAC/resources/configs/pipeline_config_abcd-options.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,16 @@ registration_workflows:
210210
# input: ['Mean_Functional', 'Selected_Functional_Volume', 'fmriprep_reference']
211211
input: [Selected_Functional_Volume]
212212

213+
# Mask the sbref created by coregistration input prep nodeblocks above before registration
214+
mask_sbref: Off
215+
213216
# Choose coregistration interpolation
214217
interpolation: spline
215218

216219
# Choose coregistration degree of freedom
217220
dof: 12
221+
222+
218223

219224
func_registration_to_template:
220225

@@ -311,7 +316,7 @@ functional_preproc:
311316

312317
nuisance_corrections:
313318
2-nuisance_regression:
314-
319+
run: Off
315320
# Select which nuisance signal corrections to apply
316321
Regressors:
317322
- Name: default
@@ -324,6 +329,9 @@ nuisance_corrections:
324329
include_delayed_squared: On
325330
include_squared: On
326331

332+
# switch to Off if nuisance regression is off and you don't want to write out the regressors
333+
create_regressors: Off
334+
327335
# Process and refine masks used to produce regressors and time series for
328336
# regression.
329337
regressor_masks:
@@ -380,10 +388,10 @@ regional_homogeneity:
380388
# -----------------------
381389
post_processing:
382390
spatial_smoothing:
383-
run: On
391+
run: Off
384392

385393
z-scoring:
386-
run: On
394+
run: Off
387395

388396
seed_based_correlation_analysis:
389397

0 commit comments

Comments
 (0)