Heat maps


This tutorial demonstrates how to use the Zanscript language to create visualised heat maps along with any processed data file. Heat maps can be used to get a visual representation of how much time an animal spends in the different areas of the experimental environment.

The heat map .bmp files are saved to the Media directory on the Homepage of the Control Console.

Heatmap 20230206 T120151
Adult zebrafish activity in a plus maze with Zantiks colourmap.
Top

Commands to create a Heat Map


There are 3 DEFINE directives which need to be included in your script in order for the heat map to work. These are developmental settings and they should be placed at the top of your script prior to the ACTION MAIN.

DEFINE MAKEMAP 5682 
DEFINE COLOURMAP 5683 
DEFINE SUMSIZE 20 

DEFINE MAKEMAP 5682: setting to allow for generating heatmap

DEFINE COLOURMAP 5683: setting to allow for selecting which colourmap to use. The colourmap will be activated and selected later in the script via the SET(COLOURMAP,#) command.

DEFINE SUMSIZE 20: sets radius of the area to sum. It is measured in pixels.


SETCOLOUR(15,0.5,0.5,0.8) 
SET(COLOURMAP,0) 
SET(MAKEMAP,SUMSIZE)

SETCOLOUR(15,0.5,0.5,0.8): sets colour of area outside heat map arenas. 15 indicates the area to be coloured. The following three numbers are the percentage of Red, Green, and Blue to mix.

SET(COLOURMAP,0): This command sets the colour palette to colour in the heat map.

  • 0 = Zantiks
zantiks_heatmap.png#asset:5462
  • 1 = Berkeley Inferno

INFERNO.bmp#asset:4464

  • 2 = Berkeley Plasma

PLASMA.bmp#asset:4463


SET(MAKEMAP,SUMSIZE): This is the final command to generate the heatmap. This command needs to be written into the script following the final time bin that is to be included. For example, if the heatmap needs to show the entire experimental session, it will be written after all the ACTIONs are invoked.

Top

Full example script

DEFINE MAKEMAP 5682 
DEFINE COLOURMAP 5683 
DEFINE SUMSIZE 20 
 
DEFINE NUM_SAMPLES 20 
DEFINE TIME_BIN 1
 
SET(TARGET_SIZE,2) 
SET(DETECTOR_THRESHOLD,6) 
 
SET(AUTOREF_MODE,MOVEMENT) 
SET(AUTOREF_TIMEOUT,10)
 
LOAD(ARENAS,"a24.bmp")
 
 
ACTION MAIN
 
 SET(COLOURMAP,0) 
 LOGCREATE("TEXT:RUNTIME|TEXT:UNIT")
 LOGAPPEND("TEXT:VARIABLE|TEXT:A1|TEXT:A2")
 LOGAPPEND("TEXT:A3|TEXT:A4|TEXT:A5|TEXT:A6") 
 LOGAPPEND("TEXT:A7|TEXT:A8|TEXT:A9|TEXT:A10") 
 LOGAPPEND("TEXT:A11|TEXT:A12|TEXT:A13|TEXT:A14")
 LOGAPPEND("TEXT:A15|TEXT:A16|TEXT:A17|TEXT:A18") 
 LOGAPPEND("TEXT:A19|TEXT:A20|TEXT:A21|TEXT:A22") 
 LOGAPPEND("TEXT:A23|TEXT:A24") 
 LOGRUN() 
 
 AUTOREFERENCE() 
 INVOKE(SAMPLE,NUM_SAMPLES) 
 SET(MAKEMAP,SUMSIZE)
 
COMPLETE
 
 
ACTION SAMPLE 
 
 LOGDATA(DATA_SNAPSHOT,"begin") 
 WAIT(TIME_BIN) 
 LOGDATA(DATA_SNAPSHOT,"end") 
 LOGDATA(DATA_SELECT,"begin") 
 LOGDATA(DATA_DELTA,"end") 
 
 LOGCREATE("RUNTIME|APPARATUS_ID") 
 LOGAPPEND("TEXT:TOTAL_DISTANCE|ARENA_DISTANCES*") 
 LOGRUN
 
COMPLETE
Top

Script download

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