visiannot.visiannot.components.SignalWidget¶
Summary¶
Module defining SignalWidget and PlotItemCustom
Classes¶
|
Create a new PlotItem. |
Subclass of pyqtgraph.PlotWidget so that he effect of “auto-range” button is applied only on Y axis |
API¶
Class PlotItemCustom¶
-
class
visiannot.visiannot.components.SignalWidget.PlotItemCustom(parent=None, name=None, labels=None, title=None, viewBox=None, axisItems=None, enableMenu=True, **kargs)[source]¶ Bases:
pyqtgraph.graphicsItems.PlotItem.PlotItem.PlotItemCreate a new PlotItem. All arguments are optional. Any extra keyword arguments are passed to
PlotItem.plot().Arguments:
title
Title to display at the top of the item. Html is allowed.
labels
A dictionary specifying the axis labels to display:
{'left': (args), 'bottom': (args), ...}
The name of each axis and the corresponding arguments are passed to
PlotItem.setLabel()Optionally, PlotItem my also be initialized with the keyword arguments left, right, top, or bottom to achieve the same effect.name
Registers a name for this view so that others may link to it
viewBox
If specified, the PlotItem will be constructed with this as its ViewBox.
axisItems
Optional dictionary instructing the PlotItem to use pre-constructed items for its axes. The dict keys must be axis names (‘left’, ‘bottom’, ‘right’, ‘top’) and the values must be instances of AxisItem (or at least compatible with AxisItem).
Methods:
Re-implemented
Class SignalWidget¶
-
class
visiannot.visiannot.components.SignalWidget.SignalWidget(visi, widget_position, parent=None, background='default', wid_height=150, cursor_style={'color': 'F00', 'width': 1}, cursor_dragged_style={'color': 'F0F', 'width': 2}, **kwargs)[source]¶ Bases:
pyqtgraph.widgets.PlotWidget.PlotWidgetSubclass of pyqtgraph.PlotWidget so that he effect of “auto-range” button is applied only on Y axis
The constructor is re-implemented so that an instance of
PlotItemCustomis used as the central item of the widget.See https://pyqtgraph.readthedocs.io/en/latest/widgets/plotwidget.html for details about parent class.
- Parameters
visi – associated instance of
ViSiAnnoTwidget_position (tuple or list) – position of the widget in the layout of the associated instance of
ViSiAnnoTparent – first positional argument of pyqtgraph.GraphicsView
background – second positional argument of pyqtgraph.GraphicsView
kwargs – keyword arguments of
setAxesStyle()
Methods:
Clears the display of intervals regions
createPlotItems(first_frame_ms, …)Creates signal plot items, interval region items and threshold lines
currentCursorClicked(position, visi)Sets the current frame
frame_idat the specified positioncurrentCursorDragged(cursor, visi)Callback method for mouse dragging of the temporal cursor in a signal widget
Gets the position of the mouse on the X axis
plotIntervals(data_interval, freq, color)Plots intervals data as a region
setAxesStyle([y_range, left_label, …])Sets style of left and bottom axes
signalMouseClicked(ev, visi)Callback method for managing mouse click on the signal widget
updatePlotItems(first_frame_ms, …)Updates signal plot items, interval region items and threshold lines
Attributes:
Instance of
PlotItemCustom, central item of the widget(list) Signal plots in the widget, each element corresponds to one signal and is an instance of pyqtgraph.PlotDataItem
(list) Displayed temporal intervals, each element is a list of instances of pyqtgraph.LinearRegionItem
-
clearIntervalsRegions()[source]¶ Clears the display of intervals regions
It sets the attribute
region_interval_listto an empty list.
-
createPlotItems(first_frame_ms, last_frame_ms, sig_list, interval_list, threshold_list)[source]¶ Creates signal plot items, interval region items and threshold lines
It also sets the bounds of
cursor.- Parameters
first_frame_ms (float) – start timestamp of the temporal range to display (in milliseconds)
last_frame_ms (float) – end timestamp of the temporal range to display (in milliseconds)
sig_list (list) – signals to plot, each element is an instance of
Signalinterval_list (list) –
intervals to plot, each element is a list of length 3:
(numpy array) Intervals data, shape

(float) Frequency (
0if timestamps)(tuple) Plot color (RGBA)
threshold_list (list) –
thresholds to plot, each element is a list of length 2:
(float) Value of the threshold on Y axis
(tuple) Color to plot (RGB), it can also be a string with HEX color
-
currentCursorClicked(position, visi)[source]¶ Sets the current frame
frame_idat the specified positionIf the specified position is out of bounds of the current temporal range defined by
first_frameandlast_frame, then the current frame is not set.- Parameters
position (int) – frame number (sampled at the reference frequency
ViSiAnnoT.fps)visi – associated instance of
ViSiAnnoT
-
currentCursorDragged(cursor, visi)[source]¶ Callback method for mouse dragging of the temporal cursor in a signal widget
It updates the current frame
ViSiAnnoT.frame_idat the current position of the temporal cursor.Connected to the signal
sigDraggedof the attributecursor- Parameters
cursor (pyqtgraph.InfiniteLine) – temporal cursor that is dragged
-
getMouseTemporalPosition(ev)[source]¶ Gets the position of the mouse on the X axis
- Parameters
ev (QtGui.QMouseEvent) – emitted when the mouse is clicked/moved
- Returns
position of the mouse on the X axis,
-1if the mouse clicked on a label item (most likely the widget title)- Return type
float
-
plotIntervals(data_interval, freq, color)[source]¶ Plots intervals data as a region
It appends the attribute
region_interval_listwith the displayed region- Parameters
data_interval (numpy array) – intervals to be displayed, shape
, each line is an interval with start
frame and end frame (sampled at freq), relatively to the start timestamp of the data file) ; the intervals might be expressed in milliseconds, thenfreqmust be set to0freq (float) – sampling frequency of intervals frames, set it to
0if intervals expressed in millisecondscolor (tuple or list) – plot color (RGBA)
-
setAxesStyle(y_range=[], left_label='', left_label_style={'color': '#000', 'font-size': '10pt'}, ticks_color='#000', ticks_size=9, ticks_offset=0, y_ticks_width=30)[source]¶ Sets style of left and bottom axes
For details about color, see https://pyqtgraph.readthedocs.io/en/latest/functions.html#color-pen-and-brush-functions
- Parameters
y_range (tuple) – visible Y range, length 2
(y_min, y_max), set to[]for auto rangeleft_label (str) – label for Y axis
left_label_style (dict) – axis label title style
ticks_color (str or tuple) – color of the ticks text in HEX string or RGB format
ticks_size (float or int) – font size of the ticks text in pt
ticks_offset (int) – ticks text offset
y_ticks_width (int) – horizontal space in pixels for the text of Y axis ticks
-
signalMouseClicked(ev, visi)[source]¶ Callback method for managing mouse click on the signal widget
Connected to the signal
sigMouseClickedof the attributescene.On one hand, it allows to define manually a temporal interval on which to zoom by calling the method
zoom_or_annot_clicked().On the other hand, it allows to define a new annotation and to add it the annotation file by calling the method
zoom_or_annot_clicked(). Also, it allows to delete manually a specific events annotation by calling the methoddelete_clicked()on the attributeViSiAnnoT.wid_annotevent.It also updates the position of the temporal cursor by calling the method
currentCursorClicked().- Parameters
ev (QtGui.QMouseEvent) – emitted when the mouse is clicked/moved
visi – associated instance of
ViSiAnnoT
-
updatePlotItems(first_frame_ms, last_frame_ms, sig_list, interval_list)[source]¶ Updates signal plot items, interval region items and threshold lines
It also sets the bounds of
cursor.- Parameters
first_frame_ms (int) – start timestamp of the temporal range to display (in milliseconds)
last_frame_ms (int) – end timestamp of the temporal range to display (in milliseconds)
sig_list (list) – signals to plot, each element is an instance of
Signalinterval_list (list) –
intervals to plot, each element is a list of length 3:
(numpy array) Intervals data, shape

(float) Frequency (
0if timestamps)(tuple) Plot color (RGBA)
-
plotItem¶ Instance of
PlotItemCustom, central item of the widget
-
plot_list¶ (list) Signal plots in the widget, each element corresponds to one signal and is an instance of pyqtgraph.PlotDataItem
-
region_interval_list¶ (list) Displayed temporal intervals, each element is a list of instances of pyqtgraph.LinearRegionItem