Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Lingering calls to `cpac_outputs.csv` (was changed to `cpac_outputs.tsv` in v1.8.1).
- A bug in the `freesurfer_abcd_preproc` nodeblock where the `Template` image was incorrectly used as `reference` during the `inverse_warp` step. Replacing it with the subject-specific `T1w` image resolved the issue of the `desc-restoreBrain_T1w` being chipped off.
- A bug in `ideal_bandpass` where the frequency mask was incorrectly applied, which caused filter to fail in certain cases.
- `Freesufer-ABCD` brain masking strategy to create mask as per the original DCAN script.
- A bug where `$ANTSPATH` was unset in C-PAC with FreeSurfer images.

### Upgraded dependencies
Expand Down
39 changes: 6 additions & 33 deletions CPAC/anat_preproc/anat_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,37 +1128,12 @@ def freesurfer_abcd_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
name=f"wmparc_to_nifti_{pipe_num}",
)

# Register wmparc file if ingressing FreeSurfer data
if strat_pool.check_rpool("pipeline-fs_xfm"):
wmparc_to_native = pe.Node(
Function(
input_names=["source_file", "target_file", "xfm", "out_file"],
output_names=["transformed_file"],
function=normalize_wmparc,
),
name=f"wmparc_to_native_{pipe_num}",
)

wmparc_to_native.inputs.out_file = "wmparc_warped.mgz"

node, out = strat_pool.get_data("pipeline-fs_wmparc")
wf.connect(node, out, wmparc_to_native, "source_file")

node, out = strat_pool.get_data("pipeline-fs_raw-average")
wf.connect(node, out, wmparc_to_native, "target_file")

node, out = strat_pool.get_data("pipeline-fs_xfm")
wf.connect(node, out, wmparc_to_native, "xfm")

wf.connect(wmparc_to_native, "transformed_file", wmparc_to_nifti, "in_file")

else:
node, out = strat_pool.get_data("pipeline-fs_wmparc")
wf.connect(node, out, wmparc_to_nifti, "in_file")
node, out = strat_pool.get_data("pipeline-fs_wmparc")
wf.connect(node, out, wmparc_to_nifti, "in_file")

wmparc_to_nifti.inputs.args = "-rt nearest"

node, out = strat_pool.get_data("desc-preproc_T1w")
node, out = strat_pool.get_data(["desc-restore_T1w", "desc-preproc_T1w"])
wf.connect(node, out, wmparc_to_nifti, "reslice_like")

binary_mask = pe.Node(
Expand Down Expand Up @@ -1194,7 +1169,7 @@ def freesurfer_abcd_brain_connector(wf, cfg, strat_pool, pipe_num, opt):

wf.connect(binary_filled_mask, "out_file", brain_mask_to_t1_restore, "in_file")

node, out = strat_pool.get_data("desc-preproc_T1w")
node, out = strat_pool.get_data(["desc-restore_T1w", "desc-preproc_T1w"])
wf.connect(node, out, brain_mask_to_t1_restore, "ref_file")

outputs = {"space-T1w_desc-brain_mask": (brain_mask_to_t1_restore, "out_file")}
Expand Down Expand Up @@ -2010,10 +1985,9 @@ def brain_mask_acpc_freesurfer(wf, cfg, strat_pool, pipe_num, opt=None):
option_key=["anatomical_preproc", "brain_extraction", "using"],
option_val="FreeSurfer-ABCD",
inputs=[
"desc-preproc_T1w",
["desc-restore_T1w", "desc-preproc_T1w"],
"pipeline-fs_wmparc",
"pipeline-fs_raw-average",
"pipeline-fs_xfm",
"freesurfer-subject-dir",
],
outputs=["space-T1w_desc-brain_mask"],
Expand Down Expand Up @@ -2067,10 +2041,9 @@ def brain_mask_freesurfer_fsl_tight(wf, cfg, strat_pool, pipe_num, opt=None):
option_key=["anatomical_preproc", "brain_extraction", "using"],
option_val="FreeSurfer-ABCD",
inputs=[
"desc-preproc_T1w",
["desc-restore_T1w", "desc-preproc_T1w"],
"pipeline-fs_wmparc",
"pipeline-fs_raw-average",
"pipeline-fs_xfm",
"freesurfer-subject-dir",
],
outputs=["space-T1w_desc-acpcbrain_mask"],
Expand Down
8 changes: 6 additions & 2 deletions CPAC/anat_preproc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ def mri_convert(in_file, reslice_like=None, out_file=None, args=None):
import os

if out_file is None:
out_file = in_file.replace(".mgz", ".nii.gz")
out_file = os.path.join(
os.getcwd(), os.path.basename(in_file).replace(".mgz", ".nii.gz")
)

cmd = "mri_convert %s %s" % (in_file, out_file)

Expand Down Expand Up @@ -525,7 +527,9 @@ def mri_convert_reorient(in_file, orientation, out_file=None):
import os

if out_file is None:
out_file = in_file.split(".")[0] + "_reoriented.mgz"
out_file = os.path.join(
os.getcwd(), os.path.basename(in_file).split(".")[0] + "_reoriented.mgz"
)

cmd = "mri_convert %s %s --out_orientation %s" % (in_file, out_file, orientation)

Expand Down
1 change: 0 additions & 1 deletion CPAC/pipeline/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,6 @@ def ingress_freesurfer(wf, rpool, cfg, data_paths, unique_id, part_id, ses_id):
"pipeline-fs_hemi-R_desc-surfaceMap_volume": "surf/rh.volume",
"pipeline-fs_hemi-L_desc-surfaceMesh_white": "surf/lh.white",
"pipeline-fs_hemi-R_desc-surfaceMesh_white": "surf/rh.white",
"pipeline-fs_xfm": "mri/transforms/talairach.lta",
}

for key, outfile in recon_outs.items():
Expand Down