Skip to content

Commit 48826ec

Browse files
committed
Fixing freesurfer-abcd brain masking
1 parent e2d6a31 commit 48826ec

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

CPAC/anat_preproc/anat_preproc.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,37 +1128,12 @@ def freesurfer_abcd_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
11281128
name=f"wmparc_to_nifti_{pipe_num}",
11291129
)
11301130

1131-
# Register wmparc file if ingressing FreeSurfer data
1132-
if strat_pool.check_rpool("pipeline-fs_xfm"):
1133-
wmparc_to_native = pe.Node(
1134-
Function(
1135-
input_names=["source_file", "target_file", "xfm", "out_file"],
1136-
output_names=["transformed_file"],
1137-
function=normalize_wmparc,
1138-
),
1139-
name=f"wmparc_to_native_{pipe_num}",
1140-
)
1141-
1142-
wmparc_to_native.inputs.out_file = "wmparc_warped.mgz"
1143-
1144-
node, out = strat_pool.get_data("pipeline-fs_wmparc")
1145-
wf.connect(node, out, wmparc_to_native, "source_file")
1146-
1147-
node, out = strat_pool.get_data("pipeline-fs_raw-average")
1148-
wf.connect(node, out, wmparc_to_native, "target_file")
1149-
1150-
node, out = strat_pool.get_data("pipeline-fs_xfm")
1151-
wf.connect(node, out, wmparc_to_native, "xfm")
1152-
1153-
wf.connect(wmparc_to_native, "transformed_file", wmparc_to_nifti, "in_file")
1154-
1155-
else:
1156-
node, out = strat_pool.get_data("pipeline-fs_wmparc")
1157-
wf.connect(node, out, wmparc_to_nifti, "in_file")
1131+
node, out = strat_pool.get_data("pipeline-fs_wmparc")
1132+
wf.connect(node, out, wmparc_to_nifti, "in_file")
11581133

11591134
wmparc_to_nifti.inputs.args = "-rt nearest"
11601135

1161-
node, out = strat_pool.get_data("desc-preproc_T1w")
1136+
node, out = strat_pool.get_data("desc-restore_T1w")
11621137
wf.connect(node, out, wmparc_to_nifti, "reslice_like")
11631138

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

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

1197-
node, out = strat_pool.get_data("desc-preproc_T1w")
1172+
node, out = strat_pool.get_data("desc-restore_T1w")
11981173
wf.connect(node, out, brain_mask_to_t1_restore, "ref_file")
11991174

12001175
outputs = {"space-T1w_desc-brain_mask": (brain_mask_to_t1_restore, "out_file")}
@@ -2028,7 +2003,7 @@ def brain_mask_acpc_freesurfer(wf, cfg, strat_pool, pipe_num, opt=None):
20282003
option_key=["anatomical_preproc", "brain_extraction", "using"],
20292004
option_val="FreeSurfer-ABCD",
20302005
inputs=[
2031-
"desc-preproc_T1w",
2006+
"desc-restore_T1w",
20322007
"pipeline-fs_wmparc",
20332008
"pipeline-fs_raw-average",
20342009
"pipeline-fs_xfm",

CPAC/anat_preproc/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def mri_convert(in_file, reslice_like=None, out_file=None, args=None):
487487
import os
488488

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

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

@@ -525,7 +525,7 @@ def mri_convert_reorient(in_file, orientation, out_file=None):
525525
import os
526526

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

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

0 commit comments

Comments
 (0)