Skip to content

Commit 5166979

Browse files
mgxdeffigies
authored andcommitted
FIX: Fetch templates during workflow construction
1 parent 97f4556 commit 5166979

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

smriprep/interfaces/templateflow.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ def _run_interface(self, runtime):
163163
return runtime
164164

165165

166-
def fetch_template_files(template: str, specs: dict | None = None) -> dict:
166+
def fetch_template_files(
167+
template: str,
168+
specs: dict | None = None,
169+
sloppy: bool = False,
170+
) -> dict:
167171
if specs is None:
168172
specs = {}
169173

@@ -178,11 +182,18 @@ def fetch_template_files(template: str, specs: dict | None = None) -> dict:
178182
}
179183
)
180184

181-
if specs['resolution'] and not isinstance(specs['resolution'], list):
185+
if res := specs.pop('res', None):
186+
if res != 'native':
187+
specs['resolution'] = res
188+
189+
if not specs.get('resolution'):
190+
specs['resolution'] = 2 if sloppy else 1
191+
192+
if specs.get('resolution') and not isinstance(specs['resolution'], list):
182193
specs['resolution'] = [specs['resolution']]
183194

184195
available_resolutions = tf.TF_LAYOUT.get_resolutions(template=name[0])
185-
if specs['resolution'] and not set(specs['resolution']) & set(available_resolutions):
196+
if specs.get('resolution') and not set(specs['resolution']) & set(available_resolutions):
186197
fallback_res = available_resolutions[0] if available_resolutions else None
187198
LOGGER.warning(
188199
f"Template {name[0]} does not have resolution(s): {specs['resolution']}."

smriprep/workflows/anatomical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,9 @@ def init_anat_fit_wf(
974974
templates = []
975975
found_xfms = {}
976976
for template in spaces.get_spaces(nonstandard=False, dim=(3,)):
977-
from ..utils.misc import get_template_t1w
977+
from smriprep.interfaces.templateflow import fetch_template_files
978978

979-
get_template_t1w(template, sloppy)
979+
fetch_template_files(template, specs=None, sloppy=sloppy)
980980
xfms = precomputed.get('transforms', {}).get(template, {})
981981
if set(xfms) != {'forward', 'reverse'}:
982982
templates.append(template)

0 commit comments

Comments
 (0)