|
13 | 13 | from niworkflows.utils.connections import pop_file |
14 | 14 | from smriprep.workflows.anatomical import ( |
15 | 15 | _is_skull_stripped, |
16 | | - init_anat_ribbon_wf, |
17 | 16 | init_anat_template_wf, |
18 | 17 | ) |
19 | 18 | from smriprep.workflows.fit.registration import init_register_template_wf |
20 | 19 | from smriprep.workflows.outputs import ( |
21 | 20 | init_ds_dseg_wf, |
22 | 21 | init_ds_fs_registration_wf, |
23 | 22 | init_ds_mask_wf, |
| 23 | + init_ds_surface_masks_wf, |
24 | 24 | init_ds_surface_metrics_wf, |
25 | 25 | init_ds_surfaces_wf, |
26 | 26 | init_ds_template_registration_wf, |
27 | 27 | init_ds_template_wf, |
28 | 28 | init_ds_tpms_wf, |
29 | 29 | ) |
30 | 30 | from smriprep.workflows.surfaces import ( |
| 31 | + init_anat_ribbon_wf, |
| 32 | + init_cortex_masks_wf, |
31 | 33 | init_fsLR_reg_wf, |
32 | 34 | init_gifti_morphometrics_wf, |
33 | 35 | init_gifti_surfaces_wf, |
@@ -147,6 +149,7 @@ def init_infant_anat_fit_wf( |
147 | 149 | 'sphere_reg', |
148 | 150 | 'sphere_reg_fsLR', |
149 | 151 | 'sphere_reg_msm', |
| 152 | + 'cortex_mask', |
150 | 153 | 'anat_ribbon', |
151 | 154 | # Reverse transform; not computable from forward transform |
152 | 155 | 'std2anat_xfm', |
@@ -1413,6 +1416,32 @@ def init_infant_anat_fit_wf( |
1413 | 1416 | else: |
1414 | 1417 | LOGGER.info('ANAT Stage 9: Found pre-computed fsLR registration sphere') |
1415 | 1418 | fsLR_buffer.inputs.sphere_reg_fsLR = sorted(precomputed['sphere_reg_fsLR']) |
| 1419 | + |
| 1420 | + # Stage 10: Cortical surface mask |
| 1421 | + if len(precomputed.get('cortex_mask', [])) < 2: |
| 1422 | + LOGGER.info('ANAT Stage 11: Creating cortical surface mask') |
| 1423 | + |
| 1424 | + cortex_masks_wf = init_cortex_masks_wf() |
| 1425 | + ds_cortex_masks_wf = init_ds_surface_masks_wf( |
| 1426 | + output_dir=output_dir, |
| 1427 | + mask_type='cortex', |
| 1428 | + name='ds_cortex_masks_wf', |
| 1429 | + ) |
| 1430 | + |
| 1431 | + workflow.connect([ |
| 1432 | + (surfaces_buffer, cortex_masks_wf, [ |
| 1433 | + ('midthickness', 'inputnode.midthickness'), |
| 1434 | + ('thickness', 'inputnode.thickness'), |
| 1435 | + ]), |
| 1436 | + (cortex_masks_wf, ds_cortex_masks_wf, [ |
| 1437 | + ('outputnode.cortex_masks', 'inputnode.mask_files'), |
| 1438 | + ('outputnode.source_files', 'inputnode.source_files'), |
| 1439 | + ]), |
| 1440 | + (ds_cortex_masks_wf, outputnode, [('outputnode.mask_files', 'cortex_mask')]), |
| 1441 | + ]) # fmt:skip |
| 1442 | + else: |
| 1443 | + LOGGER.info('ANAT Stage 11: Found pre-computed cortical surface mask') |
| 1444 | + outputnode.inputs.cortex_mask = sorted(precomputed['cortex_mask']) |
1416 | 1445 | return workflow |
1417 | 1446 |
|
1418 | 1447 |
|
@@ -1476,6 +1505,7 @@ def init_infant_single_anat_fit_wf( |
1476 | 1505 | 'sphere_reg', |
1477 | 1506 | 'sphere_reg_fsLR', |
1478 | 1507 | 'sphere_reg_msm', |
| 1508 | + 'cortex_mask', |
1479 | 1509 | 'anat_ribbon', |
1480 | 1510 | # Reverse transform; not computable from forward transform |
1481 | 1511 | 'std2anat_xfm', |
@@ -2342,4 +2372,30 @@ def init_infant_single_anat_fit_wf( |
2342 | 2372 | else: |
2343 | 2373 | LOGGER.info('ANAT Stage 9: Found pre-computed fsLR registration sphere') |
2344 | 2374 | fsLR_buffer.inputs.sphere_reg_fsLR = sorted(precomputed['sphere_reg_fsLR']) |
| 2375 | + |
| 2376 | + # Stage 10: Cortical surface mask |
| 2377 | + if len(precomputed.get('cortex_mask', [])) < 2: |
| 2378 | + LOGGER.info('ANAT Stage 11: Creating cortical surface mask') |
| 2379 | + |
| 2380 | + cortex_masks_wf = init_cortex_masks_wf() |
| 2381 | + ds_cortex_masks_wf = init_ds_surface_masks_wf( |
| 2382 | + output_dir=output_dir, |
| 2383 | + mask_type='cortex', |
| 2384 | + name='ds_cortex_masks_wf', |
| 2385 | + ) |
| 2386 | + |
| 2387 | + workflow.connect([ |
| 2388 | + (surfaces_buffer, cortex_masks_wf, [ |
| 2389 | + ('midthickness', 'inputnode.midthickness'), |
| 2390 | + ('thickness', 'inputnode.thickness'), |
| 2391 | + ]), |
| 2392 | + (cortex_masks_wf, ds_cortex_masks_wf, [ |
| 2393 | + ('outputnode.cortex_masks', 'inputnode.mask_files'), |
| 2394 | + ('outputnode.source_files', 'inputnode.source_files'), |
| 2395 | + ]), |
| 2396 | + (ds_cortex_masks_wf, outputnode, [('outputnode.mask_files', 'cortex_mask')]), |
| 2397 | + ]) # fmt:skip |
| 2398 | + else: |
| 2399 | + LOGGER.info('ANAT Stage 11: Found pre-computed cortical surface mask') |
| 2400 | + outputnode.inputs.cortex_mask = sorted(precomputed['cortex_mask']) |
2345 | 2401 | return workflow |
0 commit comments