Skip to content

Commit e351f9a

Browse files
mgxdeffigies
authored andcommitted
RF: Move template fetching to iterator workflow, adhere to style
1 parent 5166979 commit e351f9a

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

smriprep/interfaces/templateflow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ def fetch_template_files(
203203

204204
files = {}
205205
files['t1w'] = tf.get(name[0], desc=None, suffix='T1w', **specs)
206-
files['mask'] = (
207-
tf.get(name[0], desc='brain', suffix='mask', **specs)
208-
or tf.get(name[0], label='brain', suffix='mask', **specs)
206+
files['mask'] = tf.get(name[0], desc='brain', suffix='mask', **specs) or tf.get(
207+
name[0], label='brain', suffix='mask', **specs
209208
)
210209
return files

smriprep/utils/misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#
2323
"""Self-contained utilities to be used within Function nodes."""
2424

25+
2526
def apply_lut(in_dseg, lut, newpath=None):
2627
"""Map the input discrete segmentation to a new label set (lookup table, LUT)."""
2728
import nibabel as nb

smriprep/workflows/anatomical.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,6 @@ def init_anat_fit_wf(
974974
templates = []
975975
found_xfms = {}
976976
for template in spaces.get_spaces(nonstandard=False, dim=(3,)):
977-
from smriprep.interfaces.templateflow import fetch_template_files
978-
979-
fetch_template_files(template, specs=None, sloppy=sloppy)
980977
xfms = precomputed.get('transforms', {}).get(template, {})
981978
if set(xfms) != {'forward', 'reverse'}:
982979
templates.append(template)

smriprep/workflows/outputs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,7 @@ def init_anat_second_derivatives_wf(
11161116

11171117

11181118
def init_template_iterator_wf(
1119-
*,
1120-
spaces: 'SpatialReferences',
1121-
sloppy: bool = False,
1122-
name='template_iterator_wf'
1119+
*, spaces: 'SpatialReferences', sloppy: bool = False, name='template_iterator_wf'
11231120
):
11241121
"""Prepare the necessary components to resample an image to a template space
11251122
@@ -1130,6 +1127,11 @@ def init_template_iterator_wf(
11301127
11311128
The fields in `outputnode` can be used as if they come from a single template.
11321129
"""
1130+
for template in spaces.get_spaces(nonstandard=False, dim=(3,)):
1131+
from smriprep.interfaces.templateflow import fetch_template_files
1132+
1133+
fetch_template_files(template, specs=None, sloppy=sloppy)
1134+
11331135
workflow = pe.Workflow(name=name)
11341136

11351137
inputnode = pe.Node(
@@ -1167,9 +1169,7 @@ def init_template_iterator_wf(
11671169
name='select_xfm',
11681170
run_without_submitting=True,
11691171
)
1170-
select_tpl = pe.Node(
1171-
TemplateFlowSelect(), name='select_tpl', run_without_submitting=True
1172-
)
1172+
select_tpl = pe.Node(TemplateFlowSelect(), name='select_tpl', run_without_submitting=True)
11731173

11741174
# fmt:off
11751175
workflow.connect([

0 commit comments

Comments
 (0)