magmap.io.cli module¶
Command line parser and and environment setup for MagellanMapper.
This module can be run either as a script to work in headless mode or loaded and initialized by calling main().
Note on dimensions order: User-defined dimension variables are generally given in (x, y, z) order as per normal convention, but otherwise dimensions are generally in (z, y, x) for consistency with microscopy order and ease of processing stacks by z.
Examples
Launch in headless mode with the given file at a particular size and offset:
$ python -m magmap.cli --img /path/to/file.czi --offset 30,50,205 \
--size 150,150,10
For a table of command-line arguments and their usage, see: https://github.com/sanderslab/magellanmapper/blob/master/docs/cli.md
- magmap.io.cli.args_to_dict(args, keys, args_dict=None, sep_args='=', sep_vals=',', default=None)[source]¶
Parse positional and keyword-based arguments to an enum-keyed dictionary.
- Parameters:
args (
List[str]) – List of arguments with positional values followed bysep_args-delimited values. Positional values will be entered in the existing order ofkeysbased on member values, while keyword-based values will be entered if a member corresponding to the keyword exists. Entries can also besep_vals-delimited to specify lists.keys (
Union[Type[Enum],Type[TypeVar(DataClass, bound=DataClassProtocol)]]) – Enum class or data class instance whose fields will be used as keys for dictionary. Enum values are assumed to range from 1 to number of members as output by the default Enum functional API.args_dict (
Optional[Dict[Enum,Any]], default:None) – Dictionary to be filled or updated with keys fromkeys_enum. Defaults to None, which will assign an empty dict. Ignored ifkeys_classis a data class instance, which will be updated instead.sep_args (
str, default:'=') – Separator between arguments and values; defaults to “=”.sep_vals (
str, default:',') – Separator within values; defaults to “,”.default (
Optional[Any], default:None) – Default value for each argument. Effectively turns off positional argument assignments since all args become<keyword>=<default>. Defaults to None. If a str, will undergo splitting bysep_vals.
- Return type:
Union[Dict[Enum,Any],Type[TypeVar(DataClass, bound=DataClassProtocol)]]- Returns:
Dictionary or data class corresponding to
keys, filled with arguments. Values that contain commas will be split into comma-delimited lists. All values will be converted to ints if possible.
- magmap.io.cli.args_with_dict(args)[source]¶
Parse arguments list with optional arguments given as dictionary-like elements.
- Parameters:
args (
List[str]) – List of arguments, which can be single values or “=” delimited values. Single values will be stored in the same order, while delimited entries will be entered sequentially into a dictionary. Entries can also be comma-delimited to specify lists.- Return type:
- Returns:
List of arguments ordered first with single-value entries in the same order in which they were entered, followed by a dictionary with all equals-delimited entries, also in the same order as entered. Entries that contain commas will be split into comma-delimited lists. All values will be converted to ints if possible.
- magmap.io.cli.main(process_args_only=False, skip_dbs=False)[source]¶
Starts the visualization GUI.
Processes command-line arguments.
- magmap.io.cli.process_cli_args()[source]¶
Parse command-line arguments.
Typically stores values as
magmap.settings.configattributes.
- magmap.io.cli.process_file(path, proc_type, proc_val=None, series=None, subimg_offset=None, subimg_size=None, roi_offset=None, roi_size=None)[source]¶
Processes a single image file non-interactively.
Assumes that the image has already been set up.
- Parameters:
path (
str) – Path to image from which MagellanMapper-style paths will be generated.proc_type (
Enum) – Processing type, which should be a one ofconfig.ProcessTypes.proc_val (
Optional[Any], default:None) – Processing value associated withproc_type; defaults to None.series (
Optional[int], default:None) – Image series number; defaults to None.subimg_offset (
Optional[List[int]], default:None) – Sub-image offset as (z,y,x) to load; defaults to None.subimg_size (
Optional[List[int]], default:None) – Sub-image size as (z,y,x) to load; defaults to None.roi_offset (
Optional[List[int]], default:None) – Region of interest offset as (x, y, z) to process; defaults to None.roi_size (
Optional[List[int]], default:None) – Region of interest size of region to process, given as(x, y, z); defaults to None.
- Return type:
- Returns:
Tuple of stats from processing, or None if no stats, and text feedback from the processing, or None if no feedback.
- magmap.io.cli.process_proc_tasks(path=None, series_list=None)[source]¶
Apply processing tasks.
- Parameters:
- Return type:
- Returns:
Dictionary of set processing types.
- magmap.io.cli.process_tasks()[source]¶
Process command-line tasks.
Perform tasks set by the
--procparameter or any other entry point, such as--registertasks. Only the first identified task will be performed.
- magmap.io.cli.setup_atlas_profiles(atlas_profiles_names, reset=True)[source]¶
Set up atlas profiles.
If a profile is None, only a default set of profile settings will be generated. Any previously set up profile will be replaced.
- magmap.io.cli.setup_dbs()[source]¶
Set up databases for the given image file.
Only sets up each database if it has not been set up already.
- magmap.io.cli.setup_grid_search_profiles(grid_search_profiles_names)[source]¶
Setup grid search profiles.
If a profile is None, only a default set of profile settings will be generated. Any previously set up profile will be replaced.
- Parameters:
grid_search_profiles_names (
str) – Grid search profiles names.
- magmap.io.cli.setup_image(path, series=None, proc_tasks=None)[source]¶
Set up the main image from CLI args and process any tasks.
- magmap.io.cli.setup_roi_profiles(roi_profiles_names)[source]¶
Set up ROI profiles.
If a profile is None, only a default set of profile settings will be generated. Also sets up colormaps based on ROI profiles. Any previously set up profile will be replaced.