@@ -11,12 +11,13 @@ def copy_ltas(in_file, subjects_dir, subject_id, long_template):
11
11
return out_file
12
12
13
13
def create_AutoRecon2 (name = "AutoRecon2" , longitudinal = False ,
14
- field_strength = "1.5T" , plugin_args = None ):
14
+ plugin_args = None , fsvernum = 5.3 ):
15
15
# AutoRecon2
16
16
# Workflow
17
17
ar2_wf = pe .Workflow (name = name )
18
18
19
19
inputspec = pe .Node (IdentityInterface (fields = ['orig' ,
20
+ 'nu' , # version < 6
20
21
'brainmask' ,
21
22
'transform' ,
22
23
'subject_id' ,
@@ -47,40 +48,39 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
47
48
inputspec .inputs .timepoints = config ['timepoints' ]
48
49
49
50
50
- # NU Intensity Correction
51
- """
52
- Non-parametric Non-uniform intensity Normalization (N3), corrects for
53
- intensity non-uniformity in MR data, making relatively few assumptions about
54
- the data. This runs the MINC tool 'nu_correct'.
55
- """
56
- intensity_correction = pe .Node (
57
- MNIBiasCorrection (), name = "Intensity_Correction" )
58
- intensity_correction .inputs .iterations = 1
59
- intensity_correction .inputs .protocol_iterations = 1000
60
- intensity_correction .inputs .stop = 0.0001
61
- intensity_correction .inputs .shrink = 2
62
- if field_strength == '3T' :
63
- intensity_correction .inputs .distance = 50
64
- else :
65
- # default for 1.5T scans
66
- intensity_correction .inputs .distance = 200
67
-
68
- intensity_correction .inputs .out_file = 'nu.mgz'
69
- ar2_wf .connect ([(inputspec , intensity_correction , [('orig' , 'in_file' ),
70
- ('brainmask' , 'mask' ),
71
- ('transform' , 'transform' )
72
- ])
73
- ])
74
-
75
- add_to_header_nu = pe .Node (AddXFormToHeader (), name = "Add_XForm_to_NU" )
76
- add_to_header_nu .inputs .copy_name = True
77
- add_to_header_nu .inputs .out_file = 'nu.mgz'
78
- ar2_wf .connect ([(intensity_correction , add_to_header_nu , [('out_file' , 'in_file' ),
51
+ if fsvernum >= 6 :
52
+ # NU Intensity Correction
53
+ """
54
+ Non-parametric Non-uniform intensity Normalization (N3), corrects for
55
+ intensity non-uniformity in MR data, making relatively few assumptions about
56
+ the data. This runs the MINC tool 'nu_correct'.
57
+ """
58
+ intensity_correction = pe .Node (
59
+ MNIBiasCorrection (), name = "Intensity_Correction" )
60
+ intensity_correction .inputs .out_file = 'nu.mgz'
61
+ ar2_wf .connect ([(inputspec , intensity_correction , [('orig' , 'in_file' ),
62
+ ('brainmask' , 'mask' ),
63
+ ('transform' , 'transform' )])])
64
+
65
+ # intensity correction parameters are more specific in 6+
66
+ intensity_correction .inputs .iterations = 1
67
+ intensity_correction .inputs .protocol_iterations = 1000
68
+ if stop :
69
+ intensity_correction .inputs .stop = stop
70
+ if shrink :
71
+ intensity_correction .inputs .shrink = shrink
72
+ intensity_correction .inputs .distance = distance
73
+
74
+ add_to_header_nu = pe .Node (AddXFormToHeader (), name = "Add_XForm_to_NU" )
75
+ add_to_header_nu .inputs .copy_name = True
76
+ add_to_header_nu .inputs .out_file = 'nu.mgz'
77
+ ar2_wf .connect ([(intensity_correction , add_to_header_nu , [('out_file' , 'in_file' ),
79
78
]),
80
- (inputspec , add_to_header_nu ,
81
- [('transform' , 'transform' )])
79
+ (inputspec , add_to_header_nu ,
80
+ [('transform' , 'transform' )])
82
81
])
83
82
83
+
84
84
# EM Registration
85
85
"""
86
86
Computes the transform to align the mri/nu.mgz volume to the default GCA
@@ -103,8 +103,12 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
103
103
align_transform .plugin_args = plugin_args
104
104
ar2_wf .connect ([(inputspec , align_transform , [('brainmask' , 'mask' ),
105
105
('reg_template' , 'template' ),
106
- ('num_threads' , 'num_threads' )]),
107
- (add_to_header_nu , align_transform , [('out_file' , 'in_file' )])])
106
+ ('num_threads' , 'num_threads' )])])
107
+ if fsvernum >= 6 :
108
+ ar2_wf .connect ([(add_to_header_nu , align_transform , [('out_file' , 'in_file' )])])
109
+ else :
110
+ ar2_wf .connect ([(inputspec , align_transform , [('nu' , 'in_file' )])])
111
+
108
112
109
113
# CA Normalize
110
114
"""
@@ -128,8 +132,12 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
128
132
129
133
ar2_wf .connect ([(align_transform , ca_normalize , [('out_file' , 'transform' )]),
130
134
(inputspec , ca_normalize , [('brainmask' , 'mask' ),
131
- ('reg_template' , 'atlas' )]),
132
- (add_to_header_nu , ca_normalize , [('out_file' , 'in_file' )])])
135
+ ('reg_template' , 'atlas' )])])
136
+ if fsvernum >= 6 :
137
+ ar2_wf .connect ([(add_to_header_nu , ca_normalize , [('out_file' , 'in_file' )])])
138
+ else :
139
+ ar2_wf .connect ([(inputspec , ca_normalize , [('nu' , 'in_file' )])])
140
+
133
141
134
142
# CA Register
135
143
# Computes a nonlinear transform to align with GCA atlas.
@@ -159,8 +167,11 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
159
167
remove_neck .inputs .radius = 25
160
168
remove_neck .inputs .out_file = 'nu_noneck.mgz'
161
169
ar2_wf .connect ([(ca_register , remove_neck , [('out_file' , 'transform' )]),
162
- (add_to_header_nu , remove_neck , [('out_file' , 'in_file' )]),
163
170
(inputspec , remove_neck , [('reg_template' , 'template' )])])
171
+ if fsvernum >= 6 :
172
+ ar2_wf .connect ([(add_to_header_nu , remove_neck , [('out_file' , 'in_file' )])])
173
+ else :
174
+ ar2_wf .connect ([(inputspec , remove_neck , [('nu' , 'in_file' )])])
164
175
165
176
# SkullLTA (EM Registration, with Skull)
166
177
# Computes transform to align volume mri/nu_noneck.mgz with GCA volume
@@ -680,8 +691,14 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
680
691
outputspec = pe .Node (IdentityInterface (fields = outputs ),
681
692
name = "outputspec" )
682
693
683
- ar2_wf .connect ([(add_to_header_nu , outputspec , [('out_file' , 'nu' )]),
684
- (align_transform , outputspec , [('out_file' , 'tal_lta' )]),
694
+ if fsvernum >= 6 :
695
+ ar2_wf .connect ([(add_to_header_nu , outputspec , [('out_file' , 'nu' )])])
696
+ else :
697
+ # add to outputspec to perserve datasinking
698
+ ar2_wf .connect ([(inputspec , outputspec , [('nu' , 'nu' )])])
699
+
700
+
701
+ ar2_wf .connect ([(align_transform , outputspec , [('out_file' , 'tal_lta' )]),
685
702
(ca_normalize , outputspec , [('out_file' , 'norm' )]),
686
703
(ca_normalize , outputspec , [('control_points' , 'ctrl_pts' )]),
687
704
(ca_register , outputspec , [('out_file' , 'tal_m3z' )]),
0 commit comments