44import re
55import sys
66
7- from .conf import TF_LAYOUT , TF_S3_ROOT , TF_USE_DATALAD
7+ from .conf import TF_LAYOUT , TF_S3_ROOT , TF_USE_DATALAD , requires_layout
88
99
10+ @requires_layout
1011def get (template , raise_empty = False , ** kwargs ):
1112 """
1213 Fetch one file from one particular template.
@@ -61,10 +62,6 @@ def get(template, raise_empty=False, **kwargs):
6162 ...
6263
6364 """
64- if TF_LAYOUT is None :
65- from bids import __version__
66- raise RuntimeError (f"A layout with PyBIDS <{ __version__ } > could not be initiated" )
67-
6865 out_file = [
6966 Path (p ) for p in TF_LAYOUT .get (template = template , return_type = "file" , ** kwargs )
7067 ]
@@ -115,9 +112,10 @@ def get(template, raise_empty=False, **kwargs):
115112 return out_file
116113
117114
115+ @requires_layout
118116def templates (** kwargs ):
119117 """
120- Returns a list of available templates.
118+ Return a list of available templates.
121119
122120 Keyword Arguments
123121 -----------------
@@ -141,13 +139,10 @@ def templates(**kwargs):
141139 ['MNI152Lin', 'MNI152NLin2009cAsym', 'MNI152NLin2009cSym', 'MNIInfant', 'MNIPediatricAsym']
142140
143141 """
144- if TF_LAYOUT is None :
145- from bids import __version__
146- raise RuntimeError (f"A layout with PyBIDS <{ __version__ } > could not be initiated" )
147-
148142 return sorted (TF_LAYOUT .get_templates (** kwargs ))
149143
150144
145+ @requires_layout
151146def get_metadata (template ):
152147 """
153148 Fetch one file from one template.
@@ -163,10 +158,6 @@ def get_metadata(template):
163158 'Linear ICBM Average Brain (ICBM152) Stereotaxic Registration Model'
164159
165160 """
166- if TF_LAYOUT is None :
167- from bids import __version__
168- raise RuntimeError (f"A layout with PyBIDS <{ __version__ } > could not be initiated" )
169-
170161 tf_home = Path (TF_LAYOUT .root )
171162 filepath = tf_home / ("tpl-%s" % template ) / "template_description.json"
172163
0 commit comments