gui

Note

Currently, the GUI code is some of the oldest code in the library – in particular much of it was developed before the network infrastructure was mature. As a result, a lot of modules are interdependent (eg. pass objects between each other). This will be corrected before v1.0

These classes implement the GUI used by the Terminal.

The GUI is built using PySide2, a Python wrapper around Qt5.

These classes are all currently used only by the Terminal.

If performing any GUI operations in another thread (eg. as a callback from a networking object), the method must be decorated with @gui_event which will call perform the update in the main thread as required by Qt.

Functions:

gui_event(fn)

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

pop_dialog(message[, msg_type, details, buttons])

Convenience function to pop a :class:`.QtGui.QDialog window to display a message.

Classes:

Control_Panel(subjects, start_fn[, pilots])

A QtWidgets.QWidget that contains the controls for all pilots.

Subject_List([subjects, drop_fn])

A trivial modification of QListWidget that updates pilots when an item in the list is dragged to another location.

Pilot_Panel([pilot, subject_list, start_fn, …])

A little panel with

Pilot_Button([pilot, subject_list, start_fn])

A subclass of (toggled) QtWidgets.QPushButton that incorporates the style logic of a start/stop button - ie.

New_Subject_Wizard()

A popup that prompts you to define variables for a new subject.Subject object

Protocol_Wizard()

A dialog window to create a new protocol.

Graduation_Widget()

A widget used in Protocol_Wizard to define graduation parameters.

Drag_List()

A QtWidgets.QListWidget that is capable of having files dragged & dropped.

Sound_Widget()

A widget that allows sounds to be parameterized.

Bandwidth_Test(pilots)

Test the limits of the rate of messaging from the connected Pilots.

Calibrate_Water(pilots)

A window to calibrate the volume of water dispensed per ms.

Pilot_Ports(pilot[, n_clicks, click_dur])

Created by Calibrate_Water, Each pilot’s ports and buttons to control repeated release.

Reassign(subjects, protocols)

A dialog that lets subjects be batch reassigned to new protocols or steps.

Weights(subject_weights, subjects)

A table for viewing and editing the most recent subject weights.

Psychometric(subjects_protocols)

A Dialog to select subjects, steps, and variables to use in a psychometric curve plot.

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 Control_Panel(subjects, start_fn, pilots=None)[source]

Bases: PySide2.QtWidgets.QWidget

A QtWidgets.QWidget that contains the controls for all pilots.

Parameters
  • subjects (dict) – See Control_Panel.subjects

  • start_fn (toggle_start()) – the Terminal’s toggle_start function, propagated down to each Pilot_Button

  • pilots – Usually the Terminal’s pilots dict. If not passed, will try to load params.PILOT_DB

Variables
  • subjects (dict) – A dictionary with subject ID’s as keys and core.subject.Subject objects as values. Shared with the Terminal object to manage access conflicts.

  • start_fn (toggle_start()) – See Control_Panel.start_fn

  • pilots (dict) – A dictionary with pilot ID’s as keys and nested dictionaries containing subjects, IP, etc. as values

  • subject_lists (dict) – A dict mapping subject ID to subject_List

  • layout (QGridLayout) – Layout grid for widget

  • panels (dict) – A dict mapping pilot name to the relevant Pilot_Panel

Specifically, for each pilot, it contains

  • one subject_List: A list of the subjects that run in each pilot.

  • one Pilot_Panel: A set of button controls for starting/stopping behavior

This class should not be instantiated outside the context of a Terminal object, as they share the subjects dictionary.

Methods:

init_ui()

Called on init, creates the UI components.

create_subject(pilot)

Becomes Pilot_Panel.create_fn.

update_db(**kwargs)

Gathers any changes in Subject_List s and dumps pilots to prefs.PILOT_DB

Attributes:

staticMetaObject

init_ui()[source]

Called on init, creates the UI components.

Specifically, for each pilot in pilots, make a subject_List: and Pilot_Panel:, set size policies and connect Qt signals.

create_subject(pilot)[source]

Becomes Pilot_Panel.create_fn. Opens a New_Subject_Wizard to create a new subject file and assign protocol. Finally, adds the new subject to the pilots database and updates it.

Parameters

pilot (str) – Pilot name passed from Pilot_Panel, added to the created Subject object.

update_db(**kwargs)[source]

Gathers any changes in Subject_List s and dumps pilots to prefs.PILOT_DB

Parameters

kwargs – Create new pilots by passing a dictionary with the structure

new={‘pilot_name’:’pilot_values’}

where ‘pilot_values’ can be nothing, a list of subjects, or any other information included in the pilot db

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Subject_List(subjects=None, drop_fn=None)[source]

Bases: PySide2.QtWidgets.QListWidget

A trivial modification of QListWidget that updates pilots when an item in the list is dragged to another location.

Should not be initialized except by Control_Panel .

Variables
Parameters
  • subjects – see subjects. Can be None for an empty list

  • drop_fn – see drop_fn(). Passed from Control_Panel

Methods:

populate_list()

Adds each item in Subject_List.subjects to the list.

dropEvent(event)

A trivial redefinition of QtWidgets.QListWidget.dropEvent() that calls the parent dropEvent and then calls drop_fn

Attributes:

staticMetaObject

populate_list()[source]

Adds each item in Subject_List.subjects to the list.

dropEvent(event)[source]

A trivial redefinition of QtWidgets.QListWidget.dropEvent() that calls the parent dropEvent and then calls drop_fn

Parameters

event – A QtCore.QEvent simply forwarded to the superclass.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Pilot_Panel(pilot=None, subject_list=None, start_fn=None, create_fn=None)[source]

Bases: PySide2.QtWidgets.QWidget

A little panel with

Note

This class should not be instantiated except by Control_Panel

Parameters
Variables
  • layout (QtWidgets.QGridLayout) – Layout for UI elements

  • button (Pilot_Button) – button used to control a pilot

Methods:

init_ui()

Initializes UI elements - creates widgets and adds to Pilot_Panel.layout .

remove_subject()

Remove the currently selected subject in Pilot_Panel.subject_list, and calls the Control_Panel.update_db() method.

create_subject()

Just calls Control_Panel.create_subject() with our pilot as the argument

Attributes:

staticMetaObject

init_ui()[source]

Initializes UI elements - creates widgets and adds to Pilot_Panel.layout . Called on init.

remove_subject()[source]

Remove the currently selected subject in Pilot_Panel.subject_list, and calls the Control_Panel.update_db() method.

create_subject()[source]

Just calls Control_Panel.create_subject() with our pilot as the argument

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Pilot_Button(pilot=None, subject_list=None, start_fn=None)[source]

Bases: PySide2.QtWidgets.QPushButton

A subclass of (toggled) QtWidgets.QPushButton that incorporates the style logic of a start/stop button - ie. color, text.

Starts grayed out, turns green if contact with a pilot is made.

Parameters
  • pilot (str) – The ID of the pilot that this button controls

  • subject_list (Subject_List) – The Subject list used to determine which subject is starting/stopping

  • start_fn (toggle_start()) – The final resting place of the toggle_start method

Variables

state (str) – The state of our pilot, reflected in our graphical properties. Mirrors state , with an additional “DISCONNECTED” state for before contact is made with the pilot.

Methods:

toggle_start()

Minor window dressing to call the start_fn() with the appropriate pilot, subject, and whether the task is starting or stopping

set_state(state)

Set the button’s appearance and state

Attributes:

staticMetaObject

toggle_start()[source]

Minor window dressing to call the start_fn() with the appropriate pilot, subject, and whether the task is starting or stopping

set_state(state)[source]

Set the button’s appearance and state

Parameters

state (str) – one of ``(‘IDLE’, ‘RUNNING’, ‘STOPPING’, ‘DISCONNECTED’)

Todo

There is some logic duplication in this class, ie. if the button state is changed it also emits a start/stop signal to the pi, which is undesirable. This class needs to be reworked.

Returns:

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class New_Subject_Wizard[source]

Bases: PySide2.QtWidgets.QDialog

A popup that prompts you to define variables for a new subject.Subject object

Called by Control_Panel.create_subject() , which handles actually creating the subject file and updating the Terminal.pilots dict and file.

Contains two tabs - Biography_Tab - to set basic biographical information about a subject - Task_Tab - to set the protocol and step to start the subject on

Variables
  • protocol_dir (str) – A full path to where protocols are stored, received from prefs.PROTOCOLDIR

  • bio_tab (Biography_Tab) – Sub-object to set and store biographical variables

  • task_tab (Task_Tab) – Sub-object to set and store protocol and step assignment

Classes:

Biography_Tab()

A widget that allows defining basic biographical attributes about a subject

Task_Tab()

A tab for selecting a task and step to assign to the subject.

Attributes:

staticMetaObject

class Biography_Tab[source]

Bases: PySide2.QtWidgets.QWidget

A widget that allows defining basic biographical attributes about a subject

Creates a set of widgets connected to update_return_dict() that stores the parameters.

Warning

The below attributes are not the object attributes, but are descriptions of the parameters available in the values dictionary. The attributes themselves are PySide Widgets that set the values.

Variables
  • id (str) – A Subject’s ID or name

  • start_date (str) – The date the subject started the task. Automatically filled by datetime.date.today().isoformat()

  • blmass (float) – The subject’s baseline mass

  • minmass_pct (int) – The percentage of baseline mass that a water restricted subject is allowed to reach

  • minmass (float) – The subject’s minimum mass, automatically calculated blmass * (minmass_pct / 100.)

  • genotype (str) – A string describing the subject’s genotype

  • expt (str) – A tag to describe what experiment this subject is a part of

Methods:

update_return_dict(key, val)

Called by lambda functions by the widgets, eg..

calc_minmass()

Calculates the minimum mass for a subject based on its baseline mass and the allowable percentage of that baseline

Attributes:

staticMetaObject

update_return_dict(key, val)[source]

Called by lambda functions by the widgets, eg.:

self.id.editingFinished.connect(lambda: self.update_return_dict('id', self.id.text()))
Parameters
  • key (str) – The key of the value being stored

  • val – The value being stored.

calc_minmass()[source]

Calculates the minimum mass for a subject based on its baseline mass and the allowable percentage of that baseline

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Task_Tab[source]

Bases: PySide2.QtWidgets.QWidget

A tab for selecting a task and step to assign to the subject.

Reads available tasks from prefs.PROTOCOLDIR , lists them, and creates a spinbox to select from the available steps.

Warning

Like Biography_Tab , these are not the actual instance attributes. Values are stored in a values dictionary.

Variables
  • protocol (str) – the name of the assigned protocol, filename without .json extension

  • step (int) – current step to assign.

Methods:

update_step_box()

Clears any steps that might be in the step selection box, loads the protocol file and repopulates it.

protocol_changed()

When the protocol is changed, save the value and call update_step_box().

step_changed()

When the step is changed, save it.

Attributes:

staticMetaObject

update_step_box()[source]

Clears any steps that might be in the step selection box, loads the protocol file and repopulates it.

protocol_changed()[source]

When the protocol is changed, save the value and call update_step_box().

step_changed()[source]

When the step is changed, save it.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Protocol_Wizard[source]

Bases: PySide2.QtWidgets.QDialog

A dialog window to create a new protocol.

Warning

This is a heavily overloaded class, and will be split into separate objects to handle parameters separately. For now this is what we got though and it works.

Protocols are collections of multiple tasks (steps) with some graduation criterion for moving between them.

This widget is composed of three windows:

  • left: possible task types from tasks.TASK_LIST

  • center: current steps in task

  • right: Parameters for currently selected step.

The parameters that are used are of the form used by Task.PARAMS (see Nafc.PARAMS for an example).

Todo

Make specific parameter class so this definition is less squishy

its general structure is:

{'parameter_key': {'tag':'Human Readable Name',
                   'type':'param_type'}}

while some parameter types have extra items, eg.:

{'list_param': {'tag':'Select from a List of Parameters',
                'type': 'list',
                'values': {'First Option':0, 'Second Option':1}}

where k:v pairs are still used with lists to allow parameter values (0, 1) be human readable.

The available types include:

  • int - integer

  • float - floating point number

  • bool - boolean boolbox

  • list - a list of values to choose from

  • sounds - a Sound_Widget that allows sounds to be defined.

  • graduation - a Graduation_Widget that allows graduation criteria to be defined

Variables
  • task_list (QtWidgets.QListWidget) – The leftmost window, lists available tasks

  • step_list (QtWidgets.QListWidget) – The center window, lists tasks currently in protocol

  • param_layout (QtWidgets.QFormLayout) – The right window, allows changing available parameters for currently selected step.

  • steps (list) – A list of dictionaries defining the protocol.

Methods:

add_step()

Loads PARAMS from task object, adds base parameters to steps list

rename_step()

When the step name widget’s text is changed, fire this function to update step_list which updates steps

remove_step()

Remove step from step_list and steps

populate_params()

Calls clear_params() and then creates widgets to edit parameter values.

clear_params()

Clears widgets from parameter window

reorder_steps(*args)

When steps are dragged into a different order, update the step dictionary

set_param()

Callback function connected to the signal each widget uses to signal it has changed.

set_sounds()

Stores parameters that define sounds.

set_graduation()

Stores parameters that define graduation criteria in self.steps

check_depends()

Handle dependencies between parameters, eg.

Attributes:

staticMetaObject

add_step()[source]

Loads PARAMS from task object, adds base parameters to steps list

rename_step()[source]

When the step name widget’s text is changed, fire this function to update step_list which updates

steps

remove_step()[source]

Remove step from step_list and steps

populate_params()[source]

Calls clear_params() and then creates widgets to edit parameter values. Returns:

clear_params()[source]

Clears widgets from parameter window

reorder_steps(*args)[source]

When steps are dragged into a different order, update the step dictionary

Parameters

*args – Input from our step_list ‘s QtWidgets.QListModel ‘s reorder signal.

set_param()[source]

Callback function connected to the signal each widget uses to signal it has changed.

Identifies the param that was changed, gets the current value, and updates self.steps

set_sounds()[source]

Stores parameters that define sounds.

Sound parameters work a bit differently, specifically we have to retrieve Sound_Widget.sound_dict.

set_graduation()[source]

Stores parameters that define graduation criteria in self.steps

Graduation parameters work a bit differently, specifically we have to retrieve Graduation_Widget.param_dict.

check_depends()[source]

Handle dependencies between parameters, eg. if “correction trials” are unchecked, the box that defines the correction trial percentage should be grayed out.

Todo

Not implemented.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Graduation_Widget[source]

Bases: PySide2.QtWidgets.QWidget

A widget used in Protocol_Wizard to define graduation parameters.

See tasks.graduation .

A protocol is composed of multiple tasks (steps), and graduation criteria define when a subject should progress through those steps.

eg. a subject should graduate one stage after 300 trials, or after it reaches 75% accuracy over the last 500 trials.

Variables

Methods:

populate_params([params])

Repopulate the widget with fields to edit graduation parameters, fill fields if we are passed params.

clear_params()

Clear any parameter widgets we have.

store_param()

When a parameter is edited, save it in our param_dict, and also call our set_graduation method, which should be Protocol_Wizard.set_graduation() passed to us after instantiation.

Attributes:

staticMetaObject

populate_params(params=None)[source]

Repopulate the widget with fields to edit graduation parameters, fill fields if we are passed params.

Each QtWidgets.QLineEdit ‘s QLineEdit.editingFinished() signal is connected to Graduation_Widget.store_param() .

Todo

For now we assume all parameters are defined with a text edit box, so it’s not clear how we’d do boolean parameters for example. This will be fixed with refactoring the parameter scheme.

Parameters

params (dict) – In the case that Protocol_Wizard switches us back to a step where we have already defined graduation parameters, it will pass them so we can repopulate the relevant widgets with them.

clear_params()[source]

Clear any parameter widgets we have.

store_param()[source]

When a parameter is edited, save it in our param_dict, and also call our set_graduation method, which should be Protocol_Wizard.set_graduation() passed to us after instantiation.

If we were not passed set_graduation, just saves in param_dict.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Drag_List[source]

Bases: PySide2.QtWidgets.QListWidget

A QtWidgets.QListWidget that is capable of having files dragged & dropped.

copied with much gratitude from stackoverflow

Primarily used in Sound_Widget to be able to drop sound files.

To use: connect fileDropped to a method, that method will receive a list of files dragged onto this widget.

Variables

fileDropped (QtCore.Signal) – A Qt signal that takes a list

Attributes:

fileDropped(*args, **kwargs)

Call self as a function.

staticMetaObject

Methods:

dragEnterEvent(e)

When files are dragged over us, if they have paths in them, accept the event.

dragMoveEvent(event)

If the dragEnterEvent was accepted, while the drag is being moved within us, setDropAction to QtCore.Qt.CopyAction

dropEvent(event)

When the files are finally dropped, if they contain paths, emit the list of paths through the fileDropped signal.

fileDropped(*args, **kwargs)

Call self as a function.

dragEnterEvent(e)[source]

When files are dragged over us, if they have paths in them, accept the event.

Parameters

e (QtCore.QEvent) – containing the drag information.

dragMoveEvent(event)[source]

If the dragEnterEvent was accepted, while the drag is being moved within us, setDropAction to QtCore.Qt.CopyAction

Parameters

event (QtCore.QEvent) – containing the drag information.

dropEvent(event)[source]

When the files are finally dropped, if they contain paths, emit the list of paths through the fileDropped signal.

Parameters

event (QtCore.QEvent) – containing the drag information.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Sound_Widget[source]

Bases: PySide2.QtWidgets.QWidget

A widget that allows sounds to be parameterized.

Used in Protocol_Wizard .

Has two Drag_List s for left and right sounds (for a 2afc task), given Buttons beneath them allow adding and removing sounds.

Adding a sound will open a Add_SoundDialog

Todo

Sounds will eventually be more elegantly managed by a … sound manager.. For now sound managers are rudimentary and only support random presentation with correction trials and bias correction.

Variables

sound_dict (dict) –

Dictionary with the structure:

{'L': [{'param_1':'param_1', ... }], 'R': [...]}

where multiple sounds can be present in either ‘L’ or ‘R’ list.

Methods:

pass_set_param_function(set_param_fnxn)

Receives Protocol_Wizard.set_sounds()

add_sound(side)

When the “+” button on either side is pressed, open an Add_Sound_Dialog.

remove_sound(side)

When the “-” button is pressed, remove the currently highlighted sound.

populate_lists(sound_dict)

Populates the sound lists after re-selecting a step.

files_dropped(files)

Classes:

Add_Sound_Dialog()

Presents a dialog to define a new sound.

Attributes:

staticMetaObject

pass_set_param_function(set_param_fnxn)[source]

Receives Protocol_Wizard.set_sounds()

Parameters

set_param_fnxn (Protocol_Wizard.set_sounds()) – Called when sounds are changed.

add_sound(side)[source]

When the “+” button on either side is pressed, open an Add_Sound_Dialog.

Parameters

side (str) – The buttons are connected with a lambda function, this will be either ‘L’ or ‘R’. Used to add sounds to the sound_dict

remove_sound(side)[source]

When the “-” button is pressed, remove the currently highlighted sound.

Parameters

side (str) – The buttons are connected with a lambda function, this will be either ‘L’ or ‘R’. Selects that list so we can remove the currently selected row.

populate_lists(sound_dict)[source]

Populates the sound lists after re-selecting a step.

Parameters

sound_dict (dict) – passed to us by Protocol_Wizard upon reselecting a step.

files_dropped(files)[source]

Warning

This was programmed hastily and is pretty idiosyncratic to my use.

It does work for general files but has some extra logic built in to handle my stimuli.

To be made more general in v0.3

Note

Sounds must be in the folder specified in prefs.SOUNDDIR.

When files are dropped on the lists, strips prefs.SOUNDDIR from them to make them relative paths, adds them to the sound_dict

Parameters

files (list) – List of absolute paths.

class Add_Sound_Dialog[source]

Bases: PySide2.QtWidgets.QDialog

Presents a dialog to define a new sound.

Makes a selection box to choose the sound type from sounds.SOUND_LIST , and then populates edit boxes so we can fill in its PARAMS .

Variables
  • type_selection (QtWidgets.QComboBox) – Select from a list of available sounds

  • param_dict (dict) – Parameters that are retreived by the calling Sound_Widget.

Methods:

populate_params()

When a sound type is selected, make a QtWidgets.QLineEdit for each PARAM in its definition.

clear_params()

Clear all current widgets

store_param()

When one of our edit boxes is edited, stash the parameter in param_dict

Attributes:

staticMetaObject

populate_params()[source]

When a sound type is selected, make a QtWidgets.QLineEdit for each PARAM in its definition.

clear_params()[source]

Clear all current widgets

store_param()[source]

When one of our edit boxes is edited, stash the parameter in param_dict

staticMetaObject = <PySide2.QtCore.QMetaObject object>
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Bandwidth_Test(pilots)[source]

Bases: PySide2.QtWidgets.QDialog

Test the limits of the rate of messaging from the connected Pilots.

Asks pilots to send messages at varying rates and with varying payload sizes, and with messages with/without receipts.

Measures drop rates and message latency

Variables
  • rate_list (list) – List of rates (Hz) to test

  • payload_list (list) – List of payload sizes (KB) to test

  • messages (list) – list of messages received during test

Methods:

init_ui()

Look we’re just making the stuff in the window over here alright? relax.

start()

Start the test!!!

send_test(rate, payload, n_msg, confirm)

Send a message describing the test to each of the pilots in Bandwidth_Test.test_pilots

process_test(rate, n_msg, confirm)

Process the results of the test and update the plot window.

save()

Select save file location for test results (csv) and then save them there

register_msg(value)

Receive message from pilot, stash timestamp, number and pilot

update_pbar(val)

validate_list()

Checks that the entries in Bandwidth_Test.rates and Bandwidth_Test.payloads are well formed.

Attributes:

staticMetaObject

init_ui()[source]

Look we’re just making the stuff in the window over here alright? relax.

start()[source]

Start the test!!!

send_test(rate, payload, n_msg, confirm)[source]

Send a message describing the test to each of the pilots in Bandwidth_Test.test_pilots

Parameters
  • rate (int) – Rate of message sending in Hz

  • payload (int) – Size of message payload in bytes

  • n_msg (int) – Number of messages to send

  • confirm (bool) – If True, use message confirmation, if False no confirmation.

Returns:

process_test(rate, n_msg, confirm)[source]

Process the results of the test and update the plot window.

Reads message results from messages, appends computed results to results, and starts the next test if any remain.

Parameters
  • rate (int) – Rate of current test in Hz

  • n_msg (int) – Number of expected messages in this test

  • confirm (bool) – Whether message confirmations were enabled for this test.

save()[source]

Select save file location for test results (csv) and then save them there

register_msg(value)[source]

Receive message from pilot, stash timestamp, number and pilot

Parameters

value (dict) – Value should contain

  • Pilot

  • Timestamp

  • Message number

  • Payload

update_pbar(val)[source]
validate_list()[source]

Checks that the entries in Bandwidth_Test.rates and Bandwidth_Test.payloads are well formed.

ie. that they are of the form ‘integer, integer, integer’…

pops a window that warns about ill formed entry and clears line edit if badly formed

If the list validates, stored as either Bandwidth_Test.rate_list or Bandwidth_Test.payload_list

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Calibrate_Water(pilots)[source]

Bases: PySide2.QtWidgets.QDialog

A window to calibrate the volume of water dispensed per ms.

Parameters
  • pilots (Terminal.pilots) – A dictionary of pilots

  • message_fn (Net_Node.send()) – The method the Terminal uses to send messages via its net node.

Methods:

init_ui()

Attributes:

staticMetaObject

init_ui()[source]
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Pilot_Ports(pilot, n_clicks=1000, click_dur=30)[source]

Bases: PySide2.QtWidgets.QWidget

Created by Calibrate_Water, Each pilot’s ports and buttons to control repeated release.

Parameters
  • pilot (str) – name of pilot to calibrate

  • n_clicks (int) – number of times to open the port during calibration

  • click_dur (int) – how long to open the port (in ms)

Methods:

init_ui()

Init the layout for one pilot’s ports:

update_volumes()

Store the result of a volume calibration test in volumes

start_calibration()

Send the calibration test parameters to the Pilot

l_progress(value)

Value should contain

Attributes:

staticMetaObject

init_ui()[source]

Init the layout for one pilot’s ports:

  • pilot name

  • port buttons

  • 3 times and vol dispersed

Returns

update_volumes()[source]

Store the result of a volume calibration test in volumes

start_calibration()[source]

Send the calibration test parameters to the Pilot

Sends a message with a 'CALIBRATE_PORT' key, which is handled by Pilot.l_cal_port()

l_progress(value)[source]

Value should contain

  • Pilot

  • Port

  • Current Click (click_num)

Parameters

value

Returns

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Reassign(subjects, protocols)[source]

Bases: PySide2.QtWidgets.QDialog

A dialog that lets subjects be batch reassigned to new protocols or steps.

Parameters
  • subjects (dict) –

    A dictionary that contains each subject’s protocol and step, ie.:

    {'subject_id':['protocol_name', step_int], ... }
    
  • protocols (list) – list of protocol files in the prefs.PROTOCOLDIR. Not entirely sure why we don’t just list them ourselves here.

Methods:

init_ui()

Initializes graphical elements.

populate_steps(subject)

When a protocol is selected, populate the selection box with the steps that can be chosen.

set_protocol()

When the protocol is changed, stash that and call Reassign.populate_steps() .

set_step()

When the step is changed, stash that.

Attributes:

staticMetaObject

init_ui()[source]

Initializes graphical elements.

Makes a row for each subject where its protocol and step can be changed.

populate_steps(subject)[source]

When a protocol is selected, populate the selection box with the steps that can be chosen.

Parameters

subject (str) – ID of subject whose steps are being populated

set_protocol()[source]

When the protocol is changed, stash that and call Reassign.populate_steps() . Returns:

set_step()[source]

When the step is changed, stash that.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Weights(subject_weights, subjects)[source]

Bases: PySide2.QtWidgets.QTableWidget

A table for viewing and editing the most recent subject weights.

Parameters
  • subject_weights (list) – a list of weights of the format returned by Subject.get_weight(baseline=True)().

  • subjects (dict) – the Terminal’s Terminal.subjects dictionary of Subject objects.

Methods:

init_ui()

Initialized graphical elements.

set_weight(row, column)

Updates the most recent weights in gui.Weights.subjects objects.

Attributes:

staticMetaObject

init_ui()[source]

Initialized graphical elements. Literally just filling a table.

set_weight(row, column)[source]

Updates the most recent weights in gui.Weights.subjects objects.

Note

Only the daily weight measurements can be changed this way - not subject name, baseline weight, etc.

Parameters
  • row (int) – row of table

  • column (int) – column of table

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class Psychometric(subjects_protocols)[source]

Bases: PySide2.QtWidgets.QDialog

A Dialog to select subjects, steps, and variables to use in a psychometric curve plot.

See Terminal.plot_psychometric()

Parameters

subjects_protocols (dict) – The Terminals Terminal.subjects_protocols dict

Variables

plot_params (list) – A list of tuples, each consisting of (subject_id, step, variable) to be given to viz.plot_psychometric()

Methods:

init_ui()

populate_steps(subject)

When a protocol is selected, populate the selection box with the steps that can be chosen.

populate_variables()

Fill selection boxes with step and variable names

check_all()

Toggle all checkboxes on or off

Attributes:

staticMetaObject

plot_params

Generate parameters for plot to be passed to viz.plot_psychometric()

init_ui()[source]
populate_steps(subject)[source]

When a protocol is selected, populate the selection box with the steps that can be chosen.

Parameters

subject (str) – ID of subject whose steps are being populated

populate_variables()[source]

Fill selection boxes with step and variable names

check_all()[source]

Toggle all checkboxes on or off

staticMetaObject = <PySide2.QtCore.QMetaObject object>
property plot_params

Generate parameters for plot to be passed to viz.plot_psychometric()

Returns

(subject_name, step_name, x_var_name, n_trials_back)

Return type

tuple

pop_dialog(message, msg_type='info', details='', buttons=['Ok'])[source]

Convenience function to pop a :class:`.QtGui.QDialog window to display a message.

Parameters
  • details

  • message (str) – message to be displayed

  • msg_type (str) – “info” (default), “question”, “warning”, or “error” to use QtGui.QMessageBox.information(), QtGui.QMessageBox.question(), QtGui.QMessageBox.warning(), or QtGui.QMessageBox.error(), respectively

  • buttons (list) – A list specifying which QtGui.QMessageBox.StandardButton s to display. Use a string matching the button name, eg. “Ok” gives QtGui.QMessageBox.Ok

Returns

The result of the dialog. If Ok/Cancel, boolean True/False, otherwise a string matching the button type

Return type

result (bool, str)