Skip to content

Commit 2df7b30

Browse files
committed
adding the template_space_func_masking nodeblock
1 parent cfeaa01 commit 2df7b30

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

CPAC/func_preproc/func_preproc.py

Lines changed: 47 additions & 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, cfg, pipe_num)
1614+
anat_brain_to_func_res = anat_brain_to_bold_res(wf_name="anat_brain_to_bold_res", cfg, pipe_num)
16151615

16161616
node, out = strat_pool.get_data("space-template_desc-preproc_T1w")
16171617
wf.connect(
@@ -1836,6 +1836,52 @@ def bold_masking(wf, cfg, strat_pool, pipe_num, opt=None):
18361836

18371837
return (wf, outputs)
18381838

1839+
@nodeblock(
1840+
name="template_space_bold_masking",
1841+
switch=[
1842+
["functional_preproc", "run"],
1843+
["functional_preproc", "template_space_func_masking", "run"],
1844+
["functional_preproc", "template_space_func_masking", "apply_func_mask_in_template_space"],
1845+
],
1846+
inputs=[("space-template_desc-preproc_bold", "space-template_desc-bold_mask")],
1847+
outputs={
1848+
"space-template_desc-preproc_bold": {
1849+
"Description": "The skull-stripped BOLD time-series.",
1850+
"SkullStripped": True,
1851+
},
1852+
"space-template_desc-brain_bold": {
1853+
"Description": "The skull-stripped BOLD time-series.",
1854+
"SkullStripped": True,
1855+
},
1856+
"space-template_desc-head_bold": {
1857+
"Description": "The non skull-stripped BOLD time-series.",
1858+
"SkullStripped": False,
1859+
},
1860+
},
1861+
)
1862+
def template_space_bold_masking(wf, cfg, strat_pool, pipe_num, opt=None):
1863+
"""Mask the bold in template space."""
1864+
func_edge_detect = pe.Node(
1865+
interface=afni_utils.Calc(), name=f"template_space_func_extract_brain_{pipe_num}"
1866+
)
1867+
1868+
func_edge_detect.inputs.expr = "a*b"
1869+
func_edge_detect.inputs.outputtype = "NIFTI_GZ"
1870+
1871+
node_head_bold, out_head_bold = strat_pool.get_data("space-template_desc-preproc_bold")
1872+
wf.connect(node_head_bold, out_head_bold, func_edge_detect, "in_file_a")
1873+
1874+
node, out = strat_pool.get_data("space-template_desc-bold_mask")
1875+
wf.connect(node, out, func_edge_detect, "in_file_b")
1876+
1877+
outputs = {
1878+
"space-template_desc-preproc_bold": (func_edge_detect, "out_file"),
1879+
"space-template_desc-brain_bold": (func_edge_detect, "out_file"),
1880+
"space-template_desc-head_bold": (node_head_bold, out_head_bold),
1881+
}
1882+
1883+
return (wf, outputs)
1884+
18391885

18401886
@nodeblock(
18411887
name="func_mean",

CPAC/pipeline/cpac_pipeline.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,6 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
12751275
bold_mask_fsl_afni,
12761276
bold_mask_anatomical_refined,
12771277
bold_mask_anatomical_based,
1278-
bold_mask_anatomical_resampled,
12791278
bold_mask_ccs,
12801279
],
12811280
bold_masking,
@@ -1402,6 +1401,13 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
14021401
if cfg.voxel_mirrored_homotopic_connectivity["run"]:
14031402
pipeline_blocks += [create_func_to_T1template_symmetric_xfm]
14041403

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+
14051411
# Nuisance Correction
14061412
generate_only = (
14071413
True not in cfg["nuisance_corrections", "2-nuisance_regression", "run"]

0 commit comments

Comments
 (0)