@@ -23,6 +23,13 @@ def _path_exists(path, parser):
2323 raise parser .error (f"Path does not exist: <{ path } >." )
2424 return Path (path ).absolute ()
2525
26+ def _is_file (path , parser ):
27+ """Ensure a given path exists and it is a file."""
28+ path = _path_exists (path , parser )
29+ if not path .is_file ():
30+ raise parser .error (f"Path should point to a file (or symlink of file): <{ path } >." )
31+ return path
32+
2633 def _min_one (value , parser ):
2734 """Ensure an argument is not lower than 1."""
2835 value = int (value )
@@ -63,6 +70,7 @@ def _bids_filter(value):
6370 formatter_class = ArgumentDefaultsHelpFormatter ,
6471 )
6572 PathExists = partial (_path_exists , parser = parser )
73+ IsFile = partial (_is_file , parser = parser )
6674 PositiveInt = partial (_min_one , parser = parser )
6775
6876 # Arguments as specified by BIDS-Apps
@@ -128,7 +136,7 @@ def _bids_filter(value):
128136 dest = "bids_filters" ,
129137 action = "store" ,
130138 type = _bids_filter ,
131- metavar = "PATH " ,
139+ metavar = "FILE " ,
132140 help = "a JSON file describing custom BIDS input filters using PyBIDS. "
133141 "For further details, please check out "
134142 "https://fmriprep.readthedocs.io/en/%s/faq.html#"
@@ -178,8 +186,10 @@ def _bids_filter(value):
178186 )
179187 g_perfm .add_argument (
180188 "--use-plugin" ,
189+ "--nipype-plugin-file" ,
181190 action = "store" ,
182- default = None ,
191+ metavar = "FILE" ,
192+ type = IsFile ,
183193 help = "nipype plugin configuration file" ,
184194 )
185195 g_perfm .add_argument (
@@ -414,8 +424,8 @@ def _bids_filter(value):
414424 g_fs = parser .add_argument_group ("Specific options for FreeSurfer preprocessing" )
415425 g_fs .add_argument (
416426 "--fs-license-file" ,
417- metavar = "PATH " ,
418- type = PathExists ,
427+ metavar = "FILE " ,
428+ type = IsFile ,
419429 help = "Path to FreeSurfer license key file. Get it (for free) by registering"
420430 " at https://surfer.nmr.mgh.harvard.edu/registration.html" ,
421431 )
@@ -551,7 +561,6 @@ def parse_args(args=None, namespace=None):
551561 """Parse args and run further checks on the command line."""
552562 import logging
553563 from niworkflows .utils .spaces import Reference , SpatialReferences
554- from niworkflows .utils .misc import check_valid_fs_license
555564
556565 parser = _build_parser ()
557566 opts = parser .parse_args (args , namespace )
@@ -567,15 +576,6 @@ def parse_args(args=None, namespace=None):
567576 # Retrieve logging level
568577 build_log = config .loggers .cli
569578
570- if not check_valid_fs_license (lic = config .execution .fs_license_file ):
571- raise RuntimeError (
572- """\
573- ERROR: a valid license file is required for FreeSurfer to run. fMRIPrep looked for an existing \
574- license file at several paths, in this order: 1) command line argument ``--fs-license-file``; \
575- 2) ``$FS_LICENSE`` environment variable; and 3) the ``$FREESURFER_HOME/license.txt`` path. Get it \
576- (for free) by registering at https://surfer.nmr.mgh.harvard.edu/registration.html"""
577- )
578-
579579 # Load base plugin_settings from file if --use-plugin
580580 if opts .use_plugin is not None :
581581 import yaml
0 commit comments