Skip to content

Commit 9e96316

Browse files
committed
rf: Use new resample_surfaces workflow directly
1 parent 564f259 commit 9e96316

File tree

2 files changed

+9
-85
lines changed

2 files changed

+9
-85
lines changed

src/smriprep/workflows/anatomical.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ def init_anat_preproc_wf(
382382
hcp_morphometrics_wf = init_hcp_morphometrics_wf(omp_nthreads=omp_nthreads)
383383
resample_surfaces_wf = init_resample_surfaces_wf(
384384
surfaces=['white', 'pial', 'midthickness'],
385-
grayord_density=cifti_output,
385+
space='fsLR',
386+
density='32k' if cifti_output == '91k' else '59k',
386387
)
387388
morph_grayords_wf = init_morph_grayords_wf(
388389
grayord_density=cifti_output, omp_nthreads=omp_nthreads

src/smriprep/workflows/surfaces.py

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,11 +1319,11 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'):
13191319
return workflow
13201320

13211321

1322-
def init_resample_surfaces_wb_wf(
1322+
def init_resample_surfaces_wf(
13231323
surfaces: list[str],
13241324
space: str,
13251325
density: str,
1326-
name: str = 'resample_surfaces_wb_wf',
1326+
name: str = 'resample_surfaces_wf',
13271327
):
13281328
"""
13291329
Resample subject surfaces surface to specified space and density.
@@ -1333,8 +1333,8 @@ def init_resample_surfaces_wb_wf(
13331333
:graph2use: colored
13341334
:simple_form: yes
13351335
1336-
from smriprep.workflows.surfaces import init_resample_surfaces_wb_wf
1337-
wf = init_resample_surfaces_wb_wf(
1336+
from smriprep.workflows.surfaces import init_resample_surfaces_wf
1337+
wf = init_resample_surfaces_wf(
13381338
surfaces=['white', 'pial', 'midthickness'],
13391339
space='onavg',
13401340
density='10k',
@@ -1349,7 +1349,7 @@ def init_resample_surfaces_wb_wf(
13491349
density : :class:`str`
13501350
The density to resample to, e.g., ``'10k'``, ``'41k'``. Number of vertices per hemisphere.
13511351
name : :class:`str`
1352-
Unique name for the subworkflow (default: ``"resample_surfaces_wb_wf"``)
1352+
Unique name for the subworkflow (default: ``"resample_surfaces_wf"``)
13531353
13541354
Inputs
13551355
------
@@ -1375,7 +1375,7 @@ def init_resample_surfaces_wb_wf(
13751375
)
13761376

13771377
outputnode = pe.Node(
1378-
niu.IdentityInterface(fields=[f'{surf}_resampled' for surf in surfaces]), name='outputnode'
1378+
niu.IdentityInterface(fields=[f'{surf}_{space}' for surf in surfaces]), name='outputnode'
13791379
)
13801380

13811381
surface_list = pe.Node(
@@ -1422,84 +1422,7 @@ def init_resample_surfaces_wb_wf(
14221422
(surface_list, resampler, [('out', 'surface_in')]),
14231423
(resampler, surface_groups, [('surface_out', 'inlist')]),
14241424
(surface_groups, outputnode, [
1425-
(f'out{i}', f'{surf}_resampled') for i, surf in enumerate(surfaces, start=1)
1426-
]),
1427-
]) # fmt:skip
1428-
1429-
return workflow
1430-
1431-
1432-
def init_resample_surfaces_wf(
1433-
surfaces: list[str],
1434-
grayord_density: ty.Literal['91k', '170k'],
1435-
name: str = 'resample_surfaces_wf',
1436-
):
1437-
"""
1438-
Resample subject surfaces surface to specified density.
1439-
1440-
Workflow Graph
1441-
.. workflow::
1442-
:graph2use: colored
1443-
:simple_form: yes
1444-
1445-
from smriprep.workflows.surfaces import init_resample_surfaces_wf
1446-
wf = init_resample_surfaces_wf(
1447-
surfaces=['white', 'pial', 'midthickness'],
1448-
grayord_density='91k',
1449-
)
1450-
1451-
Parameters
1452-
----------
1453-
surfaces : :class:`list` of :class:`str`
1454-
Names of surfaces (e.g., ``'white'``) to resample. Both hemispheres will be resampled.
1455-
grayord_density : :class:`str`
1456-
Either `91k` or `170k`, representing the total of vertices or *grayordinates*.
1457-
name : :class:`str`
1458-
Unique name for the subworkflow (default: ``"resample_surfaces_wf"``)
1459-
1460-
Inputs
1461-
------
1462-
``<surface>``
1463-
Left and right GIFTIs for each surface name passed to ``surfaces``
1464-
sphere_reg_fsLR
1465-
GIFTI surface mesh corresponding to the subject's fsLR registration sphere
1466-
1467-
Outputs
1468-
-------
1469-
``<surface>``
1470-
Left and right GIFTI surface mesh corresponding to the input surface, resampled to fsLR
1471-
"""
1472-
# import templateflow.api as tf
1473-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
1474-
1475-
workflow = Workflow(name=name)
1476-
1477-
fslr_density = '32k' if grayord_density == '91k' else '59k'
1478-
1479-
inputnode = pe.Node(
1480-
niu.IdentityInterface(fields=[*surfaces, 'sphere_reg_fsLR']),
1481-
name='inputnode',
1482-
)
1483-
1484-
outputnode = pe.Node(
1485-
niu.IdentityInterface(fields=[f'{surf}_fsLR' for surf in surfaces]), name='outputnode'
1486-
)
1487-
1488-
resample_surfaces_wb_wf = init_resample_surfaces_wb_wf(
1489-
surfaces=surfaces,
1490-
space='fsLR',
1491-
density=fslr_density,
1492-
name='resample_surfaces_fslr_wb_wf',
1493-
)
1494-
workflow.connect([
1495-
(inputnode, resample_surfaces_wb_wf, [
1496-
(surf, 'inputnode.'+surf) for surf in surfaces
1497-
]),
1498-
(inputnode, resample_surfaces_wb_wf, [
1499-
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
1500-
]),
1501-
(resample_surfaces_wb_wf, outputnode, [
1502-
(f'outputnode.{surf}_resampled', f'{surf}_fsLR') for surf in surfaces
1425+
(f'out{i}', f'{surf}_{space}') for i, surf in enumerate(surfaces, start=1)
15031426
]),
15041427
]) # fmt:skip
15051428

0 commit comments

Comments
 (0)