configs

Defines several classes that handle the different configuration levels and options (findmycells.configs)

Configurations

There are several layers that require & allow configuration of findmycells. However, only the top most level (ProjectConfigs) is fully implemented here. Both lower level configs (e.g. configs for each processing type like “preprocessing” or “quantification”, or even lower level configs like for each individual processing step represented by ProcessingStrategy subclasses), will be defined by each of these classes using the DefaultConfigs - which, inturn, is implemented here. For an example of how the DefaultConfigs shall be used, please have a look at the general implementation of ProcessingObject and ProcessingStrategy in the core module, and then check out for instance the specs module of the preprocessing submodule!


source

ProjectConfigs

 ProjectConfigs (root_dir:Union[pathlib.PosixPath,pathlib.WindowsPath])

In addition to the Database of findmycells, this class stores most of the configuration data of a findmycells project.

Associated public methods:


source

ProjectConfigs.load_available_processing_modules

 ProjectConfigs.load_available_processing_modules ()

Screens the findmycells package for all available processing modules. Processing modules will be recognized if it contain a “specs” and a “strategies” submodule. For developers who would like to add a new processing module, please check out one of the implemented ones (e.g. findmycells.preprocessing) to see how this can be done. The list of detected processing modules will be used for instance by the GUI to automatically create a ProcessingStepPage in the GUI for each available processing module. When adding new processing modules, developers also have to add them to the ’_expected_processing_step_modules’ property of the GUI class in findmycells.interfaces.


source

ProjectConfigs.add_processing_step_configs

 ProjectConfigs.add_processing_step_configs (processing_step_id:str,
                                             configs:Optional[Dict[str,Any
                                             ]]=None)

Allows the user to add configs for a specific processing step and ensures that the specified config input is valid and - in case any (or even all) values are missing - fills them with the respective defined default values.


source

ProjectConfigs.add_reader_configs

 ProjectConfigs.add_reader_configs (reader_type:str,
                                    reader_configs:Optional[Dict[str,Any]]
                                    =None)

Similarly to adding configs for a specific processing step, this method allows the user to specify the configurations for a given reader type. Likewise, it will also ensure valid input and replace missing values with defaults.

For developers:


source

ProjectConfigs._load_available_strategies_and_objects

 ProjectConfigs._load_available_strategies_and_objects ()

Screens for all available strategies and objects. Classes will only be recognized, if their names end with ‘Obejct’ or ‘Strat’, respectively. For developers who would like to add a new reader, please check out one of the implemented ones (e.g. findmycells.preprocessing.specs.PreprocessingObject or findmycells.preprocessing.strategies.CropStitchingArtefactsRGBStrat).





source

DefaultConfigs

 DefaultConfigs (default_values:Dict[str,Any],
                 valid_types:Dict[str,List[type]],
                 valid_value_ranges:Optional[Dict[str,Tuple]]=None,
                 valid_value_options:Optional[Dict[str,Tuple]]=None)

This class has to be specified as an attribute in several classes throughout findmycells and allows / ensures that each novel class defines its own set of default config values. Moreover, the ‘valid_types’ dictionary also defines which types of values are allowed. It`s used as a way to ensure that the input made by the user for any configuration parameter is of the valid type, or within a certain range or among a certain set of options, if applicable.

Type Default Details
default_values typing.Dict[str, typing.Any] Keys are identifier of config options, values the corresponding default value
valid_types typing.Dict[str, typing.List[type]] Keys must match with keys of “default_values”, values are lists of allowed types
valid_value_ranges typing.Optional[typing.Dict[str, typing.Tuple]] None Required for every config option that allows floats or integers. Keys must match with keys of “default_values”. Expected format: (start_idx, end_idx) or (start_idx, end_idx, step_size)
valid_value_options typing.Optional[typing.Dict[str, typing.Tuple]] None Keys must match with keys of “default_values”. Expected format: (‘option_a’, ‘option_b’, …)
Returns None

Associated public methods:

The following two methods are called for instance by the ProjectConfigs to ensure that the user provided configs input is actually valid and complete:


source

DefaultConfigs.assert_user_input

 DefaultConfigs.assert_user_input (user_input:Dict[str,Any])

Allows to quickly raise an assertion error if the user specified any invalid config parameter or value, instead of first starting the processing and only cause an error later on after potentially several minutes of computation time.


source

DefaultConfigs.fill_user_input_with_defaults_where_needed

 DefaultConfigs.fill_user_input_with_defaults_where_needed
                                                            (user_input:Di
                                                            ct[str,Any])

If any (or even all) of the required config parameters were not provided by the user, default values will be added and the filled configs will be returned. This ensures that always all config parameters are present - if provided by the user or not.

The following two methods are essentially used by the GUIConfigs class, which is implemented right below, to construct the associated widgets as intended:


source

DefaultConfigs.get_step_size_if_present

 DefaultConfigs.get_step_size_if_present (key:str)

source

DefaultConfigs.get_options_if_present

 DefaultConfigs.get_options_if_present (key:str)





source

GUIConfigs

 GUIConfigs (widget_names:Dict[str,str], descriptions:Dict[str,str],
             tooltips:Optional[Dict[str,str]]=None)

Note for developers: The docstrings of each processing strategy will also be used to display the description of each strategy in both the GUI and in the online hosted documentation. To improve the layout of these displayed HTML elements, we introduced some custom “string commands”. Their use is described in detail in the docstring of the “_convert_docstring_to_html()” method of this class.

Associated public methods:


source

GUIConfigs.construct_widget

 GUIConfigs.construct_widget (info_text:str,
                              default_configs:__main__.DefaultConfigs)

Allows to construct the individual widgets and put them together to construct the entire widget as intended. The full widget will be stored as an attribute at self.strategy_widget. (Could be renamed in a future version, as it is no longer used only to build widgets for the individual processing strategies, but is much more used for all sort of widgets throughout findmycells)

Type Details
info_text str will ultimately be converted into an HTML widget and, therefore, supports HTML syntax
default_configs DefaultConfigs
Returns None

source

GUIConfigs.export_current_config_values

 GUIConfigs.export_current_config_values ()

Enables to read out all current widget settings by the GUI, which then matches the format required to be passed for instance as processing_configs or as strategy_configs to the API.