FastSurferCNN.utils.parser_defaults¶
Contains the ALL_FLAGS dictionary, which can be used as follows to add default flags.
>>> parser = argparse.ArgumentParser()
>>> ALL_FLAGS["allow_root"](parser, dest="root")
>>> args = parser.parse_args()
>>> allows_root = args.root # instead of the default dest args.allow_root
Values can also be extracted by >>> print(ALL_FLAGS[“allow_root”](dict, dest=”root”) >>> # {‘flag’: ‘–allow_root’, ‘flags’: (’–allow_root’,), ‘action’: ‘store_true’, >>> # ‘dest’: ‘root’, ‘help’: ‘Allow execution as root user.’}
- class FastSurferCNN.utils.parser_defaults.CanAddArguments(*args, **kwargs)[source]¶
Methods
add_argument
(*args, **kwargs)Add an argument to the object.
- class FastSurferCNN.utils.parser_defaults.SubjectDirectoryConfig(orig_name='mri/orig.mgz', pred_name='mri/aparc.DKTatlas+aseg.deep.mgz', conf_name='mri/orig.mgz', in_dir=None, csv_file=None, sid=None, search_tag='*', brainmask_name='mri/mask.mgz', remove_suffix='', out_dir=None)[source]¶
This class describes the ‘minimal’ parameters used by SubjectList.
Attributes
csv_file
in_dir
out_dir
sid
Notes
Important: Data Types of fields should stay
Optional[<TYPE>]
and not be replaced by<TYPE> | None
, so the Parser can use the type in argparse as the value fortype
ofparser.add_argument()
(Optional
is a callable, whileUnion
is not).
- FastSurferCNN.utils.parser_defaults.add_arguments(parser, flags)[source]¶
Add default flags to the parser from the flags list in order.
- Parameters:
- parser
T_AddArgs
The parser to add flags to.
- flags
Iterable
[str
] The flags to add from ‘device’, ‘viewagg_device’.
- parser
- Returns:
T_AddArgs
The parser object.
- Raises:
RuntimeError
If parser does not support a call to add_argument.
- FastSurferCNN.utils.parser_defaults.add_plane_flags(parser, configtype, files, defaults_path)[source]¶
Add plane arguments.
Arguments will be added for each entry in files, where the key is the “plane” and the values is the file name (relative for path relative to FASTSURFER_HOME.
- Parameters:
- parser
argparse.ArgumentParser
The parser to add flags to.
- configtype
Literal
[“checkpoint”, “config”] The type of files (for help text and prefix from “checkpoint” and “config”. “checkpoint” will lead to flags like “–ckpt_{plane}”, “config” to “–cfg_{plane}”.
- files
Mapping
[Plane
,Path
|str
] A dictionary of plane to filename. Relative files are assumed to be relative to the FastSurfer root directory.
- defaults_path
Path
,str
A path to the file to load defaults from.
- parser
- Returns:
argparse.ArgumentParser
The parser object.