Skip to content

Commit add4d97

Browse files
committed
rf: Align resample_surfaces_wf arguments to templateflow.get
1 parent 71b43b9 commit add4d97

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/smriprep/workflows/anatomical.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ 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-
space='fsLR',
386385
density='32k' if cifti_output == '91k' else '59k',
387386
)
388387
morph_grayords_wf = init_morph_grayords_wf(

src/smriprep/workflows/surfaces.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,13 +1322,16 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'):
13221322

13231323
def init_resample_surfaces_wf(
13241324
surfaces: list[str],
1325+
template: str = 'fsLR',
1326+
cohort: str | None = None,
1327+
space: str | None = 'fsLR',
13251328
density: str | None = None,
13261329
grayord_density: str | None = None,
1327-
space: str = 'fsLR',
13281330
name: str = 'resample_surfaces_wf',
13291331
):
13301332
"""
1331-
Resample subject surfaces surface to specified space and density.
1333+
Resample subject surfaces surface to specified template space and density,
1334+
using a given registration space.
13321335
13331336
Workflow Graph
13341337
.. workflow::
@@ -1338,16 +1341,22 @@ def init_resample_surfaces_wf(
13381341
from smriprep.workflows.surfaces import init_resample_surfaces_wf
13391342
wf = init_resample_surfaces_wf(
13401343
surfaces=['white', 'pial', 'midthickness'],
1341-
space='onavg',
1344+
template='onavg',
13421345
density='10k',
13431346
)
13441347
13451348
Parameters
13461349
----------
13471350
surfaces : :class:`list` of :class:`str`
13481351
Names of surfaces (e.g., ``'white'``) to resample. Both hemispheres will be resampled.
1349-
space : :class:`str`
1350-
The space to resample to, e.g., ``'onavg'``, ``'fsLR'``.
1352+
template : :class:`str`
1353+
The template space to resample to, e.g., ``'onavg'``, ``'fsLR'``.
1354+
cohort : :class:`str` or :obj:`None`
1355+
The template cohort to use, if the template provides multiple.
1356+
space : :class:`str` or :obj:`None`
1357+
The registration space for which there are both subject and template
1358+
registration spheres.
1359+
If ``None``, the template space is used.
13511360
density : :class:`str`
13521361
The density to resample to, e.g., ``'10k'``, ``'41k'``. Number of vertices per hemisphere.
13531362
name : :class:`str`
@@ -1357,12 +1366,12 @@ def init_resample_surfaces_wf(
13571366
------
13581367
``<surface>``
13591368
Left and right GIFTIs for each surface name passed to ``surfaces``.
1360-
sphere_reg_fsLR
1361-
GIFTI surface mesh corresponding to the subject's fsLR registration sphere.
1369+
``sphere_reg_<space>``
1370+
GIFTI surface mesh corresponding to the subject's registration sphere to ``space``.
13621371
13631372
Outputs
13641373
-------
1365-
``<surface>``
1374+
``<surface>_<template>``
13661375
Left and right GIFTI surface mesh corresponding to the input surface, resampled to the
13671376
specified space and density.
13681377
"""
@@ -1383,12 +1392,13 @@ def init_resample_surfaces_wf(
13831392
workflow = Workflow(name=name)
13841393

13851394
inputnode = pe.Node(
1386-
niu.IdentityInterface(fields=[*surfaces, 'sphere_reg_fsLR']),
1395+
niu.IdentityInterface(fields=[*surfaces, f'sphere_reg_{space}']),
13871396
name='inputnode',
13881397
)
13891398

13901399
outputnode = pe.Node(
1391-
niu.IdentityInterface(fields=[f'{surf}_{space}' for surf in surfaces]), name='outputnode'
1400+
niu.IdentityInterface(fields=[f'{surf}_{template}' for surf in surfaces]),
1401+
name='outputnode',
13921402
)
13931403

13941404
surface_list = pe.Node(
@@ -1405,11 +1415,12 @@ def init_resample_surfaces_wf(
14051415
resampler.inputs.new_sphere = [
14061416
str(
14071417
tf.get(
1408-
template=space,
1418+
template=template,
1419+
cohort=cohort,
1420+
space=space if space != template else None,
1421+
hemi=hemi,
14091422
density=density,
14101423
suffix='sphere',
1411-
hemi=hemi,
1412-
space=(None if space == 'fsLR' else 'fsLR'),
14131424
extension='.surf.gii',
14141425
)
14151426
)
@@ -1430,12 +1441,12 @@ def init_resample_surfaces_wf(
14301441
for i, surf in enumerate(surfaces, start=1)
14311442
]),
14321443
(inputnode, resampler, [
1433-
(('sphere_reg_fsLR', _repeat, len(surfaces)), 'current_sphere'),
1444+
((f'sphere_reg_{space}', _repeat, len(surfaces)), 'current_sphere'),
14341445
]),
14351446
(surface_list, resampler, [('out', 'surface_in')]),
14361447
(resampler, surface_groups, [('surface_out', 'inlist')]),
14371448
(surface_groups, outputnode, [
1438-
(f'out{i}', f'{surf}_{space}') for i, surf in enumerate(surfaces, start=1)
1449+
(f'out{i}', f'{surf}_{template}') for i, surf in enumerate(surfaces, start=1)
14391450
]),
14401451
]) # fmt:skip
14411452

0 commit comments

Comments
 (0)