Measuring pixel difference


Here we will describe a function for measuring the activity of animals using the MSD function (Mean Square Difference). This function is particularly useful for long thin animals which make tracking using the centre point unhelpful. It also allows measurements of activity for multiple animals per arena without the need for multiple tracking facilities. It may also be used to measure the difference between an animal that is totally still, and an animal that is moving a little but not going anywhere (e.g. grooming, turning on the spot, sleep). 

Please be aware that the lighting in the MWP is a little dimmer towards the edge of the image, and so values of MSD may not be directly comparable across a plate (e.g. centre wells maybe have higher values than edge wells) but measures over time within each well should be consistent, and judicious setting of the threshold value (see below) should distinguish reliably between activity and no activity. 

Top

How it works

The units output image data at 30 frames per second. MSD works by subtracting one frame from the next, leaving a frame of the pixel difference between the two images. This pixel difference could be positive or negative. Squaring the difference generates just positive results. The data is then reported as the mean value per pixel for each arena. It is then summed over the interval over which it is reported.

Top

Setting the threshold value

In an empty arena, with constant lighting and a perfect camera, the MSD readout should always be 0. However, 'video noise' generates a signal in an arena which has no moving animals. To combat this noise in the data, a threshold should be set, which takes effect before squaring the pixel difference between two images. For example, if the MSD threshold has been set to 5, any pixel difference below 5 is eliminated (i.e. not reported as a signal).

Below is data for the water flea (Daphnia spp.) and blood worms (Glycera spp.) demonstrating the effects of both increasing the threshold value and increasing the number of animals per arena on MSD data output.

Increasing the number of animals in an arena increases the size of the signal producing a higher MSD output reading.

At a threshold of 0 there is some signal reported in arenas which have no animals present. This represents the video noise. At threshold 19 all signal has been eliminated even when there are animals present. The ideal threshold is one which reports no signal when there are no animals present but is robust and sensitive enough to pick up signal when animals are present.

24-well plate with either 0, 1, 3 or 9 individuals of Daphnia spp. per arena

Daphnia Msd Plot
MSD activity output for Daphnia spp. at increasing threshold values

24-well plate with either 0, 1, 3 or 6 individuals of Chironimid larvae per arena

Chironimid Msd Plot
MSD activity output for Chironimid larvae at increasing threshold values

An MSD threshold of 5-6 is usually adequate for eliminating video noise whilst still accurately reporting the activity of organisms, but it should be verified for your animals in your situation. 

Top

Script download

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


Assets

You will need to upload the appropriate asset into the Asset directory on your Zantiks Control Console and ensure the correct asset name is in the LOAD(DETECTORS,"name_of_asset") command in the script.

See the Calibrating your Zantiks unit page and Asset building in the MWP unit page for details on how to create assets customised to your system.