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={}, flag_synchro=True, 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. If signals are not synchronized with videos, then it creates temporary files with info for synchronization. Each created file corresponds to one video file and contains the path to the signal file to use with the starting second.

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).

  • flag_synchro (bool) – specify if video and signal are synchronized, in case there is no video and several signals that are not synchronized with each other, then flag_synchro can be set to False and the synchronization reference is the first signal

  • layout_mode (int) –

    layout mode of the window for positioning the widgets, 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).

  • poswid_dict (dict) –

    custom position of the widgets in the window, default {} to use the positions defined by the layout mode (see input layout_mode). Value is a tuple of length 2 (row, col) or 4 (row, col, rowspan, colspan). Key identifies the widget:

    • "logo"

    • "select_trunc"

    • "select_manual"

    • "select_from_cursor"

    • "annot_event"

    • "annot_image"

    • "visi"

    • "zoomin"

    • "zoomout"

    • "previous"

    • "next"

    • "file_selection"

    • "progress"

  • kwargs – keyword arguments of ViSiAnnoT constructor

Methods for managing the navigation along the recording files:

change_file_in_long_rec(ite_file, new_frame_id)

Changes file in the long recording

get_current_file_configuration()

Gets configuration dictionaries for the current file in the 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 finding data files of the long recording:

check_holes(data_list_dict, **kwargs)

Checks if there are holes in the list of data files when comparing different modalities

check_holes_video(**kwargs)

Checks if there are holes in the list of video files when comparing the different cameras

check_holes_video_signal_interval(**kwargs)

Checks if there are holes in the list of signal files when comparing the different cameras and signals

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

Methods for signal synchronization:

create_synchronization_files(data_path_list, …)

Class method for creating synchronization files

process_synchronization_all()

Creates temporary synchronization files for all signals and intervals and updates the attributes signal_list_dict and interval_list_dict with the synchronization files

process_synchronization_single_widget(signal_id)

Creates temporary synchronization files for signals or intervals in a specific widget and updates the attribute signal_list_dict or interval_list_dict with the synchronization files

replace_holes(path_list_list)

Replaces holes in the list of data paths of first modality with another modality

set_reference_modality_info()

Finds the beginning datetimes and the durations of the files of reference modality along the recording

Attributes:

flag_synchro

(bool) Specify if video and signal are synchronized

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.

tmp_name

(str) Directory where to save temporary files for synchrnonization

tmp_delimiter

(str) Delimiter for parsing temporary files for synchronization

ref_beg_datetime_list

(list) Beginning datetimes of the files of the reference modality

ref_duration_list

(list) Durations of the files of the reference modality

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, new_frame_id, flag_previous_scroll=False)[source]

Changes file in the long recording

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

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

  • new_frame_id (int) – new current frame number (sampled at the reference frequency ViSiAnnoT.fps)

  • flag_previous_scroll (bool) – specify if the new file is reach backward by scrolling

Returns

specify if the file has been effectively changed

Return type

bool

static check_holes(data_list_dict, **kwargs)[source]

Checks if there are holes in the list of data files when comparing different modalities

It updates the positional argument data_list_dict by filling the holes with a fake empty data file.

Parameters
  • data_list_dict (dict) –

    each item corresponds to one modality - key is the modality name - value is a list of length 2:

    • list of paths to data files

    • list of beginning datetimes of data files

  • kwargs – keyword arguments of convert_string_to_datetime()

check_holes_video(**kwargs)[source]

Checks if there are holes in the list of video files when comparing the different cameras

It updates the attribute video_list_dict by filling the holes with a fake empty video file.

Parameters

kwargs – keyword arguments of check_holes()

check_holes_video_signal_interval(**kwargs)[source]

Checks if there are holes in the list of signal files when comparing the different cameras and signals

Parameters

kwargs – keyword arguments of check_holes()

It updates the attributes video_list_dict and signal_list_dict by filling the holes with a fake empty video/signal file.

static create_synchronization_files(data_path_list, signal_id, ref_beginning_datetime_list, ref_duration_list, data_beginning_datetime_list, data_ending_datetime_list, output_dir, delimiter)[source]

Class method for creating synchronization files

The reference for synchronization is given by ref_beginning_datetime_list and ref_duration_list. A synchronization file is created for each element of those lists.

An example of synchronization file:

None *=* 30
dir/file1.h5

It means that for the first 30 seconds there is no signal, then there is the file “signal dir/file1.h5” until the end of the reference file is reached.

Another example:

dir/file2.h5 *=* 50
dir/file3.h5
dir/file4.h5

It means that the first 50 seconds of the file “dir/file2.h5” are excluded, then there is the full file “dir/file3.h5”, then there is the file “dir/file4.h5” until the end of the reference file is reached.

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

  • signal_id (str) – signal identifier, used for the name of the synchronization files

  • ref_beginning_datetime_list (list) – instances of datetime.datetime with the beginning datetime of each reference file

  • ref_duration_list (list) – durations of each reference file in seconds, same length as ref_beginning_datetime_list

  • 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

  • output_dir (str) – directory where to save the synchronization files

  • delimiter (str) – delimiter between data path and starting second in the synchronization file, in the examples above it is " *=* "

Returns

paths to the created synchronization files

Return type

list

get_current_file_configuration()[source]

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

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

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 signals and intervals and updates the attributes signal_list_dict and interval_list_dict with the synchronization files

First it calls set_reference_modality_info(), then it calls process_synchronization_single_widget() for each signal widget.

process_synchronization_single_widget(signal_id, flag_interval=False)[source]

Creates temporary synchronization files for signals or intervals in a specific widget and updates the attribute signal_list_dict or interval_list_dict with the 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

static replace_holes(path_list_list)[source]

Replaces holes in the list of data paths of first modality with another modality

Parameters

path_list_list (list) – nested list, each element corresponds to one modality and is the corresponding list of data paths, first element is first modality

Returns

updated list of data paths of first modality

Return type

list

set_reference_modality_info()[source]

Finds the beginning datetimes and the durations of the files of reference modality along the recording

The reference modality is the first camera, or the first signal in case there is no video.

It sets the attributes ref_beg_datetime_list and ref_duration_list

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

flag_synchro

(bool) Specify if video and signal are synchronized

In case there is no video and several signals not synchronized, then synchro can be set to False and the synchronization reference is the first signal

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

ref_beg_datetime_list

(list) Beginning datetimes of the files of the reference modality

ref_duration_list

(list) Durations of the files of the reference modality

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

tmp_delimiter

(str) Delimiter for parsing temporary files for synchronization

tmp_name

(str) Directory where to save temporary files for synchrnonization

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

wid_next

(NextWidget) Widget for selecting next file

wid_previous

(PreviousWidget) Widget for selecting previous file