Skip to main content

sort_dedup_scan_tof

Function sort_dedup_scan_tof 

Source
pub fn sort_dedup_scan_tof(
    scans: &[u32],
    tofs: &[u32],
    intensities: &[u32],
) -> (Vec<u32>, Vec<u32>, Vec<u32>)
Expand description

Deduplicate (scan, tof) pairs (summing their intensities) and return the arrays sorted ascending by (scan, tof).

The Bruker tdf_bin layout requires this ordering: modify_tofs delta- encodes TOF within each scan (so TOFs must ascend within a scan) and get_peak_cnts walks scans assuming they ascend. The Python writer enforces the same invariant via an np.unique dedup + np.lexsort((tof, scan)) before encoding; the Rust write path previously fed raw, unsorted frame data straight into the encoder, producing negative/garbage TOF deltas that vendor readers (e.g. DiaNN) reject. Mirroring the Python preprocessing here keeps the two writers byte-for-byte identical.