Plot

Widgets to plot waveforms of sensor values

The PVP_Gui creates a Plot_Container that allows the user to select

  • which plots (of those in values.PLOT ) are displayed

  • the timescale (x range) of the displayed waveforms

Plots display alarm limits as red horizontal bars

Classes:

AlarmSeverity(value)

An enumeration.

ControlSetting(name, value, min_value, …)

Message containing ventilation control parameters.

Plot(name, buffer_size, plot_duration, …)

Waveform plot of single sensor value.

Plot_Container(plot_descriptors, …)

Container for multiple :class;`.Plot` objects

SensorValues([timestamp, loop_counter, …])

Structured class for communicating sensor readings throughout PVP.

Value(name, units, abs_range, safe_range, …)

Class to parameterize how a value is used in PVP.

ValueName(value)

Canonical names of all values used in PVP.

deque

deque([iterable[, maxlen]]) –> deque object

Data:

PLOT_FREQ

Update frequency of Plot s in Hz

PLOT_TIMER

A QTimer that updates :class:`.TimedPlotCurveItem`s

Functions:

get_gui_instance()

Retreive the currently running instance of the GUI

init_logger(module_name[, log_level, …])

Initialize a logger for logging events.

mono_font()

module function to return a PySide2.QtGui.QFont to use as the mono font.

pvp.gui.widgets.plot.PLOT_TIMER = None

A QTimer that updates :class:`.TimedPlotCurveItem`s

pvp.gui.widgets.plot.PLOT_FREQ = 5

Update frequency of Plot s in Hz

class pvp.gui.widgets.plot.Plot(name: str, buffer_size: int = 4092, plot_duration: float = 10, plot_limits: tuple = None, color=None, units='', **kwargs)[source]

Waveform plot of single sensor value.

Plots values continuously, wrapping at zero rather than shifting x axis.

Parameters
  • name (str) – String version of ValueName used to set title

  • buffer_size (int) – number of samples to store

  • plot_duration (float) – default x-axis range

  • plot_limits (tuple) – tuple of (ValueName)s for which to make pairs of min and max range lines

  • color (None, str) – color of lines

  • units (str) – Unit label to display along title

  • **kwargs

timestamps

deque of timestamps

Type

collections.deque

history

deque of sensor values

Type

collections.deque

cycles

deque of breath cycles

Type

collections.deque

When initializing PlotWidget, parent and background are passed to GraphicsWidget.__init__() and all others are passed to PlotItem.__init__().

Attributes:

limits_changed(*args, **kwargs)

staticMetaObject

Methods:

reset_start_time()

Reset start time – return the scrolling time bar to position 0

set_duration(dur)

Set duration, or span of x axis.

set_safe_limits(limits)

Set the position of the max and min lines for a given value

set_units(units)

Set displayed units

update_value(new_value)

Update with new sensor value

limits_changed(*args, **kwargs) = <PySide2.QtCore.Signal object>
set_duration(dur: float)[source]

Set duration, or span of x axis.

Parameters

dur (float) – span of x axis (in seconds)

update_value(new_value: tuple)[source]

Update with new sensor value

Parameters

new_value (tuple) – (timestamp from time.time(), breath_cycle, value)

set_safe_limits(limits: pvp.common.message.ControlSetting)[source]

Set the position of the max and min lines for a given value

Parameters

limits (ControlSetting) – Controlsetting that has either a min_value or max_value defined

reset_start_time()[source]

Reset start time – return the scrolling time bar to position 0

set_units(units)[source]

Set displayed units

Currently only implemented for Pressure, display either in cmH2O or hPa

Parameters

units ('cmH2O', 'hPa') – unit to display pressure as

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class pvp.gui.widgets.plot.Plot_Container(plot_descriptors: Dict[pvp.common.values.ValueName, pvp.common.values.Value], *args, **kwargs)[source]

Container for multiple :class;`.Plot` objects

Allows user to show/hide different plots and adjust x-span (time zoom)

Note

Currently, the only unfortunately hardcoded parameter in the whole GUI is the instruction to initially hide FIO2, there should be an additional parameter in Value that says whether a plot should initialize as hidden or not

Todo

Currently, colors are set to alternate between orange and light blue on initialization, but they don’t update when plots are shown/hidden, so the alternating can be lost and colors can look random depending on what’s selcted.

Parameters

plot_descriptors (typing.Dict[ValueName, Value]) – dict of Value items to plot

plots

Dict mapping ValueName s to Plot s

Type

dict

slider

slider used to set x span

Type

PySide2.QtWidgets.QSlider

Methods:

init_ui()

reset_start_time()

Call Plot.reset_start_time() on all plots

set_duration(duration)

Set the current duration (span of the x axis) of all plots

set_plot_mode()

set_safe_limits(control)

Try to set horizontal alarm limits on all relevant plots

set_units(units)

Call Plot.set_units() for all contained plots

toggle_plot(state)

Toggle the visibility of a plot.

update_value(vals)

Try to update all plots who have new sensorvalues

Attributes:

staticMetaObject

init_ui()[source]
update_value(vals: pvp.common.message.SensorValues)[source]

Try to update all plots who have new sensorvalues

Parameters

vals (SensorValues) – Sensor Values to update plots with

toggle_plot(state: bool)[source]

Toggle the visibility of a plot.

get the name of the plot from the sender’s objectName

Parameters

state (bool) – Whether the plot should be visible (True) or not (False)

set_safe_limits(control: pvp.common.message.ControlSetting)[source]

Try to set horizontal alarm limits on all relevant plots

Parameters

control (ControlSetting) – with either min_value or max_value set

Returns:

set_duration(duration: float)[source]

Set the current duration (span of the x axis) of all plots

Also make sure that the text box and slider reflect this duration

Parameters

duration (float) – new duration to set

Returns:

reset_start_time()[source]

Call Plot.reset_start_time() on all plots

set_units(units: str)[source]

Call Plot.set_units() for all contained plots

staticMetaObject = <PySide2.QtCore.QMetaObject object>
set_plot_mode()[source]

Todo

switch between longitudinal timeseries and overlaid by breath cycle!!!