menus

file

Classes:

Protocol_Wizard()

A dialog window to create a new protocol.

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 autopilot.get_task()

  • 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 at 0x7fa121acf500>

plots

Classes:

Psychometric(subjects_protocols)

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

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:

plot_params

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

staticMetaObject

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

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

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa121acf540>

plugins

Classes:

Plugins()

Dialog window that allows plugins to be viewed and installed.

class Plugins[source]

Bases: PySide2.QtWidgets.QDialog

Dialog window that allows plugins to be viewed and installed.

Works by querying the wiki , find anything in the category Autopilot Plugins , clone the related repo, and reload plugins.

At the moment this widget is a proof of concept and will be made functional asap :)

Methods:

init_ui()

list_plugins()

download_plugin()

select_plugin_type()

select_plugin()

Attributes:

staticMetaObject

init_ui()[source]
list_plugins()[source]
download_plugin()[source]
select_plugin_type()[source]
select_plugin()[source]
staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa121b0f800>

swarm

Classes:

Stream_Video(pilots, *args, **kwargs)

Dialogue to stream, display, and save video.

class Stream_Video(pilots: dict, *args, **kwargs)[source]

Bases: PySide2.QtWidgets.QDialog

Dialogue to stream, display, and save video.

Parameters

pilots (dict) – The Terminal.pilot_db with the prefs of each pilot (given by Pilot.handshake())

Methods:

init_ui()

populate_cameras()

camera_selected()

toggle_start()

write_video()

l_frame(value)

closeEvent(self, arg__1)

Attributes:

current_pilot

current_camera

staticMetaObject

writer
comboboxes
buttons
cam_info
init_ui()[source]
property current_pilot: str
property current_camera: str
populate_cameras()[source]
camera_selected()[source]
toggle_start()[source]
write_video()[source]
l_frame(value)[source]
closeEvent(self, arg__1: PySide2.QtGui.QCloseEvent) None[source]
staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa121ac7cc0>

tests

Classes:

Bandwidth_Test(pilots)

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

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, blosc, ...)

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: int, payload: int, n_msg: int, confirm: bool, blosc: bool, random: bool, preserialized: bool)[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.

  • blosc (bool) – Use blosc compression?

  • random (bool) – Use random arrays?

  • preserialized (bool) – Serialize the message once, rather than serializing every time?

Returns:

process_test(rate, n_msg, confirm, blosc, random, preserialized)[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 at 0x7fa121ac7c80>

tools

Classes:

Calibrate_Water(pilots)

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

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.

Pilot_Ports(pilot[, n_clicks, click_dur])

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

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 at 0x7fa121a402c0>
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.

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 at 0x7fa121b2f080>
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 at 0x7fa121b2f240>
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 at 0x7fa121b2f2c0>