diff --git a/CHANGELOG.md b/CHANGELOG.md index a82254901..cac9fc998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CPAC/anat_preproc/anat_preproc.py b/CPAC/anat_preproc/anat_preproc.py index 4e9639c5b..f3ef8c1e1 100644 --- a/CPAC/anat_preproc/anat_preproc.py +++ b/CPAC/anat_preproc/anat_preproc.py @@ -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( @@ -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")} @@ -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"], @@ -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"], diff --git a/CPAC/anat_preproc/utils.py b/CPAC/anat_preproc/utils.py index a494ebced..63a20a488 100644 --- a/CPAC/anat_preproc/utils.py +++ b/CPAC/anat_preproc/utils.py @@ -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) @@ -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) diff --git a/CPAC/pipeline/engine.py b/CPAC/pipeline/engine.py index ac6e0cfe4..93e5cd798 100644 --- a/CPAC/pipeline/engine.py +++ b/CPAC/pipeline/engine.py @@ -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():