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:
|
Wrapper/decorator around an event that posts GUI events back to the main thread that our window is running in. |
|
Convenience function to pop a :class:`.QtGui.QDialog window to display a message. |
Classes:
|
A |
|
A trivial modification of |
|
A little panel with |
|
A subclass of (toggled) |
A popup that prompts you to define variables for a new |
|
A dialog window to create a new protocol. |
|
A widget used in |
|
A |
|
A widget that allows sounds to be parameterized. |
|
|
Test the limits of the rate of messaging from the connected Pilots. |
|
A window to calibrate the volume of water dispensed per ms. |
|
Created by |
|
A dialog that lets subjects be batch reassigned to new protocols or steps. |
|
A table for viewing and editing the most recent subject weights. |
|
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 eachPilot_Button
pilots – Usually the Terminal’s
pilots
dict. If not passed, will try to loadparams.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()
) – SeeControl_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 widgetpanels (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 thesubjects
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 dumpspilots
toprefs.get('PILOT_DB')
Attributes:
-
init_ui
()[source]¶ Called on init, creates the UI components.
Specifically, for each pilot in
pilots
, make asubject_List
: andPilot_Panel
:, set size policies and connect Qt signals.
-
create_subject
(pilot)[source]¶ Becomes
Pilot_Panel.create_fn
. Opens aNew_Subject_Wizard
to create a new subject file and assign protocol. Finally, adds the new subject to thepilots
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 dumpspilots
toprefs.get('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 at 0x7f5191961370>¶
-
class
Subject_List
(subjects=None, drop_fn=None)[source]¶ Bases:
PySide2.QtWidgets.QListWidget
A trivial modification of
QListWidget
that updatespilots
when an item in the list is dragged to another location.Should not be initialized except by
Control_Panel
.- Variables
subjects (list) – A list of subjects ID’s passed by
Control_Panel
drop_fn (
Control_Panel.update_db()
) – called on a drop event
- Parameters
subjects – see
subjects
. Can be None for an empty listdrop_fn – see
drop_fn()
. Passed fromControl_Panel
Methods:
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 callsdrop_fn
Attributes:
-
dropEvent
(event)[source]¶ A trivial redefinition of
QtWidgets.QListWidget.dropEvent()
that calls the parent dropEvent and then callsdrop_fn
- Parameters
event – A
QtCore.QEvent
simply forwarded to the superclass.
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f51919614b0>¶
-
class
Pilot_Panel
(pilot=None, subject_list=None, start_fn=None, create_fn=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A little panel with
the name of a pilot,
A
Pilot_Button
to start and stop the taskAdd and remove buttons to
create_subject()
andPilot_Panel.remove_subject()
Note
This class should not be instantiated except by
Control_Panel
- Parameters
pilot (str) – The name of the pilot this panel controls
subject_list (
Subject_List
) – TheSubject_List
we controlstart_fn (
toggle_start()
) – Passed byControl_Panel
create_fn (
Control_Panel.create_subject()
) – Passed byControl_Panel
- Variables
layout (
QtWidgets.QGridLayout
) – Layout for UI elementsbutton (
Pilot_Button
) – button used to control a pilot
Methods:
init_ui
()Initializes UI elements - creates widgets and adds to
Pilot_Panel.layout
.Remove the currently selected subject in
Pilot_Panel.subject_list
, and calls theControl_Panel.update_db()
method.Just calls
Control_Panel.create_subject()
with our pilot as the argumentAttributes:
-
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 theControl_Panel.update_db()
method.
-
create_subject
()[source]¶ Just calls
Control_Panel.create_subject()
with our pilot as the argument
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191961410>¶
-
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/stoppingstart_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:
Minor window dressing to call the
start_fn()
with the appropriate pilot, subject, and whether the task is starting or stoppingset_state
(state)Set the button’s appearance and state
Attributes:
-
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 at 0x7f5191966c30>¶
-
class
New_Subject_Wizard
[source]¶ Bases:
PySide2.QtWidgets.QDialog
A popup that prompts you to define variables for a new
subject.Subject
objectCalled by
Control_Panel.create_subject()
, which handles actually creating the subject file and updating theTerminal.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.get('PROTOCOLDIR')
bio_tab (
Biography_Tab
) – Sub-object to set and store biographical variablestask_tab (
Task_Tab
) – Sub-object to set and store protocol and step assignment
Classes:
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:
-
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..
Calculates the minimum mass for a subject based on its baseline mass and the allowable percentage of that baseline
Attributes:
-
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 at 0x7f5191966c80>¶
-
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.get(‘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
Methods:
Clears any steps that might be in the step selection box, loads the protocol file and repopulates it.
When the protocol is changed, save the value and call
update_step_box()
.When the step is changed, save it.
Attributes:
-
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()
.
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191966cd0>¶
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191966d20>¶
-
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
(seeNafc.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 tasksstep_list (
QtWidgets.QListWidget
) – The center window, lists tasks currently in protocolparam_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
listWhen the step name widget’s text is changed, fire this function to update
step_list
which updatessteps
Remove step from
step_list
andsteps
Calls
clear_params()
and then creates widgets to edit parameter values.Clears widgets from parameter window
reorder_steps
(*args)When steps are dragged into a different order, update the step dictionary
Callback function connected to the signal each widget uses to signal it has changed.
Stores parameters that define sounds.
Stores parameters that define graduation criteria in self.steps
Handle dependencies between parameters, eg.
Attributes:
-
rename_step
()[source]¶ When the step name widget’s text is changed, fire this function to update
step_list
which updatessteps
-
populate_params
()[source]¶ Calls
clear_params()
and then creates widgets to edit parameter values. Returns:
-
reorder_steps
(*args)[source]¶ When steps are dragged into a different order, update the step dictionary
- Parameters
*args – Input from our
step_list
‘sQtWidgets.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 at 0x7f5191966d70>¶
-
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
type_selection (
QtWidgets.QComboBox
) – A box to select from the available graduation types listed intasks.GRAD_LIST
. Has its currentIndexChanged signal connected toGraduation_Widget.populate_params()
param_dict (dict) – Stores the type of graduation and the relevant params, fetched by
Protocol_Wizard
when defining a protocol.set_graduation (
Protocol_Wizard.set_graduation()
) – Passed to us after we’re inited.
Methods:
populate_params
([params])Repopulate the widget with fields to edit graduation parameters, fill fields if we are passed params.
Clear any parameter widgets we have.
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:
-
populate_params
(params=None)[source]¶ Repopulate the widget with fields to edit graduation parameters, fill fields if we are passed params.
Each
QtWidgets.QLineEdit
‘sQLineEdit.editingFinished()
signal is connected toGraduation_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.
-
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 at 0x7f5191966dc0>¶
-
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.
Methods:
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 at 0x7f5191966e10>¶
-
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:
Presents a dialog to define a new sound.
Attributes:
-
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.get(‘SOUNDDIR’).
When files are dropped on the lists, strips prefs.get(‘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 soundsparam_dict (dict) – Parameters that are retreived by the calling
Sound_Widget
.
Methods:
When a sound type is selected, make a
QtWidgets.QLineEdit
for each PARAM in its definition.Clear all current widgets
When one of our edit boxes is edited, stash the parameter in param_dict
Attributes:
-
populate_params
()[source]¶ When a sound type is selected, make a
QtWidgets.QLineEdit
for each PARAM in its definition.
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191966e60>¶
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191966eb0>¶
-
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
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)Checks that the entries in
Bandwidth_Test.rates
andBandwidth_Test.payloads
are well formed.Attributes:
-
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 toresults
, 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.
-
register_msg
(value)[source]¶ Receive message from pilot, stash timestamp, number and pilot
- Parameters
value (dict) – Value should contain
Pilot
Timestamp
Message number
Payload
-
validate_list
()[source]¶ Checks that the entries in
Bandwidth_Test.rates
andBandwidth_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
orBandwidth_Test.payload_list
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191971050>¶
-
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 pilotsmessage_fn (
Net_Node.send()
) – The method the Terminal uses to send messages via its net node.
Methods:
init_ui
()Attributes:
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f51919710f0>¶
-
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:
Store the result of a volume calibration test in
volumes
Send the calibration test parameters to the
Pilot
l_progress
(value)Value should contain
Attributes:
-
init_ui
()[source]¶ Init the layout for one pilot’s ports:
pilot name
port buttons
3 times and vol dispersed
- Returns
-
start_calibration
()[source]¶ Send the calibration test parameters to the
Pilot
Sends a message with a
'CALIBRATE_PORT'
key, which is handled byPilot.l_cal_port()
-
l_progress
(value)[source]¶ Value should contain
Pilot
Port
Current Click (click_num)
- Parameters
value –
- Returns
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f51919712d0>¶
-
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.get(‘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.
When the protocol is changed, stash that and call
Reassign.populate_steps()
.set_step
()When the step is changed, stash that.
Attributes:
-
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:
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f5191971320>¶
-
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 ofSubject
objects.
Methods:
init_ui
()Initialized graphical elements.
set_weight
(row, column)Updates the most recent weights in
gui.Weights.subjects
objects.Attributes:
-
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 at 0x7f5191971410>¶
-
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.
Fill selection boxes with step and variable names
Toggle all checkboxes on or off
Attributes:
Generate parameters for plot to be passed to
viz.plot_psychometric()
-
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
-
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
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f51919714b0>¶
-
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()
, orQtGui.QMessageBox.error()
, respectivelybuttons (list) – A list specifying which
QtGui.QMessageBox.StandardButton
s to display. Use a string matching the button name, eg. “Ok” givesQtGui.QMessageBox.Ok
- Returns
The result of the dialog. If Ok/Cancel, boolean True/False, otherwise a string matching the button type
- Return type