visiannot.configuration.ConfigurationWindow

Summary

Module defining class ConfigurationWindow

Classes

visiannot.configuration.ConfigurationWindow.ConfigurationWindow([path])

Class creating the window for configuring ViSiAnnoTLongRec

API

Class ConfigurationWindow

class visiannot.configuration.ConfigurationWindow.ConfigurationWindow(path='')[source]

Bases: object

Class creating the window for configuring ViSiAnnoTLongRec

Parameters

path (str or dict) – path to the configuration file to load when creating the window, it might be a configuration dictionary

The window is composed of 5 main widgets:

  • Video configuration

  • Signal configuration

  • Events annotation configuration

  • General configuration

  • Group box with load/save/done push buttons

Each one of the video configuration, signal configuration and event annotation configuration is contained in an instance of Configuration.

The signal configuration has several configuration children (Interval, Threshold and YRange), each one displayed in a separate window.

All the instances of Configuration are stored in the dictionary meta_dict.

On the one hand, the attribute ConfigurationWindow.lay refers to the first level of QGridLayout, meaning the layout filling the whole window. On the other hand, the second level of QGridLayout fills the first level layout ConfigurationWindow.lay. These layouts are the configuration widgets (general => ConfigurationWindow.general_lay, video => ConfigurationWindow.meta_dict[“Video”].lay, …).

The different types of configuration are stored in 7 dictionaries:

  • ConfigurationWindow.general_dict

  • ConfigurationWindow.meta_dict["Video"].dict

  • ConfigurationWindow.meta_dict["Signal"].dict

  • ConfigurationWindow.meta_dict["Interval"].dict

  • ConfigurationWindow.meta_dict["Threshold"].dict

  • ConfigurationWindow.meta_dict["AnnotEvent"].dict

  • ConfigurationWindow.meta_dict["AnnotImage"].dict

When values are modified manually in the window, these dictionaries are not updated. The method set_configuration_dictionaries() must be called to do so.

Methods for the management of callbacks:

call_lsd(button_id)

Callback method for Load/Save/Done push buttons

set_directory_annotations()

Callback method for annotations directory selection

show_child_window(button_id)

Callback method for opening child configuration window related to signal configuration

Static methods for converting dictionary to list:

convert_dict_to_list(dic)

Puts the values of a dictionary in a list

convert_dict_to_list_nested(dic[, level])

Puts the values of a nested dictionary in a nested list

Methods for widget creation:

create_child_configuration_window(…[, …])

Creates a window for a child configuration

create_widget_general(widget_position)

Adds a widget with the general configuration to the layout ConfigurationWindow.lay

Methods for loading/saving configuration:

load(path)

Loads a configuration file and store it directly in the configuration dictionaries

load_config_file(path[, key_dict])

Loads a configuration file

reset_display()

Deletes the whole configuration display and replaces it with the current values of the attribute dictionaries

set_configuration_dictionaries()

Sets the configuration dictionaries with the values filled in the GUI

set_general_configuration(flag_display)

Displays the values in the general configuration widget from general_dict or sets the values of general_dict from the values filled in the general configuration widget (i.e.

write_configobj_file(path)

Creates a .ini configuration file with the current configuration

Attributes:

meta_dict

(dict) Each value is an instances of Configuration contained in the window

config_type_list

(list) Types of configuration, each element is a string and must be a key of meta_dict

general_config_position_dict

(dict) Same keys as general_dict, value is the list of positions of the corresponding widgets in the general configuration widget (general_lay)

general_lay

(QtWidgets.QGridLayout) Layout of the general configuration widget

general_group_box

(QtWidgets.QGroupBox) Group box of the general configuration widget

general_push_button

(QtWidgets.QPushButton) Push button for changing the directory of annotations

app

(QtWidgets.QApplication) Display initializer

win

(QtWidgets.QWidget) Container of main configuration window

lay

(QtWidgets.QGridLayout) Layout of the main configuration window

button_group_lsd

(QtWidgets.QButtonGroup) Group of buttons with the push buttons Load/Save/Done

children_win_list

(list) Instances of QtWidgets.QWidget containing the children configuration windows

general_dict_default

(dict) Default general configuration, see general_dict for details

general_dict

(dict) General configuration

call_lsd(button_id)[source]

Callback method for Load/Save/Done push buttons

Connected to the signal buttonClicked[int] of the button group button_group_lsd

The group button ConfigurationWindow.button_group_lsd has 3 buttons:

  • button_id == 0 => load configuration file

  • button_id == 1 => save configuration file

  • button_id == 2 => set configuration dictionaries and close main window

Parameters

button_id (int) – index of the button that has been pushed

static convert_dict_to_list(dic)[source]

Puts the values of a dictionary in a list

Parameters

dic (dict) – dictionary

If dic is not a dictionary, then it returns dic.

Returns

list

Return type

list

static convert_dict_to_list_nested(dic, level=1)[source]

Puts the values of a nested dictionary in a nested list

Parameters

dic (dict) – dictionary

Returns

list of lists

Return type

list

create_child_configuration_window(parent_config, *args, win_size=(0, 0), **kwargs)[source]

Creates a window for a child configuration

This method can be used when a configuration type is linked to another one so that the keys in Configuration.dict must be the same.

For example, this applies to the signal configuration. We can specify some threshold values to plot on the signal widgets. The thresholds must be defined for an existing signal, so the keys in the configuration dictionary are the same as in the signal configuration.

As a consequence, when a configuration grid is added in the child configuration window, it has automatically the same key as in the signal configuration and it cannot be changed. If the whole configuration grid for a given key is deleted in the signal configuration, then it is also deleted in the threshold configuration.

This method sets the following attributes:

  • additional_win_list.

  • additional_lay_list.

  • meta_dict.

Parameters
  • parent_config (Configuration) – parent configuration

  • args – positional arguments of Configuration constructor, starting from the third position

  • win_size (tuple) – window size (width, height), set one value to 0 to maximize the window

  • kwargs – keyword arguments of Configuration constructor (excepted parent_config which is the first positional argument of this method)

create_widget_general(widget_position)[source]

Adds a widget with the general configuration to the layout ConfigurationWindow.lay

The widget is contained in an instance of QtWidgets.QGroupBox.

This method sets the following attributes:

Parameters

widget_position (tuple of integers) – position of the group box in the parent grid layout, length 2 (row, col) or 4 (row, col, rowspan, colspan)

load(path)[source]

Loads a configuration file and store it directly in the configuration dictionaries

It calls the static method load_config_file() and then sets the following attributes:

Parameters

path (str) – path to the configuration file to load

static load_config_file(path, key_dict={'AnnotEvent': 1, 'AnnotImage': 0, 'General': 0, 'Interval': 2, 'Signal': 2, 'Threshold': 2, 'Video': 1, 'YRange': 1})[source]

Loads a configuration file

Parameters
  • path (str) – path to the configuration file to load

  • key_dict (dict) – each item corresponds to a configuration type to retrieve, key is the configuration key, value is the number of nesting levels to apply for converting a nested dictionary (that may be retrieved by ConfigObj) to a nested list (equivalent to nb_level of corresponding instance of Configuration)

Returns

configuration dictionary, with the same keys as key_dict

Return type

dict

reset_display()[source]

Deletes the whole configuration display and replaces it with the current values of the attribute dictionaries

set_configuration_dictionaries()[source]

Sets the configuration dictionaries with the values filled in the GUI

The configuration dictionaries are:

set_directory_annotations()[source]

Callback method for annotations directory selection

Connected to the signal clicked of general_push_button.

set_general_configuration(flag_display)[source]

Displays the values in the general configuration widget from general_dict or sets the values of general_dict from the values filled in the general configuration widget (i.e. general_lay)

Parameters

flag_display (bool) – specify if displaying values in the general configuration widget, if False then it sets the values of general_dict

show_child_window(button_id)[source]

Callback method for opening child configuration window related to signal configuration

Connected to the signal buttonClicked[int] of ConfigurationWindow.meta_dict["Signal"].button_group_children.

The group button ConfigurationWindow.meta_dict["Signal"].button_group_children has as much buttons as children configurations (see Configuration.children_configuration_list of ConfigurationWindow.meta_dict["Signal"]).

Parameters

button_id (int) – index of the button that has been pushed

write_configobj_file(path)[source]

Creates a .ini configuration file with the current configuration

Before writing the file, the method calls set_configuration_dictionaries().

Parameters

path (str) – path to the configuration file to create

app

(QtWidgets.QApplication) Display initializer

button_group_lsd

(QtWidgets.QButtonGroup) Group of buttons with the push buttons Load/Save/Done

children_win_list

(list) Instances of QtWidgets.QWidget containing the children configuration windows

config_type_list

(list) Types of configuration, each element is a string and must be a key of meta_dict

general_config_position_dict

(dict) Same keys as general_dict, value is the list of positions of the corresponding widgets in the general configuration widget (general_lay)

general_dict

(dict) General configuration

The keys and values are:

  • "temporal_range": (list) duration of temporal range for splitting long recording into several files, 2 elements (minutes, seconds)

  • "flag_pause_status": (bool) specify if the video is paused at launching

  • "layout_mode": (int) either 0, 1 or 2

  • "zoom_factor": (int)

  • "max_points": (int)

  • "nb_ticks": (int)

  • "time_zone": (str) time zone (complying with pytz package)

  • "flag_annot_overlap": (bool) specify if overlap of events annotations is enabled

  • "annot_dir": (str) directory of the annotations

  • "from_cursor_list": (list) each element is a list of length 2 (minute, second)

  • "current_fmt": (str) datetime string format of the current temporal position in progress bar, see keyword argument fmt of convert_datetime_to_string()

  • "range_fmt": (str) datetime string format of the temporal range duration in progress bar, see keyword argument fmt of convert_datetime_to_string()

  • "ticks_fmt": (str) datetime string format of X axis ticks text, see keyword argument fmt of convert_datetime_to_string()

  • "ticks_size": (int) size of the ticks text in signal plots

  • "ticks_color": (list) RGB color of ticks

  • "ticks_offset": (int) space in pixels between ticks and associated values

  • "y_ticks_width": (int) horizontal space in pixels for the of Y axis ticks in signal widgets

  • "font_name": (str) font of the text in ViSiAnnoT

  • "font_size": (int) font size in ViSiAnnoT

  • "font_size_title": (int) font size in ViSiAnnoT (title of video widget and progress bar widget)

  • "font_color": (list) RGB color of font in ViSiAnnoT

  • "nb_table_annot": (int) maximum number of labels in one row in annotation widgets

  • "bg_color": (list) RGB color of background in ViSiAnnoT

  • "bg_color_plot": (list) RGB color of background color of signal plots

general_dict_default

(dict) Default general configuration, see general_dict for details

general_group_box

(QtWidgets.QGroupBox) Group box of the general configuration widget

general_lay

(QtWidgets.QGridLayout) Layout of the general configuration widget

general_push_button

(QtWidgets.QPushButton) Push button for changing the directory of annotations

lay

(QtWidgets.QGridLayout) Layout of the main configuration window

meta_dict

(dict) Each value is an instances of Configuration contained in the window

The keys are:

  • Video

  • Signal

  • Interval

  • Threshold

  • YRange

  • AnnotEvent

  • AnnotImage

See Configuration.dict for details.

win

(QtWidgets.QWidget) Container of main configuration window