ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Testing > Procedures > Elements of a procedure > Events available to procedures

Events available to procedures

Introduction

Events represent things that may occur as the test is run. These could be events due to animal movement (the animal enters a zone, the animal freezes, etc.) or I/O events (a lever was pressed, etc.), or other events such as the test ending.

If you've used previous versions of ANY-maze, these events are similar to the events in the old 'Events and Actions' system.

  

A basic set of events is listed automatically on the left-hand side of the procedure editor under the Events tab; you can set up more complex events by clicking the Create event button in the ribbon bar. These user-defined events are usually similar to the basic events, but with an additional time constraint or a count of a number of events occurring.

For example, the basic list of events will include an event for Animal becomes immobile, but using the Create event button you can set up an event that will occur when the animal has remained immobile for a specific period of time.

  

There are a great many events in the procedure system, and they are described below. You can also see what is available by expanding all the event groups in the Events tab of the procedure editor. Events will be available for all relevant items in the protocol list - zones, points, animal activity, key presses, I/O inputs, and more. Hovering over the relevant event will show a tool tip giving you more information on that event.

An event in a procedure must be used within a Wait until statement. Once the procedure has waited for an event, you can then use it in an If statement. This would be useful if, for example, you had waited for one of a number of events to happen. However, an event cannot be used in an If statement without first being waited for.

If you try and use an event in an If statement without first waiting for it, this will result in an error in the procedure editor, and the test will not run.

  

Note that a procedure that waits for an event will only continue to run when the event next occurs - so, for example, a procedure that waits for the Animal enters zone event will not continue execution past this statement if the animal is already in the zone. It will only continue execution when the animal leaves the zone and then re-enters it again.

Test performance events

Test is waiting to startThis event will fire when the test is waiting to start. This will be when you click the (Start test) button for the apparatus.
Test startsThis event should be used with care. It is not normally used in a procedure (since the procedure will automatically wait for the test to start, after running the shaded section at the top of the procedure, and before running the un-shaded section at the bottom). However, there may be circumstances when you need to use this event in the shaded area at the top of the procedure - for example, waiting for an I/O reading such as a temperature sensor.
Test endsThis event will fire when the test is ended, either manually or by the procedure. The procedure can use an action to end the test.

Note that this event exists to allow simple cleanup at the end of the test, and will continue to run until it's finished; you cannot use another 'Wait until' statement or a 'Repeat...' statement after this event (this will end the procedure).

Test pausedThis event will fire when the test is paused, either manually or by the procedure.

Note that while the test is paused, procedures will not respond to any events except for the Test un-paused event.

Test Un-pausedThis event will fire when the test is resumed after a pause.
Test continuationThis event will fire when the user manually forces the test to continue, after it has been ended automatically.

This event will only fire if the test was stopped using the action End the test, but allow continuation (or End the test (specifying reason), but allow continuation).

Timer events

Timer events, or Time elapsed events, will fire when a specified time period has elapsed.

Note that the Time elapsed event will start timing from the first point that it is encountered by the procedure, and not from the start of the test.

If you want to wait for the time elapsed since the beginning of the test, use the Create event button to open the Event trigger wizard and select A specific duration since the start of the test from the list of Triggers that relate to time.

Timer events are slightly different to normal events. Since you may have a procedure that waits for multiple Time elapsed events to occur (with each one potentially waiting for a different time), each Time elapsed event is given a unique numerical ID. So if you wait for a time to elapse, and then use that event in an If statement, you can match up the Time elapsed event using its timer ID.

  

  

Figure 1. This procedure waits for a specific time to elapse; it can then use that same timer in the following If statement.

When entering the time to wait for, you can either type in a valid time (using the units d, h, m, s, ms for days, hours, minutes, seconds and milliseconds) or use an expression that returns a numerical value. If you use an expression (or just type in a number, without any units), then the value will be assumed to be in seconds.

  

  

Figure 2. Times can be entered as text, or as a numeric expression, in which case the number evaluated will be assumed to be in seconds.

Zone events

Animal enters zoneThis event will fire when the animal enters the zone. This event is only available when a zone is not set to be an Investigation zone.
Animal exits zoneThis event will fire when the animal exits the zone. This event is only available when a zone is not set to be an Investigation zone.
Animal starts investigating zoneThis event will fire when the animal starts investigating the zone. This event is only available when a zone is set to be an Investigation zone.
Animal stops investigating zoneThis event will fire when the animal stops investigating the zone. This event is only available when a zone is set to be an Investigation zone.
Animal becomes oriented towards zoneThis event will fire when the animal becomes oriented towards the zone. To determine this, the procedure uses the settings made in the protocol's Orientation and movement element. This event is not available for hidden zones.
Animal becomes oriented away from zoneThis event will fire when the animal is no longer oriented towards the zone. To determine this, the procedure uses the settings made in the protocol's Orientation and movement element. This event is not available for hidden zones.
Animal partially exits zoneThis event will fire when the animal partially exits a hidden zone which is set to have partial exits scored. Note that there may be a short delay between the partial exit and the event; this is due to the minimum time specified between partial exits - see Scoring partial exits from a hidden zone for details.

Point events

Animal becomes oriented towards pointThis event will fire when the animal becomes oriented towards the point. To determine this, the procedure uses the settings made in the Orientation and movement element of the protocol.
Animal becomes oriented away from pointThis event will fire when the animal is no longer oriented towards the point. To determine this, the procedure uses the settings made in the protocol's Orientation and movement element.

Animal position events

Animal centre position changesThis event will fire when the animal's centre position changes.
Animal head position changesThis event will fire when the animal's head position changes. This event is only available when head and tail tracking is turned on in the protocol.
Animal tail position changesThis event will fire when the animal's tail position changes. This event is only available when head and tail tracking is turned on in the protocol.
These events can happen quite frequently during the test; perhaps around 30 times per second.

Mobility events

Animal becomes mobileThis event will fire when the animal becomes mobile.
Animal becomes immobileThis event will fire when the animal becomes immobile.

The protocol's immobility settings are used to determine when the animal becomes mobile or immobile.

Activity events

Animal becomes activeThis event will fire when the animal becomes active (either through movement, or a key marked as an activity key is pressed).
Animal becomes inactiveThis event will fire when the animal becomes inactive (either through lack of movement, or a key marked as an activity key is released).

Note that these events are only included for legacy reasons and are not available to be included in new procedures. Activity depends on a number of separate conditions - for example, whether the animal is mobile, or a key is pressed that counts as an activity. However, immobility cannot be detected immediately - there is a 'timeout period' specified, and until the end of that timeout, the system doesn't know that the animal has gone immobile (so the current state is still 'mobile' until the end of the timeout). Even though the animal has actually stopped moving (but the system hasn't yet detected it), during this timeout period something else - such as a keypress - might indicate the animal being active. But because the system has not yet detected the inactive state (it still thinks the animal is mobile), it effectively 'misses' the activity keypress and therefore does not generate an event for it.

Because of this inability to detect the active and inactive state during the test, ANY-maze no longer generates events for the animal becoming active and inactive. (Note that activity can still be calculated during result analysis, because at that point the system has a full history of exactly what happened at every point during the test).

Freezing events

Animal freezesThis event will fire when the animal becomes frozen.
Animal unfreezesThis event will fire when the animal becomes unfrozen.

The protocol's freezing detection settings are used to determine when the animal freezes and unfreezes.

Rearing events

Animal starts rearingThis event will fire when the animal starts rearing.
Animal stops rearingThis event will fire when the animal stops rearing.

These events are only available if the Video source for the apparatus is set to view the apparatus from the side rather than from above.

Sequence events

Sequence completedThis event will fire when the sequence is completed.

Key press events

Key startsThis event will fire when the key is pressed.
Key stopsThis event will fire when the key is released.

On/off input events

On/off input activatedThis event will fire when the on/off input is activated.
On/off input deactivatedThis event will fire when the on/off input is deactivated.

Rotary encoder events

Rotary encoder rotationThis event will fire when the rotary encoder performs a full rotation, either clockwise or anti-clockwise.
Rotary encoder clockwise rotationThis event will fire when the rotary encoder performs a full rotation in the clockwise direction.
Rotary encoder anti-clockwise rotationThis event will fire when the rotary encoder performs a full rotation in the anti-clockwise direction.
Rotary encoder direction reversedThis event will fire when the direction of the rotary encoder is reversed.

Signal input events

Signal changedThis event will fire whenever a new signal value is received from the input.

If the sample rate of the input is more that 100Hz, the rate at which new values are received by the procedure will be limited to 100Hz.

If you are using signal value events to determine when the value of a signal goes above or below a certain threshold, you can set up a Virtual Switch to detect the threshold, and then wait for this Virtual Switch event in the procedure.

Sensor events

Sensor changedThis event will fire whenever a new value is received from the sensor.

On/off output events

Output switch activatedThis event will fire when the on/off output is activated.
Output switch deactivatedThis event will fire when the on/off output is deactivated.
Output switch timed outThis event will fire for on/off outputs with a feedback port, if the feedback is not received in a timely fashion. The timeout will depend on the output.

Speaker events

Speaker starts playingThis event will fire when the speaker starts playing a sound.
Speaker stops playingThis event will fire when the speaker stops playing a sound.
Speaker reaches the end of the sound fileThis event will fire when the speaker reaches the end of the file it is playing.

Shocker events

Shocker activatedThis event will fire when the shocker is activated.
Shocker deactivatedThis event will fire when the shocker is deactivated.

Pellet dispenser events

Pellet dispensesThis event will fire when a pellet is dispensed.
Pellet dispenser out of pelletsThis event will fire when the pellet dispenser runs out of pellets.
Pellet dispenser dispense failedThis event will fire when the pellet dispenser fails to dispense a pellet. This may be because the dispenser is out of pellets; it could also be because of a blockage or a mechanical failure.
Note that the 'Pellet dispenser dispense failed' event will fire every time that the pellet dispenser is asked to dispense a pellet, but fails. If the pellet dispenser is out of pellets, but the animal's actions result in further attempts to dispense pellets, the 'failed' event will fire each time. If you're using the event to send you an SMS message, for example, you won't want a message every time this happens - just the once, so you can fill up the pellet dispenser again. Figure 3 shows how you can use a procedure to ensure that only a single message is sent.

  

  

Figure 3. This procedure will monitor the 'Reward' pellet dispenser, and send an SMS message when there is an error dispensing a pellet. A user-defined variable is used to prevent multiple messages being generated.

Syringe pump events

Syringe pump startedThis event will fire when the syringe pump is started.
Syringe pump stoppedThis event will fire when the syringe pump is stopped.
Syringe pump stalledThis event will fire when the syringe pump stalls.
Syringe pump changed directionThis event will fire when the syringe pump changes direction, from infuse to withdraw (or vice versa).

Laser controller events

Laser controller activatedThis event will fire when the laser controller is activated.
Laser controller deactivatedThis event will fire when the laser controller is deactivated.

Analogue output events

Analogue output changedThis event will fire when the value of the analogue output changes.
This event can occur fairly frequently - perhaps 30 times a second.

Temperature controller events

Temperature controller ramp startedThis event will fire when the temperature controller starts ramping towards its target temperature.
Temperature controller ramp endedThis event will fire when the temperature controller finishes ramping to its target temperature, i.e. the target temperature is reached.

Light controller events

Light controller switched onThis event will fire when the light controller is switched on.
Light controller switched offThis event will fire when the light controller is switched off.
Light controller light level changesThis event will fire when the light controller's target light level is changed.
Light controller ramp startedThis event will fire when the light controller starts ramping towards its target light level.
Light controller ramp endedThis event will fire when the light controller finishes ramping to its target light level, i.e. the target light level is reached.

Selector events

Selector value changedThis event will fire when the value of the selector changes.
Selector value timed outThis event will fire for selectors with a feedback port, if the feedback is not received in a timely fashion. The timeout will depend on the selector.
Selectors are only available on certain types of device (such as the ANY-maze Operant interface and Ugo Basile Operon).

Virtual switch events

Virtual switch startedThis event will fire when the virtual switch is started.
Virtual switch stoppedThis event will fire when the virtual switch is stopped.

Errors & Warnings events

VCR disk fullThis event will fire when the disk to which the test is being recorded becomes full. At this point the video will have stopped recording.
VCR recording errorThis event will fire if there's an error recording the video of the test. At this point the video will have stopped recording.
Disk space lowThis event will fire when the warning is generated that disk space is low, either for the disk to which the experiment itself is being saved, or the disk to which videos are being recorded.
Movie recording errorThis event will fire if there's an error recording the test to a standard format (MP4 or WMV).

User-defined events

If none of the pre-defined events in the list are quite right for you, you can create your own. To do this, use the Create event button in the ribbon bar. This will open the Event trigger wizard which will lead you a step at a time through the process of defining the trigger for the event.

User-defined events are mostly events which apply counts or durations to the standard events listed under the Procedures tab of the procedure editor, for example:

 A zone entry event is listed in the procedure editor for each zone; however, the Event trigger wizard allows you to set up an event that will occur after a specific number of entries to that zone. 
 You can set up an event to trigger when the animal fails to enter the zone for a specific amount of time. 
 Triggering when a sequence is completed a specific number of times. 
 There are some handy events for times; for example, triggering repeatedly at certain time intervals, or at a specific time of day.  

Once you've set up a user-defined event, it will be available to all procedures in the protocol.

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0488