@@ -62,6 +62,7 @@ def process_extra_commands(outdir, args):
62
62
for f in args .files :
63
63
treat_infofile (f )
64
64
elif args .command == 'ls' :
65
+ ensure_heuristic_arg (args )
65
66
heuristic = load_heuristic (args .heuristic )
66
67
heuristic_ls = getattr (heuristic , 'ls' , None )
67
68
for f in args .files :
@@ -78,6 +79,7 @@ def process_extra_commands(outdir, args):
78
79
% (str (study_session ), len (sequences ), suf )
79
80
)
80
81
elif args .command == 'populate-templates' :
82
+ ensure_heuristic_arg (args )
81
83
heuristic = load_heuristic (args .heuristic )
82
84
for f in args .files :
83
85
populate_bids_templates (f , getattr (heuristic , 'DEFAULT_FIELDS' , {}))
@@ -88,16 +90,21 @@ def process_extra_commands(outdir, args):
88
90
for name_desc in get_known_heuristics_with_descriptions ().items ():
89
91
print ("- %s: %s" % name_desc )
90
92
elif args .command == 'heuristic-info' :
91
- from ..utils import get_heuristic_description , get_known_heuristic_names
92
- if not args .heuristic :
93
- raise ValueError ("Specify heuristic using -f. Known are: %s"
94
- % ', ' .join (get_known_heuristic_names ()))
93
+ ensure_heuristic_arg (args )
94
+ from ..utils import get_heuristic_description
95
95
print (get_heuristic_description (args .heuristic , full = True ))
96
96
else :
97
97
raise ValueError ("Unknown command %s" , args .command )
98
98
return
99
99
100
100
101
+ def ensure_heuristic_arg (args ):
102
+ from ..utils import get_known_heuristic_names
103
+ if not args .heuristic :
104
+ raise ValueError ("Specify heuristic using -f. Known are: %s"
105
+ % ', ' .join (get_known_heuristic_names ()))
106
+
107
+
101
108
def main (argv = None ):
102
109
parser = get_parser ()
103
110
args = parser .parse_args (argv )
0 commit comments