The zebrafish Danio rerio is a widely used model organism in studies of genetics, developmental biology, and recently, biomechanics. In order to quantify changes in swimming during all stages of development, we have developed a visual tracking system that estimates the posture of fish. Our current approach assumes planar motion of the fish, given image sequences taken from a top view. An accurate geometric fish model is automatically designed and fit to the images at each time frame. Our approach works across a range of fish shapes and sizes and is therefore well suited for studying the ontogeny of fish swimming, while also being robust to common environmental occlusions. Our current analysis focuses on measuring the influence of vertebra development on the swimming capabilities of zebrafish. We examine wild-type zebrafish and mutants with stiff vertebrae (stocksteif) and quantify their body kinematics as a function of their development from larvae to adult (mutants made available by the Hubrecht laboratory, The Netherlands). By tracking the fish, we are able to measure the curvature and net acceleration along the body that result from the fish's body wave. Here, we demonstrate the capabilities of the tracking system for the escape response of wild-type zebrafish and stocksteif mutant zebrafish. The response was filmed with a digital high-speed camera at 1500 frames s–1. Our approach enables biomechanists and ethologists to process much larger datasets than possible at present. Our automated tracking scheme can therefore accelerate insight in the swimming behavior of many species of (developing) fish.
Capturing the detailed locomotory kinematics and behavior of biological organisms plays an important role in a wide variety of research disciplines (Fry et al., 2003; Gray, 1933; Park et al., 2001; Pfau et al., 2005). Many studies in biomechanics, neuroethology and developmental biology rely on the analysis of video sequences. Such analyses stand to benefit greatly from computer vision techniques, which can accurately and efficiently screen complex morphometric and locomotory characteristics.
Following the pioneering work of Eadweard Muybridge (Muybridge, 1887), scientists have developed a wide range of methods to record and quantify animal locomotion. Many studies have relied on tracking landmarks, such as leg joints (Full and Tu, 1991) or markers on the animal's body (Hedrick et al., 2004; Standen and Lauder, 2005). However, it is not always feasible or advisable to attach markers, e.g. during field observations or on animals that have a mucous layer (e.g. many fish) or motile skin (e.g. horses). In these cases, tracking the silhouette of the animal or a body part can offer an alternative [e.g. silhouettes of ascidian larvae and swimming fish (McHenry, 2001; Tytell and Lauder, 2002)].
Tracking swimming movements by filming the swimmer's silhouette has a long tradition (Batty, 1984; Gray, 1933). Silhouettes lend themselves to automatic tracking (Tytell and Lauder, 2002). Furthermore, tracking routines can be refined by using information about the shape of the animal or limb to be tracked [e.g. insect wings (Fry et al., 2003; Willmott and Ellington, 1997)]. Error reduction as a result of including shape information is particularly valuable when studying the propulsive body wave of fishes. The exact shape of a fish's body wave depends on the interaction between the solid body of the fish and the surrounding water. Exact knowledge of the wave shape can provide valuable insight into swimming performance and the interaction between undulating body and surrounding water (Cheng and Pedley, 1998; McHenry et al., 1995; Wainwright, 1983). For example, the stiffness of the fish's body affects the shape of the body wave and thereby influences the propulsive performance of the fish. An interesting case study is presented by the stocksteif mutation in zebrafish, which is characterized by an overossification of the notochord. The axial skeleton of these mutants is a stiff, bony rod, contrasting the flexible series of articulating vertebrae in their wild-type siblings.
The zebrafish has long served as a convenient model to study the various aspects of fish swimming (Fuiman and Webb, 1988; Thorsen et al., 2004). Automated tracking and analysis systems have been previously developed for zebrafish (Bang et al., 2002; Blaser and Gerlai, 2006). However, these systems track the fish only as a point and cannot quantify body wave kinematics of swimming. Other studies of zebrafish swimming have manually tracked the fish to quantify the body posture, a method that is both time-consuming and potentially prone to subjective errors (Budick and O'Malley, 2000; McElligott and O'Malley, 2005; Müller and van Leeuwen, 2004). Tytell and Lauder used a semi-automated method to estimate the fish midline by manually indentifying the snout and tail and automatically estimating the midline from the extracted silhouette (Tytell and Lauder, 2002). Other authors have relied on `skeletonizing' algorithms that dissolve a binary image representing the animal's silhouette down to its midline (Cronin et al., 2005; Geng et al., 2004; McHenry, 2001). Although this approach is automated, it will not estimate the correct midline if other objects are present in the binary image because it cannot distinguish between pixels that belong to the animal's silhouette and those that belong to a different object. As a result, these algorithms will not correctly estimate the fish's body posture when there is environmental clutter such as other fish, plants, or a hair used to initiate behavioral responses, as we did in our recordings. Automated kinematic analysis of multiple zebrafish larvae was recently demonstrated. However, this particluar analysis technique utilizes an image filter that is customized for the appearance of zebrafish larvae of a specific age (Burgess and Granato, 2007). This technique does not extend nicely to zebrafish of different ages, other fish species, or when environmental clutter is present.
Here, we present a complete method for accurately and efficiently quantifying the body posture of zebrafish and other organisms with symmetric medial profiles. Our approach directly models the shape of the animal and utilizes locations of high contrast in the image to estimate its posture. The posture estimate is calculated using techniques that remain robust to clutter. The detailed swimming motion is estimated based on dorsal images of the fish recorded at sufficiently high frame rate (Harper and Blake, 1989), which enables a quantitative evaluation of the animal's kinematics and dynamics (provided the mass distribution of the animal is known). In the first section, we review the overall approach for performing model-based visual tracking. Subsequently, we develop a detailed geometric model for the zebrafish, including appropriate motion and measurement models that use information from the previous and current frame to estimate the fish's current position and posture. Finally, we demonstrate the capabilities of our tracking approach on zebrafish performing an escape response at three stages during their development (from larvae to juvenile).
MATERIALS AND METHODS
Zebrafish (Danio rerio Hamilton 1822) eggs were collected after mating one stocksteif heterozygous female with one stocksteif heterozygous male. The batch of eggs contained both stocksteif mutant and wild-type embryos, but the mutant phenotype does not become apparent until 5 days post fertilization (d.p.f.). The embryos were reared at the optimal rearing temperature of 28°C. After hatching, the embryos were fed Paramecium (5 and 6 d.p.f.) and Artemia (from day 7 onwards). A fast startle response was recorded at 5, 15 and 28 d.p.f. for both wild-type and stocksteif mutant animals using a high-speed video camera (Photron, APX RS, 1500 frames s–1, 1024×1024 pixels, exposure time 1/8000 s) fitted with a 105 mm Nikon lens. The startle responses were elicited by touching the animals with a horse hair. We analyzed recorded sequences from the initiation of the escape response to the moment when the fish either leaves the field of view or ceases active swimming. Our sequences therefore include stages 1 and 2 of an escape response, and usually several tail beats that are part of stage 3 (Weihs, 1973) (Movie 1 in supplementary material).
Model-based image tracking and nonlinear estimation
Our goal was to quantify the body wave and swimming kinematics of a zebrafish from video sequences recorded from a top view. First, we built a geometric model of the zebrafish that is defined by the vector p, which contains the parameters that encode the body wave shape and location of the model. Then, tracking is performed by recursively estimating the fish parameters pk from measurements in the image, zk at time step k. This tracking approach is formulated within a discrete time (k), dynamic state space, framework as: (1) where f is the motion model, h is the measurement model andζ k and νk are independent and identically distributed noise processes (models of the noise present in our image sequence). From a Bayesian perspective, this corresponds to estimating the probability density function P of the fish parameters given all of the image measurements up to the current time step (i.e. the posterior) via Bayes' rule: (2) The optimal estimate of the fish's shape and position will then correspond to the conditional mean of this probability density function, p̂k=E[pk|zk]=∫ pkP(pk|z1:k)dpk. In general, this recursive solution to the tracking problem is intractable and approximate solutions must be used instead. These approximation methods can primarily be broken into two categories: those that assume the probability density functions are normal distributions [e.g. Kalman Filters (van der Merwe and Wan, 2003)] and those that allow the probability density functions to assume arbitrary distributions [e.g. particle filters (Doucet et al., 2001)]. Although particle filters are able to solve very general estimation problems, there are many problems within visual tracking when the normal assumption holds, in which case Kalman filters provide accurate solutions and computational efficiency. The present study demonstrates that the normal assumption holds for estimating the location of zebrafish from top view images within a constrained laboratory that contains few environmental occlusions, hence we adopt Kalman filtering.
Recently, the Kalman filter has been considerably improved by statistical linearization and now performs well when applied to nonlinear motion and measurement models (Ito and Xiong, 2000; van der Merwe and Wan, 2003; Nörgaard et al., 2000; Sibley et al., 2006). These Sigma Point Kalman Filters (SPKF) recursively estimate the optimal fish parameters and their uncertainty by taking the weighted average of a set of regression points drawn from the probability density function that describes the fish's shape and location at the previous time step. In this study, we leverage the power of SPKFs to solve our nonlinear estimation problem. However, in order to estimate the fish parameters, we must also develop equations for the motion model f and the measurement model h that make sense for a swimming zebrafish during development. In the following sections we apply a two-step approach. First we construct a flexible geometric model of a zebrafish outline. Second, we develop appropriate motion and measurement equations for this model, which are used in conjunction with the SPKF to automatically optimize the fish parameters based on the processed image data.
The motion of zebrafish in the shallow water of a tank is largely planar, so we model the fish motion as restricted to two dimensions and assume orthographic projection in the camera model. We also assume that the zebrafish maintains a constant length and width profile during swimming. Therefore, we model the centerline of the fish as a planar, inextensible curve, which can only undergo bending. The body shape can therefore be described effectively by the bend angle of the fish as a function of distance along its length, u. This function, (u), is finitely parameterized using a linear combination of known basis functions where , is the jth basis function of order k. The current implementation uses eight (N=8) periodic cubic B-splines as the basis functions, which we found to be sufficient to capture the different bending modes of the swimming zebrafish and mating Caenorhabditis elegans (Fontaine et al., 2006). Other choices in the order and number of basis functions are possible. However, determining the minimum set of basis functions needed to describe all possible fish configurations is beyond the scope of this study. To increase the tracker's robustness and accuracy, our model assumes that fish have a stiff head. This assumption prevented the tracker from creating unrealistic bending deformations in the head region. This simplification is based on our experimental results (Müller and van Leeuwen, 2004), which show that the head region of freely swimming zebrafish undergoes negligible bending (zero local curvature). This corresponds to (u) remaining constant in the head region, which we define as starting at the snout and extending to 20% of the fish's body length (length from snout to tail tip or caudal penduncle in the case of juvenile fish, see Fig. 5); in other words, the relative length of the stiff head region compared with the total length of the fish L is γ=0.2. We keptγ fixed for our experiments and found that γ=0.2 provided good tracking results in all three considered age groups. We implemented the head region mathematically by defining the origin of u (where u is zero) at a distance of 0.2 L behind the snout, such that the head region is described by positive u values (0≤u<0.2L) and the tail region by negative u values (–0.8L<u≤0). This approach simplifies the formulation of the basis functions (u) and the corresponding local bend amplitudes αj along the fish's body: (3) Fig. 1B illustrates these concepts, i.e. the definition of u as well as how the B-spline basis functions describe the body wave. The spline bases have local maxima in the tail region, but become constant in the head region.
Our complete fish model is a symmetric planar mesh with grid parameters u and v, which define a local coordinate frame in the fish body in the length and width directions, respectively. The points in this mesh [x(u,v) y(u,v)]T are continuous functions of u and v, so we can evaluate them at whatever discrete grid we choose. For our experiments, we sample 30 uniformly spaced points in the domain [–(1–γ)L,γ L] for u and three uniformly spaced points in the domain [–1, 1] for v. Because the number of sampled points in the (u,v) grid remains constant during tracking, the mesh points that make up our fish model become functions of the position and shape parameters, p. We construct the centerline of our symmetric mesh by integrating the unit tangent vector along the grid parameter u, and the width is created by expanding the centerline in the direction of the normal vector according to the value of R(u), which is the fish's width as a function of distance along its length. R(u) is defined as a fourth-order periodic B-spline function using 20 basis functions, and its value is calculated from the first frame of the video recording (see `Initial detection of zebrafish') and held fixed during tracking. This process is illustrated by Fig. 2 and further details are provided in the Appendix. We denote the complete fish model as H(p) where are the fish parameters, which include the bend angle amplitudes defined earlier and , the global translation vector of the entire fish.
Creating deformable models based on medial profiles has been used in segmentation problems in medical imaging (Hamarneh and McInerney, 2001) and for tracking multiple C. elegans from microscopy images (Fontaine et al., 2006; Roussel et al., 2007). Because zebrafish are laterally symmetric about their body axis, our medial profile representation offers several advantages for the tracking framework. Each B-spline basis function is defined only over a subregion of the fish body. Therefore, the local bend amplitudes, αj, have local control over the degree of bending in the body. This property is analogous to the fish anatomy, where contractions of individual muscles affect the bending over subregions of the fish's body. In summary, our parameterization of the centerline has few degrees of freedom, requires no training data, and offers a natural and anatomically sound way to constrain the fish's length and designate certain regions as stiff.
The motion model of the fish predicts the fish parameters at the current time step based on the parameters calculated at the previous time step. By predicting the motion, it provides a better initial estimate of the fish parameters before they are updated using the measurement model. We assume that the fish movement is a combination of undulatory motion along its body and a displacement of the whole body along the centerline axis. The undulatory motion of steady swimming in fish consists of a traveling wave of increasing amplitude from head to tail. Given our model of the zebrafish, this motion is governed by the change in local bend amplitudes, αj, from the previous time step to the current one. Given that our video sequences are filmed at a sufficiently high frame rate, we make the assumption that the current local bend amplitudes are equal to the previous ones plus a random variable drawn from a zero mean normal distribution. This is a simple way to allow in the model that we are more uncertain about the body wave shape of the fish since it has moved between frames. We further assume that the fish has constant velocity, η1, between frames during displacement along its body axis that is corrupted by acceleration noise, η2. This velocity is also estimated and thus incorporated into the set of fish parameters . The complete motion model calculates the current fish parameters after the fish has undergone a total axial displacement ofη 0=η1Δt+η2(Δt2/2) from the previous frame, where Δt is the time step between subsequent frames (inverse of the camera frame rate) and η2 is modeled as a zero mean random variable drawn from a normal distribution with fixed variance. An overview of the motion model is shown in Fig. 3 with displacements exaggerated for illustration purposes.
The present tracker system assumes that we are able to measure the location of the fish boundary, so our measurement model consists of the boundary points, qi=[xiyi]T, along with their outward normal vectors, along the fish's outline. In order to fit our geometric model to the image at each frame, we must take the appropriate image measurements and match them with corresponding locations in the model. To achieve this, we first segment the image using background subtraction, which produces a binary image that is used to search for edges. Next, we apply a one-dimensional edge-detector filter in the direction normal to the boundary at each of the boundary points in the fish model (Blake and Isard, 1998). The distance between qi and the corresponding detected edge point, ri, is projected onto ni so that the error minimized by the SPKF is the normal displacement between the edge points and model points. This process is illustrated in Fig. 4 where the initial estimate, edge points, and final solution are overlaid on an actual image. By using the SPKF, we minimize this error to obtain an updated estimate of our fish parameters p̂k (see Appendix for details). At age 28 days, the zebrafish has fully developed pectoral and caudal fins. These fins can cause incorrect tracking because the lighting conditions can make them appear as solid as the fish's body. However, by modifying the fish model to not take edge measurements in the pectoral and caudal regions, we are able to accurately estimate the body posture of the juvenile fish (Fig. 5).
Initial detection of zebrafish
Any tracking algorithm relies on an initial estimate of the object location. To achieve this, we have developed a semi-automated initialization routine that operates on the first movie frame and extracts three important pieces of information for tracking: (1) an estimate of the background image, (2) the initial fish parameters p0, and (3) the width function R(u). The background model is estimated by selecting a region around the fish and erasing it using the built-in Matlab™ function `roifill', which smoothly interpolates inward from the pixel values on the boundary of the user-defined region. Next, the background image is used to segment the first movie frame, and the Matlab™ function `bwboundaries' calculates the fish boundary from the resulting binary image. The user is then requested to click on the snout and tail locations of the fish, which allows us to divide the boundary into the left and right discrete boundaries of the fish denoted BL(i) and BR(i), respectively.
The initial centerline of the fish will be the curve that is equidistant from the left and right boundaries. To determine this centerline, we use a modification of the integral area distance used in (Roussel et al., 2007) which iterates and converges to the fish centerline. Our method works by first finding the closest point in BL to each point in BR and vice versa. Then, we calculate the median locations between each set of corresponding points in BL and BR. These median locations are assigned as the new left and right boundaries and this process is repeated until the boundaries converge onto the true discrete centerline C(i) (see Appendix for more details). The estimated centerline curve C(u) is determined by fitting a B-spline through the points calculated from C(i), and is illustrated in Fig. 6A along with the original left and right boundaries it was derived from. The bend angle function (u) is calculated from C(u), and initial bending amplitudes are calculated by projecting the bend angle function onto the basis functions from Eqn 3 and illustrated in Fig. 1B. Once the centerline of the fish has been calculated, we can estimate its optimal radius function R(u) by minimizing the normal displacement between the extracted image boundary BL,R and the model boundary dictated by the radius function in the manner described in Fig. 2. The result of this minimization is shown in Fig. 6B and demonstrates that we are able to reconstruct accurately the width profile of the fish.
In this section we present automated tracking results for wild-type and stocksteif mutant zebrafish at 5, 15 and 28 d.p.f. Fig. 7 shows the raw centerlines of the zebrafish estimated by the tracker at fixed time intervals and demonstrates the quality of the proposed method. Our method successfully tracks fast escape responses of fish larvae (Fig. 7A,D) despite occasional partial occlusions [in this case, the hair used to induce the escape response (Fig. 7E)]. Furthermore, tracking takes an average computation time of 5.5±1.7 s frame–1 on a 3.0 GHz Intel® Xeon processor, which enables us to analyze large datasets very quickly. To calculate an upper bound on the accuracy of our tracking approach, we created a synthetic movie sequence by rendering our model along a known trajectory. We then tracked this synthetic sequence and measured the average error between the known and estimated centerlines over time (Fig. 8). We were able to localize the synthetic data within 0.5% of the body length on average; our errors in estimating the real movie sequences will be slightly larger because they contain additional noise sources not present in the synthetic one.
From these centerlines, we wish to extract important kinematic parameters to gain insight into developmental influences on the propulsion mechanisms of swimming fish, and vice versa: the mechanical influences on the development of the fish. One of these parameters is body axis curvature, which provides information about the muscle strains the fish undergoes. To measure curvature, we apply spatial smoothing to the extracted centerlines and then apply temporal smoothing directly to the curvature values. Spatial smoothing is performed by fitting a cubic B-spline curve to the extracted centerlines, and the curvature is calculated directly from these smoothed curves (see Appendix for details). We calculate curvature from these smoothed centerlines instead of deriving it from the raw centerline of our geometric model because the model contains a discontinuity in the curvature at the location where it becomes stiff.
Temporal smoothing is performed by applying a low-pass filter to the curvature values across time at fixed locations along the fish's body (we use 51 uniformly spaced points). The cut-off frequency for the filter is chosen based on visual inspection of the magnitude response of the curvature's Fourier transform at each of the body locations. Fig. 9 plots the error between the filtered and unfiltered centerlines and curvature values for both wild-type and stocksteif zebrafish. With average errors around 0.1% of body length and 0.1 for the centerline and curvature, respectively, our filtering process retains all-important information and does not compromise the accuracy achieved by the tracker. The resulting curvature profiles after filtering are shown in Fig. 10. Comparing stocksteif with wild type at age 15 and 28 days (Fig. 10B,E, Fig. 10C,F) we find that the peak curvature values of stocksteif are smaller than those of wild type.
Analysis of swimming performance
To analyze the performance of our fish, we measure several additional kinematic parameters. The angular acceleration is the second temporal derivative of the fish bend angle function, (u). In Fig. 11, we observe similar peak angular accelerations between wild type and stocksteif at 5 d.p.f., when the mutant phenotype has just become manifest. However, as the fish get older, large discrepancies appear in the angular accelerations. At 28 d.p.f., the peak angular accelerations of the wild type are two orders of magnitude larger than that of the stocksteif. This trend is also present in the tail beat frequency of the fish. To develop an objective method for estimating the tail beat frequency of the fish, we calculated the Fourier transform of the curvature values during continuous swimming at equally spaced locations along the fish's body. This approach does not rely on determining the tail's lateral displacement from a mean path of motion, and is therefore invariant to the spatial trajectory of the fish. The time period of continuous swimming was manually determined by inspecting the curvature profiles for regions where wavespeed remained relatively constant (see Fig. 10). Fig. 12 plots the magnitude of the frequency response along the body axis of the fish. For all fish, the body axis position at approximately 90% posterior to the snout has the largest frequency response. The tail beat frequency f is calculated by taking a weighted average of the frequencies with the maximum response at each location along the fish's body axis (see Appendix for precise definition). Again, similar tail beat frequencies are observed at 5 d.p.f. However, the 15 and 28 d.p.f. stocksteif have smaller tail beat frequencies than the wild type. We estimate the curvature wave speed by performing a linear fit to the points of zero curvature during continuous swimming (see Fig. 10), and then calculate the resulting wavelength given the tail beat frequency provided by the Fourier analysis using Eqn A7. A summary of these values is provided in Table 1.
Typical measures of escape swimming performance include displacement, speed, and acceleration of the fish center of mass (COM) when stretched straight (Domenici and Blake, 1997; Walker, 1998). To estimate the location of the COM, we reconstructed the fish volume from dorsal and lateral photographs assuming an elliptic cross-section (McHenry, 2001) (see supplementary material Figs S1–S3). The center of volume (COV) and center of area from the dorsal view (COA) were calculated. The COV will correspond to the COM assuming the fish has uniform density. COV calculations were only performed on wildtype zebrafish for comparison with published literature on escape responses. However, COV calculations do not lend themselves to high-throughput analysis because separate photographs of each individual fish must be acquired to account for the variation in morphometry for fish at a given age (very large variation exists for the stocksteif at a specific age). Instead, we propose to use the COA as a location for comparison between wild type and stocksteif because it is easily measured from the video sequence and has similar speed and acceleration profiles to the COV (see Fig. 13). Fig. S4 in supplementary material demonstrates that the COA location has a maximum deviation of 5–6% body length from the COV at age 5 days and the deviation decreases as the fish gets older. Fig. 13 illustrates the results of these measurements. Speed and acceleration are calculated using the MSE spline method (Walker, 1998). The stocksteif consistently exhibits lower peak acceleration and speed compared with wild type at each age. Although these preliminary measurements indicate consistent discrepancies between the wild type and stocksteif due to the stiffer vertebral column present in the mutant, a larger sample must be analyzed to produce statistically significant results, such an analysis will be presented in our next paper.
We have presented a method for estimating the body posture of zebrafish within laboratory environments using flexible geometric models and nonlinear estimation. Given the generalized mathematical framework used to model the fish's appearance, this method should track any fish species with a symmetric medial profile and that swims by undulating the body. The discrete time, dynamic state, space model also provides a general framework for performing statistical inference that is robust to outliers and enables tracking during partial occlusions. This is a strong improvement over previously developed methods that are either manual (Budick and O'Malley, 2000; McElligott and O'Malley, 2005; Müller and van Leeuwen, 2004), require a perfectly segmented image with no environmental clutter (Cronin et al., 2005; Geng et al., 2004; McHenry, 2001), or are customized for fish of a specific size and appearance (Burgess and Granato, 2007).
The assumption of planar motion is a limitation in the proposed method, which arises directly from the recorded material – top-view shots with a single camera. For behaviors that contain large out-of-plane motions, the geometric model will not accurately represent the appearance of the fish. For such behaviors, a 3D version of our model-based tracker would be required; our principle is sound, but should be extended. The tracker may also fail if a significant portion of the fish becomes completely occluded by environmental clutter (e.g. the entire head). Nevertheless, this could be improved by extending the algorithm to use a more advanced nonlinear estimator, a more advanced motion model, or a direct model of the occlusions. However, in laboratory settings, where many environmental parameters are controlled, this technique represents an accurate and fully automatic approach to quantify behavior and will facilitate studies requiring the analysis of many and long image sequences.
In addition to traditional swimming performance indicators we explored two new ways of analyzing the kinematics data: by plotting the angular acceleration as a function of time and the frequency response along the body. We also used more objective mathematical definitions and corresponding algorithms to quantify standard variables such as tail beat frequency, wave speed and length. The center of area (COA) of the fish dorsal view was proposed as a valid location for comparison between wild-type and stocksteif fish because its ease of measurement lends itself to high-throughput analysis. Our preliminary comparison between wild-type and stocksteif swimming performance indicators already suggest significant differences. Hence, this preliminary data analysis of swimming fish illustrates the capabilities of the automatic fish tracker and bodes well for gaining a complete understanding of how stiffness of the vertebral column affects swimming performance.
Here, we present some of the detailed equations related to the geometric, motion and measurement models used in our approach for tracking zebrafish. The tangent and normal vectors of the model's centerline are: (A1) and the complete fish model is given by: (A2) where (u) is defined in Eqn 3, H(p) is the complete fish model, and β is a constant scaling term (pixels mm–1) to scale the model to the appropriate size depending on the camera magnification. For our experiments, the scaling term β is calculated from the test image of a calibration grid.
The equations for our motion model predict the current fish parameters given the previous ones. The noise vector is included in the motion model to account for the uncertainty in the fish parameters, and is drawn from a zero mean multivariate normal distribution with fixed diagonal covariance: (A3) Here, Φ(u) is a N dimensional row vector of B-spline bases and is a s by N matrix of B-spline bases evaluated at s sampled grid points in u (we set s=30). The predicted local bend amplitudes are calculated by projecting onto this basis in the domain of displacement u+η0, calculating the new (u+η0), and projecting back onto the original basis, Φ(u). Likewise, the predicted translation is calculated by integrating the tangent vector over the axial displacement.
The measurement model minimizes the normal displacement between the model boundary points q and the edge feature points r detected in the current image. We use the SPKF to minimize the error E=½||nT(q–r)||2 (i.e. the sum of squares normal distance), and thus we obtain an updated estimate of our model location p̂k by iterating the equation: (A4) where Pab=E[(â–a)(b̂–b)T] is the covariance matrix associated with the random variables a and b and is the predicted state estimate from our motion model. At the first iteration, Pi+1= and after convergence (typically 5 iterations for our system), the updated state estimate is set to the current value, p̂k=pi+1. [For more detail on how to calculate the appropriate covariance matrices using the statistical linearization approach, see elsewhere (van der Merwe and Wan, 2003; Sibley et al., 2006).]
The initialization process used to determine the initial shape of the fish is described by the following pseudo-code: We first calculate the initial left and right boundaries and in a semi-automated fashion, then create a correspondence between them using the nearest neighbor functionλ , where λA(B) is the element in A that is closest to B. Then, the computed centerlines become the new boundaries (i.e. ), and the process is repeated until the average RMS error between the boundaries is less than a threshold (i.e. they have converged on top of each other). Once we have found the centerline through this iterative process, we must determine the width profile of the fish R(u)=ΛR(u)S, where S is a 20×1 vector of control points, andΛ R is the matrix of B-spline bases associated with the radius function. The optimal radius function is found by minimizing the squared normal displacement between the extracted image boundary BL,R and the model boundary ML,R dictated by the radius function while constraining the width profile to positive values: (A5) where ML,R(ui)=C(ui)±N(ui)ΛR(ui)S and Ni is the vector normal to C(ui) from the local Frenet frame. The result of this minimization is shown in Fig. 6B and shows that we are able to reconstruct the shape accurately.
We use the spatially smoothed centerlines of the fish to calculate the curvature values directly. A planar B-spline curve has the formγ (u)=Λ(u)X where Λ(u) denotes the s×m matrix of B-spline bases evaluated at s sampled grid points in u, and X denotes the m×2 matrix of control points. Let t(u) and n(u) denote the unit tangent and normal vectors to the curveγ (u), then t′(u)=κ(u).n(u) from the geometry of planar curves. Therefore, the curvature,κ (u), can be derived directly from the B-spline bases as follows: (A6)
The tail beat frequency of the fish is calculated as follows. Let F[.] denote the Fourier transform of a function, and κ(u,t) the curvature as a function of position along body axis and time. Then Ki(ω)=|F[κ(u,t)|u=ui]| is the magnitude of the Fourier transform at the ith location along the fish's body, and is the frequency that maximizes the magnitude response at the ith location. The tail beat frequency f is calculated as: (A7) using N locations sampled along the fish's body. This is an average frequency over the length of the body that is weighted by the magnitude response.
LIST OF ABBREVIATIONS AND SYMBOLS
- initial left and right boundaries of fish image (in pixels)
- initial centerline of fish image (in pixels)
- initial centerline of fish image modeled as B-spline
- center of area
- center of mass
- center of volume
- tangent vector to fish model centerline
- normal vector to fish model centreline
- motion model of zebrafish
- measurement model of zebrafish
- complete geometric model of zebrafish
- total length
- outward normal vectors of model boundary
- number of B-spline basis functions used to model centerline bend angle
- initial fish parameters
- fish parameters at the kth time step
- covariance matrix associated with the random variables a and b
- model boundary point
- edge feature point in image
- width profile of zebrafish model
- global translation vector of fish model
- grid parameterization of model mesh
- image measurements at the kth time step
- local bend amplitudes
- bend angle amplitude
- model scaling term (pixels mm–1)
- ratio of stiff region of zebrafish model to entire length
- time between frames
- axial displacement of fish between frames
- axial velocity of fish between frames
- axial acceleration fish between frames, sampled from normal distribution
- bend angle of centerline in zebrafish model
- nearest-neighbor function; the element in A that is closest to B
- s by matrix of B-spline basis functions evaluated at s sampled grid points in u
- B-spline basis function of order k
The authors would like to thank B. Walderich, H. M. Maischein and J. Odenthal of the Hubrecht laboratory for graciously allowing us to use video of the stocksteif mutant for demonstrating the ability of our tracker system. We also thank Ansa Wasim for recording the movie sequences and Henk Schipper for capturing the photographs used in the COV calculations. E.I.F., A.H.B. and J.W.B. thank the Beckman Institute of Caltech for providing financial support of this project. D.L. and J.L.v.L. are funded by NOW-ALW grant 817.02.012.
Supplementary material available online at http://jeb.biologists.org/cgi/content/full/211/8/1305/DC1
- © The Company of Biologists Limited 2008