Using MATLAB to Process Large Telemetry Data Sets for Biomechanical Performance Analysis
By Michael Davies, EquuSys
Horses are very valuable, but also very fragile; at any given time, one in six top equine athletes are lame in some way. Because horses are ‘flight’ animals, a lame horse will go to extraordinary lengths to hide its injury. Wild horses evolved this trait to help prevent an injured animal from being singled out from the herd as easy prey. This behavior can have disastrous consequences for domesticated horses and their riders: Because horses are so adept at masking injuries, it is challenging even for experts with decades of experience to recognize subtle lameness, while diagnosing the precise cause of the injury is harder still.
At EquuSys, we used MATLAB® to develop an easy-to-use, noninvasive system that enables equine professionals to identify and diagnose lameness that would otherwise be undetectable, even for the well-trained eye.
EquuSense technology sits at the conjunction of several different disciplines, including telemetry, biomechanics, and veterinary medicine. Despite the complex, multidisciplinary challenge, a small team of developers with little MATLAB experience was able to move rapidly from the initial idea to a production system.
The EquuSense system (Figure 1) provides real-time quantitative data on horses trotting in-hand, being ridden on the flat, or jumping. Its 18 wireless sensor nodes measure position, velocity, acceleration, orientation and rotation, relative to the horse or a global frame of reference, to an accuracy of a few millimeters or a few degrees. EquuSense software processes this telemetry data to provide objective data on equine biomechanics in the form of charts, 3-D plots, and animation.
Common Lameness Diagnosis Methods
At present, professionals rely primarily on the unaided human eye to observe the motion of horses and use palpation and blocking of the lame limb to diagnose lameness.
Most quantitative approaches to diagnosing lameness, including high-speed cameras, treadmills, and pressure pads, have met with limited success. A typical video motion-capture system is designed for human athletes. It is not scalable to the speed and size of a horse; its capture volume is typically limited to analyzing one or two steps at full gallop. On the other hand, treadmills distort the gait of the horse, and attaching the approximately 75 video markers needed for analysis can take hours. Pressure pads simply do not produce accurate results.
To provide meaningful information on equine biomechanics, we must translate and aggregate raw data obtained from localized sensors on the horse’s body to produce a six-degrees-of-freedom representation of the horse’s motion. The EquuSense nodes use accelerometers and gyroscopes to measure acceleration and angular rotation. Magnetometers measure orientation with respect to the earth’s magnetic field. Our first objective was to convert the acceleration and angular rotation data from a local to a global frame of reference.
With multiple sensor nodes measuring at up to 1000 times per second, it was immediately clear that each session would generate gigabytes of data. With MATLAB, we transformed the millions of rows of data from comma-separated value files into matrices that we could then filter, process, and convert into meaningful information.
We used Aerospace Toolbox™ to transform frames of reference by converting direction cosine matrices to Euler angles. Because our sensors provided acceleration in meters-per-second squared, we needed to integrate acceleration over time to find sensor velocity. We then used that measurement to determine the position of each sensor.
During the early, exploratory phases of development, we moved between scripts and interactive mode in MATLAB to examine variables and try out new ideas quickly. We could visualize the data using MATLAB plotting capabilities without writing our own custom routines. We could process large data sets very efficiently by using arrays, matrices, and vectorized functions. If we had used C or C++ instead of MATLAB, these tasks would have taken much longer.
One of our inertial navigation experts had written an extensive signal processing library in C++ that we initially called from MATLAB. Eventually, we recoded the entire library in MATLAB because we found that MATLAB scripts for signal processing, manipulating matrices, and performing frame-of-reference calculations are easier to understand and more transparent than an equivalent set of C++ routines.
Testing the First-Generation Prototype
As a proof of concept, we tested the first generation of the EquuSense system with help from an expert veterinarian who used a technique called blocking. Commonly used to pinpoint the location of an injury, blocking involves anesthetizing an area of the lame leg and then examining the horse’s gait. If the horse begins to walk normally, the injury can be assumed to be in the anesthetized area.
During tests of our first-generation prototype system, a veterinarian anesthetized the leg of an injured horse so that the horse was no longer visibly lame. Even to the veterinarian’s expert eye, the horse appeared sound. However, the MATLAB plots generated by our analysis revealed that the horse was transmitting less power to the right front leg (RF) and more power to the left rear leg (LR)—he was leaning back to put less pressure on the hurt leg (Figure 2).
The data demonstrated that the horse put much more pressure on LR than on RF. The plot on the right in Figure 2 shows the data for the anesthetized hoof. Although the injury was no longer evident from a visual inspection, the plot clearly shows that the animal is favoring the right front leg.
This test demonstrated that transmitted power, a metric that we had calculated from the raw sensor data, provided a reliable indication of the gait asymmetries associated with lameness.
We learned another important lesson from this test: The EquuSense interface left the vet unable to interpret the plots of transmitted power without our help. Clearly, we would have to improve all aspects of the system in parallel. As we moved to more advanced sensors with more sophisticated signal processing algorithms, we would also need to develop an interface that gave users a more intuitive view of how the horse was moving.
The second-generation prototype and subsequent trials of EquuSense provided more data on equine motion, including more precise measurements of acceleration and angular rotation. It also included an enhanced user interface, which we developed with MATLAB GUI-building tools.
When analyzing a horse, veterinarians and equine professionals use this software to define sessions from the trial data. A session includes all the data for a particular gait (trot, canter, and so on) or a specific episode in the motion of the horse. The session is then processed using the MATLAB algorithms that we have been improving iteratively since the initial exploration phases of development. The algorithms recognize gaits and calculate the 3-D hoof trajectory (Figure 3) and the Euler angles for the orientation of each hoof.
Users can annotate the data to mark specific events, such as a phased transition from the hoof landing on the ground to the hoof taking off, and then replicate that event throughout the data set of interest.
We achieved another critical breakthrough in the second-generation EquuSense: We developed MATLAB algorithms to create an animated representation of the hoof flight path shown in Figure 3. When we showed some of our early users this animation together with a video replay of the event, they reported that this feature helped them visualize vital aspects of the data and understand it intuitively.
Into Production and Beyond
Production EquuSense systems are already being used in clinical research, and we continue to improve the system. We have started to use Instrument Control Toolbox™ to stream data directly from the sensors into MATLAB, and we plan to create a standalone version of the EquuSense software with MATLAB Compiler™. We are also exploring other applications for the technology, including biomechanical studies of human athletes.
Published 2009 - 91643v00