An imaging system for standardized quantitative analysis of C. elegans behavior

Background The nematode Caenorhabditis elegans is widely used for the genetic analysis of neuronal cell biology, development, and behavior. Because traditional methods for evaluating behavioral phenotypes are qualitative and imprecise, there is a need for tools that allow quantitation and standardization of C. elegans behavioral assays. Results Here we describe a tracking and imaging system for the automated analysis of C. elegans morphology and behavior. Using this system, it is possible to record the behavior of individual nematodes over long time periods and quantify 144 specific phenotypic parameters. Conclusions These tools for phenotypic analysis will provide reliable, comprehensive scoring of a wide range of behavioral abnormalities, and will make it possible to standardize assays such that behavioral data from different labs can readily be compared. In addition, this system will facilitate high-throughput collection of phenotypic data that can ultimately be used to generate a comprehensive database of C. elegans phenotypic information. Availability The hardware configuration and software for the system are available from wschafer@ucsd.edu.

. Left panel shows a wild type (N2) animal represented by its skeleton, a skeleton point set of 30 skeleton points, its skewer fitting, and its centroid in the Tracker field. Right panel is the detailed view of first four skeleton points (P 0 -P 3 ) in this skeleton point set.

Abstract representations:
Centroid: The centroid (shown as the red circle in the left panel of Figure 1) is the point whose coordinates represent the mean value of the coordinates of all points (pixels) representing 'worm' (as opposed to 'background') in a binary worm image. Skeleton: A skeleton or 'skt' (shown as the solid curve in the left panel of Figure 1) is the curve resulting from mathematically thinning the binary image of the worm.
Sktp: The skeleton is segmented with a user-defined number of equally spaced dots with each dot defined as a skeleton point or 'sktp'. By our notation, the group of dots for a worm is a skeleton point set or 'sktp set'. The sktps in a sktp set are ordered with the sktp representing the head of the animal designated as P 0 and is marked by a cross ( Figure  1). Sktp P i is the i th sktp after P 0 along the animal's skeleton. We designate the vector from P i to P i+1 as skeleton point vector[i] (sktp vector). Further, the angle from sktp vector[i] to sktp vector [i+1] is designated as sktp vector angle[i] (Right panel Figure 1). Skewer Fit: A 'skewer fit' (the dashed line in the left panel of Figure 1) is the line that passes through the centroid and is parallel to a line linking the head and tail sktps. Note: For length and distance measurements we use 'pixels' as our basic measurement unit where we consider a pixel to be the width or height of an individual square pixel in a worm image. The user must provide the appropriate scaling factors (based on their system's optics and image handling hardware/software) to convert pixels to an appropriate physical measurement like millimeters.

Basic morphological features
Area = Number of pixels representing the animal in a binary image Length = Length (in pixels) of the skeleton curve. (Note: 'Length' must not be confused with the number of square pixels needed to represent a contiguous curve in a real image, a number which will always be greater than or equal to the curve 'length.') Thickness = Width (in pixels) of the worm at its midpoint. Measured as the length of the shortest line across a worm passing through the midpoint of the worm skeleton. (This line will typically be perpendicular to the worm skeleton at the skeleton midpoint.) Transparency = Mean gray value of the animal in a grey-scale image after intensity calibration Fatness = Area / Length LengthToPixel = Length / number of pixels in a skeleton (see note above regarding pixels) Loop = Percentage of time worms curls or 'loops.' Our automatic system distinguishes three types of loops: Type 1: Worm head or tail sktp contacts another part of its body. (Consider the shape of a lowercase Greek letter 'delta.') Type 2: Worm skeleton curve crosses itself. (Consider the shape of a lowercase Greek letter 'gamma.') Type 3: Worm skelton forms a closed curve or spiral without crossing itself 2. Morphology based on binary image analysis The following features are quantified using widely accepted image quantitative analysis algorithms provided in National Instruments' IMAQ Vision software (1999 edition).
The titles of the features as referenced in our system and the corresponding National Instruments IMAQ features are listed below. The details of these morphological features are fully described in National Instruments' IMAQ Vision documentation.  SktvDisMaxToLength = Maximum distance between adjacent skeleton points / skeleton length SktvDisMinToLength = Minimum distance between adjacent skeleton points / skeleton length SktvAglMax = Maximum sktVector Angle in a sktp set.

Body posture
Our automatic system mathematically rotates and offsets the matrices of skeleton point set coordinates to measure aspects of body posture.
1. Body posture (Part I) We rotate and offset the worm's skeleton point set to align the skewer fit to the x-axis with the centroid at the origin (X = 0, Y = 0) and with P 0 (the sktp representing the worm's head) as the smaller x-value. In this orientation we determine the size of the best-fit rectangle for the skeleton point set with sides parallel to the X and Y axes. The rotated sktp set helps in automatically identifying omega turns, since the sktp set of an animal in an omega turn has a smaller SktElgFactor value and larger SktHight and SktAglAve values. (See below for detail algorithms of these features.) The features obtained from rotated sktp analysis may also be useful to quantify other morphological identifications.
Here we also introduce an additional measure, sktAgl, the angle between the skewer fit line and a line between a skeleton point and centroid (Figure 4) which we see as a means of quantifying an aspect of a worm's range of motion. With a worm's skeleton point set rotated and offset, sktAgl is the angular position of a skeleton point in polar coordinates. SktAglAve is the mean value of sktAgls in a sktp set.  II) A sktp set can also be rotated and offset so that the skewer fit is parallel to x-axis, the average of x, y maximum and minimum is the origin, and the sktp representing head of the worm on the left of y axis.
We also rotate and offset the worm's skeleton point set to align the skewer fit to the xaxis, but with the mean of the worm's rotated x-and y-maximum and minimum as the origin, again with P 0 (the sktp representing the worm's head) as the smaller x-value. For an animal moving with a sinusoidal waveform, the sktp set representing this waveform should be symmetric in three ways on the rotated tracker field. First, the sum of x coordinates is zero, i.e. x-axis symmetric. Second, the sum of y coordinates is zero, i.e. y-axis symmetric. Finally, XYSYM (see below) is zero, i.e. it is symmetric against origin (left panel).
To calculate track wavelength, our system treats the coordinates of a rotated skeleton point set as a sinusoidal "signal." We perform a standard Fast Fourier Transform (using Matlab-provided algorithms) on the sinusoidal "signal," calculating in the spatial domain (as opposed to the time domain) which yields component frequencies in "cycles [or waves] per pixel" (that is, working in the spatial domain). Selecting the lowest non-zero frequency as the 'characteristic' frequency, we find the inverse to be the worm's wavelength in "pixels per wave" which is converted into convenient physical units (for example millimeters/wave) with the appropriate user-provided scaling factor. -600 x Figure 7 shows the sktp sets, centroids and skewer fits for an N2 animal at two times spaced 0.5 second apart while performing a reversal. (Time τ is in red, time τ + 0.5 second is in blue.) When the angle between an animal's skewer fits for consecutive times is smaller than 10º, our system identifies a movement reversal provided the following conditions are satisfied after superimposing two sktp sets: 1) between time _ and _ + 1, the head skeleton point moves toward where the tail skeleton point was at time _ 2) between time _ and _ + 1, the tail skeleton point moves away from where the head skeleton point was at time _ 3) the average distances moved by the head and tail during the time interval is larger than 2.5% of body length. Reversal = Percentage of time that a worm performs a reversal (rearward movement) reversalCount = Number of reversal sessions (periods of rearward movement) that a worm performs during a recording session reversalDisAve = Mean distance the centroid travels during a reversal session Figure 8 shows the sktp sets, centroids and skewer fits of an N2 animal at two consecutive time points τ (red) and τ + 1 (blue). Left panel shows the animal performing foraging behavior; right panel shows an animal demonstrating sharp turn behavior. When the angle between the skewer fits at times _ and _ + 1 is smaller than 15º, our system identifies foraging behavior provided: 1) the average distance traveled by last 20 skeleton points is less than 2 % of the body length, and 2) the average distance traveled by first 4 skeleton points is larger than 4 times of the average distance traveled by the last 20 skeleton points. If the angle between the skewer fitting of time _ and that of time _ + 1 is larger than 15º, a sharp turn is counted. foraging = percentage of time that a worm performs foraging behavior (as described above) turn = percentage of time that a worm exhibits sharp turn behavior foraging angle = the angle between skewer fits at all consecutive times _ and _ + 1 when foraging behavior is identified at time _ + 1 foraging distance = distance moved by skeleton point P 0 the head skeleton point) between time _ and _ + 1 when a foraging behavior is  Figure 10 shows two consecutive skeleton points sets for an N2 animal at time τ (in red) and τ + 1 (in blue). Each skeleton point vector, V i , for example V 0 (shown in left panel), or V 6 (right panel) pivots when the animal navigates.

Reversal Movement
The angle between adjacent sktp vectors V i and V i+1 , located at skeletonBend[i], is designated as its sktpVectorAngle. Each sktpVectorAngle varies with time as the animal moves. Our system uses the varying sktpVectorAngle to calculate 'flex' and bending frequency ('fre') for each skeletonBend.
We calculate 'flex' as the maximum sktpVectorAngle difference (that is, most positive angle minus most negative angle) demonstrated during a time interval, for each skeletonBend.
Likewise, our to extract the bending frequency at each skeletonBend of an animal we apply the specgram function provided in The MathWorks' Matlab (R13) Signal Processing toolbox software (http://www.mathworks.com/access/helpdesk/help/toolbox/signal/specgram.html) to compute the discrete-time Fourier transform of the time-varying sktpVectorAngle "signal" with a sliding (32 frame wide) time window. The specgram function yields a representation of the magnitude and phase of the component frequencies of the sktpVectorAngle "signal" for every 32 frame time window. Our system identifies the bending frequency at each skeletonBend (for each time window) as the component frequency with the highest magnitude.

Additional morphological and behavioral analysis
Our system further evaluates the attributes 'Area' (area of the worm shown in a binary image) and 'GlbSpeed' (centroid speed) by binning the range of values for each attribute, done in the same manner as when creating a histogram. For these evaluations our system uses 12 evenly spaced bins, representing 12 evenly spaced ranges of area or centroid speed.