Measuring distance and zone use


This script demonstrates how to use the zanscript language to write a behavioural assay to measure locomotion for a small model organism, such as Drosophila, larval zebrafish or Daphnia. Normally this type of experiment is done in a standard-sized well plate that fits in the experimental chamber of the MWP unit.

It is advisable to first read through the Tutorials for zanscript, in particular view the video in the tutorial for Using logdata, logcreate, logrun.

Top

Script outline

This script demonstrates how you can use the LOGCREATE, LOGDATA and LOGRUN commands to collect summarised results data from an experiment in the MWP unit.

In particular this script demonstrates how a script with two zones may work with the MWP unit. The script records the movement of singly-housed animals in a 24 multi well plate. The well plate is illuminated with a white light during the trials.

The results data will give overall distance moved, in both the whole arena and in the two different zones, as well as distance moved in time_bins. As the results data is recorded in time bins - DEFINE TIME_BIN 10 records in 10 sec time bins - non movement can be calculated in time bins.

IMPORTANT - the arena and zone assets must be uploaded in the Assets directory.

Whilst familiarising yourself with scripting, it is advisable to use the script below in tandem with the Zanscript syntax manual.

Top
DEFINE ACCLIMATION 0 
DEFINE TIME_BIN_SECS 5 
DEFINE RGB_NUM_SERIES 2 
 
# define the animal model tracking requirements (dependent on animal size) 
SET(TILE_SIZE,5) 
SET(DETECTOR_THRESHOLD,6) 
SET(SEARCH_DISTANCE,10) 
SET(SEARCH_STEP,3) 
SET(FILTER_RADIUS,3) 
 
# define auto reference tracking requirements 
SET(AUTOREF_MODE,MOVEMENT) 
SET(AUTOREF_TIMEOUT,10)
 
ACTION MAIN 
 
 LOGCREATE("TEXT:TIME|TEXT:TEMPERATURE") 
 LOGAPPEND("TEXT:VARIABLE|TEXT:TREATMENT|TEXT:SERIES") 
 
 # INVOKE(WELL_6,1) 
 # INVOKE(WELL_12,1) 
 INVOKE(WELL_24,1) 
 # INVOKE(WELL_48,1) 
 # INVOKE(WELL_96,1) 
 
 LOGRUN() 
 
 SETLIGHT(LIGHT1,2,800,500,1600) 
# Sets the data output counter label to begin at 0. The counter is used in the script below to label the series 
 
 SET(COUNTER1,COUNTER_ZERO) 
 INVOKE(DARK,1) 
 
 AUTOREFERENCE() 
 INVOKE(RGB_SERIES,RGB_NUM_SERIES) 
 LIGHTS(ALL,OFF) 
 
COMPLETE 
 
ACTION RGB_SERIES 
 
 SET(COUNTER1,COUNTER_INC) 
 INVOKE(MMRED,1) 
 INVOKE(MMGREEN,1) 
 INVOKE(MMBLUE,1) 
 
COMPLETE 
 
ACTION MMRED 
 
 INVOKE(LT_RED,1) 
 LOGDATA(DATA_SNAPSHOT,"BEGIN") 
 WAIT(TIME_BIN_SECS) 
 
 LOGDATA(DATA_SNAPSHOT,"END") 
 LOGDATA(DATA_SELECT,"BEGIN") 
 LOGDATA(DATA_DELTA,"END") 
 LOGCREATE("RUNTIME|TEMPERATURE1|TEXT:ARENA_DISTANCES|TEXT:RED") 
 LOGAPPEND("COUNTER1|ARENA_DISTANCES:*") 
 LOGRUN()
 
 INVOKE(DARK,1) 
 
COMPLETE 
 
ACTION MMGREEN 
 
 INVOKE(LT_GREEN,1) 
 LOGDATA(DATA_SNAPSHOT,"BEGIN") 
 WAIT(TIME_BIN_SECS)
 
 LOGDATA(DATA_SNAPSHOT,"END") 
 LOGDATA(DATA_SELECT,"BEGIN") 
 LOGDATA(DATA_DELTA,"END") 
 LOGCREATE("RUNTIME|TEMPERATURE1|TEXT:ARENA_DISTANCES|TEXT:GREEN") 
 LOGAPPEND("COUNTER1|ARENA_DISTANCES:*") 
 LOGRUN() 
 
 INVOKE(DARK,1) 
 
COMPLETE 
 
ACTION MMBLUE 
 
 INVOKE(LT_BLUE,1) 
 LOGDATA(DATA_SNAPSHOT,"BEGIN") 
 WAIT(TIME_BIN_SECS)
 
 LOGDATA(DATA_SNAPSHOT,"END") 
 LOGDATA(DATA_SELECT,"BEGIN") 
 LOGDATA(DATA_DELTA,"END") 
 LOGCREATE("RUNTIME|TEMPERATURE1|TEXT:ARENA_DISTANCES|TEXT:BLUE")
 LOGAPPEND("COUNTER1|ARENA_DISTANCES:*") 
 LOGRUN() 
 
 INVOKE(DARK,1) 
 
COMPLETE 
 
ACTION DARK 
 
 LIGHTS(ALL,OFF) 
 SET(GPO6,0) 
 SET(GPO7,0) 
 SET(GPO8,0) 
 
COMPLETE 
 
ACTION LT_RED 
 
 LIGHTS(LIGHT1,RED) 
 SET(GPO6,1) 
 SET(GPO7,0) 
 SET(GPO8,0) 
 
COMPLETE 
 
ACTION LT_GREEN
 
 LIGHTS(LIGHT1,GREEN) 
 SET(GPO6,0) 
 SET(GPO7,1) 
 SET(GPO8,0) 
 
COMPLETE 
 
ACTION LT_BLUE 
 
 LIGHTS(LIGHT1,BLUE) 
 
 SET(GPO6,0) 
 SET(GPO7,0) 
 SET(GPO8,1) 
 
COMPLETE 
 
ACTION BRIGHT 
 
 LIGHTS(LIGHT1,ON) 
 SET(GPO6,1) 
 SET(GPO7,1) 
 SET(GPO8,1) 
 
COMPLETE 
 
ACTION WELL_6 
 
 LOAD(ARENAS,"6well.bmp") 
 LOGAPPEND("TEXT:A1|TEXT:A2|TEXT:A3|TEXT:A4|TEXT:A5|TEXT:A6") 
 
COMPLETE 
 
ACTION WELL_12 
 
 LOAD(ARENAS,"12well.bmp") 
 LOGAPPEND("TEXT:A1|TEXT:A2|TEXT:A3|TEXT:A4") 
 LOGAPPEND("TEXT:B1|TEXT:B2|TEXT:B3|TEXT:B4") 
 LOGAPPEND("TEXT:C1|TEXT:C2|TEXT:C3|TEXT:C4") 
 
COMPLETE 
 
ACTION WELL_24 
 
 LOAD(ARENAS,"24wella") 
 LOGAPPEND("TEXT:A1|TEXT:A2|TEXT:A3|TEXT:A4|TEXT:A5|TEXT:A6") 
 LOGAPPEND("TEXT:B1|TEXT:B2|TEXT:B3|TEXT:B4|TEXT:B5|TEXT:B6") 
 LOGAPPEND("TEXT:C1|TEXT:C2|TEXT:C3|TEXT:C4|TEXT:C5|TEXT:C6") 
 LOGAPPEND("TEXT:D1|TEXT:D2|TEXT:D3|TEXT:D4|TEXT:D5|TEXT:D6") 
 
COMPLETE 
 
ACTION WELL_48 
 
 LOAD(ARENAS,"48well.bmp") 
 LOGAPPE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T:D10|TEXT:D11|TEXT:D12") 
 LOGAPPEND("TEXT:E1|TEXT:E2|TEXT:E3|TEXT:E4|TEXT:E5|TEXT:E6") 
 LOGAPPEND("TEXT:E7|TEXT:E8|TEXT:E9|TEXT:E10|TEXT:E11|TEXT:E12") 
 LOGAPPEND("TEXT:F1|TEXT:F2|TEXT:F3|TEXT:F4|TEXT:F5|TEXT:F6") 
 LOGAPPEND("TEXT:F7|TEXT:F8|TEXT:F9|TEXT:F10|TEXT:F11|TEXT:F12") 
 LOGAPPEND("TEXT:G1|TEXT:G2|TEXT:G3|TEXT:G4|TEXT:G5|TEXT:G6") 
 LOGAPPEND("TEXT:G7|TEXT:G8|TEXT:G9|TEXT:G10|TEXT:G11|TEXT:G12") 
 LOGAPPEND("TEXT:H1|TEXT:H2|TEXT:H3|TEXT:H4|TEXT:H5|TEXT:H6") 
 LOGAPPEND("TEXT:H7|TEXT:H8|TEXT:H9|TEXT:H10|TEXT:H11|TEXT:H12") 
 
COMPLETE
Top

Script explanation

You can amend this script (as explained below) for a smaller well plate, e.g. for 6 wellplate, 12 wellplate, 48 wellplate, 96 wellplate.

DEFINE ACCLIMATION 0

DEFINE TIME_BIN_SECS 5

  • The two DEFINE commands enable you change the time values in seconds as used in the script. For example, if you want to collect summarised data in 1 second time bins you would replace 5 with 1 accordingly: DEFINE TIME_BIN_SECS 1
DEFINE RGB_NUM_SERIES 2

This DEFINE command details the value for RGB_NUM_SERIES when used in the script. At the moment 2 series of lights on and off will be conducted. This can then easily be changed so that each experiment runs more or less trials.

SET(TILE_SIZE,5) 
SET(DETECTOR_THRESHOLD,6) 
SET(SEARCH_DISTANCE,10) 
SET(SEARCH_STEP,3) 
SET(FILTER_RADIUS,3) 

The SET commands above define the animal model tracking requirements, which are dependent on animal size.

For more details on adjusting the tracking requirements see the tracking settings support pageTracking settings - Z2S.

SET(AUTOREF_MODE,MOVEMENT) 
SET(AUTOREF_TIMEOUT,10) 

The two SET commands above define the auto reference tracking requirements. If the animals you are using will take a while before they move for the first time, increase the value for the command AUTOREF_TIMEOUT which is currently set to last 10 seconds.

LOAD(ARENAS,"6well.bmp")
LOAD(ARENAS,"12well.bmp")
LOAD(ARENAS,"24wella")
LOAD(ARENAS,"48well.bmp")

LOAD(ARENAS,"96well.bmp")

  • The LOAD commands tells the unit to use the assets detailed in brackets (in parenthesis) to define the location of each arena and the zones in each arena. The assets / .bmp files must be loaded in the unit's Assets directory.
SET(COUNTER1,COUNTER_ZERO)
  • The SET command above tells the unit to set COUNTER1 at zero, COUNTER1 will be used later in the script to count the trials - as found under the ACTION RGB_SERIES, where the command - SET(COUNTER1,COUNTER_INC) - sets COUNTER1 to count the trials - i.e. count incrementally each time the Action occurs.
AUTOREFERENCE()
  • The AUTOREFERENCE command tells the unit to take an auto reference image needed for tracking, using the settings detailed above.
LOGCREATE("RUNTIME|TEMPERATURE1|TEXT:ARENA_DISTANCES|TEXT:RED") 
LOGAPPEND("COUNTER1|ARENA_DISTANCES:*") 
LOGRUN()
  • The LOGCREATE (and subsequent LOGAPPEND) command tell the unit to commit to memory information for a line of data. In this case, the temperature will be written in the 2nd cell, ARENA_DISTANCES will be written in the 3rd cell, RED in the 4th cell, the series counter in the 5th and the calculated distances moved in the final cells.
  • The LOGCREATE (and subsequent LOGAPPEND) commands are used for writing the well plates' identifications. for a 24 well plate and need to be amended for a different sized well plate. For example, a 6 well plate is labelled as:
    • LOGAPPEND("TEXT:A1|TEXT:A2|TEXT:A3|TEXT:B1|TEXT:B2|TEXT:B3")
  • The LOGRUN outputs the data specified in the previous LOGCREATE command.
LOGDATA(DATA_SNAPSHOT,"BEGIN")
WAIT(TIME_BIN_SECS)
LOGDATA(DATA_SNAPSHOT,"END")
LOGDATA(DATA_SELECT,"BEGIN")
LOGDATA(DATA_DELTA,"END") 
  • The first LOGDATA command tells the unit to take a snapshot of the experiment, remembering the tracking details of the animals, and labelling this snapshot BEGIN.
  • The second LOGDATA(DATA_SNAPSHOT,...) command tells the unit to take another snapshot of the experiment after all the trials have finished, labelling it END.
  • The last two LOGDATA lines of code, LOGDATA(DATA_SELECT,....) and LOGDATA(DATA_DELTA,.....), instruct the unit to calculate the difference in data between the two snapshots taken, "BEGIN" and "END".
SET(GPO6,1) 
SET(GPO7,1) 
SET(GPO8,1) 
  • These SET commands turn on the three different overhead LED lights in the experimental chamber.
  • The first part in the brackets determines the light: GPO6 is the red LED light, GPO7 is the green LED, GPO8 is the blue LED.
  • The second part in the brackets determines the strength of the light, i.e. 1 is full strength.
SET(GPO6,0) 
SET(GPO7,0) 
SET(GPO8,0)
  • Setting GPO to 0 turns the light fully off

For a demo on using the overhead lights in the MWP unit see the support page, Lights demo MWP.

Top

Results data

Below is a screenshot of the processed results data, which is downloaded from the Data directory on the unit as a .csv file. In this case the .csv file has been opened using Numbers.

Screen Shot 2019 10 15 At 14 54 32
Showing part of the processed results taken from a demo experiment using this script

In the screenshot above you can see some of the text headings for the results data file. The results for each trial in each arena are also detailed, although only the first 3 trials are evident for the first few arenas.

Top

Script Download

To download the locomotion_data_demo_MWP 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: locomotion_data_demo_MWP.zs