fix: xNoiseSanPlot refined negative noise read from wrong array#386
fix: xNoiseSanPlot refined negative noise read from wrong array#386lpatiny wants to merge 4 commits into
Conversation
The refined negative noise level was indexed out of cloneSignPositive (the positive signal) using the negative clone's length, a copy-paste error. It now reads from cloneSignNegative and negates it, matching the initial negative-noise formula, so with refine enabled the reported negative level reflects the negative signal.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #386 +/- ##
==========================================
+ Coverage 97.13% 97.15% +0.02%
==========================================
Files 207 209 +2
Lines 4147 4148 +1
Branches 1036 1030 -6
==========================================
+ Hits 4028 4030 +2
+ Misses 115 114 -1
Partials 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| noiseLevelNegative = | ||
| cloneSignPositive[ | ||
| -1 * | ||
| cloneSignNegative[ |
There was a problem hiding this comment.
seems to me that cutOffSignalsIndexNeg would be always zero. because cutOffSignals defined positive. So there is not a refinning for noiseLevelNegative.
…eNormInvRaw in xNoiseSanPlot
|
@lpatiny could you have a look, I propose use negative data to find the negative noise level |
|
It is true than there is a bug in the determineCutOff function with the missing division for the number of elements in the window, but I would like to keep it out of this PR, to open a new one that would refactor the xFindClosestIndex to accept descending order arrays. @lpatiny what do you think? |








Bug
In the
refinebranch ofxNoiseSanPlot, the refined negative noise level was read fromcloneSignPositive(the positive signal) while indexing withcloneSignNegative.length— a copy-paste error from the positive branch just above. Withrefine: true(the default), the reportednegativelevel did not reflect the negative signal at all.The fix reads from
cloneSignNegativeand negates it, mirroring the initial negative-noise formula (-1 * signNegative[...]). Added a regression assertion: the refined negative level is now positive and of the same order as the positive one.All 2230 tests pass.
For your review, @jobo322 — a second, separate issue I did not touch
determineCutOffaccumulatesaverageValueas a plain sum and then uses it as a mean in(element[1] - averageValue)², sokiSqrtisn't the intended dispersion measure and the chosen cut-off is likely skewed. DividingaverageValuebyelementsOfCutOff.lengthlooks correct, but it changes the magnitude-mode SNR on the test spectrum from ~40.2 to ~63.5 — a real behavioral change to the published-method output. I left it as-is since that needs your domain judgment on what the reference value should be. Happy to open a follow-up if you confirm the intended behavior.