Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed broken support for native-space masking.
- Introduced a new `template_space_func_masking` section in the pipeline config for template-space-only methods.
- Moved `Anatomical_Resampled` masking method from `func_masking` to the `template_space_func_masking`.
- Turned `On` boundary_based_registration for abcd-options preconfig.
- Refactored `transform_timeseries_to_T1template_abcd` nodeblock removing unnecessary nodes, changing `desc-preproc_T1w` inputs as reference to `desc-head_T1w`.
- Appended `T1w to Template` FOV match transform to the XFM.

### Upgraded

Expand Down
39 changes: 16 additions & 23 deletions CPAC/func_preproc/func_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,12 +1559,12 @@ def anat_brain_to_bold_res(wf_name, cfg, pipe_num):

inputNode = pe.Node(
util.IdentityInterface(
fields=["T1w-template-funcreg", "space-template_desc-preproc_T1w"]
fields=["T1w-template-funcreg", "space-template_desc-head_T1w"]
),
name="inputspec",
)
outputNode = pe.Node(
util.IdentityInterface(fields=["space-template_res-bold_desc-brain_T1w"]),
util.IdentityInterface(fields=["space-template_res-bold_desc-head_T1w"]),
name="outputspec",
)

Expand All @@ -1579,15 +1579,15 @@ def anat_brain_to_bold_res(wf_name, cfg, pipe_num):
]["registration"]["FSL-FNIRT"]["identity_matrix"]

wf.connect(
inputNode, "space-template_desc-preproc_T1w", anat_brain_to_func_res, "in_file"
inputNode, "space-template_desc-head_T1w", anat_brain_to_func_res, "in_file"
)
wf.connect(inputNode, "T1w-template-funcreg", anat_brain_to_func_res, "ref_file")

wf.connect(
anat_brain_to_func_res,
"out_file",
outputNode,
"space-template_res-bold_desc-brain_T1w",
"space-template_res-bold_desc-head_T1w",
)
return wf

Expand All @@ -1598,7 +1598,7 @@ def anat_brain_mask_to_bold_res(wf_name, cfg, pipe_num):
wf = pe.Workflow(name=f"{wf_name}_{pipe_num}")
inputNode = pe.Node(
util.IdentityInterface(
fields=["space-template_desc-brain_mask", "space-template_desc-preproc_T1w"]
fields=["space-template_desc-brain_mask", "space-template_desc-head_T1w"]
),
name="inputspec",
)
Expand All @@ -1625,7 +1625,7 @@ def anat_brain_mask_to_bold_res(wf_name, cfg, pipe_num):
)
wf.connect(
inputNode,
"space-template_desc-preproc_T1w",
"space-template_desc-head_T1w",
anat_brain_mask_to_func_res,
"ref_file",
)
Expand All @@ -1649,11 +1649,11 @@ def anat_brain_mask_to_bold_res(wf_name, cfg, pipe_num):
option_val="Anatomical_Resampled",
inputs=[
"T1w-template-funcreg",
"space-template_desc-preproc_T1w",
"space-template_desc-head_T1w",
"space-template_desc-brain_mask",
],
outputs=[
"space-template_res-bold_desc-brain_T1w",
"space-template_res-bold_desc-head_T1w",
"space-template_desc-bold_mask",
],
)
Expand All @@ -1666,9 +1666,9 @@ def bold_mask_anatomical_resampled(wf, cfg, strat_pool, pipe_num, opt=None):
wf_name="anat_brain_to_bold_res", cfg=cfg, pipe_num=pipe_num
)

node, out = strat_pool.get_data("space-template_desc-preproc_T1w")
node, out = strat_pool.get_data("space-template_desc-head_T1w")
wf.connect(
node, out, anat_brain_to_func_res, "inputspec.space-template_desc-preproc_T1w"
node, out, anat_brain_to_func_res, "inputspec.space-template_desc-head_T1w"
)

node, out = strat_pool.get_data("T1w-template-funcreg")
Expand All @@ -1690,15 +1690,15 @@ def bold_mask_anatomical_resampled(wf, cfg, strat_pool, pipe_num, opt=None):

wf.connect(
anat_brain_to_func_res,
"outputspec.space-template_res-bold_desc-brain_T1w",
"outputspec.space-template_res-bold_desc-head_T1w",
anat_brain_mask_to_func_res,
"inputspec.space-template_desc-preproc_T1w",
"inputspec.space-template_desc-head_T1w",
)

outputs = {
"space-template_res-bold_desc-brain_T1w": (
"space-template_res-bold_desc-head_T1w": (
anat_brain_to_func_res,
"outputspec.space-template_res-bold_desc-brain_T1w",
"outputspec.space-template_res-bold_desc-head_T1w",
),
"space-template_desc-bold_mask": (
anat_brain_mask_to_func_res,
Expand Down Expand Up @@ -1897,7 +1897,7 @@ def bold_masking(wf, cfg, strat_pool, pipe_num, opt=None):
["functional_preproc", "template_space_func_masking", "run"],
],
inputs=[
("space-template_desc-preproc_bold", "space-template_desc-bold_mask"),
("space-template_desc-head_bold", "space-template_desc-bold_mask"),
],
outputs={
"space-template_desc-preproc_bold": {
Expand All @@ -1908,10 +1908,6 @@ def bold_masking(wf, cfg, strat_pool, pipe_num, opt=None):
"Description": "The skull-stripped BOLD time-series.",
"SkullStripped": True,
},
"space-template_desc-head_bold": {
"Description": "The non skull-stripped BOLD time-series.",
"SkullStripped": False,
},
},
)
def template_space_bold_masking(
Expand All @@ -1930,9 +1926,7 @@ def template_space_bold_masking(
func_apply_mask.inputs.expr = "a*b"
func_apply_mask.inputs.outputtype = "NIFTI_GZ"

node_head_bold, out_head_bold = strat_pool.get_data(
"space-template_desc-preproc_bold"
)
node_head_bold, out_head_bold = strat_pool.get_data("space-template_desc-head_bold")
wf.connect(node_head_bold, out_head_bold, func_apply_mask, "in_file_a")

node, out = strat_pool.get_data("space-template_desc-bold_mask")
Expand All @@ -1941,7 +1935,6 @@ def template_space_bold_masking(
outputs: POOL_RESOURCE_DICT = {
"space-template_desc-preproc_bold": (func_apply_mask, "out_file"),
"space-template_desc-brain_bold": (func_apply_mask, "out_file"),
"space-template_desc-head_bold": (node_head_bold, out_head_bold),
}

return wf, outputs
Expand Down
14 changes: 8 additions & 6 deletions CPAC/pipeline/cpac_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,13 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
mask_sbref,
]

# Template space functional mask
if cfg.functional_preproc["template_space_func_masking"]["run"]:
if not rpool.check_rpool("space-template_desc-bold_mask"):
pipeline_blocks += [
bold_mask_anatomical_resampled,
]

# Distortion/Susceptibility Correction
distcor_blocks = []
if "fmap" in sub_dict:
Expand Down Expand Up @@ -1472,13 +1479,8 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None):
warp_deriv_mask_to_EPItemplate,
]

# Template space functional masking
# Apply mask in template space
if cfg.functional_preproc["template_space_func_masking"]["run"]:
if not rpool.check_rpool("space-template_desc-bold_mask"):
pipeline_blocks += [
bold_mask_anatomical_resampled,
]

pipeline_blocks += [
template_space_bold_masking,
]
Expand Down
2 changes: 1 addition & 1 deletion CPAC/pipeline/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,10 @@ def sanitize(filename):
},
"boundary_based_registration": {
"run": forkable,
"reference": In({"whole-head", "brain"}),
"bbr_schedule": str,
"bbr_wm_map": In({"probability_map", "partial_volume_map"}),
"bbr_wm_mask_args": str,
"reference": In({"whole-head", "brain"}),
},
},
"EPI_registration": {
Expand Down
Loading
Loading