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.
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 MWP unit.
Whilst familiarising yourself with scripting, it is advisable to use the script below in tandem with the Zanscript syntax manual.
SET(DETECTOR_THRESHOLD,10) SET(SEARCH_DISTANCE,50) SET(SEARCH_STEP,7) SET(FILTER_RADIUS,15) SET(AUTOREF_MODE,MOVEMENT) SET(AUTOREF_TIMEOUT,20) DEFINE SCROLLTIME 5 DEFINE WAIT_TIME 6 DEFINE ITI 2 DEFINE TRIALS 7
The six SET commands are the settings required for tracking a single zebrafish.
ACTION MAIN LOAD(ZONES,"operant5hole") SETLIGHT(LIGHT1,SQUARE,1475,100,140) SETLIGHT(LIGHT2,SQUARE,1475,300,140) SETLIGHT(LIGHT3,SQUARE,1475,500,140) SETLIGHT(LIGHT4,SQUARE,1475,700,140) SETLIGHT(LIGHT5,SQUARE,1475,900,140) SETLIGHT(LIGHT6,SQUARE,325,500,140) SETLIGHT(LIGHT7,SQUARE,150,500,140) SETLIGHT(LIGHT8,SPRITE,0,500,0) LOAD(SPRITE_IMAGE,"8:danio_small") AUTOREFERENCE() INVOKE(ZONES_TEST,TRIALS) COMPLETE
ACTION MAIN outlines the actions for the whole experiment
The bitmap "operant5hole" 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 - 7 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
- LIGHT7 is under the feeder.
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-7 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,1800,500,SCROLLTIME) WAIT(WAIT_TIME) LIGHTS(LIGHT8,OFF) WAIT(WAIT_TIME) SETLIGHT(LIGHT8,SPRITE,0,500,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 1800,500 - these coordinates are slightly off the screen to ensure that the whole fish image 'swims' off 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,500 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,RED) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
The lights all turn off.
The overhead light (LIGHT16) turns on red.
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(LIGHT7,RED) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
The unit turns all lights off.
LIGHT 7 (positioned under the feeder as determined earlier in the script) turns on red.
The unit waits the predefined WAIT_TIME.
All lights turn off and the Action is complete.
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. You will also need to have the assets used in the script saved into the unit's Asset directory.
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