Skip to content

Conversation

@htsugawa
Copy link
Contributor

@htsugawa htsugawa commented Jan 8, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 counterThreshold from 4 to 15 in three method overloads of GetBackgroundSubtractedPeaks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
}

public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) {
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
}
}

public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<IChromatogramPeak> peaklist) {
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
@YukiMatsuzawa YukiMatsuzawa merged commit b60e035 into master Jan 13, 2026
14 of 15 checks passed
@YukiMatsuzawa YukiMatsuzawa deleted the improve_internalpeakdetection_threshold branch January 13, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants