Skip to content

Commit 527e46e

Browse files
committed
fix error, connect template for unet
1 parent 107bf78 commit 527e46e

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

CPAC/anat_preproc/anat_preproc.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ def acpc_alignment(skullstrip_tool='afni', config=None, acpc_target='whole-head'
3838

3939
inputnode = pe.Node(util.IdentityInterface(fields=['anat_leaf',
4040
'brain_mask',
41-
'template_head',
42-
'template_brain']),
41+
'template_brain_only_for_anat', 'template_brain_only_for_anat',
42+
'template_skull_for_anat',
43+
'template_brain_for_acpc',
44+
'template_head_for_acpc']),
4345
name='inputspec')
4446

4547
output_node = pe.Node(util.IdentityInterface(fields=['acpc_aligned_head',
@@ -63,7 +65,12 @@ def acpc_alignment(skullstrip_tool='afni', config=None, acpc_target='whole-head'
6365
initial_skullstrip, 'inputspec.anat_data')
6466
if skullstrip_tool == 'mask':
6567
preproc.connect(inputnode, 'brain_mask',
66-
initial_skullstrip, 'inputspec.brain_mask')
68+
initial_skullstrip, 'inputspec.brain_mask')
69+
elif skullstrip_tool == 'unet':
70+
preproc.connect(inputnode, 'template_brain_only_for_anat',
71+
initial_skullstrip, 'inputspec.template_brain_only_for_anat')
72+
preproc.connect(inputnode, 'template_skull_for_anat',
73+
initial_skullstrip, 'inputspec.template_skull_for_anat')
6774
preproc.connect(initial_skullstrip, 'outputspec.brain',
6875
robust_fov, 'in_file')
6976

@@ -85,11 +92,11 @@ def acpc_alignment(skullstrip_tool='afni', config=None, acpc_target='whole-head'
8592

8693
# align head-to-head to get acpc.mat (for human)
8794
if acpc_target == 'whole-head':
88-
preproc.connect(inputnode, 'template_head', align, 'reference')
95+
preproc.connect(inputnode, 'template_head_for_acpc', align, 'reference')
8996

9097
# align brain-to-brain to get acpc.mat (for monkey)
9198
if acpc_target=='brain':
92-
preproc.connect(inputnode, 'template_brain', align, 'reference')
99+
preproc.connect(inputnode, 'template_brain_for_acpc', align, 'reference')
93100

94101
concat_xfm = pe.Node(interface=fsl_utils.ConvertXFM(),
95102
name='anat_acpc_4_concatxfm')
@@ -114,7 +121,7 @@ def acpc_alignment(skullstrip_tool='afni', config=None, acpc_target='whole-head'
114121
apply_xfm.inputs.relwarp = True
115122

116123
preproc.connect(inputnode, 'anat_leaf', apply_xfm, 'in_file')
117-
preproc.connect(inputnode, 'template_head', apply_xfm, 'ref_file')
124+
preproc.connect(inputnode, 'template_head_for_acpc', apply_xfm, 'ref_file')
118125
preproc.connect(aff_to_rig, 'out_mat', apply_xfm, 'premat')
119126
preproc.connect(apply_xfm, 'out_file', output_node, 'acpc_aligned_head')
120127

@@ -125,7 +132,7 @@ def acpc_alignment(skullstrip_tool='afni', config=None, acpc_target='whole-head'
125132
apply_xfm_mask.inputs.relwarp = True
126133

127134
preproc.connect(inputnode, 'brain_mask', apply_xfm_mask, 'in_file')
128-
preproc.connect(inputnode, 'template_brain', apply_xfm_mask, 'ref_file')
135+
preproc.connect(inputnode, 'template_brain_for_acpc', apply_xfm_mask, 'ref_file')
129136
preproc.connect(aff_to_rig, 'out_mat', apply_xfm_mask, 'premat')
130137
preproc.connect(apply_xfm_mask, 'out_file', output_node, 'acpc_brain_mask')
131138

@@ -603,6 +610,8 @@ def create_anat_preproc(method='afni', already_skullstripped=False,
603610
'brain_mask',
604611
'template_brain_only_for_anat',
605612
'template_skull_for_anat',
613+
'template_brain_only_for_acpc',
614+
'template_skull_for_acpc',
606615
'template_cmass']),
607616
name='inputspec')
608617

@@ -643,10 +652,12 @@ def create_anat_preproc(method='afni', already_skullstripped=False,
643652

644653
preproc.connect(anat_reorient, 'out_file', acpc_align, 'inputspec.anat_leaf')
645654
preproc.connect(inputnode, 'brain_mask', acpc_align, 'inputspec.brain_mask')
646-
preproc.connect(inputnode, 'template_brain_only_for_anat', acpc_align, 'inputspec.template_brain')
647-
preproc.connect(inputnode, 'template_skull_for_anat', acpc_align, 'inputspec.template_head')
655+
preproc.connect(inputnode, 'template_brain_only_for_acpc', acpc_align, 'inputspec.template_brain_for_acpc')
656+
preproc.connect(inputnode, 'template_skull_for_acpc', acpc_align, 'inputspec.template_head_for_acpc')
648657
preproc.connect(acpc_align, 'outputspec.acpc_aligned_head', anat_leaf, 'anat_data')
649-
658+
if method == 'unet':
659+
preproc.connect(inputnode, 'template_brain_only_for_anat', acpc_align, 'inputspec.template_brain_only_for_anat')
660+
preproc.connect(inputnode, 'template_skull_for_anat', acpc_align, 'inputspec.template_skull_for_anat')
650661
# Disable non_local_means_filtering and n4_bias_field_correction when run niworkflows-ants
651662
if method == 'niworkflows-ants':
652663
config.non_local_means_filtering = False

CPAC/pipeline/cpac_pipeline.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,9 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
960960
workflow.connect(node, out_file,
961961
anat_preproc, 'inputspec.brain_mask')
962962
workflow.connect(c.acpc_template_skull, 'local_path',
963-
anat_preproc, 'inputspec.template_skull_for_anat')
963+
anat_preproc, 'inputspec.template_skull_for_acpc')
964964
workflow.connect(c.acpc_template_brain, 'local_path',
965-
anat_preproc, 'inputspec.template_brain_only_for_anat')
965+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
966966

967967
new_strat.append_name(anat_preproc.name)
968968
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
@@ -992,9 +992,9 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
992992
workflow.connect(node, out_file,
993993
anat_preproc, 'inputspec.anat')
994994
workflow.connect(c.acpc_template_skull, 'local_path',
995-
anat_preproc, 'inputspec.template_skull_for_anat')
995+
anat_preproc, 'inputspec.template_skull_for_acpc')
996996
workflow.connect(c.acpc_template_brain, 'local_path',
997-
anat_preproc, 'inputspec.template_brain_only_for_anat')
997+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
998998

999999
new_strat.append_name(anat_preproc.name)
10001000
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
@@ -1026,9 +1026,9 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
10261026
workflow.connect(node, out_file,
10271027
anat_preproc, 'inputspec.anat')
10281028
workflow.connect(c.acpc_template_skull, 'local_path',
1029-
anat_preproc, 'inputspec.template_skull_for_anat')
1029+
anat_preproc, 'inputspec.template_skull_for_acpc')
10301030
workflow.connect(c.acpc_template_brain, 'local_path',
1031-
anat_preproc, 'inputspec.template_brain_only_for_anat')
1031+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
10321032
new_strat.append_name(anat_preproc.name)
10331033
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
10341034
new_strat.update_resource_pool({
@@ -1050,9 +1050,9 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
10501050
workflow.connect(node, out_file,
10511051
anat_preproc, 'inputspec.anat')
10521052
workflow.connect(c.acpc_template_skull, 'local_path',
1053-
anat_preproc, 'inputspec.template_skull_for_anat')
1053+
anat_preproc, 'inputspec.template_skull_for_acpc')
10541054
workflow.connect(c.acpc_template_brain, 'local_path',
1055-
anat_preproc, 'inputspec.template_brain_only_for_anat')
1055+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
10561056
new_strat.append_name(anat_preproc.name)
10571057
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
10581058
new_strat.update_resource_pool({
@@ -1074,9 +1074,9 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
10741074
workflow.connect(node, out_file,
10751075
anat_preproc, 'inputspec.anat')
10761076
workflow.connect(c.acpc_template_skull, 'local_path',
1077-
anat_preproc, 'inputspec.template_skull_for_anat')
1077+
anat_preproc, 'inputspec.template_skull_for_acpc')
10781078
workflow.connect(c.acpc_template_brain, 'local_path',
1079-
anat_preproc, 'inputspec.template_brain_only_for_anat')
1079+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
10801080
new_strat.append_name(anat_preproc.name)
10811081
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
10821082
new_strat.update_resource_pool({
@@ -1097,10 +1097,16 @@ def build_workflow(subject_id, sub_dict, c, pipeline_name=None, num_ants_cores=1
10971097
node, out_file = new_strat['anatomical']
10981098
workflow.connect(node, out_file,
10991099
anat_preproc, 'inputspec.anat')
1100+
node, out_file = new_strat['template_brain_for_anat']
1101+
workflow.connect(node, out_file,
1102+
anat_preproc, 'inputspec.template_brain_only_for_anat')
1103+
node, out_file = new_strat['template_skull_for_anat']
1104+
workflow.connect(node, out_file,
1105+
anat_preproc, 'inputspec.template_skull_for_anat')
11001106
workflow.connect(c.acpc_template_skull, 'local_path',
1101-
anat_preproc, 'inputspec.template_skull_for_anat')
1107+
anat_preproc, 'inputspec.template_skull_for_acpc')
11021108
workflow.connect(c.acpc_template_brain, 'local_path',
1103-
anat_preproc, 'inputspec.template_brain_only_for_anat')
1109+
anat_preproc, 'inputspec.template_brain_only_for_acpc')
11041110
new_strat.append_name(anat_preproc.name)
11051111
new_strat.set_leaf_properties(anat_preproc, 'outputspec.brain')
11061112
new_strat.update_resource_pool({

0 commit comments

Comments
 (0)