ANY-maze Help > The ANY-maze reference > The File page > Exporting experiment data > Exporting an experiment in XML format

Exporting an experiment in XML format

The ability to export an experiment in XML format is a work in progress. At present, it is targeted at saving the tracking data for performed tests; however we will gladly include more data, so if there's something you would like included, just contact us at ANY-maze Support.

Introduction

ANY-maze experiments are saved in a proprietary binary format. This format is optimized for speed of access and file size (some of the data is compressed) which is ideal for ANY-maze itself, but means that it is virtually impossible for any other programs to read the experiment data.

To address this, you can export an experiment in XML format. XML is a standard, text-based format which can be used to record data about virtually anything. Many programs (for example, Excel and Matlab) can read XML files.

 How to export an experiment as an XML file 
 Specifying the XML file name 
 Selecting the data to export 
 Exporting coordinates relative to the centre of the apparatus 
 Choosing the format for animal 'images' 
 Excluding tests performed on retired animals 
 Exporting an XSD (schema) file 
 The XML file contents  

How to export an experiment as an XML file

The option to export an experiment as an XML file is included on the File page. To use it, switch to the file page, select Export > Export experiment as XML. When you do this, the right side of the page will show a field for you to enter the name of the XML file, a list for you to select the data to be included in the XML file, and various options - see figure 1.

  

  

Figure 1. The options available when exporting a file as XML.

Specifying the XML file name

By default, ANY-maze will save the XML file in the same location as the experiment (.szd) file and with the same name - just the file extension will change to .xml.

However, you can alter the folder and/or XML file name simply by clicking the button (on the right of the name field), which will open the standard 'Save file' window.

Selecting the data to export

The export function will always export an experiment and the animals and tests within it, but you can choose what details of each item you would like included. This is quite self-explanatory - just check the boxes next to the data you would like included. Note that the animal number and the test number are always included in the XML file, so they're not listed as options.

Exporting coordinates relative to the centre of the apparatus

By default exported coordinates are relative to the top/left of the video image in which the test was performed, with positive x moving to the right and positive y moving down.

In some situations this coordinate system can be a bit unsatisfactory and you may find that exporting coordinates relative to the centre of the apparatus is a better option. In this case the origin of the coordinate system is the centre of the apparatus map, with positive x moving to the right and positive y moving up (in other words this coordinates system is the same as the Cartesian coordinate system usually used in graphs).

Choosing the format for animal 'images'

In tests where ANY-maze tracks an animal, it will usually save the 'image' of the animal together with every position (this behaviour can be switched off using the option Don't record animal images in the What to record while testing element of the protocol). These 'images' represent the area that ANY-maze considers to be the animal - this is the area that it can shade in blue during a test.

These animal images can be saved as part of the XML file, but doing so will create a dramatically larger file - so you should carefully consider whether you want to include them or not. There are three options:

 Don't save animal images. This is the default option. The animals' position data will be saved in the XML file, but the images will not. 
 Output animal images as Base64 encoded bitmaps. This option encodes the images to help reduce the XML file size, but the resulting data is less easy to process than the 'pixel' option (see below). The exact format of the data is described in the XML file contents section of this document. 
 Output animal images as unencoded pixels. This option creates the largest files, but the image data is most easily processed. Be warned, using this option can create very large XML files.  

Excluding tests performed on retired animals

ANY-maze will normally export all the animals and all the tests in the experiment except for animals which are marked as deleted and tests which are marked as cancelled. If you also wish to exclude animals which are marked as retired then you should choose this option.

Exporting an XSD (schema) file

If you need an XSD (schema) file for the exported XML file, select the option to Output an XSD file.  The XSD file will be saved to the same location as the XML file and will have the same name, just the extension will be different - it will be .xsd rather than .xml.

The XML file contents

We will gladly extend the data included in an exported XML file - just contact ANY-maze Support.

The XML file that is exported by this function does NOT include ALL the data that is held in the ANY-maze experiment file; rather it targets the tracking data of performed tests.

The XML file consists of a hierarchy of elements as follows:

Experiment

Animal

Test

Result

Animal image data

Experiment

The experiment element is the root. It contains the experiment title, creation date, notes, and all the animals.

Animal

There is one animal element for each animal which that has any performed tests (note that animals which have not yet had an tests performed will, of course, be in your experiment file, but they will NOT be exported).

The element contains the number, ID (if you have specified an animal ID field), treatment, notes (if any), and all of the animal's performed tests.

Tests

There is one test element for each test which has been performed on the animal (tests which have not yet been performed are NOT included in the XML file). The test element contains the test number, the date and time the test was performed, the test's stage and trial, the name of the apparatus the test was performed on, the reason the test ended, test notes (if any), the position of all zones, scaling (i.e. the number of pixels per metre) and all of the test's results.

The information about the position of zones deserves a little explanation. First, the position of the zones is defined for each test so as to cope with any movable zones - the position provided will be the position the zone had in the specific test. Second, the position is provided as two values; the coordinates of the centre of the zone and the zone's bounding box. The centre is the zone's centre of mass and is the mean x and mean y coordinate of every pixel that is in the zone. It is important to understand that the centre may not actually be in the zone; for example, a ring-shaped zone would have its centre of mass in the centre of the hole in the middle of the ring. The zone's bounding box is a box which exactly encloses the zone and is specified as the top-left coordinate of the box and its width and height.

Results

Only tracking results are included in the XML file (so, for example, results from I/O devices are not exported). There is one result for each position of the animal. Each result contains the time of the position (in seconds relative the start of the test) and the position of the animal's centre (relative to the top left of the video image). The results may also contain the position of the animal's head and tail (if the tracking system was able to determine them) and details of any zones that the position implies the animal has entered or exited.

While most of the tags used in the XML file are self-explanatory, the result tags are abbreviated to keep file sizes to a minimum. The abbreviated tags are:

 r  = result 
 tm = time 
 c  = position of the animal's centre 
 h  = position of the animal's head 
 t  = position of the animal's tail 
 np = no position 

The 'no position' tag is output when the animal was not tracked in a frame and the option to Record frames in which the animal was not tracked is turned on.

If you choose to output the animal images (see above), then each result will also include animal image data.

Animal image

When selected, each result will include animal image data - this being the area of the video image which ANY-maze considered to be the animal. The image data consists of two parts: The first part defines a rectangular area by providing values for x, y, w and h; where x, y are the location of the top left of the rectangle in the video image (relative to the top left corner) and w and h are the rectangle's width and height respectively. (Note that the area will always have a width that is a multiple of 8).

The second part defines the contents of the rectangular area as a series of pixels - a pixel that is on is deemed to be part of the animal, a pixel that is off is not part of the animal. There are two ways in which the pixels can be defined:

The first method defines the rows of the rectangular area with each row consisting of a text string. A '0' in the string represents an off pixel and a '1' represents an on pixel; there are as many 0s and 1s as the width of the area.

For example:

  

  

   107

   336

   16

   6  

   0000000111100000

   0000011111111000

   0000001111110000

   0000000111100000

   0000000011000000

   0000000011000000

  

Note how the area is defined as having a width of 16, so each row has 16 0s or 1s in it, and a height of 6, so there are 6 rows.

The second method encodes the image data in Base64. In this case all the row data is viewed as continuous (the w value can be used to determine the row length) and the 0 and 1 values are encoded as bits in a series of bytes. The resulting series of bytes is then encoded in Base64.

Using the data from the above example, we would therefore get something like this:

  

  

The first row is 0000000111100000 which can be viewed as two bytes:

   00000001 = 0x01,  11100000 = 0xE0

  

Processing the other rows in the same way gives :

   00000111 = 0x07,  11111000 = 0xF8

   00000011 = 0x03,  11110000 = 0xF0

   00000001 = 0x01,  11100000 = 0xE0

   00000000 = 0x00,  11000000 = 0xC0

   00000000 = 0x00,  11000000 = 0xC0

  

So the complete bytes series is:

   0x01,0xE0,0x07,0xF8,0x03,0xF0,0x01,0xE0,0x00,0xC0,0x00,0xC0

  

Which encoded in Base64 is:

   AeAH+APwAeAAwADA

  

So in this case the resulting XML would be:

  

  

   107

   336

   16

   6  

   AeAH+APwAeAAwADA

  

As can be seen, this is much more compact than the pixel format (it's about 20% of the size), but the data will need to be decoded before it can be processed.

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0068