@@ -1071,8 +1071,6 @@ def init_hcp_morphometrics_wf(
1071
1071
HCP-style curvature file in GIFTI format
1072
1072
sulc
1073
1073
HCP-style sulcal depth file in GIFTI format
1074
- roi
1075
- HCP-style cortical ROI file in GIFTI format
1076
1074
"""
1077
1075
DEFAULT_MEMORY_MIN_GB = 0.01
1078
1076
@@ -1090,7 +1088,7 @@ def init_hcp_morphometrics_wf(
1090
1088
)
1091
1089
1092
1090
outputnode = pe .JoinNode (
1093
- niu .IdentityInterface (fields = ['thickness' , 'curv' , 'sulc' , 'roi' ]),
1091
+ niu .IdentityInterface (fields = ['thickness' , 'curv' , 'sulc' ]),
1094
1092
name = 'outputnode' ,
1095
1093
joinsource = 'itersource' ,
1096
1094
)
@@ -1115,11 +1113,6 @@ def init_hcp_morphometrics_wf(
1115
1113
# Thickness is presumably already positive, but HCP uses abs(-thickness)
1116
1114
abs_thickness = pe .Node (MetricMath (metric = 'thickness' , operation = 'abs' ), name = 'abs_thickness' )
1117
1115
1118
- # Native ROI is thickness > 0, with holes and islands filled
1119
- initial_roi = pe .Node (MetricMath (metric = 'roi' , operation = 'bin' ), name = 'initial_roi' )
1120
- fill_holes = pe .Node (MetricFillHoles (), name = 'fill_holes' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1121
- native_roi = pe .Node (MetricRemoveIslands (), name = 'native_roi' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1122
-
1123
1116
# Dilation happens separately from ROI creation
1124
1117
dilate_curv = pe .Node (
1125
1118
MetricDilate (distance = 10 , nearest = True ),
@@ -1158,15 +1151,99 @@ def init_hcp_morphometrics_wf(
1158
1151
(dilate_curv , outputnode , [('out_file' , 'curv' )]),
1159
1152
(dilate_thickness , outputnode , [('out_file' , 'thickness' )]),
1160
1153
(invert_sulc , outputnode , [('metric_file' , 'sulc' )]),
1161
- # Native ROI file from thickness
1162
- (inputnode , initial_roi , [('subject_id' , 'subject_id' )]),
1154
+ ]) # fmt:skip
1155
+
1156
+ return workflow
1157
+
1158
+
1159
+ def init_cortex_masks_wf (
1160
+ * ,
1161
+ name : str = 'cortex_masks_wf' ,
1162
+ ):
1163
+ """Create cortical surface masks from surface files.
1164
+
1165
+ Workflow Graph
1166
+ .. workflow::
1167
+ :graph2use: orig
1168
+ :simple_form: yes
1169
+
1170
+ from smriprep.workflows.surfaces import init_cortex_masks_wf
1171
+ wf = init_cortex_masks_wf()
1172
+
1173
+ Inputs
1174
+ ------
1175
+ midthickness : len-2 list of str
1176
+ Each hemisphere's FreeSurfer midthickness surface file in GIFTI format
1177
+ thickness : len-2 list of str
1178
+ Each hemisphere's FreeSurfer thickness file in GIFTI format
1179
+
1180
+ Outputs
1181
+ -------
1182
+ cortex_masks : len-2 list of str
1183
+ Cortical surface mask in GIFTI format for each hemisphere
1184
+ source_files : len-2 list of lists of str
1185
+ Each hemisphere's source files, which are used to create the mask
1186
+ """
1187
+ DEFAULT_MEMORY_MIN_GB = 0.01
1188
+
1189
+ workflow = Workflow (name = name )
1190
+
1191
+ inputnode = pe .Node (
1192
+ niu .IdentityInterface (fields = ['midthickness' , 'thickness' ]),
1193
+ name = 'inputnode' ,
1194
+ )
1195
+
1196
+ itersource = pe .Node (
1197
+ niu .IdentityInterface (fields = ['hemi' ]),
1198
+ name = 'itersource' ,
1199
+ iterables = [('hemi' , ['L' , 'R' ])],
1200
+ )
1201
+
1202
+ outputnode = pe .JoinNode (
1203
+ niu .IdentityInterface (fields = ['cortex_masks' , 'source_files' ]),
1204
+ name = 'outputnode' ,
1205
+ joinsource = 'itersource' ,
1206
+ )
1207
+
1208
+ select_surfaces = pe .Node (
1209
+ KeySelect (fields = ['thickness' , 'midthickness' ], keys = ['L' , 'R' ]),
1210
+ name = 'select_surfaces' ,
1211
+ run_without_submitting = True ,
1212
+ )
1213
+
1214
+ combine_sources = pe .Node (niu .Merge (2 ), name = 'combine_sources' , run_without_submitting = True )
1215
+
1216
+ abs_thickness = pe .Node (
1217
+ MetricMath (metric = 'thickness' , operation = 'abs' ),
1218
+ name = 'abs_thickness' ,
1219
+ mem_gb = DEFAULT_MEMORY_MIN_GB ,
1220
+ )
1221
+ initial_roi = pe .Node (
1222
+ MetricMath (metric = 'roi' , operation = 'bin' ), name = 'initial_roi' , mem_gb = DEFAULT_MEMORY_MIN_GB
1223
+ )
1224
+ fill_holes = pe .Node (MetricFillHoles (), name = 'fill_holes' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1225
+ native_roi = pe .Node (MetricRemoveIslands (), name = 'native_roi' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1226
+
1227
+ workflow .connect ([
1228
+ (inputnode , select_surfaces , [
1229
+ ('thickness' , 'thickness' ),
1230
+ ('midthickness' , 'midthickness' ),
1231
+ ]),
1232
+ (itersource , select_surfaces , [('hemi' , 'key' )]),
1233
+ (itersource , abs_thickness , [('hemi' , 'hemisphere' )]),
1163
1234
(itersource , initial_roi , [('hemi' , 'hemisphere' )]),
1164
- (abs_thickness , initial_roi , [('metric_file ' , 'metric_file' )]),
1235
+ (select_surfaces , abs_thickness , [('thickness ' , 'metric_file' )]),
1165
1236
(select_surfaces , fill_holes , [('midthickness' , 'surface_file' )]),
1166
1237
(select_surfaces , native_roi , [('midthickness' , 'surface_file' )]),
1238
+ (abs_thickness , initial_roi , [('metric_file' , 'metric_file' )]),
1167
1239
(initial_roi , fill_holes , [('metric_file' , 'metric_file' )]),
1168
1240
(fill_holes , native_roi , [('out_file' , 'metric_file' )]),
1169
- (native_roi , outputnode , [('out_file' , 'roi' )]),
1241
+ (native_roi , outputnode , [('out_file' , 'cortex_masks' )]),
1242
+ (select_surfaces , combine_sources , [
1243
+ ('midthickness' , 'in1' ),
1244
+ ('thickness' , 'in2' ),
1245
+ ]),
1246
+ (combine_sources , outputnode , [('out' , 'source_files' )]),
1170
1247
]) # fmt:skip
1171
1248
1172
1249
return workflow
0 commit comments