diff --git a/src/smriprep/workflows/anatomical.py b/src/smriprep/workflows/anatomical.py index 0a9c3c7311..18d12620e2 100644 --- a/src/smriprep/workflows/anatomical.py +++ b/src/smriprep/workflows/anatomical.py @@ -382,7 +382,8 @@ def init_anat_preproc_wf( hcp_morphometrics_wf = init_hcp_morphometrics_wf(omp_nthreads=omp_nthreads) resample_surfaces_wf = init_resample_surfaces_wf( surfaces=['white', 'pial', 'midthickness'], - grayord_density=cifti_output, + space='fsLR', + density='32k' if cifti_output == '91k' else '59k', ) morph_grayords_wf = init_morph_grayords_wf( grayord_density=cifti_output, omp_nthreads=omp_nthreads diff --git a/src/smriprep/workflows/surfaces.py b/src/smriprep/workflows/surfaces.py index 28c3ea6ca8..f80880fd19 100644 --- a/src/smriprep/workflows/surfaces.py +++ b/src/smriprep/workflows/surfaces.py @@ -29,6 +29,7 @@ """ import typing as ty +import warnings from nipype.interfaces import freesurfer as fs from nipype.interfaces import io as nio @@ -1318,11 +1319,13 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'): def init_resample_surfaces_wf( surfaces: list[str], - grayord_density: ty.Literal['91k', '170k'], + density: str | None = None, + grayord_density: str | None = None, + space: str = 'fsLR', name: str = 'resample_surfaces_wf', ): """ - Resample subject surfaces surface to specified density. + Resample subject surfaces surface to specified space and density. Workflow Graph .. workflow:: @@ -1332,36 +1335,49 @@ def init_resample_surfaces_wf( from smriprep.workflows.surfaces import init_resample_surfaces_wf wf = init_resample_surfaces_wf( surfaces=['white', 'pial', 'midthickness'], - grayord_density='91k', + space='onavg', + density='10k', ) Parameters ---------- surfaces : :class:`list` of :class:`str` Names of surfaces (e.g., ``'white'``) to resample. Both hemispheres will be resampled. - grayord_density : :class:`str` - Either `91k` or `170k`, representing the total of vertices or *grayordinates*. + space : :class:`str` + The space to resample to, e.g., ``'onavg'``, ``'fsLR'``. + density : :class:`str` + The density to resample to, e.g., ``'10k'``, ``'41k'``. Number of vertices per hemisphere. name : :class:`str` Unique name for the subworkflow (default: ``"resample_surfaces_wf"``) Inputs ------ ```` - Left and right GIFTIs for each surface name passed to ``surfaces`` + Left and right GIFTIs for each surface name passed to ``surfaces``. sphere_reg_fsLR - GIFTI surface mesh corresponding to the subject's fsLR registration sphere + GIFTI surface mesh corresponding to the subject's fsLR registration sphere. Outputs ------- ```` - Left and right GIFTI surface mesh corresponding to the input surface, resampled to fsLR + Left and right GIFTI surface mesh corresponding to the input surface, resampled to the + specified space and density. """ import templateflow.api as tf from niworkflows.engine.workflows import LiterateWorkflow as Workflow - workflow = Workflow(name=name) + if density is None: + if grayord_density is None: + raise ValueError('No density specified. Set density argument.') + density = '32k' if grayord_density == '91k' else '59k' + warnings.warn( + 'Deprecated grayord_density passed. Replace with\n\t' + "density='32k' if grayord_density == '91k' else '59k'", + DeprecationWarning, + stacklevel=2, + ) - fslr_density = '32k' if grayord_density == '91k' else '59k' + workflow = Workflow(name=name) inputnode = pe.Node( niu.IdentityInterface(fields=[*surfaces, 'sphere_reg_fsLR']), @@ -1369,7 +1385,7 @@ def init_resample_surfaces_wf( ) outputnode = pe.Node( - niu.IdentityInterface(fields=[f'{surf}_fsLR' for surf in surfaces]), name='outputnode' + niu.IdentityInterface(fields=[f'{surf}_{space}' for surf in surfaces]), name='outputnode' ) surface_list = pe.Node( @@ -1386,11 +1402,11 @@ def init_resample_surfaces_wf( resampler.inputs.new_sphere = [ str( tf.get( - template='fsLR', - density=fslr_density, + template=space, + density=density, suffix='sphere', hemi=hemi, - space=None, + space=(None if space == 'fsLR' else 'fsLR'), extension='.surf.gii', ) ) @@ -1416,7 +1432,7 @@ def init_resample_surfaces_wf( (surface_list, resampler, [('out', 'surface_in')]), (resampler, surface_groups, [('surface_out', 'inlist')]), (surface_groups, outputnode, [ - (f'out{i}', f'{surf}_fsLR') for i, surf in enumerate(surfaces, start=1) + (f'out{i}', f'{surf}_{space}') for i, surf in enumerate(surfaces, start=1) ]), ]) # fmt:skip