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 unuseful. It also allows measurements of activity for multiple animals per arena without the need for multiple tracking facilities.


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.


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.


Example Zanscript

To use the MSD function the following SET commands should be included in your script


An example script can be found here