This demo script shows how the unit can be programmed with detection zones that correspond to stimuli, in this case we have used screen lights to mark the detection zones.
Script explanation
This script is written for the AD (hence it uses screen coordinates for the AD's screen, and includes motor commands for the brass feeder mechanism used to deliver fish food) but it can be edited for use with the LT unit.
Whilst familiarising yourself with scripting, it is advisable to use the script below in tandem with the Zanscript syntax manual.
DEFINE SCROLLTIME 5 DEFINE WAIT_TIME 6 DEFINE ITI 2 DEFINE TRIALS 7 SET(TARGET_SIZE,15) SET(DETECTOR_THRESHOLD,5) SET(AUTOREF_MODE,MOVEMENT) SET(AUTOREF_TIMEOUT,30)
The four SET commands are the settings required for tracking a single zebrafish.
SETLIGHT(LIGHT1,SQUARE,194.5,18.2,21) SETLIGHT(LIGHT2,SQUARE,194.5,45.6,21) SETLIGHT(LIGHT3,SQUARE,194.5,73,21) SETLIGHT(LIGHT4,SQUARE,194.5,100.4,21) SETLIGHT(LIGHT5,SQUARE,194.5,127.8,21) SETLIGHT(LIGHT6,SQUARE,37,72,21) SETLIGHT(LIGHT8,SPRITE,103,73,0) LOAD(SPRITE_IMAGE,"8:danio_small") LOAD(ZONES,"5_CHOICE") ACTION MAIN AUTOREFERENCE() INVOKE(ZONES_TEST,TRIALS) COMPLETE
ACTION MAIN outlines the actions for the whole experiment
The bitmap "5_CHOICE" is loaded to tell the unit where the detection zones are. This bitmap must be saved in the Asset directory. View this zone bitmap in the 'Assets for the AD unit' section in the Zanscripts & services manual.
The SETLIGHT command is used to define coloured squares at various positions on the screen. This is indicated by the LIGHTS 1-6 commands followed by SQUARE, the series of numbers after this define where the squares appear on the screen and what size they are:
- LIGHTS 1 to 5 line up sequentially against the back of the screen
- LIGHT 6 is in a typical initiator position, central & near the front of the screen
LIGHT 8 is a sprite, set as the image "danio:small" which must be loaded in the Assets directory.
AUTOREFERENCE() creates an auto referenced image of the tank prior to invoking the trials. It is needed for tracking - during the test move your fake fish around a little at the beginning during this period.
The action ZONES_TEST is then invoked and is repeated the number of times as defined by "TRIALS" at the top of the script.
ACTION ZONES_TEST LIGHTS(LIGHT1,MAGENTA) LIGHTS(LIGHT2,BLUE) LIGHTS(LIGHT3,GREEN) LIGHTS(LIGHT4,YELLOW) LIGHTS(LIGHT5,CYAN) LIGHTS(LIGHT6,RED) DETECTOR(DETECTOR1,DETECTOR1_TRIGGERED) DETECTOR(DETECTOR2,DETECTOR2_TRIGGERED) DETECTOR(DETECTOR3,DETECTOR3_TRIGGERED) DETECTOR(DETECTOR4,DETECTOR4_TRIGGERED) DETECTOR(DETECTOR5,DETECTOR5_TRIGGERED) DETECTOR(DETECTOR6,DETECTOR6_TRIGGERED) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) WAIT(WAIT_TIME) COMPLETE
- This section of code details the action of the DETECTOR_TEST
- LIGHTS 1-6 are lit in their designated colours, magenta, blue etc.
- The DETECTOR zones 1-6 are turned on, and if activated during this period by an animal (or fake fish in this case) will activate another action, for example if DETECTOR1 (which is where LIGHT1 is illuminated) is activated, the action DETECTOR1_TRIGGERED takes place and so on.
- The lights are all turned off after the "WAIT_TIME" period which is defined at the top of the script.
ACTION DETECTOR1_TRIGGERED LIGHTS(ALL,OFF) LIGHTS(LIGHT8,ON) PANLIGHT(LIGHT8,250,73,SCROLLTIME) WAIT(WAIT_TIME) LIGHTS(LIGHT8,OFF) WAIT(WAIT_TIME) SETLIGHT(LIGHT8,SPRITE,103,73,0) COMPLETE
If DETECTOR1 is triggered during ACTION DETECTOR_TEST the following actions occur:
- All the lights turn off.
- The sprite which is loaded as LIGHT8, turns on.
- PANLIGHT causes the sprite image to pan across the screen from the position in which it was originally set (i.e., in ACTION MAIN, or at the end of a previous ACTION) to the screen coordinates 390,141 - these coordinates are slightly off the screen to ensure that the whole image leaves the screen. The light will pan across during the period predefined at the top of the script as SCROLLTIME.
- The unit will wait for the defined WAIT_TIME. It is important that the WAIT_TIME is at least as long as SCROLLTIME to allow the sprite (LIGHT8) to finish panning across the screen before it turns off - LIGHTS(LIGHT8,OFF).
- The final command resets the sprite (i.e. LIGHT8) in a new position (coordinates 0,141 on the screen)
ACTION DETECTOR2_TRIGGERED LIGHTS(ALL,OFF) WAIT(WAIT_TIME) COMPLETE
- All the lights turn off.
- The unit waits for a period of WAIT_TIME as defined in the first part of code in seconds.
ACTION DETECTOR3_TRIGGERED LIGHTS(ALL,OFF) LIGHTS(LIGHT16,BLUE) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
- The lights all turn off.
- The overhead light (LIGHT16) turns on BLUE.
- The unit waits for the defined WAIT_TIME and then the light turns off.
ACTION DETECTOR4_TRIGGERED LIGHTS(ALL,OFF) FEEDER(1) WAIT(WAIT_TIME) COMPLETE
- The lights all turn off.
- FEEDER (1) operates the brass feeder mechanism for fish, which needs to be attached to the unit's motor see Fish Feeder Demo. The motor turns on to run the brass feeder mechanism to deliver solid food.
- The unit waits for the defined WAIT_TIME and then the action is complete.
ACTION DETECTOR5_TRIGGERED LIGHTS(ALL,OFF) SET(VOLTAGE_LEVEL,9000) WAIT(ITI) SET(VOLTAGE4,70) WAIT(ITI) COMPLETE
- This action operates the mild shocking plates, which need to be connected to the unit. Ensure that the metal plates are not touching when you perform the test.
- The two SET commands set the voltage level at 9000 and runs an electric pulse runs through the shocking plates for 70ms.
- For more details about running the shocking plates see the Mild Shock Demo.
ACTION DETECTOR6_TRIGGERED LIGHTS(ALL,OFF) LIGHTS(LIGHT6,GREEN) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
- The unit turns all lights off.
- LIGHT 6 lights up GREEN.
- The unit waits the predefined WAIT_TIME.
- All lights turn off and the Action is complete.
Script download
To download the zones_demo script as a .zs file (file type Zantiks software reads), choose the Save File As option in the right-click dialogue box. Clicking on the script name hyperlink will open a read-only version of the script.
Script download:
zones_screen_demo.zs
Asset
You will need to upload the appropriate asset into the Asset directory on your Zantiks Control Console and ensure the correct asset name is in the LOAD(ZONES,"name_of_asset") command in the script.
See the Calibrating your Zantiks unit page and Asset building in the AD unit page or Asset building in the LT unit page for details on how to create assets customised to your system.
Sprite asset downloads:
Video demo
This video illustrates how a model organism triggers a stimulus. In this case a fake fish swims over the magenta light (LIGHT1) and triggers the screen to pan an image of a fish across the screen.
Demo of fish image scrolling across screen when detection zone is activated