Skip to content

Commit 4444b76

Browse files
committed
ENH: Query the templateflow layout rather than metadata
1 parent 542f5e9 commit 4444b76

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

smriprep/interfaces/templateflow.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,17 @@ def _run_interface(self, runtime):
121121
}
122122
)
123123

124-
metadata = tf.get_metadata(name[0])
125-
if "res" not in metadata and "resolution" not in metadata:
126-
# template does not have any resolution fields
127-
LOGGER.warning(f"Template {name[0]} does not include any resolution information.")
128-
specs["resolution"] = None
124+
if specs['resolution'] and not isinstance(specs['resolution'], list):
125+
specs['resolution'] = [specs['resolution']]
126+
127+
available_resolutions = tf.TF_LAYOUT.get_resolutions(template=name[0])
128+
if specs['resolution'] and not set(specs["resolution"]) & set(available_resolutions):
129+
fallback_res = available_resolutions[0] if available_resolutions else None
130+
LOGGER.warning(
131+
f"Template {name[0]} does not have resolution(s): {specs['resolution']}."
132+
f"Falling back to resolution: {fallback_res}."
133+
)
134+
specs["resolution"] = fallback_res
129135

130136
self._results["t1w_file"] = tf.get(name[0], desc=None, suffix="T1w", **specs)
131137

0 commit comments

Comments
 (0)