plots

plot

Functions:

gui_event(fn)

Wrapper/decorator around an event that posts GUI events back to the main thread that our window is running in.

Classes:

Plot_Widget()

Main plot widget that holds plots for all pilots

Plot(pilot[, x_width, parent])

Widget that hosts a pyqtgraph.PlotWidget and manages graphical objects for one pilot depending on the task.

gui_event(fn)[source]

Wrapper/decorator around an event that posts GUI events back to the main thread that our window is running in.

Parameters

fn (callable) – a function that does something to the GUI

class Plot_Widget[source]

Bases: PySide2.QtWidgets.QWidget

Main plot widget that holds plots for all pilots

Essentially just a container to give plots a layout and handle any logic that should apply to all plots.

Variables
  • logger (logging.Logger) – The ‘main’ logger

  • plots (dict) – mapping from pilot name to Plot

Methods:

init_plots(pilot_list)

For each pilot, instantiate a Plot and add to layout.

Attributes:

staticMetaObject

init_plots(pilot_list)[source]

For each pilot, instantiate a Plot and add to layout.

Parameters

pilot_list (list) – the keys from Terminal.pilots

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5b3caa00>
class Plot(pilot, x_width=50, parent=None)[source]

Bases: PySide2.QtWidgets.QWidget

Widget that hosts a pyqtgraph.PlotWidget and manages graphical objects for one pilot depending on the task.

listens

Key

Method

Description

‘START’

l_start()

starting a new task

‘DATA’

l_data()

getting a new datapoint

‘STOP’

l_stop()

stop the task

‘PARAM’

l_param()

change some parameter

Plot Parameters

The plot is built from the PLOT={data:plot_element} mappings described in the Task class. Additional parameters can be specified in the PLOT dictionary. Currently:

  • continuous (bool): whether the data should be plotted against the trial number (False or NA) or against time (True)

  • chance_bar (bool): Whether to draw a red horizontal line at chance level (default: 0.5)

  • chance_level (float): The position in the y-axis at which the chance_bar should be drawn

  • roll_window (int): The number of trials Roll_Mean take the average over.

Variables
  • pilot (str) –

    The name of our pilot, used to set the identity of our socket, specifically:

    'P_{pilot}'
    

  • infobox (QtWidgets.QFormLayout) – Box to plot basic task information like trial number, etc.

  • info (dict) –

    Widgets in infobox:

    • ’N Trials’: QtWidgets.QLabel,

    • ’Runtime’ : Timer,

    • ’Session’ : QtWidgets.QLabel,

    • ’Protocol’: QtWidgets.QLabel,

    • ’Step’ : QtWidgets.QLabel

  • plot (pyqtgraph.PlotWidget) – The widget where we draw our plots

  • plot_params (dict) – A dictionary of plot parameters we receive from the Task class

  • data (dict) – A dictionary of the data we’ve received

  • plots (dict) – The collection of plots we instantiate based on plot_params

  • node (Net_Node) – Our local net node where we listen for data.

  • state (str) – state of the pilot, used to keep plot synchronized.

Parameters
  • pilot (str) – The name of our pilot

  • x_width (int) – How many trials in the past should we plot?

Methods:

init_plots()

Make pre-task GUI objects and set basic visual parameters of self.plot

l_start(value)

Starting a task, initialize task-specific plot objects described in the Task.PLOT attribute.

l_data(value)

Receive some data, if we were told to plot it, stash the data and update the assigned plot.

l_stop(value)

Clean up the plot objects.

l_param(value)

Warning

Not implemented

l_state(value)

Pilot letting us know its state has changed.

Attributes:

staticMetaObject

init_plots()[source]

Make pre-task GUI objects and set basic visual parameters of self.plot

l_start(value)[source]

Starting a task, initialize task-specific plot objects described in the Task.PLOT attribute.

Matches the data field name (keys of Task.PLOT ) to the plot object that represents it, eg, to make the standard nafc plot:

{'target'   : 'point',
 'response' : 'segment',
 'correct'  : 'rollmean'}
Parameters

value (dict) – The same parameter dictionary sent by Terminal.toggle_start(), including

  • current_trial

  • step

  • session

  • step_name

  • task_type

l_data(value)[source]

Receive some data, if we were told to plot it, stash the data and update the assigned plot.

Parameters

value (dict) – Value field of a data message sent during a task.

l_stop(value)[source]

Clean up the plot objects.

Parameters

value (dict) – if “graduation” is a key, don’t stop the timer.

l_param(value)[source]

Warning

Not implemented

Parameters

value

l_state(value)[source]

Pilot letting us know its state has changed. Mostly for the case where we think we’re running but the pi doesn’t.

Parameters

value (Pilot.state) – the state of our pilot

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da30a80>

geom

Classes:

Point([color, size])

A simple point.

Line([color, size])

A simple line

Segment(**kwargs)

A line segment that draws from 0.5 to some endpoint.

Roll_Mean

Shaded area underneath a rolling average.

Shaded(**kwargs)

Shaded area for a continuous plot

HLine()

A Horizontal line.

Data:

PLOT_LIST

A dictionary connecting plot keys to objects.

class Point(color=(0, 0, 0), size=5, **kwargs)[source]

Bases: pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem

A simple point.

Variables
  • brush (QtWidgets.QBrush) –

  • pen (QtWidgets.QPen) –

Parameters
  • color (tuple) – RGB color of points

  • size (int) – width in px.

Methods:

update(data)

Parameters

data (numpy.ndarray) -- an x_width x 2 array where

Attributes:

staticMetaObject

update(data)[source]
Parameters

data (numpy.ndarray) – an x_width x 2 array where column 0 is trial number and column 1 is the value, where value can be “L”, “C”, “R” or a float.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5db51340>
class Line(color=(0, 0, 0), size=1, **kwargs)[source]

Bases: pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem

A simple line

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

PlotDataItem(x, y)

x, y: array_like coordinate values

PlotDataItem(y)

y values only – x will be automatically set to range(len(y))

PlotDataItem(x=x, y=y)

x and y given by keyword arguments

PlotDataItem(ndarray(N,2))

single numpy array with shape (N, 2), where x=data[:,0] and y=data[:,1]

Data initialization arguments: (x,y data AND may include spot style)

PlotDataItem(recarray)

numpy record array with dtype=[('x', float), ('y', float), ...]

PlotDataItem(list-of-dicts)

[{'x': x, 'y': y, ...},   ...]

PlotDataItem(dict-of-lists)

{'x': [...], 'y': [...],  ...}

Line style keyword arguments:

connect

Specifies how / whether vertexes should be connected. See below for details.

pen

Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a QPen or any single argument accepted by mkPen()

shadowPen

Pen for secondary line to draw behind the primary line. Disabled by default. May be a QPen or any single argument accepted by mkPen()

fillLevel

If specified, the area between the curve and fillLevel is filled.

fillOutline

(bool) If True, an outline surrounding the fillLevel area is drawn.

fillBrush

Fill to use in the fillLevel area. May be any single argument accepted by mkBrush()

stepMode

(str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

connect supports the following arguments:

  • ‘all’ connects all points.

  • ‘pairs’ generates lines between every other point.

  • ‘finite’ creates a break when a nonfinite points is encountered.

  • If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

  • In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See arrayToQPath() for more details.

Point style keyword arguments: (see ScatterPlotItem.setData() for more information)

symbol

Symbol to use for drawing points, or a list of symbols for each. The default is no symbol.

symbolPen

Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by mkPen().

symbolBrush

Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by mkBrush().

symbolSize

Diameter of symbols, or list of diameters.

pxMode

(bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by ScatterPlotItem can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a QtGui.QPainterPath instance.

Optimization keyword arguments:

antialias

(bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when pxMode=True), points will be rendered antialiased even if this is set to False.

downsample

(int) Reduce the number of samples displayed by the given factor.

downsampleMethod

‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.

autoDownsample

(bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage.

clipToView

(bool) If True, only data visible within the X range of the containing ViewBox is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time.

dynamicRangeLimit

(float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the ViewBox height.

dynamicRangeHyst

(float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated.

skipFiniteCheck

(bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit.

In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

name

(string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, pyqtgraph.mkPen() will automatically create a QPen with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

update() -> None)

Attributes:

staticMetaObject

update(self, rect: PySide2.QtCore.QRectF = Default(QRectF)) None[source]
update(self, x: float, y: float, width: float, height: float) None
staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da28700>
class Segment(**kwargs)[source]

Bases: pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem

A line segment that draws from 0.5 to some endpoint.

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

PlotDataItem(x, y)

x, y: array_like coordinate values

PlotDataItem(y)

y values only – x will be automatically set to range(len(y))

PlotDataItem(x=x, y=y)

x and y given by keyword arguments

PlotDataItem(ndarray(N,2))

single numpy array with shape (N, 2), where x=data[:,0] and y=data[:,1]

Data initialization arguments: (x,y data AND may include spot style)

PlotDataItem(recarray)

numpy record array with dtype=[('x', float), ('y', float), ...]

PlotDataItem(list-of-dicts)

[{'x': x, 'y': y, ...},   ...]

PlotDataItem(dict-of-lists)

{'x': [...], 'y': [...],  ...}

Line style keyword arguments:

connect

Specifies how / whether vertexes should be connected. See below for details.

pen

Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a QPen or any single argument accepted by mkPen()

shadowPen

Pen for secondary line to draw behind the primary line. Disabled by default. May be a QPen or any single argument accepted by mkPen()

fillLevel

If specified, the area between the curve and fillLevel is filled.

fillOutline

(bool) If True, an outline surrounding the fillLevel area is drawn.

fillBrush

Fill to use in the fillLevel area. May be any single argument accepted by mkBrush()

stepMode

(str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

connect supports the following arguments:

  • ‘all’ connects all points.

  • ‘pairs’ generates lines between every other point.

  • ‘finite’ creates a break when a nonfinite points is encountered.

  • If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

  • In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See arrayToQPath() for more details.

Point style keyword arguments: (see ScatterPlotItem.setData() for more information)

symbol

Symbol to use for drawing points, or a list of symbols for each. The default is no symbol.

symbolPen

Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by mkPen().

symbolBrush

Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by mkBrush().

symbolSize

Diameter of symbols, or list of diameters.

pxMode

(bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by ScatterPlotItem can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a QtGui.QPainterPath instance.

Optimization keyword arguments:

antialias

(bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when pxMode=True), points will be rendered antialiased even if this is set to False.

downsample

(int) Reduce the number of samples displayed by the given factor.

downsampleMethod

‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.

autoDownsample

(bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage.

clipToView

(bool) If True, only data visible within the X range of the containing ViewBox is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time.

dynamicRangeLimit

(float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the ViewBox height.

dynamicRangeHyst

(float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated.

skipFiniteCheck

(bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit.

In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

name

(string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, pyqtgraph.mkPen() will automatically create a QPen with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

update(data)

data is doubled and then every other value is set to 0.5, then setData() is used with connect='pairs' to make line segments.

Attributes:

staticMetaObject

update(data)[source]

data is doubled and then every other value is set to 0.5, then setData() is used with connect=’pairs’ to make line segments.

Parameters

data (numpy.ndarray) – an x_width x 2 array where column 0 is trial number and column 1 is the value, where value can be “L”, “C”, “R” or a float.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da28400>
class Roll_Mean[source]

Bases: pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem

Shaded area underneath a rolling average.

Typically used as a rolling mean of corrects, so area above and below 0.5 is drawn.

Parameters

winsize (int) – number of trials in the past to take a rolling mean of

Methods:

update(data)

Parameters

data (numpy.ndarray) -- an x_width x 2 array where

Attributes:

staticMetaObject

update(data)[source]
Parameters

data (numpy.ndarray) – an x_width x 2 array where column 0 is trial number and column 1 is the value.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da28780>
class Shaded(**kwargs)[source]

Bases: pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem

Shaded area for a continuous plot

There are many different ways to create a PlotDataItem.

Data initialization arguments: (x,y data only)

PlotDataItem(x, y)

x, y: array_like coordinate values

PlotDataItem(y)

y values only – x will be automatically set to range(len(y))

PlotDataItem(x=x, y=y)

x and y given by keyword arguments

PlotDataItem(ndarray(N,2))

single numpy array with shape (N, 2), where x=data[:,0] and y=data[:,1]

Data initialization arguments: (x,y data AND may include spot style)

PlotDataItem(recarray)

numpy record array with dtype=[('x', float), ('y', float), ...]

PlotDataItem(list-of-dicts)

[{'x': x, 'y': y, ...},   ...]

PlotDataItem(dict-of-lists)

{'x': [...], 'y': [...],  ...}

Line style keyword arguments:

connect

Specifies how / whether vertexes should be connected. See below for details.

pen

Pen to use for drawing the lines between points. Default is solid grey, 1px width. Use None to disable line drawing. May be a QPen or any single argument accepted by mkPen()

shadowPen

Pen for secondary line to draw behind the primary line. Disabled by default. May be a QPen or any single argument accepted by mkPen()

fillLevel

If specified, the area between the curve and fillLevel is filled.

fillOutline

(bool) If True, an outline surrounding the fillLevel area is drawn.

fillBrush

Fill to use in the fillLevel area. May be any single argument accepted by mkBrush()

stepMode

(str or None) If specified and not None, a stepped curve is drawn. For ‘left’ the specified points each describe the left edge of a step. For ‘right’, they describe the right edge. For ‘center’, the x coordinates specify the location of the step boundaries. This mode is commonly used for histograms. Note that it requires an additional x value, such that len(x) = len(y) + 1 .

connect supports the following arguments:

  • ‘all’ connects all points.

  • ‘pairs’ generates lines between every other point.

  • ‘finite’ creates a break when a nonfinite points is encountered.

  • If an ndarray is passed, it should contain N int32 values of 0 or 1. Values of 1 indicate that the respective point will be connected to the next.

  • In the default ‘auto’ mode, PlotDataItem will normally use ‘all’, but if any nonfinite data points are detected, it will automatically switch to ‘finite’.

See arrayToQPath() for more details.

Point style keyword arguments: (see ScatterPlotItem.setData() for more information)

symbol

Symbol to use for drawing points, or a list of symbols for each. The default is no symbol.

symbolPen

Outline pen for drawing points, or a list of pens, one per point. May be any single argument accepted by mkPen().

symbolBrush

Brush for filling points, or a list of brushes, one per point. May be any single argument accepted by mkBrush().

symbolSize

Diameter of symbols, or list of diameters.

pxMode

(bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Any symbol recognized by ScatterPlotItem can be specified, including ‘o’ (circle), ‘s’ (square), ‘t’, ‘t1’, ‘t2’, ‘t3’ (triangles of different orientation), ‘d’ (diamond), ‘+’ (plus sign), ‘x’ (x mark), ‘p’ (pentagon), ‘h’ (hexagon) and ‘star’.

Symbols can also be directly given in the form of a QtGui.QPainterPath instance.

Optimization keyword arguments:

antialias

(bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particular, when pxMode=True), points will be rendered antialiased even if this is set to False.

downsample

(int) Reduce the number of samples displayed by the given factor.

downsampleMethod

‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.

autoDownsample

(bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage.

clipToView

(bool) If True, only data visible within the X range of the containing ViewBox is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time.

dynamicRangeLimit

(float or None) Limit off-screen y positions of data points. None disables the limiting. This can increase performance but may cause plots to disappear at high levels of magnification. The default of 1e6 limits data to approximately 1,000,000 times the ViewBox height.

dynamicRangeHyst

(float) Permits changes in vertical zoom up to the given hysteresis factor (the default is 3.0) before the limit calculation is repeated.

skipFiniteCheck

(bool, default False) Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit.

In the default ‘auto’ connect mode, PlotDataItem will apply this setting automatically.

Meta-info keyword arguments:

name

(string) Name of item for use in the plot legend

Notes on performance:

Plotting lines with the default single-pixel width is the fastest available option. For such lines, translucent colors (alpha < 1) do not result in a significant slowdown.

Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors require merging the entire plot into a single entity before the alpha value can be applied. For plots with more than a few hundred points, this can result in excessive slowdown.

Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments separately for fully opaque lines. Setting alpha < 1 reverts to the previous, slower drawing method.

For lines with a width of more than 4 pixels, pyqtgraph.mkPen() will automatically create a QPen with Qt.PenCapStyle.RoundCap to ensure a smooth connection of line segments. This incurs a small performance penalty.

Methods:

update(data)

Parameters

data (numpy.ndarray) -- an x_width x 2 array where

Attributes:

staticMetaObject

update(data)[source]
Parameters

data (numpy.ndarray) – an x_width x 2 array where column 0 is time and column 1 is the value.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da28940>
class HLine[source]

Bases: PySide2.QtWidgets.QFrame

A Horizontal line.

Attributes:

staticMetaObject

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5da28a40>
PLOT_LIST = {   'line': <class 'autopilot.gui.plots.geom.Line'>,     'point': <class 'autopilot.gui.plots.geom.Point'>,     'rollmean': <class 'autopilot.gui.plots.geom.Roll_Mean'>,     'segment': <class 'autopilot.gui.plots.geom.Segment'>,     'shaded': <class 'autopilot.gui.plots.geom.Shaded'>}

A dictionary connecting plot keys to objects.

Todo

Just reference the plot objects.

info

Classes:

Timer()

A simple timer that counts.

class Timer[source]

Bases: PySide2.QtWidgets.QLabel

A simple timer that counts… time…

Uses a QtCore.QTimer connected to Timer.update_time() .

Methods:

start_timer([update_interval])

Parameters

update_interval (float) -- How often (in ms) the timer should be updated.

stop_timer()

you can read the sign ya punk

update_time()

Called every (update_interval) milliseconds to set the text of the timer.

Attributes:

staticMetaObject

start_timer(update_interval=1000)[source]
Parameters

update_interval (float) – How often (in ms) the timer should be updated.

stop_timer()[source]

you can read the sign ya punk

update_time()[source]

Called every (update_interval) milliseconds to set the text of the timer.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5b3cab40>

video

Classes:

Video(videos[, fps])

Display Video data as it is collected.

ImageItem_TimedUpdate(*args, **kwargs)

Reclass of pyqtgraph.ImageItem to update with a fixed fps.

class Video(videos, fps=None)[source]

Bases: PySide2.QtWidgets.QWidget

Display Video data as it is collected.

Uses the ImageItem_TimedUpdate class to do timed frame updates.

Parameters
  • videos (list, tuple) – Names of video streams that will be displayed

  • fps (int) – if None, draw according to prefs.get('DRAWFPS'). Otherwise frequency of widget update

Variables
  • videos (list, tuple) – Names of video streams that will be displayed

  • fps (int) – if None, draw according to prefs.get('DRAWFPS'). Otherwise frequency of widget update

  • ifps (int) – 1/fps, duration of frame in s

  • qs (dict) – Dictionary of :class:`~queue.Queue`s in which frames will be dumped

  • quitting (threading.Event) – Signal to quit drawing

  • update_thread (threading.Thread) – Thread with target=:meth:~.Video._update_frame

  • layout (PySide2.QtWidgets.QGridLayout) – Widget layout

  • vid_widgets (dict) – dict containing widgets for each of the individual video streams.

Methods:

init_gui()

update_frame(video, data)

Put a frame for a video stream into its queue.

release()

Attributes:

staticMetaObject

init_gui()[source]
update_frame(video, data)[source]

Put a frame for a video stream into its queue.

If there is a waiting frame, pull it from the queue first – it’s old now.

Parameters
  • video (str) – name of video stream

  • data (numpy.ndarray) – video frame

release()[source]
staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5b4b0900>
class ImageItem_TimedUpdate(*args, **kwargs)[source]

Bases: pyqtgraph.graphicsItems.ImageItem.ImageItem

Reclass of pyqtgraph.ImageItem to update with a fixed fps.

Rather than calling update() every time a frame is updated, call it according to the timer.

fps is set according to prefs.get('DRAWFPS'), if not available, draw at 10fps

Variables

timer (QTimer) – Timer held in globals() that synchronizes frame updates across image items

See setOpts() for further keyword arguments and and setImage() for information on supported formats.

image: array

Image data

Methods:

setImage([image, autoLevels])

Updates the image displayed by this ImageItem.

update_img()

Call update()

Attributes:

staticMetaObject

setImage(image=None, autoLevels=None, **kargs)[source]

Updates the image displayed by this ImageItem. For more information on how the image is processed before displaying, see makeARGB().

For backward compatibility, image data is assumed to be in column-major order (column, row) by default. However, most data is stored in row-major order (row, column). It can either be transposed before assignment:

imageitem.setImage(imagedata.T)

or the interpretation of the data can be changed locally through the axisOrder keyword or by changing the imageAxisOrder global configuration option.

All keywords supported by setOpts() are also allowed here.

image: array

Image data given as NumPy array with an integer or floating point dtype of any bit depth. A 2-dimensional array describes single-valued (monochromatic) data. A 3-dimensional array is used to give individual color components. The third dimension must be of length 3 (RGB) or 4 (RGBA).

rect: QRectF, QRect or list_like of floats [x, y, w, h], optional

If given, sets translation and scaling to display the image within the specified rectangle. See setRect().

autoLevels: bool, optional

If True, ImageItem will automatically select levels based on the maximum and minimum values encountered in the data. For performance reasons, this search subsamples the images and may miss individual bright or or dark points in the data set.

If False, the search will be omitted.

The default is False if a levels keyword argument is given, and True otherwise.

levelSamples: int, default 65536

When determining minimum and maximum values, ImageItem only inspects a subset of pixels no larger than this number. Setting this larger than the total number of pixels considers all values.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7efe5bcc68c0>
update_img()[source]

Call update()