TrainingProtocolBase

class TrainingProtocolBase[source]

Bases: object

Base class for defining training protocols and managing settings.

Training protocols dictate how settings change over sessions based on subject performance.

__init__() None[source]

Initializes the TrainingProtocolBase instance.

Methods

__init__()

Initializes the TrainingProtocolBase instance.

check_variables()

Validates that all required settings are present and of the correct type.

copy_settings()

Copies current settings to default settings and validates them.

correct_types_in_dict(current_dict)

Ensures that dictionary values match the types of default settings.

default_training_settings()

Sets the default values for the training settings.

define_gui_tabs()

Defines the tabs and organization for the GUI settings editor.

get_default_dict()

Returns the default settings as a dictionary.

get_dict([exclude])

Returns the current settings as a dictionary.

get_jsonstring([exclude])

Returns the current settings as a JSON string.

get_jsonstring_from_jsonstring(current_value)

Merges a JSON string with defaults and returns a valid JSON string.

get_settings_names()

Returns a list of all setting names, including defaults and extras.

get_string()

Returns the settings as a JSON string with corrected types.

load_settings_from_dict(current_dict)

Loads settings from a dictionary, correcting types where necessary.

load_settings_from_jsonstring(current_value)

Loads settings from a JSON string.

restore()

Restores all settings to their default values.

update_training_settings()

Updates the settings based on performance.

check_variables() None[source]

Validates that all required settings are present and of the correct type.

Raises:

TrainingError – If a required variable is invalid or missing.

default_training_settings() None[source]

Sets the default values for the training settings. Must be overridden.

update_training_settings() None[source]

Updates the settings based on performance. Must be overridden.

define_gui_tabs() None[source]

Defines the tabs and organization for the GUI settings editor.

copy_settings() None[source]

Copies current settings to default settings and validates them.

get_settings_names() list[str][source]

Returns a list of all setting names, including defaults and extras.

Returns:

list of setting names.

Return type:

list[str]

get_dict(exclude: list[str] = []) dict[str, Any][source]

Returns the current settings as a dictionary.

Parameters:

exclude (list[str], optional) – List of keys to exclude. Defaults to [].

Returns:

Dictionary of settings.

Return type:

dict[str, Any]

get_default_dict() dict[str, Any][source]

Returns the default settings as a dictionary.

Returns:

Dictionary of default settings.

Return type:

dict[str, Any]

get_jsonstring(exclude: list[str] = []) str[source]

Returns the current settings as a JSON string.

Parameters:

exclude (list[str], optional) – List of keys to exclude. Defaults to [].

Returns:

JSON representation of settings.

Return type:

str

load_settings_from_dict(current_dict: dict[str, Any]) list[str][source]

Loads settings from a dictionary, correcting types where necessary.

Parameters:

current_dict (dict[str, Any]) – Dictionary containing new setting values.

Returns:

List of keys that failed type correction.

Return type:

list[str]

load_settings_from_jsonstring(current_value: str) None[source]

Loads settings from a JSON string.

Parameters:

current_value (str) – JSON string of settings.

restore() None[source]

Restores all settings to their default values.

get_jsonstring_from_jsonstring(current_value: str) str[source]

Merges a JSON string with defaults and returns a valid JSON string.

Parameters:

current_value (str) – Input JSON string.

Returns:

Merged JSON string.

Return type:

str

correct_types_in_dict(current_dict: dict[str, Any]) Tuple[list[str], dict[str, Any]][source]

Ensures that dictionary values match the types of default settings.

Parameters:

current_dict (dict[str, Any]) – Input dictionary.

Returns:

A tuple containing a list of keys with type errors and the corrected dictionary.

Return type:

Tuple[list[str], dict[str, Any]]

get_string() str[source]

Returns the settings as a JSON string with corrected types.

Returns:

JSON string of settings.

Return type:

str