Skip to content

Commit 9946a71

Browse files
committed
enh: output cortex mask
1 parent 2e1e2de commit 9946a71

File tree

5 files changed

+71
-10
lines changed

5 files changed

+71
-10
lines changed

nibabies/data/io_spec_anat.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@
232232
"desc": "msmsulc",
233233
"suffix": "sphere",
234234
"extension": ".surf.gii"
235+
},
236+
"cortex_mask": {
237+
"datatype": "anat",
238+
"hemi": ["L", "R"],
239+
"space": null,
240+
"desc": "cortex",
241+
"suffix": "mask",
242+
"extension": ".label.gii"
235243
}
236244
},
237245
"masks": {

nibabies/workflows/anatomical/apply.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def init_infant_anat_apply_wf(
7575
)
7676

7777
outputnode = pe.Node(
78-
niu.IdentityInterface(fields=['anat_aseg', 'anat_aparc', 'midthickness_fsLR', 'roi']),
78+
niu.IdentityInterface(fields=['anat_aseg', 'anat_aparc', 'midthickness_fsLR']),
7979
name='outputnode',
8080
)
8181

@@ -242,10 +242,6 @@ def init_infant_anat_apply_wf(
242242
('outputnode.curv', 'inputnode.curv'),
243243
('outputnode.sulc', 'inputnode.sulc'),
244244
('outputnode.thickness', 'inputnode.thickness'),
245-
('outputnode.roi', 'inputnode.roi'),
246-
]),
247-
(hcp_morphometrics_wf, outputnode, [
248-
('outputnode.roi', 'roi'),
249245
]),
250246
(resample_surfaces_wf, morph_grayords_wf, [
251247
('outputnode.midthickness_fsLR', 'inputnode.midthickness_fsLR'),

nibabies/workflows/anatomical/fit.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@
1313
from niworkflows.utils.connections import pop_file
1414
from smriprep.workflows.anatomical import (
1515
_is_skull_stripped,
16-
init_anat_ribbon_wf,
1716
init_anat_template_wf,
1817
)
1918
from smriprep.workflows.fit.registration import init_register_template_wf
2019
from smriprep.workflows.outputs import (
2120
init_ds_dseg_wf,
2221
init_ds_fs_registration_wf,
2322
init_ds_mask_wf,
23+
init_ds_surface_masks_wf,
2424
init_ds_surface_metrics_wf,
2525
init_ds_surfaces_wf,
2626
init_ds_template_registration_wf,
2727
init_ds_template_wf,
2828
init_ds_tpms_wf,
2929
)
3030
from smriprep.workflows.surfaces import (
31+
init_anat_ribbon_wf,
32+
init_cortex_masks_wf,
3133
init_fsLR_reg_wf,
3234
init_gifti_morphometrics_wf,
3335
init_gifti_surfaces_wf,
@@ -147,6 +149,7 @@ def init_infant_anat_fit_wf(
147149
'sphere_reg',
148150
'sphere_reg_fsLR',
149151
'sphere_reg_msm',
152+
'cortex_mask',
150153
'anat_ribbon',
151154
# Reverse transform; not computable from forward transform
152155
'std2anat_xfm',
@@ -1413,6 +1416,32 @@ def init_infant_anat_fit_wf(
14131416
else:
14141417
LOGGER.info('ANAT Stage 9: Found pre-computed fsLR registration sphere')
14151418
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'])
14161445
return workflow
14171446

14181447

@@ -1476,6 +1505,7 @@ def init_infant_single_anat_fit_wf(
14761505
'sphere_reg',
14771506
'sphere_reg_fsLR',
14781507
'sphere_reg_msm',
1508+
'cortex_mask',
14791509
'anat_ribbon',
14801510
# Reverse transform; not computable from forward transform
14811511
'std2anat_xfm',
@@ -2342,4 +2372,30 @@ def init_infant_single_anat_fit_wf(
23422372
else:
23432373
LOGGER.info('ANAT Stage 9: Found pre-computed fsLR registration sphere')
23442374
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'])
23452401
return workflow

nibabies/workflows/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,10 @@ def init_single_subject_wf(
809809

810810
if config.workflow.cifti_output:
811811
workflow.connect([
812+
(anat_fit_wf, bold_wf, [
813+
('outputnode.cortex_mask', 'inputnode.cortex_mask'),
814+
]),
812815
(anat_apply_wf, bold_wf, [
813-
('outputnode.roi', 'inputnode.cortex_mask'),
814816
('outputnode.midthickness_fsLR', 'inputnode.midthickness_fsLR'),
815817
('outputnode.anat_aseg', 'inputnode.anat_aseg'),
816818
]),

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ dependencies = [
2525
"nireports >= 23.2.0",
2626
"nitime",
2727
"nitransforms >= 24.1.1",
28-
#"niworkflows >= 1.13.1",
29-
"niworkflows @ git+https://github.com/nipreps/niworkflows.git@master",
28+
"niworkflows >= 1.14.1",
3029
"numpy >= 1.21.0",
3130
"packaging",
3231
"pandas < 3",
@@ -35,7 +34,7 @@ dependencies = [
3534
"pybids >= 0.15.0",
3635
"requests",
3736
"sdcflows >= 2.13.0",
38-
"smriprep >= 0.17.0",
37+
"smriprep >= 0.19.1",
3938
"tedana >= 23.0.2",
4039
"templateflow >= 24.2.0",
4140
"toml",

0 commit comments

Comments
 (0)