Developing motion analysis algorithms

MathWorks Australia

By Edgar Charry, dorsaVi
Friday, 06 March, 2015


Developing motion analysis algorithms

Elite athletes want to return to match play as quickly as possible after injury. As a result, they often convince themselves and their physicians that they are fit to play before they have fully recovered. Advanced technologies such as optical tracking systems, which capture motion, and force plates, which measure ground reaction forces, enable athletes and trainers to determine when the athlete can safely return to full activity. 

These technologies provide metrics and insights that are impossible to obtain by simply observing the athlete, but they have several drawbacks. In addition to being costly, they typically depend on specially trained technicians and lengthy set-up procedures. Further, because they often require the athlete to perform in a constrained environment, such as on a treadmill, they make it difficult to assess natural movement.

At dorsaVi, my colleagues and I have developed wearable, wireless motion analysis devices that precisely measure and track movement while the athlete moves freely in any environment. ViPerform incorporates inertial measurement units (IMU) and magnetometers, as well as electromyography sensors for measuring muscle activity. Sensor data is transmitted to a recording and feedback device (RFD), which can be worn on the arm or carried in a pocket. The RFD sends the data to a PC, where it is processed and displayed by the dorsaVi software package.

At the heart of the dorsaVi technology are proprietary algorithms that filter and analyse raw sensor data, providing information that can be used to evaluate knee control, lower back range of motion, hamstring activity, hip and core control, and running performance. By developing and testing the algorithms in MATLAB and developing portable C code with MATLAB Coder, the development time was cut by almost half compared to our previous approach, which involved hand-coding in C#.

Developing algorithms for objective analysis

Objective analysis is made possible by sophisticated algorithms that process raw sensor data and present results in a meaningful form. For example, an algorithm may identify large negative spikes in the accelerometer output that occur on each step when an athlete is running. From the timing and magnitude of these spikes, the algorithm can calculate the runner’s cadence and the ground reaction force of each step, respectively. This analysis may detect an asymmetrical cadence or unequal ground reaction forces for each leg, revealing an inability or unwillingness for the athlete to apply equal force through both legs. Similarly, analysing knee deviation, flexion and rotation as the athlete squats or hops can guide recovery from ACL and other knee injuries. Even healthy athletes can benefit from such analysis, using feedback from the algorithms to refine their technique or optimise the efficiency of key movements.

When we implemented our algorithms directly in C#, we had to develop our own low-level signal processing and graphing functions. By switching to MATLAB, we have sped up development by using built-in functions for data visualisation and discrete Fourier transforms. Today, we use Signal Processing Toolbox and Wavelet Toolbox to further streamline development.

Verifying and testing the algorithms

After developing an algorithm in MATLAB, we verify it by comparing its results with results produced by an independent measuring device, such as an optical motion tracking system or a force plate. Once we are satisfied that the algorithm is performing well on a limited set of test scenarios, we run more than 1000 tests in MATLAB using recorded data from athletes around the world. We continue to fine-tune and optimise the algorithm until it meets our requirements for accuracy and performance.

Generating C++ code from MATLAB algorithms

DorsaVi software, which serves as the primary interface for viewing sensor data and evaluating an athlete’s performance, is written primarily in C#. When we first began using MATLAB to develop signal processing algorithms, our workflow still relied on C++ and C# programmers to implement the production version of the algorithm that was incorporated into the dorsaVi software. This approach was inefficient because it involved duplication of effort. It could take an additional month to reprogram and retest algorithms that had already been developed and tested in MATLAB.

To eliminate this inefficiency and shorten project delivery times, we decided to use MATLAB coder to generate C++ code from our verified MATLAB algorithms. We prepare our algorithms for code generation by initialising all variables and looking for opportunities to optimise loops. We verify that our algorithm is ready for code generation by generating a MEX function that wraps the compiled code, and then invoking the MEX function in place of the original MATLAB algorithm. After generating the C++ code from our algorithm, we compile the algorithm into a DLL. The C# programmers load this DLL into the dorsaVi software.

Translating the MATLAB algorithm into production code previously took up to a month. With MATLAB Coder it now takes a day or two. As a final step, we perform full system testing of the algorithms of the dorsaVi software. To date, we have not found any defects introduced during code generation. The extensive testing we perform in MATLAB enables our C# programmers to spend their time developing new features for the dorsaVi software instead of recoding our algorithms in C# and then retesting them.

Re-using algorithms and responding to customer requests

We have re-used several algorithms initially developed for ViPerform in our ViMove and ViSafe products, designed for elite sports, clinical applications and occupational health applications, respectively. My team is currently working on new algorithms to analyse data from sensors placed on different body parts, as well as algorithm development and enhancement requests from existing customers.

With MATLAB and MATLAB Coder, we can respond quickly to customer requests. In a recent release, we updated two algorithm modules, created two new ones and delivered all four with a confidence that would have been impossible using our old workflow

Related Articles

Ricoh chooses u-blox module for long-lasting GNSS performance

The Ricoh Theta X camera incorporates the ZOE-M8B GNSS module from u-blox, allowing users to...

Single-step 3D printing method to create tiny robots

The breakthrough enables the mechanical and electronic systems needed to operate a robot to be...

Fast inspection technique for modern semiconductor devices

Researchers developed a novel approach to inspect and measure critical dimensions of...


  • All content Copyright © 2024 Westwick-Farrow Pty Ltd