task
Base task implementation and some generic tasks.
See the user guide for information on implementing tasks.
- class axopy.task.Oscilloscope(pipeline=None)[source]
A visualizer for data acquisition devices.
This task connects to the experiment input DAQ and displays each of its channels on a separate plot. You can optionally pass a
Pipeline
object to preprocess the input data before displaying it.- Parameters:
pipeline (Pipeline, optional) – Pipeline to run the input data through before displaying it. Often this is some preprocessing like filtering. It is often useful to use a
Windower
in the pipeline to display a larger chunk of data than is given on each input update of the DAQ. This gives a “scrolling” view of the input data, which can be helpful for experiment setup (e.g. placing electrodes, making sure the device is recording properly, etc.).
- key_press(key)[source]
Handle key press events.
Override this method to receive key press events. Available keys can be found in
axopy.util
(named key_<keyname>, e.g. key_k).Important note: if relying on the
advance_block_key
to advance the task, make sure to call this super implementation.
- prepare_daq(daqstream)[source]
Set up the input device, if applicable.
- Parameters:
daqstream (DaqStream) – Interface to the data acquisition device.
- prepare_graphics(container)[source]
Initialize graphical elements and messaging connections.
This method should be overridden if the task uses any graphics (which most do). It is important to defer initializing any graphical elements until this method is called so that the graphical backend has a chance to start.
- Parameters:
container (axopy.gui.Container) – The graphical container you can add objects to.
- run()[source]
Start running the task.
Simply calls next_block to start running trials in the first block. This method is called automatically if the task is added to an
Experiment
. Tasks that have a block design shouldn’t normally need to override this method. Tasks that are “free-running” for experimenter interaction (e.g. a plot visualization task that the experimenter controls) should override.
- class axopy.task.Task[source]
Base class for tasks.
This base class handles iteration through the trials of the task in blocks.
Most task implementations will want to override the prepare and run_trial methods, while the rest can be left to default behavior.
If you need to implement a custom constructor (
__init__
), you must call the base task__init__
:class CustomTask(Task): def __init__(self, custom_param): super(CustomTask, self).__init__()
- advance_block_key
Key for the user to press in order to advance to the next block. Can set to
None
to disable the feature (next block starts immediately after one finishes).- Type:
- finished
Emitted when the last trial of the last block has run. This is primarily for the
axopy.experiment.Experiment
to know when the task has finished so it can run the next one. You shouldn’t need to use this transmitter at all.- Type:
Transmitter
- connect(transmitter, receiver)[source]
Connect a transmitter to a receiver.
This method helps the task keep track of connections so that all of the manually specified connections can be torn down by the
axopy.experiment.Experiment
.
- finish()[source]
Clean up at the end of the task.
Override if you need to clean up once the task is completely finished. If you do override this method, you should call the base
Task.finish()
method or call thefinished
transmitter yourself.
- finish_block()[source]
Finishes the block and starts the next one.
Override if you need to do some cleanup between blocks.
- key_press(key)[source]
Handle key press events.
Override this method to receive key press events. Available keys can be found in
axopy.util
(named key_<keyname>, e.g. key_k).Important note: if relying on the
advance_block_key
to advance the task, make sure to call this super implementation.
- next_block()[source]
Get the next block of trials and starts running them.
Before starting the block, a prompt is shown to verify that the user is ready to proceed. If there are no more blocks to run, the finish method is called. You usually do not need to override this method.
- next_trial()[source]
Get the next trial in the block and starts running it.
If there are no more trials in the block, the finish_block method is called.
- prepare_daq(daqstream)[source]
Set up the input device, if applicable.
- Parameters:
daqstream (DaqStream) – Interface to the data acquisition device.
- prepare_design(design)[source]
Callback for setting up the task design.
See
axopy.design.Design
for details on how to design the task. By default, nothing is added to the design.- Parameters:
design (Design) – The task design object you can use to add blocks and trials.
- prepare_graphics(container)[source]
Initialize graphical elements and messaging connections.
This method should be overridden if the task uses any graphics (which most do). It is important to defer initializing any graphical elements until this method is called so that the graphical backend has a chance to start.
- Parameters:
container (axopy.gui.Container) – The graphical container you can add objects to.
- prepare_storage(storage)[source]
Initialize data storage.
Override to read or write task data. A
axopy.storage.Storage
object is given, which can be used to create a newaxopy.storage.TaskWriter
for storing new data or aaxopy.storage.TaskReader
for reading in existing data. Note that the subject ID has already been set.- Parameters:
storage (Storage) – The top-level storage object with which new storage can be allocated and existing data can be read.
- run()[source]
Start running the task.
Simply calls next_block to start running trials in the first block. This method is called automatically if the task is added to an
Experiment
. Tasks that have a block design shouldn’t normally need to override this method. Tasks that are “free-running” for experimenter interaction (e.g. a plot visualization task that the experimenter controls) should override.