29
29
"""
30
30
31
31
import typing as ty
32
+ import warnings
32
33
33
34
from nipype .interfaces import freesurfer as fs
34
35
from nipype .interfaces import io as nio
@@ -1398,11 +1399,16 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'):
1398
1399
1399
1400
def init_resample_surfaces_wf (
1400
1401
surfaces : list [str ],
1401
- grayord_density : ty .Literal ['91k' , '170k' ],
1402
+ template : str = 'fsLR' ,
1403
+ cohort : str | None = None ,
1404
+ space : str | None = 'fsLR' ,
1405
+ density : str | None = None ,
1406
+ grayord_density : str | None = None ,
1402
1407
name : str = 'resample_surfaces_wf' ,
1403
1408
):
1404
1409
"""
1405
- Resample subject surfaces surface to specified density.
1410
+ Resample subject surfaces surface to specified template space and density,
1411
+ using a given registration space.
1406
1412
1407
1413
Workflow Graph
1408
1414
.. workflow::
@@ -1412,44 +1418,64 @@ def init_resample_surfaces_wf(
1412
1418
from smriprep.workflows.surfaces import init_resample_surfaces_wf
1413
1419
wf = init_resample_surfaces_wf(
1414
1420
surfaces=['white', 'pial', 'midthickness'],
1415
- grayord_density='91k',
1421
+ template='onavg',
1422
+ density='10k',
1416
1423
)
1417
1424
1418
1425
Parameters
1419
1426
----------
1420
1427
surfaces : :class:`list` of :class:`str`
1421
1428
Names of surfaces (e.g., ``'white'``) to resample. Both hemispheres will be resampled.
1422
- grayord_density : :class:`str`
1423
- Either `91k` or `170k`, representing the total of vertices or *grayordinates*.
1429
+ template : :class:`str`
1430
+ The template space to resample to, e.g., ``'onavg'``, ``'fsLR'``.
1431
+ cohort : :class:`str` or :obj:`None`
1432
+ The template cohort to use, if the template provides multiple.
1433
+ space : :class:`str` or :obj:`None`
1434
+ The registration space for which there are both subject and template
1435
+ registration spheres.
1436
+ If ``None``, the template space is used.
1437
+ density : :class:`str`
1438
+ The density to resample to, e.g., ``'10k'``, ``'41k'``. Number of vertices per hemisphere.
1424
1439
name : :class:`str`
1425
1440
Unique name for the subworkflow (default: ``"resample_surfaces_wf"``)
1426
1441
1427
1442
Inputs
1428
1443
------
1429
1444
``<surface>``
1430
- Left and right GIFTIs for each surface name passed to ``surfaces``
1431
- sphere_reg_fsLR
1432
- GIFTI surface mesh corresponding to the subject's fsLR registration sphere
1445
+ Left and right GIFTIs for each surface name passed to ``surfaces``.
1446
+ ``sphere_reg_<space>``
1447
+ GIFTI surface mesh corresponding to the subject's registration sphere to ``space``.
1433
1448
1434
1449
Outputs
1435
1450
-------
1436
- ``<surface>``
1437
- Left and right GIFTI surface mesh corresponding to the input surface, resampled to fsLR
1451
+ ``<surface>_<template>``
1452
+ Left and right GIFTI surface mesh corresponding to the input surface, resampled to the
1453
+ specified space and density.
1438
1454
"""
1439
1455
import templateflow .api as tf
1440
1456
from niworkflows .engine .workflows import LiterateWorkflow as Workflow
1441
1457
1442
- workflow = Workflow (name = name )
1458
+ if density is None :
1459
+ if grayord_density is None :
1460
+ raise ValueError ('No density specified. Set density argument.' )
1461
+ density = '32k' if grayord_density == '91k' else '59k'
1462
+ warnings .warn (
1463
+ 'Deprecated grayord_density passed. Replace with\n \t '
1464
+ "density='32k' if grayord_density == '91k' else '59k'" ,
1465
+ DeprecationWarning ,
1466
+ stacklevel = 2 ,
1467
+ )
1443
1468
1444
- fslr_density = '32k' if grayord_density == '91k' else '59k'
1469
+ workflow = Workflow ( name = name )
1445
1470
1446
1471
inputnode = pe .Node (
1447
- niu .IdentityInterface (fields = [* surfaces , 'sphere_reg_fsLR ' ]),
1472
+ niu .IdentityInterface (fields = [* surfaces , f'sphere_reg_ { space } ' ]),
1448
1473
name = 'inputnode' ,
1449
1474
)
1450
1475
1451
1476
outputnode = pe .Node (
1452
- niu .IdentityInterface (fields = [f'{ surf } _fsLR' for surf in surfaces ]), name = 'outputnode'
1477
+ niu .IdentityInterface (fields = [f'{ surf } _{ template } ' for surf in surfaces ]),
1478
+ name = 'outputnode' ,
1453
1479
)
1454
1480
1455
1481
surface_list = pe .Node (
@@ -1466,11 +1492,12 @@ def init_resample_surfaces_wf(
1466
1492
resampler .inputs .new_sphere = [
1467
1493
str (
1468
1494
tf .get (
1469
- template = 'fsLR' ,
1470
- density = fslr_density ,
1471
- suffix = 'sphere' ,
1495
+ template = template ,
1496
+ cohort = cohort ,
1497
+ space = space if space != template else None ,
1472
1498
hemi = hemi ,
1473
- space = None ,
1499
+ density = density ,
1500
+ suffix = 'sphere' ,
1474
1501
extension = '.surf.gii' ,
1475
1502
)
1476
1503
)
@@ -1491,12 +1518,12 @@ def init_resample_surfaces_wf(
1491
1518
for i , surf in enumerate (surfaces , start = 1 )
1492
1519
]),
1493
1520
(inputnode , resampler , [
1494
- (('sphere_reg_fsLR ' , _repeat , len (surfaces )), 'current_sphere' ),
1521
+ ((f'sphere_reg_ { space } ' , _repeat , len (surfaces )), 'current_sphere' ),
1495
1522
]),
1496
1523
(surface_list , resampler , [('out' , 'surface_in' )]),
1497
1524
(resampler , surface_groups , [('surface_out' , 'inlist' )]),
1498
1525
(surface_groups , outputnode , [
1499
- (f'out{ i } ' , f'{ surf } _fsLR ' ) for i , surf in enumerate (surfaces , start = 1 )
1526
+ (f'out{ i } ' , f'{ surf } _ { template } ' ) for i , surf in enumerate (surfaces , start = 1 )
1500
1527
]),
1501
1528
]) # fmt:skip
1502
1529
0 commit comments