@@ -1277,35 +1277,55 @@ def init_ds_surface_masks_wf(
1277
1277
)
1278
1278
outputnode = pe .Node (niu .IdentityInterface (fields = ['mask_files' ]), name = 'outputnode' )
1279
1279
1280
- sources = pe .MapNode (
1281
- niu .Function (function = _bids_relative ),
1282
- name = 'sources' ,
1283
- iterfield = 'in_files' ,
1280
+ combine_masks = pe .Node (
1281
+ niu .Merge (2 ),
1282
+ name = 'combine_masks' ,
1284
1283
)
1285
- sources . inputs . bids_root = output_dir
1284
+ workflow . connect ( combine_masks , outputnode , [( 'out' , 'mask_files' )])
1286
1285
1287
- ds_mask = pe .MapNode (
1288
- DerivativesDataSink (
1289
- base_directory = output_dir ,
1290
- hemi = ['L' , 'R' ],
1291
- desc = mask_type ,
1292
- ** entities ,
1293
- ),
1294
- iterfield = ('in_file' , 'hemi' , 'source_file' ),
1295
- name = 'ds_mask' ,
1296
- run_without_submitting = True ,
1297
- )
1298
- if mask_type == 'brain' :
1299
- ds_mask .inputs .Type = 'Brain'
1300
- else :
1301
- ds_mask .inputs .Type = 'ROI'
1286
+ for i_hemi , hemi in enumerate (['L' , 'R' ]):
1287
+ select_mask = pe .Node (
1288
+ niu .Select (index = i_hemi ),
1289
+ name = f'select_mask_{ hemi } ' ,
1290
+ run_without_submitting = True ,
1291
+ )
1292
+ workflow .connect (inputnode , select_mask , [('mask_files' , 'inlist' )])
1302
1293
1303
- workflow .connect ([
1304
- (inputnode , ds_mask , [('mask_files' , 'in_file' )]),
1305
- (inputnode , sources , [('source_files' , 'in_files' )]),
1306
- (sources , ds_mask , [('out' , 'source_file' )]),
1307
- (ds_mask , outputnode , [('out_file' , 'mask_files' )]),
1308
- ]) # fmt:skip
1294
+ select_source = pe .Node (
1295
+ niu .Select (index = i_hemi ),
1296
+ name = f'select_source_{ hemi } ' ,
1297
+ run_without_submitting = True ,
1298
+ )
1299
+ workflow .connect (inputnode , select_source , [('source_files' , 'inlist' )])
1300
+
1301
+ sources = pe .Node (
1302
+ niu .Function (function = _bids_relative ),
1303
+ name = f'sources_{ hemi } ' ,
1304
+ )
1305
+ sources .inputs .bids_root = output_dir
1306
+
1307
+ ds_mask = pe .Node (
1308
+ DerivativesDataSink (
1309
+ base_directory = output_dir ,
1310
+ hemi = hemi ,
1311
+ desc = mask_type ,
1312
+ ** entities ,
1313
+ ),
1314
+ name = f'ds_mask_{ hemi } ' ,
1315
+ run_without_submitting = True ,
1316
+ )
1317
+ if mask_type == 'brain' :
1318
+ ds_mask .inputs .Type = 'Brain'
1319
+ else :
1320
+ ds_mask .inputs .Type = 'ROI'
1321
+
1322
+ workflow .connect ([
1323
+ (select_mask , ds_mask , [('out' , 'in_file' )]),
1324
+ (select_source , sources , [('out' , 'in_files' )]),
1325
+ (select_source , ds_mask , [('out' , 'source_file' )]),
1326
+ (sources , ds_mask , [('out' , 'Sources' )]),
1327
+ (ds_mask , combine_masks , [('out_file' , f'in{ i_hemi + 1 } ' )]),
1328
+ ]) # fmt:skip
1309
1329
1310
1330
return workflow
1311
1331
0 commit comments