Skip to content

Commit 564f259

Browse files
feilongeffigies
authored andcommitted
Make init_resample_surfaces_wf call init_resample_surfaces_wb_wf to avoid duplicate code.
1 parent 11fbf84 commit 564f259

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

src/smriprep/workflows/surfaces.py

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ def init_resample_surfaces_wf(
14691469
``<surface>``
14701470
Left and right GIFTI surface mesh corresponding to the input surface, resampled to fsLR
14711471
"""
1472-
import templateflow.api as tf
1472+
# import templateflow.api as tf
14731473
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
14741474

14751475
workflow = Workflow(name=name)
@@ -1485,51 +1485,21 @@ def init_resample_surfaces_wf(
14851485
niu.IdentityInterface(fields=[f'{surf}_fsLR' for surf in surfaces]), name='outputnode'
14861486
)
14871487

1488-
surface_list = pe.Node(
1489-
niu.Merge(len(surfaces), ravel_inputs=True),
1490-
name='surface_list',
1491-
run_without_submitting=True,
1492-
)
1493-
1494-
resampler = pe.MapNode(
1495-
SurfaceResample(method='BARYCENTRIC'),
1496-
iterfield=['surface_in', 'current_sphere', 'new_sphere'],
1497-
name='resampler',
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',
14981493
)
1499-
resampler.inputs.new_sphere = [
1500-
str(
1501-
tf.get(
1502-
template='fsLR',
1503-
density=fslr_density,
1504-
suffix='sphere',
1505-
hemi=hemi,
1506-
space=None,
1507-
extension='.surf.gii',
1508-
)
1509-
)
1510-
# Order matters. Iterate over surfaces, then hemis to get L R L R L R
1511-
for _surf in surfaces
1512-
for hemi in ['L', 'R']
1513-
]
1514-
1515-
surface_groups = pe.Node(
1516-
niu.Split(splits=[2] * len(surfaces)),
1517-
name='surface_groups',
1518-
run_without_submitting=True,
1519-
)
1520-
15211494
workflow.connect([
1522-
(inputnode, surface_list, [
1523-
((surf, _sorted_by_basename), f'in{i}')
1524-
for i, surf in enumerate(surfaces, start=1)
1495+
(inputnode, resample_surfaces_wb_wf, [
1496+
(surf, 'inputnode.'+surf) for surf in surfaces
15251497
]),
1526-
(inputnode, resampler, [
1527-
(('sphere_reg_fsLR', _repeat, len(surfaces)), 'current_sphere'),
1498+
(inputnode, resample_surfaces_wb_wf, [
1499+
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
15281500
]),
1529-
(surface_list, resampler, [('out', 'surface_in')]),
1530-
(resampler, surface_groups, [('surface_out', 'inlist')]),
1531-
(surface_groups, outputnode, [
1532-
(f'out{i}', f'{surf}_fsLR') for i, surf in enumerate(surfaces, start=1)
1501+
(resample_surfaces_wb_wf, outputnode, [
1502+
(f'outputnode.{surf}_resampled', f'{surf}_fsLR') for surf in surfaces
15331503
]),
15341504
]) # fmt:skip
15351505

0 commit comments

Comments
 (0)