dystrack.manager.cmdline#
Dynamic construction of cmdline tool from configuration files.
- dystrack.manager.cmdline.run_via_cmdline(argv, image_analysis_func, analysis_kwargs={}, analysis_cache={}, manager_kwargs={})#
Parses command-line arguments and launches DySTrack manager event loop.
This is intended to be called through a DySTrack config file (see run dir for examples), which specifies the image analysis pipeline function to use (image_analysis_func) and optionally fixes any other parameters.
The DySTrack event loop target directory (target_dir) must be provided as the first positional argument of the command line invocation.
For all other arguments, the command line tool is dynamically generated to expose any suitable kwargs of run_dystrack_manager that are not already specified in manager_kwargs, as well as any suitable kwargs of the image_analysis_func that are not already given in analysis_kwargs or in analysis_cache. Any arguments that do not have type “bool”, “int”, “float”, or “str” as their main doc string type annotation are ignored.
Note: This feature strictly depends on numpy-style doc strings for the provided image_analysis_func, which must include both a Parameters and a Returns section and must document all parameters.
For more information on the DySTrack event loop itself, see the function that this one ultimately calls:
dystrack.manager.manager.run_dystrack_manager()
- Parameters:
argv (list) – List of command line arguments exactly as returned by sys.argv.
image_analysis_func (callable) –
Function that performs image analysis on detected files and returns new coordinates for transmission to the microscope. This function must have a numpy-style doc string that documents all parameters and has both a Parameters and a Returns section. Call signature:
z_pos, y_pos, x_pos, img_msg, img_cache = image_analysis_func( target_path, **img_kwargs, **img_cache)
The target_path argument corresponds to the first and only required argument in the cmdline call signature generated here. The keyword arguments (both img_kwargs and img_cache) will be parsed from the function’s numpy-style doc string and exposed to the cmdline interface unless they are already set in analysis_kwargs and analysis_cache, respectively (see below). Note that all keyword arguments provided via the command line will be treated as img_kwargs, not as img_cache. This means img_cache arguments cannot be provided via the command line and must instead be given in analysis_cache (or left blank) to function properly.
analysis_kwargs (dict, optional, default {}) – Additional keyword arguments to be passed to the image analysis func as **img_kwargs. These will not be exposed to the cmdline interface.
analysis_cache (dict, optional, default {}) – Additional keyword arguments to be passed to the image analysis func as **img_cache. These will not be exposed to the cmdline interface.
manager_kwargs (dict, optional, default {}) – Additional keyword arguments to be passed to run_dystrack_manager. These will not be exposed to the cmdline interface.