pub fn split_hill_persistence(
hill: &Hill,
height_frac: f64,
valley_ratio: f64,
sigma_mult: f64,
min_scans: usize,
) -> Vec<Hill>Expand description
Split a hill containing multiple co-eluting peaks (the “persistence” algorithm). Designed to be robust to noisy scans while separating visually-obvious dual peaks.
- Despike (median-3) and smooth (moving average) a WORKING COPY — all peak finding runs on this; sub-hill intensities still come from the raw trace.
- Candidate maxima above
height_frac * robust_max(95th-percentile max, so a single noise spike can’t inflate the threshold). No hard min-distance eviction — close real peaks survive. - Agglomeratively merge adjacent peaks unless the valley between them is
BOTH relatively deep (
valley / smaller_peak <= valley_ratio) AND absolutely deep (smaller_peak - valley >= sigma_mult * noise_sigma). - Width gate: drop surviving 1–2 scan spikes median-3 couldn’t remove.
- Split at the (smoothed) valley between adjacent survivors.