plot

Primary plot widgets that contain items from geom

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>