Skip to content

Commit 7246e44

Browse files
committed
reverting adding reorient node at the very begining and passing orientation set in config in the existing nodes for reorientations
1 parent d0a7c2a commit 7246e44

File tree

3 files changed

+51
-59
lines changed

3 files changed

+51
-59
lines changed

CPAC/anat_preproc/anat_preproc.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ def freesurfer_fsl_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
12331233
mem_gb=0,
12341234
mem_x=(0.0115, "in_file", "t"),
12351235
)
1236-
reorient_fs_brainmask.inputs.orientation = "RPI"
1236+
reorient_fs_brainmask.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
12371237
reorient_fs_brainmask.inputs.outputtype = "NIFTI_GZ"
12381238

12391239
wf.connect(
@@ -1255,7 +1255,7 @@ def freesurfer_fsl_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
12551255
mem_gb=0,
12561256
mem_x=(0.0115, "in_file", "t"),
12571257
)
1258-
reorient_fs_T1.inputs.orientation = "RPI"
1258+
reorient_fs_T1.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
12591259
reorient_fs_T1.inputs.outputtype = "NIFTI_GZ"
12601260

12611261
wf.connect(convert_fs_T1_to_nifti, "out_file", reorient_fs_T1, "in_file")
@@ -1454,10 +1454,21 @@ def anatomical_init(wf, cfg, strat_pool, pipe_num, opt=None):
14541454
node, out = strat_pool.get_data("T1w")
14551455
wf.connect(node, out, anat_deoblique, "in_file")
14561456

1457+
anat_reorient = pe.Node(
1458+
interface=afni.Resample(),
1459+
name=f"anat_reorient_{pipe_num}",
1460+
mem_gb=0,
1461+
mem_x=(0.0115, "in_file", "t"),
1462+
)
1463+
anat_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
1464+
anat_reorient.inputs.outputtype = "NIFTI_GZ"
1465+
1466+
wf.connect(anat_deoblique, "out_file", anat_reorient, "in_file")
1467+
14571468
outputs = {
1458-
"desc-preproc_T1w": (anat_deoblique, "out_file"),
1459-
"desc-reorient_T1w": (anat_deoblique, "out_file"),
1460-
"desc-head_T1w": (anat_deoblique, "out_file"),
1469+
"desc-preproc_T1w": (anat_reorient, "out_file"),
1470+
"desc-reorient_T1w": (anat_reorient, "out_file"),
1471+
"desc-head_T1w": (anat_reorient, "out_file"),
14611472
}
14621473

14631474
return (wf, outputs)
@@ -2251,10 +2262,21 @@ def anatomical_init_T2(wf, cfg, strat_pool, pipe_num, opt=None):
22512262
node, out = strat_pool.get_data("T2w")
22522263
wf.connect(node, out, T2_deoblique, "in_file")
22532264

2265+
T2_reorient = pe.Node(
2266+
interface=afni.Resample(),
2267+
name=f"T2_reorient_{pipe_num}",
2268+
mem_gb=0,
2269+
mem_x=(0.0115, "in_file", "t"),
2270+
)
2271+
T2_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
2272+
T2_reorient.inputs.outputtype = "NIFTI_GZ"
2273+
2274+
wf.connect(T2_deoblique, "out_file", T2_reorient, "in_file")
2275+
22542276
outputs = {
2255-
"desc-preproc_T2w": (T2_deoblique, "out_file"),
2256-
"desc-reorient_T2w": (T2_deoblique, "out_file"),
2257-
"desc-head_T2w": (T2_deoblique, "out_file"),
2277+
"desc-preproc_T2w": (T2_reorient, "out_file"),
2278+
"desc-reorient_T2w": (T2_reorient, "out_file"),
2279+
"desc-head_T2w": (T2_reorient, "out_file"),
22582280
}
22592281

22602282
return (wf, outputs)

CPAC/func_preproc/func_preproc.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,21 @@ def func_reorient(wf, cfg, strat_pool, pipe_num, opt=None):
521521
node, out = strat_pool.get_data("bold")
522522
wf.connect(node, out, func_deoblique, "in_file")
523523

524+
func_reorient = pe.Node(
525+
interface=afni_utils.Resample(),
526+
name=f"func_reorient_{pipe_num}",
527+
mem_gb=0,
528+
mem_x=(0.0115, "in_file", "t"),
529+
)
530+
531+
func_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
532+
func_reorient.inputs.outputtype = "NIFTI_GZ"
533+
534+
wf.connect(func_deoblique, "out_file", func_reorient, "in_file")
535+
524536
outputs = {
525-
"desc-preproc_bold": (func_deoblique, "out_file"),
526-
"desc-reorient_bold": (func_deoblique, "out_file"),
537+
"desc-preproc_bold": (func_reorient, "out_file"),
538+
"desc-reorient_bold": (func_reorient, "out_file"),
527539
}
528540

529541
return (wf, outputs)

CPAC/pipeline/engine.py

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,17 +1932,7 @@ def ingress_raw_anat_data(wf, rpool, cfg, data_paths, unique_id, part_id, ses_id
19321932
dl_dir=cfg.pipeline_setup["working_directory"]["path"],
19331933
img_type="anat",
19341934
)
1935-
reorient = pe.Node(
1936-
interface=afni.Resample(),
1937-
name=f"reorient_T1w_{part_id}_{ses_id}",
1938-
)
1939-
1940-
reorient.inputs.orientation = desired_orientation
1941-
reorient.inputs.outputtype = "NIFTI_GZ"
1942-
1943-
wf.connect(anat_flow, "outputspec.anat", reorient, "in_file")
1944-
1945-
rpool.set_data("T1w", reorient, "out_file", {}, "", "anat_ingress")
1935+
rpool.set_data("T1w", anat_flow, "outputspec.anat", {}, "", "anat_ingress")
19461936

19471937
if "T2w" in data_paths["anat"]:
19481938
anat_flow_T2 = create_anat_datasource(f"anat_T2w_gather_{part_id}_{ses_id}")
@@ -1953,17 +1943,7 @@ def ingress_raw_anat_data(wf, rpool, cfg, data_paths, unique_id, part_id, ses_id
19531943
dl_dir=cfg.pipeline_setup["working_directory"]["path"],
19541944
img_type="anat",
19551945
)
1956-
reorient = pe.Node(
1957-
interface=afni.Resample(),
1958-
name=f"reorient_T1w_{part_id}_{ses_id}",
1959-
)
1960-
1961-
reorient.inputs.orientation = desired_orientation
1962-
reorient.inputs.outputtype = "NIFTI_GZ"
1963-
1964-
wf.connect(anat_flow_T2, "outputspec.anat", reorient, "in_file")
1965-
1966-
rpool.set_data("T2w", reorient, "out_file", {}, "", "anat_ingress")
1946+
rpool.set_data("T2w", anat_flow_T2, "outputspec.anat", {}, "", "anat_ingress")
19671947

19681948
if cfg.surface_analysis["freesurfer"]["ingress_reconall"]:
19691949
rpool = ingress_freesurfer(
@@ -2010,28 +1990,13 @@ def ingress_freesurfer(wf, rpool, cfg, data_paths, unique_id, part_id, ses_id):
20101990
creds_path=data_paths["creds_path"],
20111991
dl_dir=cfg.pipeline_setup["working_directory"]["path"],
20121992
)
2013-
node = fs_ingress
2014-
out = "outputspec.data"
2015-
node_name = "freesurfer_config_ingress"
2016-
2017-
if fs_path.endswith(".nii.gz" or ".nii"):
2018-
reorient = pe.Node(
2019-
interface=afni.Resample(),
2020-
name=f"reorient_fs_{part_id}_{ses_id}",
2021-
)
2022-
reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
2023-
reorient.inputs.outputtype = "NIFTI_GZ"
2024-
wf.connect(fs_ingress, "outputspec.data", reorient, "in_file")
2025-
node = reorient
2026-
out = "out_file"
2027-
node_name = "reorient_fs"
20281993
rpool.set_data(
20291994
"freesurfer-subject-dir",
2030-
node,
2031-
out,
1995+
fs_ingress,
1996+
"outputspec.data",
20321997
{},
20331998
"",
2034-
node_name,
1999+
"freesurfer_config_ingress",
20352000
)
20362001

20372002
recon_outs = {
@@ -2094,15 +2059,8 @@ def ingress_raw_func_data(wf, rpool, cfg, data_paths, unique_id, part_id, ses_id
20942059
func_wf.get_node("inputnode").iterables = ("scan", list(func_paths_dct.keys()))
20952060

20962061
rpool.set_data("subject", func_wf, "outputspec.subject", {}, "", "func_ingress")
2097-
reorient = pe.Node(
2098-
interface=afni.Resample(),
2099-
name=f"reorient_func_{part_id}_{ses_id}",
2100-
)
2101-
reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
2102-
reorient.inputs.outputtype = "NIFTI_GZ"
2103-
wf.connect(func_wf, "outputspec.rest", reorient, "in_file")
2104-
rpool.set_data("bold", reorient, "out_file", {}, "", "func_ingress")
2105-
# rpool.set_data("bold", func_wf, "outputspec.rest", {}, "", "func_ingress")
2062+
2063+
rpool.set_data("bold", func_wf, "outputspec.rest", {}, "", "func_ingress")
21062064

21072065
rpool.set_data("scan", func_wf, "outputspec.scan", {}, "", "func_ingress")
21082066

0 commit comments

Comments
 (0)