Help with peak detection on signal - want to detect peaks of specific shape

5 views (last 30 days)
I want to detect peaks in a signal. The signal is the output from an accelerometer worn by an aquatic animal. I want to detect stroking (swimming). I will be using this to create a stroking rate variable. I have found a few peak detection functions that work beautifully (e.g. Carlos Adrian Vargas Aguilera's extrema function), but the problem is that there are other peaks present in the data (not noise, just due to other movements besides stroking) that are also detected by these functions. I have not been able to modify the code or filter the data properly in order to only detect the peaks associated with stroking.
This is a little complicated to explain without an example, so I have uploaded some sample files. averageddata is the data with a moving average filter (every 4) applied. averageddata2 is (averageddata.*abs(averageddata)/max(abs(averageddata))) (this just really smoothed the signal out). I hoped a bandpass filter would solve my problems but the frequencies overlap.
For an example of what stroking looks like, plot(averageddata(9350:9900,:)). For an example of movement that is NOT stroking and where I don't want peaks to be detected, plot(averageddata(700:1900,:)). As you can see, the shape of the stroking is very distinct, and there must be some way to reflect this in the coding. It is not possible for me to go through all of the data manually as there are months of data recorded at 16hz. I do have access to the signal processing toolbox (I tried those peak detection tools as well).
I would appreciate any and all help/tips on either filtering the data or modifying the peak detection code to help me achieve what I am trying to accomplish here. I have been working on this for a while and trying a bunch of different things and am really just stuck at this point. Thanks a million.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!