removeNoiseMinutes method
void
removeNoiseMinutes()
Implementation
void removeNoiseMinutes() {
List<MarkerIndices> groups = [];
// create groups form corrected Indices
int start = 1;
while (start < bpmCorrectedIndices.length) {
int margin = 7;
MarkerIndices index = MarkerIndices();
index.setFrom(bpmCorrectedIndices[start - 1]);
index.setTo(start); // change from 0 to start varibale
for (int i = start; i < bpmCorrectedIndices.length; i++) {
if ((bpmCorrectedIndices[i] - bpmCorrectedIndices[i - 1]).abs() >=
margin) {
index.setTo(bpmCorrectedIndices[i - 1]);
start = i + 1;
break;
} else {
start++;
}
}
// if (index.getTo() == 0)
// index.setTo(bpmCorrectedIndices[bpmCorrectedIndices.length - 1]); // change commented as CTG App
groups.add(index);
if (start == bpmCorrectedIndices.length - 1) break;
}
if (groups.isEmpty) {
return;
} else {
for (int i = 0, j = 0; i < groups.length; i++) {
int from = groups[i].getFrom();
int to = groups[i].getTo();
if (to<from ||(to - from) < 30) {
groups.removeAt(i);
i--;
}
}
}
int minutes = (bpmList!.length / 60).truncate();
//List<int> noiseMinutes = new int[groups.length * 2];
List<int> minuteRanges = [];
//expanding the areas to minute
for (int i = 0, j = 0; i < groups.length; i++) {
int from = groups[i].getFrom();
int to = groups[i].getTo();
from = from - (from % 60);
to = to - (to % 60);
to = to + 60;
groups[i].setFrom(from);
groups[i].setTo(to);
//converting index to min
from = ((from + 1) / 60).truncate();
to = ((to - 1) / 60).truncate();
while (from <= to) {
if(from<minutes) {
minuteRanges.add(from);
}
from++;
}
}
//identifying the minutes to clean
//asigning baseline values to avoid interpretations
for (int interval = 0; interval < minutes; interval++) {
int start1 = interval * 60;
int limit = ((1 + interval) * 60).truncate();
if (limit >= baselineBpmList!.length) limit = baselineBpmList!.length - 1;
if (minuteRanges.contains(interval)) {
for (int i = start1; i < limit; i++) {
bpmList![i] = baselineBpmList![i];
}
}
}
noiseList = groups;
}