You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// trim the distribution if requested, by requiring a minimum of "trim" counts in each bin
424
424
if (trim > 0) {
425
425
for (int i = 0; i < nBins; ++i) {
426
+
// if the count in the bin is less than the trim value, set it to zero
426
427
if (counts[i] < trim) {
427
-
counts[i] = 0;
428
+
// set the count to zero only if this is an isolated bin,
429
+
// i.e. if this count belongs to a peak, we want to keep it even if it has counts below the trim limit, as long as the whole peak is not below the trim limit
430
+
// check the previous bins until we find an empty bin or we reach the beginning of the histogram
431
+
int localPeakCount = counts[i];
432
+
for (int j = i - 1; j >= 0; --j) {
433
+
if (counts[j] == 0) {
434
+
break;
435
+
}
436
+
localPeakCount += counts[j];
437
+
}
438
+
// check the next bins until we find an empty bin or we reach the end of the histogram
439
+
for (int j = i + 1; j < nBins; ++j) {
440
+
if (counts[j] == 0) {
441
+
break;
442
+
}
443
+
localPeakCount += counts[j];
444
+
}
445
+
if (localPeakCount < trim) {
446
+
counts[i] = 0;
447
+
}
448
+
}
449
+
}
450
+
}
451
+
if (trim < 0) {
452
+
// if trim is negative, then we remove all counts belonging to local peaks with an integrated count below 1/abs(trim)
453
+
for (int i = 0; i < nBins; ++i) {
454
+
if (counts[i] == 0) {
455
+
continue; // skip empty bins
456
+
}
457
+
// check the previous bins until we find an empty bin or we reach the beginning of the histogram
458
+
int localPeakCount = counts[i];
459
+
for (int j = i - 1; j >= 0; --j) {
460
+
if (counts[j] == 0) {
461
+
break;
462
+
}
463
+
localPeakCount += counts[j];
464
+
}
465
+
// check the next bins until we find an empty bin or we reach the end of the histogram
466
+
for (int j = i + 1; j < nBins; ++j) {
467
+
if (counts[j] == 0) {
468
+
break;
469
+
}
470
+
localPeakCount += counts[j];
471
+
}
472
+
if (localPeakCount < (1.0 / std::abs(trim)) * data.size()) {
473
+
// set all bins belonging to this local peak to zero
0 commit comments