All the experiments that run in a Zantiks unit are written in Zanscript - a proprietary Zantiks scripting language that is easy to learn and edit to experimental needs.
Background to Zanscript syntax
Scripts are built on the unit to make services, which are then run on the unit. Scripts may refer to bitmap files that need to be present in the assets directory on the unit on which the service is being run. Zantiks units are supplied with sample scripts (and in some cases pre-written setting scripts) and relevant assets.
We supply ‘fake fish on sticks’ (and 'fake mouse') to enable users to run test experiments with this fake organism(s) to help build their knowledge of how the system works, test their scripts, and test the tracking before using the unit in real experiments. Please view this 'Testing a script' video which illustrates how you can test your script by running a demo service with a 'fake fish'.
All the sample scripts follow the same format. Firstly there maybe be some DEFINE and INCLUDE directives that set the script up. This is followed by the ACTION MAIN, and then other ACTIONS, both of which include commands and functions.
Once a script is fully written it needs to be ‘Built’ to create a .zex file. This compiles the script (and all the “INCLUDE” settings) into a useable format (a ‘service’, *.zex, for the unit). Press the ‘Build’ button at the top or bottom of the Zanscript page. You can then load the experiment as a service on the unit. All .zex files are held in the ‘Services Directory’ which can be accessed from a link on the Home page.
Zanscript is a proprietary Zantiks script language. There are three different types of syntax - directives, commands and functions - which are listed below with a brief explanation of how they are be used.
Before actual experimentation please do test your new scripts thoroughly with the "fake animals" provided and learn from the sample scripts provided.
Directives are invoked before the script compilation (building) begins. They are used to provide general instruction on how the compiler should process the input used later inside the script.
allows you to define new variables, and assign them values, and these can then be called upon later in the script.
They can define a name against a value, so before compiling source code, thereplaces this name with the value in source code.
This directive can be used to designate a value for terms used in the experiment (e.g., terms used for time variables, such as time in seconds, or number of times to repeat an element of the script, or light stimuli).
DEFINE CIRCLE 1 DEFINE SQUARE 2 DEFINE SPRITE 5 DEFINE SPRITE_IMAGE 520
When defining the name used in the script to describe stimuli types that appear on the screen.
DEFINE CIRCLE 1 - This example directive enables you to use the word circle in the script instead of having to remember that the number 1 will create a circle shaped image stimulus on the screen.
DEFINE SQUARE 2 - This example directive enables you to use the word square in the script instead of having to remember that the number 2 will create a square shaped image stimulus.
DEFINE SPRITE 5 - This example directive enables you to use the word sprite in the script instead of having to remember that the number 5 will instruct the program to look for a bitmap. You will need to name the image/bitmap (as it is named in the assets folder) later in the script.
N.b. sprite is a term used in computer graphics, and is a two-dimensional bitmap that is integrated into a larger scene. Using sprites allows us to display any image anywhere on the screen.
DEFINE SPRITE_IMAGE 520 - This example directive needs to be in the script if you have a sprite image.
allows you to import the content of one external script to be included as part of the script. This directive can be used to include a setting script (e.g., a setting script which contains appropriate settings for an experiment). Ensure the setting scripts are loaded on your unit. (The only exception is zsys which is preloaded, but not visible, on all Zantiks units, but is to be INCLUDE zsys at the outset in all scripts.)
Commands control where one goes when in the script.
is the name for a section of the program that can be used once, or many times. Our sample scripts have an ACTION called MAIN, and it is the first action in the script, and is typically run once. When naming an action, you can not use choose that has been defined already in the Zanscript programming language (e.g., RED, BLUE, GREEN, LIGHTS, FEEDER). You can create a version of the word (e.g., MMRED, LIGHT6)
ACTION EXAMPLE AUTOREFERENCE() WAIT(WAIT_TIME) INVOKE(TESTING,TRIALS) COMPLETE
is the command to indicate the end of the preceding ACTION.
ACTION EXAMPLE AUTOREFERENCE() WAIT(WAIT_TIME) INVOKE(TESTING,TRIALS) COMPLETE
is the command to call up an ACTION to run. It can also signify how many times an ACTION is to be run.
DEFINE TRIALS 4 ACTION EXAMPLE AUTOREFERENCE() WAIT(WAIT_TIME) INVOKE(ACTION1,4) INVOKE(ACTION1,TRIALS) COMPLETE
INVOKE(ACTION1,4) - would run the ACTION called ACTION1 4 times. The script would then go to the line below.
INVOKE(ACTION1,TRIALS) - would run ACTION called ACTION1 4 times if there was a directive TRIALS defined earlier (e.g., DEFINE TRIALS 4)
allows the script to call up other actions if the detector is triggered. A DETECTOR command must be followed by a WAIT period. If the detector is not triggered, then the ACTION continues after this WAIT statement has been completed. After the triggered ACTION has been run, the script returns to after the WAIT following the DETECTOR commands. See the Detector demo script page for a full example.
ACTION EXAMPLE LIGHTS(LIGHT7,WHITE) FEEDER(1) DETECTOR(DETECTOR1,TRIGGERED) WAIT(3) LIGHTS(ALL,OFF) COMPLETE
DETECTOR(DETECTOR1,TRIGGERED) - will turn DETECTOR1 on, and if the animal enters into this DETECTOR zone during the 3 second WAIT period it will cause the action TRIGGERED to occur.
allows one to choose between 2 options with defined probabilities.
ACTION EXAMPLE SELECT(OUTCOME1,OUTCOME2) COMPLETE
SELECT (OUTCOME1,OUTCOME2) - will choose randomly between going to (the ACTION) OUTCOME1 or OUTCOME2.
ACTION EXAMPLE2 SELECT(OUTCOME1,OUTCOME2or3,33) COMPLETE) ACTION OUTCOME2or3 SELECT(OUTCOME2,OUTCOME3) COMPLETE
SELECT(OUTCOME1,OUTCOME2or3,33) - will select between OUTCOME1 with a probability of 33.3% and OUTCOME2or3 with a probability of 66.6%.
SELECT(OUTCOME2,OUTCOME3) - selects between the first ACTION (OUTCOME2) and the second ACTION (OUTCOME3) with a 50/50 chance of choosing either.
The ACTIONs written in the SELECT commands will each need to be defined in their own ACTION section below.
These commands are useful if the position of certain stimuli need to be randomly presented in different locations.
Functions are executed as they are encountered in the script.
attempts to automatically create an image from the camera without the organism present. This image is stored as autoref.bmp in the assets directory. The image is made with the assumption the organism(s) is(are) dark on a lighter background, and that it(they) move. Its mode of operation can be changed with parameters set by the SET function.
In the autoreference mode the system, over a set period of time (as detailed in the SET(AUTOREF_TIMEOUT, #) setting) will take images, and compile them so that the organism can be tracked during the experiment.
SET(AUTOREF_MODE,1) SET(AUTOREF_TIMEOUT,20) ACTION EXAMPLE AUTOREFERENCE() INVOKE(MAIN_TASK,1) COMPLETE
details a time, in seconds, for the script to 'stay'. You can DEFINE the number of seconds in a previous DEFINE command.
DEFINE WAIT_TIME 10 ACTION EXAMPLE WAIT(10) LIGHTS(LIGHT1,ON) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
WAIT(10) - will wait 10 seconds before moving on.
WAIT(WAIT_TIME) - will wait for 10 seconds if a DEFINE directive is stated: DEFINE WAIT_TIME 10
sets the type of visual stimulus to be displayed, as well as its location in the screen - see the illustration above detailing Screen coordinates on Zantiks unit. For ‘sprite’ images (.bmp) you can also set the size.
SETLIGHT(LIGHT1,SQUARE,1475,100,140) SETLIGHT(LIGHT2,SQUARE,800,500,1600) SETLIGHT(LIGHT3,SPRITE,800,200,0
SETLIGHT(LIGHT1,SQUARE,1475,100,140) - sets LIGHT1 as a square shape of light with the centre of the square located to be with the centre of the square located at the coordinates 1475,100 on the screen. The size of the square is set at 140 pixels.
SETLIGHT(LIGHT2,SQUARE,800,500,1600) - sets LIGHT2 to the size of the entire screen (1600).
SETLIGHT(LIGHT3,SPRITE,800,200,0) - specifies that LIGHT3 is a 'sprite' bitmap image to be displayed on the screen coordinates 800,200 on the screen. The image's original size is used, as indicated by the final value 0. The size of the sprite can be altered by changing this number to the required size in pixels.
The defined LIGHTs can then be controlled using the LIGHTS command (see below).
can turn lights on and off, and specify different colours. It can refer to the overhead lights (LIGHT16) or any lights or images that have been set to appear on the screen using the SETLIGHT function.
ACTION EXAMPLE LIGHTS(LIGHT1,RED) WAIT(WAIT_TIME) LIGHTS(LIGHT2,BLUE) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
LIGHTS(LIGHT1,RED) - would turn LIGHT1 red. You would have described the location of LIGHT1 earlier in the script using the function SETLIGHT.
LIGHTS(LIGHT16,BLUE) - would turn the overhead light (the house light) blue. This light is an RGB LED light and it has predefined 7 colours - red, green, blue, cyan, magenta, yellow, white.
LIGHTS(ALL,OFF) - turns all lights off simultaneously. It can be a useful line of code to use as it ensures an experiment, or section of an experiment, begins with no stimuli on.
enables you to create a colour using red, green and blue which you can name using a number and then use in subsequent LIGHTS commands.
SETLIGHT(LIGHT1,2,300,500,50) SETCOLOUR(8,1.0,0.75,0.75) ACTION EXAMPLE LIGHTS(LIGHT1,8) COMPLETE
SETCOLOUR(8,1.0,0.75,0.75) - will create a colour, called '8', which will consist of 100% red, 75% green and 75% blue. The numbers in the brackets will always be in the following order:
(8,1.0,0.75,0.75) - the first number '8' is what this colour will be called, and how it will be referenced in later commands in the script. (Integer number only between 8 and 255 may be used for the colour name).
(8,1.0,0.75,0.75) - the second number 1.0 details how much of the red light to use, in this case 100%.
(8,1.0,0.75,0.75) - the third number, 0.75, details how much of the green light to use, in this case 75%.
(8,1.0,0.75,0.75) - the fourth number, 0.75, details how much of the blue light to use, in this case 75%.
SETCOLOUR(8,1.0,1.0,1.0) - creates the colour white by using 100% for each of the colours, red green and blue.
Please see the screen colour demo script here.
to have a sprite image scroll across the screen from a set starting position (i.e., from its original location as detailed in a SETLIGHT function or from the position it moved to following the previous PANLIGHT function) to the position detailed after the PANLIGHT command:
DEFINE SCROLL_TIME 8 LOAD(SPRITE_IMAGE,"1:zebrasingle") SETLIGHT(LIGHT1,SPRITE,1500,200,0) ACTION EXAMPLE LIGHTS(LIGHT1,ON) PANLIGHT(LIGHT1,1500,1200,SCROLLTIME) COMPLETE
PANLIGHT(LIGHT1,1500,1200,8) - will make the image move from its starting position (as detailed above in the SETLIGHT setting) to the position on the screen defined here (1500,1200), over a period of 8 seconds.
PANLIGHT(LIGHT1,1500,1200,SCROLLTIME) - will move the image from its starting position (as detailed above) to the position on the screen defined here (1500,1200), moving for the pre-defined time SCROLLTIME (see DEFINE directive above).
For an example script using these functions, see Lights demo script page.
This command details the asset/bitmap to compile with to script. It must be stored in the Assets Directory folder.
It can include instructions in what context to use the asset (i.e., as a DETECTOR or ARENA).
SETLIGHT(LIGHT1,SPRITE,0,500,0) LOAD(DETECTORS,"fullyzoned_5hole") LOAD(ARENAS,"arenas4long") ACTION EXAMPLE LOAD(SPRITE_IMAGE,"1:grey128x128") LIGHTS(LIGHT1,ON) COMPLETE
LOAD(DETECTORS,"fullyzoned_5hole") - would load the asset called "fullyzoned_5hole" as the detection zones. It will now detect movement in the highlighted zones.
LOAD(ARENAS,”arenas4long”) - would load the asset called "arenas4long" as the arena areas. It creates the area in which 1 animal will be tracked. The name "arena4long" indicates the number and shape of different arenas that are set up for tracking the animals.
LOAD(SPRITE_IMAGE,"1:grey128x128") - would load the bitmap called "grey128x128" as LIGHT1, in this example because of a previous command SETLIGHT(LIGHT1,SPRITE,0,500,0) - which sets the sprite image's beginning position, sprite mode and size on the screen. For full example, see the Lights demo page.
starts the video recording for a time (in seconds) specified in the brackets, saving the video with the name detailed in the apostrophes, “ ”
DEFINE WAIT_TIME 16 ACTION EXAMPLE VIDEO(15,"videotest") WAIT(WAIT_TIME) COMPLETE
records 15 seconds of video and saves the file into the Media Directory with a name starting “videotest” (the time and date will follow this label). The video recording has been designed to provide a useful record of short parts of the experiment, for reference only. The system prioritises running the experiment and processing the results live. It then will try and make the requested video. This means that one may have dropped frames, and it is possible the overlay of the screen onto the camera image can have a minor time delay over time. The time written into the video image will be correct (i.e., the computer time at which the image was acquired from the camera).
As the computer records the experiment the video images are processed later on and combined with any asset images used. This can lead to a slight ‘drift’ between these two events.
The “videotest” footage can be found in the Media Directory, accessible from a link on the Home page.
This command is used to set in place certain environmental parameters that remain constant for the entire script.
DEFINE WAIT_TIME 1 SET(ACTIVITY_THRESHOLD,10) SET(CAMERAPROFILE,10) SET(AUTOREF_MODE,1) SET(AUTOREF_TIMEOUT,20) SET(MSD_MODE,ON) SET(MSD_THRESHOLD,5) SET(VOLTAGE_LEVEL,9000) SET(COUNTER1,COUNTER_ZERO) ACTION EXAMPLE SET(COUNTER1,COUNTER_INC) SET(VOLTAGE4,70) WAIT(WAIT_TIME) COMPLETE
SET(AUTOREF_MODE,1) - sets the AUTOREFERENCE system to use brightness mode (the reference image is formed by using the brightest pixel seen by the camera in a particular position over the time of the autoreference procedure.
MODE,0 uses the the motion mode - appropriate only when there is one organism, and only one arena. MODE,1 is for more than one organism.
SET(AUTOREF_TIMEOUT,20) - sets the (maximum) time for the autoreference procedure.
SET(MSD_MODE,ON) - Enables MSD data collection of animals.
SET(MSD_THRESHOLD,5) - sets the threshold value for MSD.
For more information on MSD function and setting threshold values take a look at our Measuring Activity page.
SET(VOLTAGE_LEVEL,9000) - sets the voltage level to 9000 millivolts for the shocking output (socket CN5), for example in an aversion experiment.
SET(VOLTAGE4,70) - sets 4th output pair (of 4) of CN5 to the set VOLTAGE_LEVEL for 70 ms. The VOLTAGE_LEVEL can be set for any duration under 1000ms (1 second). For a duration of 1000 and above, you will need to use a separate SET command for the voltage. See the demo script: voltage_demo.zs.
SET(VOLTAGE4,ON) - turns on the voltage (at level as set previously). See Script variation on mild shock demo page.
SET(COUNTER1,COUNTER_ZERO) - allows you to count different elements of an experiment and record them accordingly in the pre-processed results data (e.g., COUNTER1 to the value 0). There are 25 counters available, COUNTER1 through to COUNTER25.
SET(COUNTER1,COUNTER_INC) - sets COUNTER1 to increment its value by 1.
SET(ACTIVITY_THRESHOLD,10) - is used in mouse nose poke experiments, this setting tracks any mouse nose poke in a live detector zone. N.B., this tracking is in addition to the movement tracking of the mouse which is based loosely on the mouse’s centre of gravity.
SET(CAMERAPROFILE,10) - changes the camera resolution to 320x240, which is only necessary to use for rodent experiments. The default setting is set at 640x480, which is used for experiments with fish. Frame rate will remains the same.
instructions the feeder mechanism to rotate. This can be used to deliver food (which will need to be pre-loaded) or to create a 'false feed' (a movement similar in noise/vibration to feeding, but does not actually deliver food).
View the Feeder demo page for an example script.
ACTION EXAMPLE FEEDER(1) WAIT(FEED_TIME) FEEDER(0) WAIT(FEED_TIME) COMPLETE
FEEDER(1) - rotates completely to deliver one portion of food.
FEEDER(0) - 'false feed', rotates to mimic a completed feed without dropping food.
MOTORCOMMAND, synonym ZCOMMAND
controls the stepper motor that rotates the peristaltic pump, the feeder mechanism for powdered food and pellets, and the vibration of the MWP_vb system.
ACTION EXAMPLE MOTORCOMMAND("U0 D1000 M200) WAIT(WAIT_TIME) MOTORCOMMAND("U0 D2000 M1 M-1 M1 M-1 M1 M-1 M1 M-1 M1 M-1 M1 M-1") WAIT(WAIT_TIME) MOTORCOMMAND("U0 D2000 M1 M-1") WAIT(WAIT_TIME) COMPLETE
MOTORCOMMAND(“U0 D1000 M200”) - the numbers in the brackets and written between inverted commas “” indicate the rotation parameters:
'M' Number of Motor steps (e.g., 200, -50). 200 steps is a full 360 degree rotation
'D' Delay between motor steps, which sets the motor speed. This should not be below 1000 for 'free' motors (e.g. as used in feeders for the AD & LT). In the MWP the motor is mounted to cause vibrations, and not rotate, and so this limit does not apply).
'U' Step mode (0-3, for full/half/quarter/eighth step modes)
'P' (Pause) - sets a delay between actions in milliseconds (i.e., 'P50' will pause for 50 milliseconds)
writes text to the data file on a new line (with the time at the front).
LOG(“this text”) - writes “this text” to the data file on a new line (with the time at the front).
The system is keeping a continuous record of the current measure of various measure (e.g., distance travelled in each detector zone, number of visits to detector zones). LOGDATA allows one to record to memory the current values using the command below.
ACTION EXAMPLE LOGDATA(DATA_SNAPSHOT,"BEGIN") WAIT(WAIT_TIME) LOGDATA(DATA_SNAPSHOT,"AFTER") LOGDATA(DATA_SELECT,"BEGIN") LOGDATA(DATA_DELTA,"AFTER") LOGRUN() COMPLETE
LOGDATA(DATA_SNAPSHOT “BEGIN”) - records information at this point of the script, and it is given the name ‘begin’. If the command was run again the data would be overwritten with the new current values.
LOGDATA(DATA_SNAPSHOT “END”) - records information with the name ‘end’.
LOGDATA(DATA_SELECT “BEGIN”) - pulls the data from the named SNAPSHOT “begin” above.
LOGDATA(DATA_DELTA “END”) - calculates the change of parameter values between the DATA_SELECT snapshot and the DATA_DELTA snapshot.
See Zanscript tutorial Using logdata, logcreate and logrun
specifies a format / contents for a line in the data output file. It can be used to create headers for columns, and for the rows containing data.
ACTION EXAMPLE LOGCREATE("TEXT:|RUNTIME|COUNTER1|TEMPERATURE1") LOGAPPEND("TEXT:TRIALS") LOGAPPEND("TEXT:|ZONE_COUNTERS:Z7|ZONE_TIMERS:Z7") LOGRUN() COMPLETE
The above script writes a blank cell, followed by the time, followed by a set counter, the unit's temperature and then the text 'TRIALS' in individual cells consecutively on one row.
|TEXT:| - leaves cell empty.
|RUNTIME| - writes the time a specified action occurs.
|COUNTER1| - writes the value of COUNTER1 at the point that this LOGCREATE command is outputted into a line of data by the next LOGRUN command.
The above script writes a blank cell, followed by the time, followed by a set counter, the unit's temperature and then the text 'TRIALS' in individual cells consecutively on one row
|TEMPERATURE1| - writes the temperature measurement taken by the thermistor in the chamber (at the time that the this LOGCREATE command is outputted by the next LOGRUN command).
|TEXT:any_text_here| - writes any text you place inside the apostrophes into a cell.
N.B., When writing a script, be aware that the system will only read the first 78 characters in a line of code. Therefore, if the text within the “ “ of a LOGCREATE command is longer than this, continue the code on a new line with a LOGAPPEND command.
You can do this multiple times. If a command line is too long when you build the script, it will not build successfully and there will be an error for the long line of code. Notes are included in the sample scripts (they appear on a line of command after a #). These lines can generate a warning when you build the script, but the script still builds successfully (as text after the # is ignored).
allows an appendage to the line above. This is required as only the first 78 characters of a line are processed.
writes the data specified in the latest LOGCREATE line to the data file. Must follow the LOGCREATE command to be written onto your data output file.
See the Locomotor data demo page for a sample script using LOGDATA, LOGCREATE, LOGRUN, and the Zanscript tutorial, Using logdata, logcreate and logrun, to see some videos illustrating how these functions are used.
Prepares in the memory the instruction that follows in brackets. The number indicates the cell - NB number the cells incrementally from 1 when 1 is the third cell in the data output line. Anything written between inverted commas, “ ” , will be written in full (a space left between “ “ indicates leave cell empty). This function is used in the tutorial, Two-choice discrimination task AD Tutorial.
ACTION EXAMPLE LOGFIELD(1,"TRIAL_INITIATED") LOGFIELD(2,"START_TIME") LOGFIELD(3,COUNTER1) LOGFIELD(4,RUNTIME) LOGFIELD(COMMIT) COMPLETE
LOGFIELD(1,”TRIAL_INITIATED”) - prepare in the memory to write words (i.e. cell heading) - TRIAL_INITIATED - in the third cell in the data output line.
LOGFIELD(2,”start_time”) - prepares in the memory to write words (i.e. cell heading) - start_time - in the fourth cell in the data output line.
LOGFIELD(3,COUNTER1) - prepares in the memory to write the number of counts COUNTER1 has got to at this stage in the script in the fifth cell in the data output line.
LOGFIELD(4,RUNTIME) - prepares in the memory to write the actual runtime in the script at that moment in the sixth cell.
LOGFIELD(COMMIT) - tells the system to write the contents of the fields as specified by earlier LOGFIELD commands (after the previous COMMIT). It then clears the contents of the fields.