stytra.gui package

Submodules

stytra.gui.buttons module

stytra.gui.buttons.get_icon(icon_name)[source]
class stytra.gui.buttons.IconButton(*args, icon_name='', action_name='', **kwargs)[source]

Bases: PyQt5.QtWidgets.QToolButton

class stytra.gui.buttons.ToggleIconButton(*args, icon_on='', icon_off=None, action_on='', action_off=None, on=False, **kwargs)[source]

Bases: PyQt5.QtWidgets.QToolButton

flip_icon(tg)[source]

stytra.gui.camera_display module

class stytra.gui.camera_display.SingleLineROI(*args, **kwargs)[source]

Bases: pyqtgraph.graphicsItems.ROI.LineSegmentROI

Subclassing pyqtgraph polyLineROI to remove the “add handle” behavior.

segmentClicked()[source]
class stytra.gui.camera_display.CameraViewWidget(*args, experiment=None, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

A widget to show images from a frame source and display the camera controls.

retrieve_image()[source]

Update displayed frame while emptying frame source queue. This is done through a while loop that takes all available frames at every update.

# TODO fix this somehow?

Important! if the input queue is too fast this will produce an infinite loop and block the interface!

scale_changed()[source]
save_image(name=None)[source]

Save a frame to the current directory.

show_params_gui()[source]
class stytra.gui.camera_display.CameraSelection(**kwargs)[source]

Bases: stytra.gui.camera_display.CameraViewWidget

Generic class to overlay on video an ROI that can be used to select regions of the image and communicate their position to the tracking algorithm (e.g., tail starting point or eyes region).

The changes of parameters read through the ROI position are handled via the track_params class, so they must have a corresponding entry in the definition of the FrameProcessingMethod of the tracking function of choice.

initialise_roi(roi)[source]

ROI is initialised separately, so it can first be defined in the child __init__.

set_pos_from_tree()[source]

Called when ROI position values are changed in the ParameterTree. Change the position of the displayed ROI.

set_pos_from_roi()[source]

Called when ROI position values are changed in the displayed ROI. Change the position in the ParameterTree values.

class stytra.gui.camera_display.TailTrackingSelection(**kwargs)[source]

Bases: stytra.gui.camera_display.CameraSelection

set_pos_from_tree()[source]

Go to parent for definition.

set_pos_from_roi()[source]

Go to parent for definition.

scale_changed()[source]
retrieve_image()[source]

Go to parent for definition.

tail_points()[source]
tail_dims()[source]
class stytra.gui.camera_display.EyeTrackingSelection(**kwargs)[source]

Bases: stytra.gui.camera_display.CameraSelection

set_pos_from_tree()[source]

Go to parent for definition.

set_pos_from_roi()[source]

Go to parent for definition.

scale_changed()[source]
retrieve_image()[source]

Go to parent for definition.

class stytra.gui.camera_display.EyeTailTrackingSelection(**kwargs)[source]

Bases: stytra.gui.camera_display.TailTrackingSelection, stytra.gui.camera_display.EyeTrackingSelection

class stytra.gui.camera_display.CameraViewCalib(*args, **kwargs)[source]

Bases: stytra.gui.camera_display.CameraViewWidget

show_calibration(calibrator)[source]
Parameters

calibrator

set_pos_from_tree()[source]
class stytra.gui.camera_display.CameraViewFish(*args, **kwargs)[source]

Bases: stytra.gui.camera_display.CameraViewCalib

retrieve_image()[source]

Update displayed frame while emptying frame source queue. This is done through a while loop that takes all available frames at every update.

# TODO fix this somehow?

Important! if the input queue is too fast this will produce an infinite loop and block the interface!

stytra.gui.container_windows module

class stytra.gui.container_windows.QPlainTextEditLogger[source]

Bases: logging.Handler

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

class stytra.gui.container_windows.ExperimentWindow(experiment, **kwargs)[source]

Bases: PyQt5.QtWidgets.QMainWindow

Window for controlling a simple experiment including only a monitor the relative controls and the buttons for data_log and protocol control.

Parameters

experiment (Experiment <stytra.experiments.Experiment> object) – experiment for which the window is built.

change_folder_gui()[source]
show_metadata_gui()[source]
add_dock(item: PyQt5.QtWidgets.QDockWidget)[source]
construct_ui()[source]
write_log(msg)[source]
toggle_db(tg)[source]
closeEvent(*args, **kwargs)[source]
Parameters
  • *args

  • **kwargs

class stytra.gui.container_windows.VisualExperimentWindow(*args, **kwargs)[source]

Bases: stytra.gui.container_windows.ExperimentWindow

Window for controlling a simple experiment including only a monitor the relative controls and the buttons for data_log and protocol control.

Parameters

experiment (Experiment <stytra.experiments.Experiment> object) – experiment for which the window is built.

construct_ui()[source]
class stytra.gui.container_windows.CameraExperimentWindow(*args, **kwargs)[source]

Bases: stytra.gui.container_windows.VisualExperimentWindow

construct_ui()[source]
class stytra.gui.container_windows.DynamicStimExperimentWindow(*args, **kwargs)[source]

Bases: stytra.gui.container_windows.VisualExperimentWindow

Window for plotting a dynamically varying stimulus.

construct_ui()[source]
class stytra.gui.container_windows.TrackingExperimentWindow(tracking=True, *args, **kwargs)[source]

Bases: stytra.gui.container_windows.CameraExperimentWindow

Window for controlling an experiment where the tail of an embedded fish is tracked.

construct_ui()[source]
open_tracking_params_tree()[source]

stytra.gui.fishplots module

class stytra.gui.fishplots.StreamingPositionPlot(*args, data_accumulator, n_points=500, **kwargs)[source]

Bases: pyqtgraph.graphicsWindows.GraphicsWindow

Plot that displays the virtual position of the fish

update()[source]
class stytra.gui.fishplots.TailStreamPlot(acc, n_points=300)[source]

Bases: PyQt5.QtWidgets.QWidget

Displays the curvature of the tail in time using a heatmap

update(self)[source]

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

stytra.gui.fishplots.rot_mat(theta)[source]

The rotation matrix for an angle theta

stytra.gui.fishplots.angle_mean(angles, axis=1)[source]

Correct calculation of a mean of an array of angles

stytra.gui.fishplots.normalise_bout(coord)[source]

Reset a bout to be facing upward and start from 0,0

Parameters

bout

class stytra.gui.fishplots.BoutPlot(acc: stytra.collectors.accumulators.QueueDataAccumulator, i_fish=0, n_bouts=10, n_save_max=300)[source]

Bases: PyQt5.QtWidgets.QWidget

Plots the last few bouts in normalized coordinates, with fish facing to the right.

edit_params()[source]
update(self)[source]

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

stytra.gui.framerate_viewer module

class stytra.gui.framerate_viewer.FramerateWidget(acc, inertia=0.985)[source]

Bases: PyQt5.QtWidgets.QWidget

update(self)[source]

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

paintEvent(self, QPaintEvent)[source]
class stytra.gui.framerate_viewer.MultiFrameratesWidget[source]

Bases: PyQt5.QtWidgets.QWidget

update(self)[source]

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

add_framerate(framerate_acc)[source]

stytra.gui.monitor_control module

class stytra.gui.monitor_control.ProjectorViewer(*args, display_size=(1280, 800), display, **kwargs)[source]

Bases: pyqtgraph.widgets.GraphicsLayoutWidget.GraphicsLayoutWidget

Widget that displays the whole projector screen and allows

configuring the stimulus display window

sig_dim_changed
set_roi()[source]
set_param_val()[source]
display_calibration_pattern(calibrator, camera_resolution=(480, 640), image=None)[source]
Parameters
  • calibrator

  • camera_resolution – (Default value = (480)

  • 640)

  • image – (Default value = None)

class stytra.gui.monitor_control.ProjectorAndCalibrationWidget(experiment, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

sig_calibrating
update_size(size)[source]
toggle_calibration()[source]
calibrate()[source]

stytra.gui.multiscope module

class stytra.gui.multiscope.PlotTuple(curve, curve_label, min_label, max_label, value_label)

Bases: tuple

curve

Alias for field number 0

curve_label

Alias for field number 1

max_label

Alias for field number 3

min_label

Alias for field number 2

value_label

Alias for field number 4

class stytra.gui.multiscope.MultiStreamPlot(time_past=5, bounds_update=0.1, compact=False, n_points_max=500, accumulators=None, precision=None, experiment=None, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

Window to plot live data that are accumulated by a DAtaAccumulator object. New plots can be added via the add_stream() method.

static get_colors(n_colors=1, lightness=50, saturation=50, shift=0)[source]

Get colors on the LCh ring

Parameters
  • n_colors – param lightness: (Default value = 1)

  • lightness – (Default value = 50)

  • saturation – (Default value = 50)

  • shift – (Default value = 0)

refresh_streams()[source]
add_stream(accumulator: stytra.collectors.accumulators.DataFrameAccumulator, header_items=None)[source]

Adds a data collector stream to the plot:

Parameters
  • accumulator – instance of the DataAccumulator class

  • header_items – specify elements in the DataAccumulator to be plot by their header name.

remove_streams()[source]
update_bounds(i_acc, new_bounds)[source]
update()[source]

Function called by external timer to update the plot

show_extra_plot()[source]
toggle_freeze()[source]
update_buflen(time_past)[source]
update_zoom(time_past=1)[source]
update_replay_limits()[source]
show_select()[source]
class stytra.gui.multiscope.StreamPlotConfig(sp: stytra.gui.multiscope.MultiStreamPlot)[source]

Bases: PyQt5.QtWidgets.QWidget

Widget for configuring streaming plots

refresh_plots()[source]
class stytra.gui.multiscope.FrameratePlot(*args, round_bounds=0.1, framerate_limits=None, **kwargs)[source]

Bases: stytra.gui.multiscope.MultiStreamPlot

update()[source]

Function called by external timer to update the plot

update_bounds(i_acc, new_bounds)[source]

stytra.gui.protocol_control module

class stytra.gui.protocol_control.ProtocolControlToolbar(protocol_runner: stytra.stimulation.ProtocolRunner, main_window=None)[source]

Bases: PyQt5.QtWidgets.QToolBar

GUI for controlling a ProtocolRunner.

This class implements the toolbar for controlling the protocol:

  • toggle button for starting/stopping the Protocol;

  • progress bar to display progression of the Protocol.

  • a button and window for controlling Protocol parameters;

Parameters

protocol_runner (ProtocolRunner object) – ProtocolRunner that is controlled by the GUI.

Signals:

sig_start_protocol

Emitted via the toggle button click, meant to start the protocol.

sig_stop_protocol

Emitted via the toggle button click, meant to abort the protocol.

show_stim_params_gui()[source]

Create and show window to update protocol parameters.

toggle_protocol_running()[source]

Emit the start and stop signals. These can be used in the Experiment class or directly connected with the respective ProtocolRunner start() and stop() methods.

toggle_icon()[source]
update_progress()[source]

Update progress bar

stytra.gui.status_display module

class stytra.gui.status_display.DisplayedMessage(message, persist=0, end_color=(0, 0, 0))[source]

Bases: PyQt5.QtWidgets.QLabel

A label for status messages which can optionally fade out

is_expired(t)[source]
refresh()[source]
update_t(t)[source]
class stytra.gui.status_display.StatusMessageDisplay[source]

Bases: PyQt5.QtWidgets.QWidget

addMessageQueue(queue)[source]
addMessage(message, persist=3)[source]
refresh()[source]

Module contents