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

Built-in variables

Introduction

Built-in variables are a way for a procedure to be able to ask the ANY-maze software about anything to do with the state of the current test. They can be anything from a simple flag specifying whether the test is currently running, to the animal's current position, to a note of how many times the animal has entered a specific zone.

There are many of these built-in variables available in the ANY-maze procedure system, and they are listed below. You can also see what is available by expanding all the groups in the Variables tab of the procedure editor. Variables are available for the apparatus itself, as well as for all relevant items in the protocol list - zones, animal activity, key presses, I/O, etc. Hovering over the relevant variable will show a tool tip to give you more information on that variable.

When the procedure editor is in 'Simple' mode, the Variables tab is not shown. You can switch the procedure editor between Simple view and Full view using the buttons on the ribbon bar.

  

Built-in variables are available to a procedure for a number of aspects of the test:

 Test information 
 Test date/time 
 Animal position and movement 
 Zone variables 
 Point variables 
 Stage and trial variables 
 Sequence variables 
 Key variables 
 On/off input variables 
 Signal input variables 
 Sensor variables 
 Rotary encoder variables 
 Output switch variables 
 Speaker variables 
 Pellet dispenser variables 
 Analogue output variables 
 Temperature controller variables 
 Light controller variables 
 Syringe pump variables 
 Shocker variables 
 Laser controller variables 
 Selector variables 
 Field variables 
 Virtual switch variables 
 ANY-maze protocol items  

More information

Built-in variables can only be read by a procedure, and not changed, so you can't use a Set value statement to alter the value of a built-in variable.

They can be one of a number of types - this is visible from the shape of the variable in the list in the procedure editor. Shapes with angled edges are True/False values, shapes with rounded edges are numeric values, and squares with cut-off corners are ANY-maze protocol items as set up in the protocol list (e.g. zones, sequences, etc.).

  

  

Figure 1. The test information built-in variables, showing their different shapes. Test is running is a True/False value; Current trial, Test duration and Number of trials are numeric values, and Current stage and Treatment are ANY-maze protocol items as set up in the protocol list.

You can use a built-in variable anywhere in a procedure where an expression of the variable's type can be used - for example, in a Maths function or operator, a logical operator, or to set as the new value for a User-defined variable.

  

The built-in variables available are listed below:

Test information

Test is running(True/False) True if the test is currently running; False if it is not yet running or has been stopped.
Test is paused(True/False) True if the test is currently paused; False if it is running, has not yet started or has been stopped.
Current stage(Protocol item) The stage that the current test is part of. The stages in the protocol are listed as protocol items on the Variables tab of the procedure editor.
Current trial(Numeric) The current trial within this stage. The first trial is 1, the second is 2, etc.
Test duration(Numeric) The programmed duration of the test (as specified for the current Stage), in seconds.
Number of trials(Numeric) The number of trials programmed for the current Stage. This may not be the same as the number of trials actually performed, if (for example) the animal completes a 'Training' stage before all programmed trials have been performed.
Apparatus(Protocol item) The apparatus in which the current test is running. The apparatus for the protocol are listed as protocol items on the Variables tab of the procedure editor.
Treatment(Protocol item) The treatment applied to the animal for this test, as specified for the animal on the Experiment page. The available treatments are listed as protocol items on the Variables tab of the procedure editor.

If the treatment's value has not yet been set, this will return '#N/A'.

Animal number(Protocol item) The animal number (not the Animal ID) of the animal for this test.

Test date/time

Test clock(Numeric) The number of seconds that have elapsed since the start of the test.
Today: day(Numeric) The day of the month on which this test is being performed, from 1 to 31.
Today: month(Numeric) The month of the year on which this test is being performed, from 1 to 12.
Today: year(Numeric) The calendar year in which this test is being performed.
Today: day of week(Numeric) A numeric representation of the day of the week on which this test is being performed. 1 = Monday, 2 = Tuesday, up to 7 = Sunday.
Current time: hour(Numeric) The 'hour' part of the current time of day at which the variable is read, from 0 to 23.
Current time: minute(Numeric) The 'minute' part of the current time of day at which the variable is read, from 0 to 59.
Current time: second(Numeric) The 'second' part of the current time of day at which the variable is read, from 0 to 59.

Animal position and movement

Animal centre (X) as % of width(Numeric) The X position of the animal's centre point, as a percentage of the width of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol.
Animal centre (Y) as % of height(Numeric) The Y position of the animal's centre point, as a percentage of the height of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol.
Animal centre (X)(Numeric) The X position of the animal's centre point, in pixels relative to the left-hand side of the apparatus image. This value is the same as that shown for the animal's X position on the Test details report.
Animal centre (Y)(Numeric) The Y position of the animal's centre point, in pixels relative to the top of the apparatus image. This value is the same as that shown for the animal's Y position on the Test details report.
Animal centre time(Numeric) The time at which the position of the animal's centre point was last measured. This value is in ms since the start of the test.
Animal head (X) as % of width(Numeric) The X position of the animal's head, as a percentage of the width of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol. This value is only available when head and tail tracking is turned on in the protocol.
Animal head (Y) as % of height(Numeric) The Y position of the animal's head, as a percentage of the height of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol. This value is only available when head and tail tracking is turned on in the protocol.
Animal head (X)(Numeric) The X position of the animal's head, in pixels relative to the left-hand side of the apparatus image. This value is the same as that shown for the head's X position on the Test details report. This value is only available when head and tail tracking is turned on in the protocol.
Animal head (Y)(Numeric) The Y position of the animal's centre point, in pixels relative to the top of the apparatus image. This value is the same as that shown for the head's X position on the Test details report. This value is only available when head and tail tracking is turned on in the protocol.
Animal head time(Numeric) The time at which the position of the animal's head was last measured. This value is in ms since the start of the test. This value is only available when head and tail tracking is turned on in the protocol.
Animal tail (X) as % of width(Numeric) The X position of the animal's tail, as a percentage of the width of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol. This value is only available when head and tail tracking is turned on in the protocol.
Animal tail (Y) as % of height(Numeric) The Y position of the animal's tail, as a percentage of the width of the apparatus. The apparatus dimensions that are used for this value are the smallest square that completely encompasses the apparatus map defined in the protocol. This value is only available when head and tail tracking is turned on in the protocol.
Animal tail (X)(Numeric) The X position of the animal's tail, in pixels relative to the left-hand side of the apparatus image. This value is the same as that shown for the tail's X position on the Test details report. This value is only available when head and tail tracking is turned on in the protocol.
Animal tail (Y)(Numeric) The Y position of the animal's tail, in pixels relative to the top of the apparatus image. This value is the same as that shown for the tail's X position on the Test details report. This value is only available when head and tail tracking is turned on in the protocol.
Animal tail time(Numeric) The time at which the position of the animal's tail was last measured. This value is in ms since the start of the test. This value is only available when head and tail tracking is turned on in the protocol.
Animal's speed(Numeric) The animal's current speed, in m/s.
Distance travelled(Numeric) The distance travelled so far in the test by the animal, in metres.
Animal is mobile(True/False) True if the animal is currently mobile; False otherwise. This variable is only available if the protocol is set up to detect periods when the animal is immobile.
Cumulative time immobile(Numeric) The total time so far in this test that the animal has been immobile. If the animal is currently immobile, this will include the time the animal has so far been immobile in the current bout, up to the time that this variable is used. This variable is only available if the protocol is set up to detect periods when the animal is immobile.
Minimum immobility period(Numeric) The 'Minimum immobility period' specified in the protocol, in seconds. This is the time that the animal has to stop moving for before it is registered as immobile. This variable is only available if the protocol is set up to detect periods when the animal is immobile.
Animal is frozen(True/False) True if the animal is currently frozen; False otherwise. This variable is only available if the protocol is set up to detect freezing.
Cumulative time freezing(Numeric) The total time so far in this test that the animal has been frozen. If the animal is currently frozen, this will include the time the animal has so far been frozen in the current bout, up to the time that this variable is used. This variable is only available if the protocol is set up to detect freezing.
Freezing score(Numeric) This value represents the animal's 'freezing score', which is used to determine whether the animal is freezing. This variable is only available if the protocol is set up to detect freezing.
Animal is rearing(True/False) True if the animal is currently rearing; False otherwise. This variable is only available if the Video source for the apparatus is set to view the apparatus from the side rather than from above.
Freezing timeout(Numeric) The 'Minimum freeze duration' specified in the protocol, in seconds. This is the amount of time that no movement is detected before recording this as a freezing episode. This variable is only available if the protocol is set up to detect freezing.
Cumulative time rearing(Numeric) The time that the animal has been rearing for in total during this test. This variable is only available if the Video source for the apparatus is set to view the apparatus from the side rather than from above.
Animal is active(True/False) True if the animal is currently active; False otherwise. An animal is considered to be active if it is mobile (assuming mobility is being detected) or if it's performing some other behaviour which has been defined to be an activity (for example, a key press).

Note that the Animal is active variable is only included for legacy reasons and is 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 hold the correct active state. (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).

Zone variables

Animal is in zone(True/False) This variable is True when the animal is in the zone, and False if it is not. This value is only available when a zone is not set to be an Investigation zone.
Animal is investigating zone(True/False) This variable is True when the animal is investigating the zone, and False if it is not. This value is only available when a zone is set to be an Investigation zone.
Distance from Zone(Numeric) The distance of the animal's centre point from the zone's border (in metres). If the animal is currently in the zone, then this variable will be 0.
Head distance from Zone(Numeric) The distance of the animal's head from the zone's border (in metres). If the animal's head is currently in the zone, then this variable will be 0. This value is only available when head and tail tracking is turned on in the protocol.
Distance from border(Numeric) The distance of the animal's centre point from the zone's border (in metres), if the centre is within the zone. If the animal is not within the zone, then this function returns 0.
Head distance from border(Numeric) The distance of the animal's head from the zone's border (in metres), if the head is within the zone. If the animal's head is not within the zone, then this function returns 0. This value is only available when head and tail tracking is turned on in the protocol.
Number of visits to zone(Numeric) The number of separate occasions that the animal has entered this zone so far in the test. If the animal has never entered the zone, this value will be 0. This value is only available when a zone is not set to be an Investigation zone.
Number of investigations of zone(Numeric) The number of separate occasions that the animal has investigated this zone so far in the test. If the animal has never investigated the zone, this value will be 0. This value is only available when a zone is set to be an Investigation zone.
Animal is oriented towards zone(True/False) True if the animal is currently oriented towards the zone. To determine this, the procedure uses the settings made in the Orientation and movement element of the protocol.
Location of Zone(Protocol item) This variable is only available for movable zones, and gives the location of the zone for this test. The possible locations of the movable zone are listed as protocol items on the Variables tab of the procedure editor.

If the location of the zone has not yet been set, this will return '#N/A'.

Point variables

Distance from point(Numeric) The distance of the animal's centre from the point (in metres).      
Head distance from point(Numeric) The distance of the animal's head from the point (in metres). This value is only available when head and tail tracking is turned on in the protocol.
Animal is oriented towards point(True/False) True if the animal is currently oriented towards the point. To determine this, the procedure uses the protocol's Orientation and movement element.

Stage and trial variables

Last trial for stage(Numeric) The last trial for this animal in the given stage. If the animal has not yet completed the stage, this variable's value will be undefined.

Sequence variables

Duration of sequence(Numeric) The amount of time, in seconds, that the animal took to perform this sequence the last time it was completed. If the sequence has never been completed, this value will be 0.

Key variables

Key is pressed(True/False) True while the key is pressed, False otherwise.

On/off input variables

On/off input is active(True/False) True if the on/off input is currently active, False otherwise.
Most recent on/off input(Numeric) On/off inputs in ANY-maze can have index values specified, which allows the sequence of activations to be analysed (this can be useful, for example, to detect a sequence of activations of doors within the RAPC apparatus). This variable will return the index of the most recently activated on/off input - of course, for this to work, there must be at least one on/off input in the protocol set up with an index. If no inputs have yet been activated, this value will be -1.

Signal input variables

Signal value(Numeric) The current value of the signal. The units for this value will depend on the units that have been defined in the set-up of the signal.

Note that Signal input values that are passed to a procedure are limited to a sample rate of 100Hz; if the signal's sample rate is greater than this, then using this built-in variable to read the signal's current value may miss transient peaks of the signal.

Sensor variables

Sensor value(Numeric) The current value of the sensor. The units for this value will depend on the sensor.

Rotary encoder variables

Clockwise rotations(Numeric) The total number of clockwise rotations of the rotary encoder.
Anti-clockwise rotations(Numeric) The total number of anti-clockwise rotations of the rotary encoder.
Total rotations(Numeric) The total number of rotations, both clockwise and anti-clockwise, of the rotary encoder.
Rotary encoder RPM(Numeric) The rotational velocity of the rotary encoder, in RPM.
Pulses per revolution(Numeric) The number of pulses per revolution of this rotary encoder. This value is set for a specific rotary encoder when an I/O device is configured.

Output switch variables

Output switch is active(True/False) True if the switch is currently active; False otherwise.

Speaker variables

Speaker is playing(True/False) True while the speaker is playing a sound; False otherwise.
Speaker source(Protocol item) The currently selected audio source for the speaker (File, Tone or White Noise). The available speaker sources are listed as protocol items on the Variables tab of the procedure editor.
Speaker volume(Numeric) The current volume of the speaker, as a percentage of full volume.
Speaker frequency(Numeric) The current frequency of the tone to play from the speaker, in Hz. Note that if the speaker source is not set to be 'Tone', then this might not be the sound that is currently playing.
Speaker duration(Numeric) The duration for which the speaker will play a sound, in seconds.
Speaker files repeat(True/False) True if audio files played through the speaker can repeat; False if they are played only once.

Pellet dispenser variables

Pellet dispenser is busy(True/False) True if the pellet dispenser is currently dispensing a pellet, and has not finished. This is only relevant for Ugo Basile pellet dispensers.

Analogue output variables

Output value(Numeric) The current level of the analogue output, in Volts.

Temperature controller variables

Controller is ramping(True/False) This will be True if the temperature controller is currently ramping to its target temperature; False otherwise.
Controller temperature(Numeric) The current temperature of the temperature controller, in °C (currently only supported by OPAD cages). This may not be the same as its 'target' (programmed) level.
Programmed temperature(Numeric) The programmed temperature of the temperature controller, in °C (currently only supported by OPAD cages).
Programmed ramp duration(Numeric) The programmed duration of the ramping of the temperature of the temperature controller, in seconds (currently only supported by OPAD cages).

Light controller variables

Controller is on(True/False) True if the light controller is currently switched on; False otherwise.
Controller is ramping(True/False) True if the light controller is currently ramping to its target light level; False otherwise.
Current light level(Numeric) The current light level of the light controller, in %. This may not be the same as its 'target' (programmed) level. If the light controller is not currently switched on, then this will return 0.
Programmed light level(Numeric) The programmed light level of the temperature controller, in %.
Ramp duration(Numeric) The programmed duration of the ramping of the light controller, in seconds.
Active duration(Numeric) The active duration of the light controller, in seconds.

Syringe pump variables

Syringe Pump is running(True/False) True if the syringe pump is currently running; False otherwise.
Syringe Pump direction(Protocol item) The direction of the syringe pump (Infuse or Withdraw). The available directions are listed as protocol items on the Variables tab of the procedure editor.
Processed volume(Numeric) The volume processed so far by the syringe pump, in µl.
Target volume(Numeric) The target volume of the syringe pump, in µl.
Flow rate(Numeric) The flow rate of the syringe pump, in µl/min.

Shocker variables

Shocker is active(True/False) True if the shocker is currently active; False otherwise.
Shocker intensity(Numeric) The current intensity of the shock produced by the shocker, in mA. If the shocker is currently inactive, this value will be 0.
Shocker duration(Numeric) The current duration of the shock produced by the shocker, in seconds. If the shocker is currently inactive, this value will be 0.
Shocker intensity limit(Numeric) The maximum limit for the intensity of the shock, as specified in the protocol, in mA.
Shocker duration limit(Numeric) The maximum limit for the duration of the shock, as specified in the protocol, in seconds.

Laser controller variables

Controller is active(True/False) True if the laser controller is currently active; False otherwise.
Controller is a pulse train(True/False) True if the laser controller is currently active, and outputting a 'pulse train' signal; False if it is off, or outputting a continuous (DC) signal or a pulse sequence defined in a pulse train file.
Controller is continuous(True/False) True if the laser controller is currently active, and outputting a continuous (DC) signal; False if it is off, or outputting a pulse train or a pulse sequence defined in a pulse train file.
Controller is playing a pulse train file(True/False) True if the laser controller is currently active, and outputting a pulse sequence defined in a pulse train file; False if it is off, or outputting a pulse train or a continuous (DC) signal.
Controller frequency(Numeric) The current frequency of the laser controller, in Hz. This frequency is only used when the laser controller is outputting a pulse train.
Controller duty cycle(Numeric) The current duty cycle of the laser controller, in percent. This duty cycle is only used when the laser controller is outputting a pulse train.
Controller duration(Numeric) The current duration that the laser controller will be on for, in seconds. A duration of 0 means that the controller will remain active until explicitly turned off.
Controller intensity(Numeric) The current intensity of the laser controller, in Volts.

Selector variables

Selectors are only available on certain types of device (such as the ANY-maze Operant interface and Ugo Basile Operon).
Selector Value(Protocol item) The current value of the selector.
Selector Maximum value(Numeric) The maximum value that the selector can be set to, as a numeric value. This is to allow the procedure to be able to determine the maximum value in order to cycle through all possible selector values. For more information, see Selector actions.
Although the current value of a selector is returned as a protocol item, it can also be evaluated as a numeric value. If the current value of the selector is copied into a user-defined variable, then it will be stored as a numeric value. This doesn't cause any problems with other parts of the procedure, because selector values can be set as either a protocol item or a numeric value.
Selector is busy(True/False) True if the selector is currently busy making the change; False otherwise. This is only relevant for certain types of selector (the Revolver in an Ugo Basile Operon, for example).
Selector Value Text(Text) The text specified in the protocol for the given numeric value of the selector.

Field variables

Field valueThe current value of this field - this will depend on how the field has been set up. If it's a number field, then a numeric value will be returned; if it's a text field, the value will be returned as whatever text was entered; if it's a choice field, a protocol item will be returned - the possible values are listed as protocol items on the Variables tab of the procedure editor.

If the field's value has not yet been set, this will return '#N/A'.

Virtual switch variables

Virtual switch is active(True/False) True if the virtual switch is currently active; False if it is inactive.

ANY-maze protocol items

Some of the variables listed above return one of a list of 'known values' from the protocol as a return value. For example, the direction of a syringe pump is always 'Infuse' or 'Withdraw', and the location of a movable zone can only be one of a set of predefined locations.

All of the possible values of these, and anything else defined in the protocol, are listed under the ANY-maze protocol items sub-heading. These values can then be used anywhere in a procedure - for example, to compare with the return value from a function (using a comparison operator), or to store in a user-defined variable.

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0491