magmap.settings.profiles module¶
Profile settings to setup common configurations.
Each profile has a default set of settings, which can be modified through “modifier” sub-profiles with groups of settings that overwrite the given default settings.
- class magmap.settings.profiles.RegKeys(value)[source]¶
Bases:
EnumRegister setting enumerations.
- ACTIVE = 1¶
- DBSCAN_EPS = 10¶
- DBSCAN_MINPTS = 11¶
- EDGE_AWARE_REANNOTATION = 8¶
- KNN_N = 12¶
- MARKER_EROSION = 2¶
- MARKER_EROSION_MIN = 3¶
- MARKER_EROSION_USE_MIN = 4¶
- METRICS_CLUSTER = 9¶
- SAVE_STEPS = 7¶
- SKELETON_EROSION = 5¶
- WATERSHED_MASK_FILTER = 6¶
- class magmap.settings.profiles.SettingsDict(*args, **kwargs)[source]¶
Bases:
dictProfile dictionary, which contains collections of settings.
Allows modification by applying additional groups of settings specified in this dictionary. Supports saving and loading settings from a YAML file.
This class is being migrated to a data class, which supports type hints and attribute access. It will also reduce the need for Enums as keys.
- Variables:
PATH_PROFILES (str) – Path to profiles directory.
NAME_KEY (str) – Key for profile name.
DEFAULT_NAME (str) – Default profile modifier name.
profiles (dict) – Dictionary of profiles to modify the default values, where each key is the profile name and the value is a nested dictionary that will overwrite or update the current values.
timestamps (dict) – Dictionary of profile files to last modified time.
delimiter (str) – Profile names delimiter; defaults to
,.
- DEFAULT_NAME = 'default'¶
- NAME_KEY = 'settings_name'¶
- PATH_PROFILES = 'profiles'¶
- add_profiles(names_str)[source]¶
Add profiles by names and files.
Layers profiles on top of one another so that any settings in the next profile take precedence over those in the prior profiles. For example, “lightsheet_5x” will give one profile, while “lightsheet_5x_contrast” will layer additional settings on top of the original lightsheet profile.
- Parameters:
names_str (str) – The name of the settings profile to apply, with individual profiles separated by “,”. Profiles will be applied in order of appearance.
- check_file_changed()[source]¶
Check whether any profile files have changed since last loaded.
- Returns:
True if any file has changed.
- Return type:
- static get_files(profiles_dir=None, filename_prefix='')[source]¶
Get profile files.
- Parameters:
profiles_dir (str) – Directory from which to get files; defaults to None to use
PATH_PROFILES.filename_prefix (str) – Only get files starting with this string; defaults to an empty string.
- Returns:
List of files in
profiles_dirmatching the givenfilename_prefixand ending with an extension in_EXT_YAML.- Return type:
List[str]
- get_profile(profile_name)[source]¶
Get the dictionary for a given profile.
Profiles may either match an existing profile in
profilesor specify a path to a YAML configuration file. YAML filenames will first be checked inPATH_PROFILES, followed byprofile_nameas the full path. If_add_mod_directlyis True, the value atprofile_namewill be added or replaced with the found modifier value.The profile in
profileswhose name matchesprofile_namewill be applied over the current settings. If both the current and new values are dictionaries, the current dictionary will be updated with the new values. Otherwise, the corresponding current value will be replaced by the new value.
- static is_identical_settings(profs, keys)[source]¶
Check whether the given settings are identical across profiles.
- modify_settings(mods)[source]¶
Modify dictionary or data class items from another dictionary.
If corresponding values are sub-dictionaries, the existing sub-dict will be updated rather than replaced with the new sub-dict.
Priority is given to updated existing dictionary keys. If unavailable, data class attributes are updated.