Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/MSDIAL5/MsdialCore/Algorithm/PeakSpottingCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public void SetMS2RawSpectrumIDs2ChromatogramPeakFeature(ChromatogramPeakFeature
}

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.
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.
var counterThreshold = 4;
var counterThreshold = 15;
var sPeakAreaList = new List<ChromatogramPeakFeature>();

foreach (var feature in chromPeakFeatures) {
Expand Down Expand Up @@ -601,7 +601,7 @@ public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<Chromatog
}

public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, IReadOnlyList<double[]> peaklist) {
var counterThreshold = 4;
var counterThreshold = 15;
var sPeakAreaList = new List<ChromatogramPeakFeature>();

foreach (var feature in chromPeakFeatures) {
Expand Down Expand Up @@ -654,7 +654,7 @@ public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<Chromatog
}

public List<ChromatogramPeakFeature> GetBackgroundSubtractedPeaks(List<ChromatogramPeakFeature> chromPeakFeatures, Chromatogram chromatogram) {
var counterThreshold = 4;
var counterThreshold = 15;
var sPeakAreaList = new List<ChromatogramPeakFeature>();

foreach (var feature in chromPeakFeatures) {
Expand Down
Loading