The below script demonstrates how to use visual stimuli in behavioural assays, such as lights and images on the built-in screen. The tutorial explaining "How to Write a Zanscript" is based on this demo script.
The script is split into several parts to explain how to write the Zanscript (the coding language) to build a service that will use the built-in visual stimuli during an experiment. For more details about screen coordinates see the illustrated description in the SETLIGHT section of the Zanscript syntax manual.
Script explanation
DEFINE TRIALS 1 DEFINE STRIPE_TRIALS 3 DEFINE SCROLLTIME 8 DEFINE QUARTER_SCROLLTIME 2 DEFINE WAIT_TIME 6 DEFINE UNIT_TIME 3
The DEFINE commands at the top of the script apply values to actions later used in the script (e.g., the number of trials, amount of time in seconds) and the use of SPRITEs (used to produce images on the screen).
SETCOLOUR(10,0.01,0.01,0.01) SETLIGHT(LIGHT1,SQUARE,25.15,73,160) SETLIGHT(LIGHT2,SQUARE,185,73,160) SETLIGHT(LIGHT8,SPRITE,0,73,0) SETLIGHT(LIGHT9,SPRITE,0,73,0) SETLIGHT(LIGHT10,SPRITE,0,73,0) SETLIGHT(LIGHT11,SPRITE,103,0,0) LOAD(SPRITE_IMAGE,"8:blue_stripe_vertical") LOAD(SPRITE_IMAGE,"9:blue_stripe_vertical") LOAD(SPRITE_IMAGE,"10:blue_stripe_vertical") LOAD(SPRITE_IMAGE,"11:danio_small")
The SETCOLOUR command enables you to change how an image is lit from the screen. In this example, this command will be used to change how LIGHT10 (which is the SPRITE bitmap: the blue bar image) is lit, so it will appear black.
The first two SETLIGHT commands position square images on the screen. The first two numbers are the coordinates of their centre, and the third number is the size (in mm).
The next four SETLIGHT commands tell the unit to look for a bitmap (.bmp) image from the Assets directory, label it as LIGHT8 - 10 and load this in the position as indicated by the screen coordinates for its centre (first 2 numbers) and size (0 will keep original size).
The LOAD command tells the unit which .bmp image should be used for which light (i.e., LIGHT8 will be the asset "blue_stripe_vertical" and LIGHT11 will be "danio_small").
ACTION MAIN LIGHTS(ALL,OFF) INVOKE(OVERHEAD_LIGHTS,TRIALS) INVOKE(FISH_MOVEMENT,TRIALS) INVOKE(STRIPE_MOVEMENT,STRIPE_TRIALS) LIGHTS(ALL,OFF) INVOKE(BLOCK_COLOURS,TRIALS) LIGHTS(ALL,OFF) COMPLETE
The next set of ACTION MAIN commands (above) details the order of the whole experiment.
At the beginning and end all the lights all turned off.
The experiment comprises four parts, First FISH_MOVEMENT is invoked and will repeat the number of times as defined in TRIALS at the top of the script. The other 2 parts will run sequentially in the order that they are invoked in the script. Each will also repeat for a number of times as defined by TRIALS.
COMPLETE indicates that the ACTION has finished.
ACTION FISH_MOVEMENT LIGHTS(LIGHT11,ON) PANLIGHT(LIGHT11,103,146,SCROLLTIME) WAIT(WAIT_TIME) LIGHTS(LIGHT11,OFF) LIGHTS(LIGHT11,MAGENTA) PANLIGHT(LIGHT11,206,0,SCROLLTIME) WAIT(WAIT_TIME) LIGHTS(LIGHT11,OFF) LIGHTS(ALL,OFF) COMPLETE
LIGHT11 comes on (as defined as above - this is a 'sprite', a .bmp image called "danio_small".
This image pans across the screen from the position where it was originally set, as instructed by the SETLIGHT command above, to the new position (co-ordinates 103,146 on the screen). It will pan across the screen in the time as defined at the top of the script as SCROLLTIME in seconds.
The unit will WAIT for the number of seconds as defined as WAIT_TIME, before turning off LIGHT11. This period of time must be at least as long as the time allotted for the image to pan across the screen (i.e., the WAIT_TIME is 1 second longer than the SCROLLTIME) if you want the image to reach the location specified.
ACTION STRIPE_MOVEMENT LIGHTS(LIGHT1,WHITE) LIGHTS(LIGHT2,WHITE) SETLIGHT(LIGHT8,SPRITE,0,73,0) LIGHTS(LIGHT8,ON) PANLIGHT(LIGHT8,300,73,SCROLLTIME) WAIT(QUARTER_SCROLLTIME) SETLIGHT(LIGHT9,SPRITE,0,73,0) LIGHTS(LIGHT9,10) PANLIGHT(LIGHT9,300,73,SCROLLTIME) WAIT(QUARTER_SCROLLTIME) SETLIGHT(LIGHT10,SPRITE,0,73,0) LIGHTS(LIGHT10,ON) PANLIGHT(LIGHT10,300,73,SCROLLTIME) WAIT(QUARTER_SCROLLTIME) COMPLETE
The first commands turn a white light on the screen.
SETLIGHT, LIGHT8, a blue vertical bar, is positioned the front end of the screen. LIGHT8 then turns on, illuminated by the screen light and pans across the screen, reaching the coordinates 300,73 in the SCROLLTIME.
After a WAIT periods defined in seconds as QUARTER_SCROLLTIME, the next light (LIGHT9) pans across the screen. This bar appears black because of the command - LIGHTS(LIGHT9,10) - as the control for how the image is lit is set in the first section after the command SETCOLOUR(10,0.01,0.01,0.01).
LIGHT10, follows after another WAIT period
This ACTION is repeated 3 times (following the ACTION MAIN command - INVOKE(STRIPE_MOVEMENT,STRIPE_TRIALS), and the previous define command - STRIPE_TRIALS 3).
ACTION BLOCK_COLOURS LIGHTS(LIGHT1,BLUE) LIGHTS(LIGHT2,GREEN) WAIT(UNIT_TIME) LIGHTS(LIGHT1,GREEN) LIGHTS(LIGHT2,BLUE) WAIT(UNIT_TIME) LIGHTS(ALL,OFF) LIGHTS(LIGHT1,BLUE) LIGHTS(LIGHT2,BLUE) WAIT(UNIT_TIME) LIGHTS(LIGHT1,GREEN) LIGHTS(LIGHT2,GREEN) WAIT(UNIT_TIME) LIGHTS(ALL,OFF) COMPLETE
LIGHT1 fills the front half of the screen and LIGHT2 fills the back half of the screen. The position and size of the lights is defined in SETLIGHT commands found earlier in the code.
The colours, blue and green, switch ends. The screen is then all blue, and then all green. There is a WAIT period between colour changes defined at the top of the script as UNIT_TIME in seconds.
The lights are then turned off and the section is completed.
Script download
To download the stimulus_lights 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.
Zantiks AD script download:
stimulus_lights_demo_AD.zs
Assets
You will need to upload the 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
The video is a clip from the lights test and shows how colours, images and shapes can be displayed on the screen.
Demonstration of the light stimulation script running in the AD unit
Making bitmaps
To use SPRITES for the display of images on the screen, the image must first be made into a bitmap file and loaded into the Asset Directory.
A bitmap can be made in image software, such as Windows Paint or Photoshop, and then saved as a .bmp file. Bitmaps are always loaded into the Asset directory as rectangles. As such, if your image is a cut out of something non-rectangular it must also have a blue background to make a rectangular image.
The blue background will not show on the screen display. The bitmap featured above has been used in the Video Demo on this page.