Conversation
There was a problem hiding this comment.
Pull request overview
This pull request changes the spike count threshold used in background-subtracted peak detection from 4 to 15 across three overloaded methods in the PeakSpottingCore class. This threshold determines how sensitive the algorithm is to noise when filtering chromatogram peaks.
- Changed
counterThresholdfrom 4 to 15 in three method overloads ofGetBackgroundSubtractedPeaks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -548,7 +548,7 @@ public void SetMS2RawSpectrumIDs2ChromatogramPeakFeature(ChromatogramPeakFeature | |||
| } | |||
|
|
|||
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |||
There was a problem hiding this comment.
The threshold change from 4 to 15 creates an inconsistency with the similar implementation in MsdialImmsCore/Algorithm/PeakSpotting.cs which uses a constant SPIKE_COUNT_THRESHOLD set to 4. Consider whether both implementations should use the same threshold value, or if the difference is intentional due to different processing requirements. If the values should differ, consider adding comments explaining why.
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |
| // Spike-count threshold for background/noise suppression in this core chromatographic peak algorithm. | |
| // Note: This value (15) intentionally differs from SPIKE_COUNT_THRESHOLD (4) in MsdialImmsCore/Algorithm/PeakSpotting.cs | |
| // because the IMMS-specific implementation and this core implementation operate on different data/processing characteristics. |
| @@ -548,7 +548,7 @@ public void SetMS2RawSpectrumIDs2ChromatogramPeakFeature(ChromatogramPeakFeature | |||
| } | |||
|
|
|||
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |||
There was a problem hiding this comment.
The threshold change from 4 to 15 is a significant algorithmic change that affects background subtraction and noise filtering in peak detection. This change lacks documentation explaining the rationale. Consider adding a comment explaining why this value was changed and what impact it has on peak detection sensitivity.
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |
| public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) { | |
| // `counter` counts how many local spike pairs have noise (0.5 * |spikeMax - spikeMin|, scaled by 3) | |
| // comparable to or larger than the peak amplitude difference (`ampDiff`). Peaks with too many such | |
| // high-noise events are treated as background and removed. The threshold of 15 was chosen empirically | |
| // to suppress peaks originating from highly noisy chromatographic regions, at the cost of slightly | |
| // reduced sensitivity for very small peaks. Lowering this value will retain more peaks (more sensitive | |
| // but more noise), while increasing it will make the background subtraction more stringent. |
No description provided.