stytra.triggering package

Module contents

This module contains Trigger objects that can be used to trigger the beginning of a stytra protocol from an external event, such as a message received via ZMQ from a microscope.

class stytra.triggering.Trigger[source]

Bases: multiprocessing.context.Process

Stytra uses Trigger objects to control the beginning of a stimulation protocol via an external event. In the most obvious case, the signal is sent by an acquisition device such as a microscope to synchronize data acquisition and stimulation. The trigger has a check_trigger function that is constantly called in a while loop in the run(). When Trigger returns True, the start_event is set. The Experiment class, if it has a trigger assigned, will wait until the start_event to be set before starting. The control in check_trigger() is defined in subclasses to reflect the condition that we want to control the beginning of the protocol.

Events

start_event:

event that is set when check_trigger() returns True. It is used by stytra to control the beginning of the protocol;

kill_event:

can be set to kill the Trigger process;

Output Queues

queue_trigger_params:

can be used to send to the Experiment data about the triggering event or device. For example, if triggering happens from a microscope via a ZMQ message, setting of the microscope can be sent in that message to be saved together with experiment metadata.

check_trigger()[source]

Check condition required for triggering to happen. Implemented in subclasses.

Returns

True if triggering condition is satisfied (e.g., message received); False otherwise.

Return type

bool

run()[source]

In this process, we constantly invoke the check_trigger class to control if start_event has to be set. Once it has been set, we wait an arbitrary time (0.1 s now) and then we clear it to be set again.

class stytra.triggering.ZmqTrigger(port)[source]

Bases: stytra.triggering.Trigger

This trigger uses the ZMQ library to receive a json file from an external source such as a microscope. The port on which the communication is happening is taken as input. The source of the trigger must be configured with the IP and the port of the computer running the stytra session.

check_trigger()[source]

Wait to receive the json file and reply with a simple “received” string. Add to the queue_trigger_params Queue the received dictionary, so that the experiment class can store it with the rest of the data.

run()[source]

In this process, we constantly invoke the check_trigger class to control if start_event has to be set. Once it has been set, we wait an arbitrary time (0.1 s now) and then we clear it to be set again.

class stytra.triggering.U3LabJackPulseTrigger(chan)[source]

Bases: stytra.triggering.Trigger

” This triiger uses the labjack u3 to recieve a TTL pulse from an external source. The DIO number is used as input. The pin is initialized as input automatically

check_trigger()[source]

” Simply returns the state of the pin as a boolean

run()[source]

In this process, we constantly invoke the check_trigger class to control if start_event has to be set. Once it has been set, we wait an arbitrary time (0.1 s now) and then we clear it to be set again.