MATLAB Answers

Identifying periods of signal above threshold

10 views (last 30 days)
The code below provides number of "bursts" or periods of activity (300 consecutive points = 0.2 s) above a given threshold. How could I add a further condition to the code that identifies "bursts" only when there are at least n values of separation (i.e. 1200 points) (below the threshold) between two different bursts?
above_threshold = (signal > threshold);
minAcceptableLength = 300;
% Find spans that are long enough.
isLongEnough = bwareafilt(above_threshold, [minAcceptableLength, inf]);
% Count the number of spans (bursts) that are long enough.
[labeledSpans, numberOfBursts] = bwlabel(isLongEnough);

Accepted Answer

Image Analyst
Image Analyst on 16 Aug 2016
You'd have to look at the inverse: ~isLongEnough. Then call regionprops() to measure the lengths of all the stretches/gaps between the bursts. Then take some action depending on whether they are long enough or not.
labeledLowSignalRegions = bwlabel(~isLongEnough);
props = regionprops(labeledLowSignalRegions, 'Area');
allLengths = [props.Area]
  1 Comment
Antonio Morales
Antonio Morales on 16 Aug 2016
Thank you, it seems to give me what I want. Nonetheless, I am not sure if I am correctly taking the number of bursts.
As an example: 70 bursts have been identified in one of the signals.
Here are all lengths of each burst (above threshold) and gap between burst (below threshold) identified:
LengthsAboveThreshold = [3296 423 1715 1189 309 536 209 364 13778 1973 1847 8843 1329 3627 6274 375 252 204 338 841 519 1454 2597 215 203 463 277 5205 404 236 722 526 367 283 931 2387 306 221 371 265 272 205 274 331 392 238 219 222 222 3192 473 708 212 213 207 2830 373 281 2074 301 232 313 854 1776 255 201 218 200 307 5155];
LengthsBelowThreshold = [1717085 14 2 36 15 140 72 13 32 47 15 24 22 18 14 39 59 7529427 465416 37 23800 10 76680 551 745 12753 27 9 1116106 9 40 137 37 34 75 27 272 134918 192 1139 166 868 171 533 293 205 275 21061 153 20 4 105 82 32 31151 49 30 1936 108560 167 59999 412 18 7 54 707 6960 243 52480 76 2605663];
Let's suppose want to quantify the number of bursts that have a gap of at least 1200 points between them. Would it be right just doing the following:
idx = find(LengthsBelowThreshold >= 1200);
numberOfBursts = length(idx);
Thank you

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!