visiannot.visiannot.ViSiAnnoTLongRec

Summary

Module defining ViSiAnnoTLongRec

Classes

visiannot.visiannot.ViSiAnnoTLongRec.ViSiAnnoTLongRec(…)

Subclass of ViSiAnnoT for managing a long recording with several files

API

Class ViSiAnnoTLongRec

class visiannot.visiannot.ViSiAnnoTLongRec.ViSiAnnoTLongRec(video_dict, signal_dict, interval_dict={}, temporal_range=(0, 30), layout_mode=1, poswid_dict={}, **kwargs)[source]

Bases: visiannot.visiannot.ViSiAnnoT.ViSiAnnoT

Subclass of ViSiAnnoT for managing a long recording with several files

First, it searches the list of paths to the video/signal files. It creates temporary files with info for synchronization. TODOTODO

Parameters
  • video_dict (dict) –

    video configuration, each item corresponds to one camera. Key is the camera ID (string). Value is a configuration list of length 5:

    • (str) Directory where to find the video files,

    • (str) Pattern to find video files (e.g. "*.mp4"),

    • (str) Delimiter to get beginning datetime in the video file name,

    • (int) Position of the beginning datetime in the video file name, according to the delimiter,

    • (str) Format of the beginning datetime in the video file name (either "posix" or a format compliant with datetime.strptime()).

  • signal_dict (dict) –

    signal configuration, each item corresponds to one signal widget. Key is the widget ID (Y axis label, string). Value is a nested list of signal configurations. Each element of the nested list corresponds to one signal plot and is a configuration list of 8 elements:

    • (str) Directory where to find the signal files, see positional argument signal_dict of ViSiAnnoT constructor for detail about data storing format,

    • (str) Pattern to find signal files,

    • (str) Delimiter to get beginning datetime in the signal file name,

    • (int) Position of the beginning datetime in the signal file name, according to the delimiter,

    • (str) Format of the beginning datetime in the signal file name (either "posix" or a format compliant with datetime.strptime()),

    • (str) Key to access the data (in case of .mat or .h5 file),

    • (int or float or str) Signal frequency, set it to 0 if signal non regularly sampled, set it to -1 if same frequency as ViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file - in case of 2D data with several value columns, then the column index must be specified, e.g. "key - 1" or "key - colName" if there is an attribute at key named columns with columns name being comma-separated (first column is always the timestamps),

    • (dict) Plot style, see https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html for details, set it to None for default.

    See Management of long recording for details.

  • interval_dict (dict) –

    interval configuration. Each item corresponds to a signal widget on which to plot intervals. The key must be the same as in signal_dict. Value is a nested list of interval configurations. Each element of the nested list corresponds to a type of interval to be plotted in the same signal widget and is a configuration list of 8 elements:

    • (str) Directory where to find interval files, see positional argument interval_dict of ViSiAnnoT constructor for detail about data storing format,

    • (str) Pattern to find interval files,

    • (str) Delimiter to get beginning datetime in the interval file name,

    • (int) Position of the beginning datetime in the interval file name, according to the delimiter,

    • (str) Format of the beginning datetime in the interval file name (either "posix" or a format compliant with datetime.strptime()),

    • (str) Key to access the data (in case of .mat or .h5 file),

    • (int) Signal frequency, set it to -1 if same frequency as ViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file,

    • (tuple or list) Plot color (RGBA).

  • temporal_range (tuple) – temporal range duration used to split the long recording into several files, 2 elements: (minutes, seconds)

  • layout_mode (int) –

    organization of widgets positioning in the window layout (ignored if custom layout organization provided with keyword argument poswid_dict), one of the following:

    • 1 (focus on video, works better with a big screen),

    • 2 (focus on signal, suitable for a laptop screen),

    • 3 (compact display with some features disabled),

    • 4 (adapted to portrait screen orientation).

  • poswid_dict (dict) –

    custom organization of widgets positioning in the window layout. Value is a tuple of length 2 (row, col) or 4 (row, col, rowspan, colspan). Key identifies the widget:

    • "video"

    • "select_manual"

    • "select_from_cursor"

    • "annot_event"

    • "annot_image"

    • "visi"

    • "zoomin"

    • "zoomout"

    • "previous"

    • "next"

    • "file_selection"

    • "progress"

    The signal widgets are automatically positioned below the progress bar.

  • kwargs – keyword arguments of ViSiAnnoT constructor

Methods for managing the navigation along the recording files:

change_file_in_long_rec(ite_file, *args, …)

Changes file in the long recording

get_current_file_configuration()

Gets configuration dictionaries for the current file in the long recording to provide to ViSiAnnoT

next_file()

Loads next file in the long recording

prepare_new_file(ite_file)

Loads data of a new file in the long recording

previous_file()

Loads previous file in the long recording

Methods for signal synchronization:

create_synchronization_files(data_name, …)

Creates temporary synchronization files for a given modality

get_recording_temporal_bounds(signal_dict)

Gets temporal bounds (beginning, ending) of the long recording

process_synchronization_all()

Creates temporary synchronization files for all videos, signals and intervals

process_synchronization_single_widget(signal_id)

Creates temporary synchronization files for signals or intervals in a specific widget

process_synchronization_video()

Creates temporary synchronization files for video modality (all cameras)

Methods for finding data files of the long recording:

get_path_list(config_id, config, config_type)

Gets list of paths and list of beginning datetimes along the recording for a specific modality

set_signal_interval_list(signal_dict, …)

Finds the list of data files (path and beginning datetime) in the long recording for signals and intervals

set_video_list_dict(video_dict, **kwargs)

Finds the list of video files (path and beginning datetime) in the long recording

Attributes:

temporal_range_duration_split

(int) Temporal range duration in seconds used to split long recording into several files

video_config_dict

(dict) Key is a camera ID.

video_list_dict

(dict) Key is a camera ID.

signal_config_dict

(dict) Key is a data type, corresponding to a signal widget.

signal_list_dict

(dict) Key is a data type, corresponding to a signal widget.

interval_config_dict

(dict) Key is a data type, corresponding to a signal widget on which to plot intervals.

interval_list_dict

(dict) Key is a data type, corresponding to a signal widget on which to plot intervals.

ref_beg_datetime_list

(list) Beginning datetimes of the files splitting in the long recording

temporal_range_duration_last

(float) Temporal range duration of the last file in the long recording (it might be lower than temporal_range_duration)

temporal_range_duration

(float) Temporal range duration of the current file in the long recording (equal to temporal_range_duration_last if last file, otherwise equal to temporal_range_duration_split)

ite_file

(int) Index of the current file in the long recording

nb_files

(int) Number of files for splitting the long recording

synchro_dir

(str) Directory where to save temporary files for synchronization

synchro_delimiter

(str) Delimiter for parsing temporary files for synchronization

synchro_timestamp_config

(list) Configuration for getting timestamp of temporary synchronization files (delimiter, index, format)

wid_previous

(PreviousWidget) Widget for selecting previous file

wid_next

(NextWidget) Widget for selecting next file

file_selection_widget

(file_selectionWidget) Widget for selecting a in a combo box

change_file_in_long_rec(ite_file, *args, **kwargs)[source]

Changes file in the long recording

It loads new data files by calling ViSiAnnoT.prepare_new_file(). Then it updates the display with ViSiAnnoT.update_plot_new_frame().

Parameters
Returns

specify if the file has been effectively changed

Return type

bool

create_synchronization_files(data_name, output_fmt, data_path_list, data_beginning_datetime_list, data_ending_datetime_list)[source]

Creates temporary synchronization files for a given modality

The reference for synchronization is given by ref_beg_datetime_list and temporal_range_duration_split. A synchronization file is created for each element of the list ref_beg_datetime_list.

See Synchronization of the different modalities for an example of temporary synchronization files.

Parameters
  • data_name (str) – modality name (used for the output path to temporary synchronization file)

  • output_fmt (str) – synchronization format in the temporary files, either “1D”, “2D” or anything else, see Synchronization of the different modalities for details

  • data_path_list (list) – paths to the data files to synchronize

  • data_beginning_datetime_list (list) – instances of datetime.datetime with the beginning datetime of each data file to synchronize

  • data_ending_datetime_list (list) – instances of datetime.datetime with the ending datetime of each data file to synchronize, same length as data_beginning_datetime_list

Returns

paths to the created synchronization files

Return type

list

get_current_file_configuration()[source]

Gets configuration dictionaries for the current file in the long recording to provide to ViSiAnnoT

It also sets temporal_range_duration according to the value of ite_file

Returns

  • video_dict (dict) – video configuration

  • signal_dict (dict) – signal configuration

  • interval_dict (dict) – interval configuration

static get_path_list(config_id, config, config_type, flag_raise_exception=False, **kwargs)[source]

Gets list of paths and list of beginning datetimes along the recording for a specific modality

Parameters
  • config_id (str) – configuration key of the modality in the configuration dictionary

  • config (list) – configuration list

  • config_type (str) – one of the following: “Video”, “Signal” or “Interval”

  • flag_raise_exception (bool) – specify if an exception must be raised i case no file is found

  • kwargs – keyword arguments of get_datetime_from_path()

Returns

2 elements:

  • (list) paths to the data files along the recording

  • (list) beginning datetimes of the data files along the recording

Return type

list

get_recording_temporal_bounds(signal_dict)[source]

Gets temporal bounds (beginning, ending) of the long recording

Parameters

signal_dict (dict) – see second positional argument of the constructor of ViSiAnnoTLongRec

Returns

  • beginning_datetime (datetime.datetime) – beginning datetime of the long recording

  • ending_datetime (datetime.datetime) – ending datetime of the long recording

next_file()[source]

Loads next file in the long recording

Returns

specify if the file has been effectively changed

Return type

bool

prepare_new_file(ite_file)[source]

Loads data of a new file in the long recording

It sets the attribute ViSiAnnoT.ite_file

It does not set ViSiAnnoT.first_frame and ViSiAnnoT.last_frame, and it does not update signal plots.

Parameters

ite_file (int) – index of the new file in the long recording

Returns

specify if the new file has been effectively loaded

Return type

bool

previous_file()[source]

Loads previous file in the long recording

process_synchronization_all()[source]

Creates temporary synchronization files for all videos, signals and intervals

It updates the attributes video_list_dict, signal_list_dict and interval_list_dict with the paths to temporary synchronization files.

process_synchronization_single_widget(signal_id, flag_interval=False)[source]

Creates temporary synchronization files for signals or intervals in a specific widget

It updates the attributes signal_list_dict and/or interval_list_dict with the paths to synchronization files

Parameters
  • signal_id (str) – widget identifier (must be a key in signal_list_dict)

  • flag_interval (bool) – specify if interval data to synchronize

process_synchronization_video()[source]

Creates temporary synchronization files for video modality (all cameras)

It updates the attribute video_list_dict with the paths to the temporary synchronization files.

set_signal_interval_list(signal_dict, interval_dict, **kwargs)[source]

Finds the list of data files (path and beginning datetime) in the long recording for signals and intervals

It sets the attributes signal_list_dict and interval_list_dict.

Parameters
set_video_list_dict(video_dict, **kwargs)[source]

Finds the list of video files (path and beginning datetime) in the long recording

It sets the attribute video_list_dict.

Parameters
file_selection_widget

(file_selectionWidget) Widget for selecting a in a combo box

interval_config_dict

(dict) Key is a data type, corresponding to a signal widget on which to plot intervals. Value is the corresponding configuration list without data path

interval_list_dict

(dict) Key is a data type, corresponding to a signal widget on which to plot intervals. Value is a list (along the intervals types in the widget) of lists of length 2: list of interval paths and list of beginning datetimes

After having called the method process_synchronization_all(), the video paths become the path to temporary synchronization files.

ite_file

(int) Index of the current file in the long recording

If flag_long_rec is False, then ite_file is always equal to 0.

nb_files

(int) Number of files for splitting the long recording

If flag_long_rec is False, then nb_files is set to 1.

ref_beg_datetime_list

(list) Beginning datetimes of the files splitting in the long recording

The temporal bounds of the long recording (beginning, ending) are retrieved with get_recording_temporal_bounds(). The list of beginning datetimes of the files splitting starts at the beginning of the long recording and is incremented by temporal_range_duration.

signal_config_dict

(dict) Key is a data type, corresponding to a signal widget. Value is the corresponding configuration list without data path

signal_list_dict

(dict) Key is a data type, corresponding to a signal widget. Value is a list (along the signals in the widget) of lists of length 2: list of signal paths and list of beginning datetimes

After having called the method process_synchronization_all(), the video paths become the path to temporary synchronization files.

synchro_delimiter

(str) Delimiter for parsing temporary files for synchronization

synchro_dir

(str) Directory where to save temporary files for synchronization

synchro_timestamp_config

(list) Configuration for getting timestamp of temporary synchronization files (delimiter, index, format)

temporal_range_duration

(float) Temporal range duration of the current file in the long recording (equal to temporal_range_duration_last if last file, otherwise equal to temporal_range_duration_split)

temporal_range_duration_last

(float) Temporal range duration of the last file in the long recording (it might be lower than temporal_range_duration)

temporal_range_duration_split

(int) Temporal range duration in seconds used to split long recording into several files

video_config_dict

(dict) Key is a camera ID. Value is the corresponding configuration list without video path

video_list_dict

(dict) Key is a camera ID. Value is a list of length 2: list of video paths and list of beginning datetimes

After having called the method process_synchronization_all(), the video paths become the path to temporary synchronization files.

wid_next

(NextWidget) Widget for selecting next file

wid_previous

(PreviousWidget) Widget for selecting previous file