visiannot.visiannot.ViSiAnnoTLongRec¶
Module defining ViSiAnnoTLongRec
Summary¶
Classes¶
Subclass of |
API¶
Class ViSiAnnoTLongRec¶
Methods for managing the navigation along the recording files:
|
Changes file in the long recording |
Callback method for loading next file in the long recording after having clicked on the “next” image |
|
Callback method for loading previous file in the long recording after having clicked on the “previous” image |
|
Loads next file in the long recording |
|
|
Loads data of a new file in the long recording |
Loads previous file in the long recording |
|
|
Callback method for choosing a new file in the long recording with the combo box |
Methods for converting converting an input signal configuration to a list of signal configurations compliant with ViSiAnnoT:
|
Class method for creating synchronization files |
|
Converts signal and interval configurations to configuration lists compliant with |
|
Converts the configuration lists for a specific signal widget and for the whole long recording |
Attributes:
(bool) Specify if video and signal are synchronized |
|
(dict) Key is a camera ID. |
|
(list) Instances of datetime.datetime with the beginning datetime of each video file (or first signal if no video) |
|
(list) Durations in seconds of each video file (or first signal if no video) |
|
(str) Directory where to save temporary files for synchrnonization |
|
(str) Delimiter for parsing temporary files for synchronization |
|
(dict) Each item corresponds to one signal widget, key is the data type of the widget, value is a nested list of signal configurations |
|
(dict) Each item corresponds to one signal widget on which to plot intervals, key is the data type of the widget, value is a nested list of interval configurations. |
|
(str) Base name of the annotation files |
|
(QtWidgets.QGridlayout) Widget of the “previous rec” image |
|
(QtWidgets.QGridlayout) Widget of the “next rec” image |
|
(QtWidgets.QComboBox) Combo box for recording file selection |
-
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.ViSiAnnoTSubclass of
ViSiAnnoTfor managing a long recording with several filesFirst, 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 withdatetime.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_dictofViSiAnnoTconstructor for detail about data storing format,(str) Key to access the data (in case of .mat or .h5 file),
(int or float or str) Signal frequency, set it to
0if signal non regularly sampled, set it to-1if same frequency asViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file,(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 withdatetime.strptime()),(dict) Plot style, see https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html for details, set it to
Nonefor default.
Here is an example:
{ "sig_1": [ [ "path/to/folder1", "", 50, "*_motion.txt", '_', 1, "%Y-%m-%dT%H-%M-%S", None ] ], "sig_2": [ [ "path/to/folder2", "ecg", 0, "*_physio.h5", '_', 0, "posix", {'pen': {'color': 'm', 'width': 1} ], [ "path/to/folder2", "resp", -1, "*_physio.h5", '_', 0, "posix",None ] ] }
In case of audio signal to plot, the configuration list is slightly different. The second element (key to access data) is a string to specify which channel to plot. It must contain
"left"or"right", whatever the letter capitalization is. Otherwise, by default the left channel is plotted. Moreover, the frequency is directly retrieved from the wav file, so the third element of the configuration list (signal frequency) is ignored.Here is an example for audio:
{ "Audio L": [[ "path/to/folder", "Left channel", 0, "*_audio.wav", '_', 1, "%Y-%m-%dT%H-%M-%S", None ]], "Audio R": [[ "path/to/folder", "Right channel", 0, "*_audio.wav", '_', 1, "%Y-%m-%dT%H-%M-%S", None]] }
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_dictofViSiAnnoTconstructor for detail about data storing format,(str) Key to access the data (in case of .mat or .h5 file),
(int) Signal frequency, set it to
-1if same frequency asViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file,(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 withdatetime.strptime()),(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_synchrocan be set toFalseand the synchronization reference is the first signallayout_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),4(even more compact display, image extraction tool is disabled).
poswid_dict (dict) –
custom position of the widgets in the window, default
{}to use the positions defined by the layout mode (see inputlayout_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""rec_choice""progress"
kwargs – keyword arguments of
ViSiAnnoTconstructor
-
changeFileInLongRec(rec_id, new_frame_id, flag_previous_scroll=False)[source]¶ Changes file in the long recording
It loads new data files by calling
ViSiAnnoTLongRec.prepareNewRecording(). Then it updates the display.- Parameters
rec_id (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
createSynchronizationFiles(data_path_list, type_data, key_data, 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_listandref_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
type_data (str) – data type, used for the name of the synchronization files
key_data (str) – key to access data (in case of .h5 or .mat files), 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
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
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
-
getSignalConfigurationAllTypes(signal_dict, interval_dict, **kwargs)[source]¶ Converts signal and interval configurations to configuration lists compliant with
ViSiAnnoTIt sets the following attributes:
ViSiAnnoTLongRec.interval_dict_list(must be initialized)
- Parameters
signal_dict (dict) – see second positional argument of
ViSiAnnoTLongRecconstructorinterval_dict (dict) – see keyword argument of
ViSiAnnoTLongRecconstructorkwargs – keyword arguments of the function
getBeginningEndingDateTimeFromList()
- Returns
signal_dict_current (list) – signal configuration of the first file in the long recording. Each element corresponds to one signal and is a list with 7 elements (see positional argument
signal_dictofViSiAnnoTconstructor)interval_dict_current (list) – interval configuration of the first file in the long recording. Each element corresponds to one interval and is a list with 7 elements (see keyword argument
interval_dictofViSiAnnoTconstructor)
-
getSignalConfigurationSingleType(type_data, data_info_list, flag_raise_exception=True, **kwargs)[source]¶ Converts the configuration lists for a specific signal widget and for the whole long recording
It can be used for signal configuration or intervals configuration.
- Parameters
type_data (str) – data type of the signal widget
data_info_list (list) –
list of configuration lists, each element is a list of length 8:
(str) Directory where to find the data files,
(str) Key to access the data (in case of .h5 or .mat files),
(float or str) Data frequency
(str) Pattern to find the data files,
(str) Delimiter to get beginning datetime in the data file name,
(int) Position of the beginning datetime in the data file name, according to the delimiter,
(str) Format of the beginning datetime in the data file name (either
"posix"or a format compliant withdatetime.strptime()),(dict) Plot style.
flag_raise_exception (bool) – specify if an exception must be raised when no data files are found
kwargs – keyword arguments of the function
getBeginningEndingDateTimeFromList()
- Returns
config_whole_rec_list (list) – nested list where each element is a configuration list and corresponds to one file in the long recording. Each element corresponds to one signal/interval and is a nested list where each element corresponds to one file in the long recording with 4 elements (path to the data file, key to access data, frequency, plot style)
config_current_list (list) – configuration list of the first file in the long recording. Each element corresponds to one signal/interval and is a list with 4 elements (path to the data file, key to access data, frequency, plot style)
-
mouseClickedNext()[source]¶ Callback method for loading next file in the long recording after having clicked on the “next” image
Connected to the signal
sigMouseClickedof the attributesceneofViSiAnnoTLongRec.wid_next.
-
mouseClickedPrevious()[source]¶ Callback method for loading previous file in the long recording after having clicked on the “previous” image
Connected to the signal
sigMouseClickedof the attributesceneofViSiAnnoTLongRec.wid_previous.
-
nextRecording()[source]¶ Loads next file in the long recording
- Returns
specify if the file has been effectively changed
- Return type
bool
-
prepareNewRecording(rec_id)[source]¶ Loads data of a new file in the long recording
It does not set
ViSiAnnoT.first_frameandViSiAnnoT.last_frame, and it does not update signal plots.- Parameters
rec_id (int) – index of the new file in the long recording
- Returns
specify if the new file has been effectively loaded
- Return type
bool
-
recChoice(ite_rec)[source]¶ Callback method for choosing a new file in the long recording with the combo box
Connected to the signal
currentIndexChangedofViSiAnnoTLongRec.combo_rec_choice.- Parameters
ite_rec (int) – index of the new file in the long recording selected in the combo box
-
annot_file_base¶ (str) Base name of the annotation files
Label and annotation type is added when loading/saving annotation files)
-
combo_rec_choice¶ (QtWidgets.QComboBox) Combo box for recording file selection
-
flag_synchro¶ (bool) Specify if video and signal are synchronized
In case there is no video and several signals not synchronized, then
synchrocan be set to False and the synchronization reference is the first signal
-
interval_dict_list¶ (dict) Each item corresponds to one signal widget on which to plot intervals, key is the data type of the widget, value is a nested list of interval configurations.
Each element of the nested list corresponds to one type of interval and is a list along the interval files in the long recording, where each element is a configuration list (see second keyword argument
interval_dictofViSiAnnoTconstructor for details about the configuration list).
-
rec_beginning_datetime_list¶ (list) Instances of datetime.datetime with the beginning datetime of each video file (or first signal if no video)
The list of video files that is used is in the first value of
ViSiAnnoTLongRec.video_dict_list(orViSiAnnoTLongRec.signal_dict_listin caseViSiAnnoTLongRec.video_dict_listis empty).
-
rec_duration_list¶ (list) Durations in seconds of each video file (or first signal if no video)
-
signal_dict_list¶ (dict) Each item corresponds to one signal widget, key is the data type of the widget, value is a nested list of signal configurations
Each element of the nested list corresponds to one signal plot and is a list along the signal files in the long recording, where each element is a configuration list (see second positional argument of
ViSiAnnoTconstructor for details about the configuration list).
-
tmp_delimiter¶ (str) Delimiter for parsing temporary files for synchronization
-
tmp_name¶ (str) Directory where to save temporary files for synchrnonization
-
video_dict_list¶ (dict) Key is a camera ID. Value is a list along the video files in the long recording, where each element is a configuration list (see first positional argument of
ViSiAnnoTconstructor for details about configuration list)
-
wid_next¶ (QtWidgets.QGridlayout) Widget of the “next rec” image
-
wid_previous¶ (QtWidgets.QGridlayout) Widget of the “previous rec” image