This demo script shows how the unit can be programmed with detector zones that correspond to stimuli, in this case we have used screen lights to mark the detector 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 used with the MWP for demo purposes.
Whilst familiarising yourself with scripting, it is advisable to use the script below in tandem with the Zanscript syntax manual.
INCLUDE ZSYS SET(AUTOREF_MODE,1) SET(AUTOREF_TIMEOUT,20) SET(DETECTOR_THRESHOLD,10) SET(SEARCH_DISTANCE,50) SET(SEARCH_STEP,7) SET(FILTER_RADIUS,15) DEFINE SQUARE 2 DEFINE SPRITE 5 DEFINE SPRITE_IMAGE 520 DEFINE SCROLLTIME 5 DEFINE WAIT_TIME 6 DEFINE ITI 2 DEFINE TRIALS 7
- INCLUDE ZSYS is always included in an experimental script.
- The six SET commands are the settings required for tracking a single zebrafish.
- The first 3 DEFINE commands set the stimuli types, a square shape, and two definitions always needed when using sprite (bitmap images).
ACTION MAIN LOAD(DETECTORS,"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(DETECTOR_TEST,TRIALS) COMPLETE
ACTION MAIN outlines the actions for the whole experiment:
- The bitmap "operant5hole" is loaded to tell the unit where the detector zones are. This bitmap must be saved in the Asset directory. View this detector bitmap in the 'Assets for the AD unit' section in the Zanscripts & services manual.
- LIGHTS 1 to 7 inclusive are then set as squares in a position on the screen - LIGHTS 1 to 5 line up sequentially against the back of the screen. LIGHT 6 is in a typical initiator position in a central position nearer the front of the screen while 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 DETECTOR_TEST is then invoked and is repeated the number of predefined amount of times "TRIALS" as written in the first part of the code.
ACTION DETECTOR_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:
- LIGHTS1 to 6 inclusive are lit in their designated colours, magenta, blue etc.
- The DETECTOR zones 1 to 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.
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.
- This sprite image pans 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 earlier as the SCROLLTIME.
- The unit will wait (WAIT_TIME) for the period predefined in the first part of code. In this instance 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 - in this case its original position and size).
ACTION DETECTOR2_TRIGGERED LIGHTS(ALL,OFF) WAIT(WAIT_TIME) COMPLETE
- All the lights turn off.
- The unit waits for a period of time (WAIT_TIME) as predefined in the first part of code.
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 and the action is complete.
ACTION DETECTOR4_TRIGGERED LIGHTS(ALL,OFF) FEEDER(1) WAIT(WAIT_TIME) COMPLETE
This action operates the brass feeder mechanism for fish, which needs to be attached to the unit's motor.
- The lights all turn off.
- 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 voltage level is set at 9000
- The unit waits for a period of time (ITI) as predefined in the first part of code.
- The electric pulse runs through the shocking plates. You will see the LED strip of lights flash at this point.
- The unit waits a predefined time (ITI) and then the action is complete.
ACTION DETECTOR6_TRIGGERED LIGHTS(ALL,OFF) LIGHTS(LIGHT7,RED) WAIT(WAIT_TIME) LIGHTS(ALL,OFF) COMPLETE
This Action turns on LIGHT 7, which was set in a position and size in the first part of the Action.
- The unit turns all lights off.
- LIGHT 7 turns on red.
- The unit waits the predefined time (WAIT_TIME).
- The unit turns all lights off and the Action is complete.
Here you can download the detector zone demo script as a .zs file. Right click on the download link below and download / save the file as a zanscript file, i.e. in the same format: detector_zone_demo.zs. You will also need to have the assets used in the script saved into the unit's Asset directory.
Script download: detector_zone_demo.zs
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.