Skip to main content

Crate dnoise_core

Crate dnoise_core 

Source
Expand description

dnoise-core — the in-memory denoising stages of dnoise, for Bruker timsTOF frames.

This crate does no I/O and has no native dependencies. A caller reads frames and run metadata itself (for example with timsrust and SQLite), then:

  1. builds one Denoiser per run from FrameMeta and the parameters,
  2. attaches any per-run state its stages need (see pipeline),
  3. calls Denoiser::process, Denoiser::denoise_ms1 or Denoiser::denoise_msms per frame, in any order, from any thread (Denoiser is Send + Sync, checked at compile time).

The dnoise crate runs exactly this path for its CLI and writes the survivors into a new .d folder.

§Example

use dnoise_core::{Acquisition, Denoiser, FilterParams, FlatFrame, FrameMeta, Stages};

let meta = vec![FrameMeta { id: 1, num_scans: 700, num_peaks: 8, ms_ms_type: 0, rt: 0.5 }];
let params = FilterParams::default();
let stages = Stages::default();
let denoiser = Denoiser::new(&params, &stages, Acquisition::Ms1Only, meta, false)?;

// A vertical streak at TOF 1000 across 8 consecutive mobility scans.
let frame = FlatFrame {
    frame_id: 1,
    num_scans: 700,
    scan: (10..18).collect(),
    tof: vec![1000; 8],
    intensity: vec![100; 8],
};
let out = denoiser.process(0, &|_| Ok(frame.clone()), None)?;
assert_eq!(out.survivors.len(), 8); // the streak survives

The lower-level stages (filter::filter_iterated, halo, the gates, smooth, watershed, box_centroid) are public too.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use frame::CsrFrame;
pub use frame::FlatFrame;
pub use mobility::MobilityScale;
pub use mobility::ScanToMobility;
pub use params::BoxCentroidParams;
pub use params::CropParams;
pub use params::DdaWindowParams;
pub use params::DiaMs1WindowParams;
pub use params::DiaWindowParams;
pub use params::FilterParams;
pub use params::HaloParams;
pub use params::Ms1PolygonParams;
pub use params::MsmsFilterParams;
pub use params::NeighborParams;
pub use params::SmoothParams;
pub use params::Stages;
pub use params::WatershedParams;
pub use pipeline::Acquisition;
pub use pipeline::DecodedFrame;
pub use pipeline::Denoiser;
pub use windows::DiaWindows;
pub use windows::FrameMeta;
pub use windows::PasefWindow;

Modules§

average
Optional pre-filter smoothing: a centered moving average over the MS1-frame subsequence, applied before the vertical-IM filter (and any downstream centroider). This stage is completely decoupled from the filter — it just produces ordinary FlatFrames that the rest of the pipeline consumes exactly as it consumes raw frames.
box_centroid
Greedy small-box centroider in integer (scan, TOF index) space.
convert
Calibration converters: TOF index <-> m/z and scan <-> 1/K0 on the linear (acquisition-range) scale, with fractional inverses.
crop
Region-of-interest crop (a.k.a. trim): keep only points inside an axis-aligned box in (m/z, 1/K0, intensity) space, plus a retention-time window handled at the frame level by the writer.
dia_ms1
diaPASEF MS1 out-of-window gate.
dia_window
diaPASEF isolation-window handling for MS/MS frames.
error
The error type of the pure stages and the per-frame API.
filter
Stage 1 of ALGORITHM.md: the iterative vertical-IM feature filter.
frame
Flat per-point view of a timsTOF frame in native integer (scan, tof, intensity) space.
halo
Horizontal (m/z-axis) halo filter: remove the weak halo flanking bright ions, left/right only.
mobility
TIMS scan ↔ 1/K0 conversion on Bruker’s acquisition-calibrated scale.
msms
ddaPASEF MS/MS denoising (precursor-centric).
neighbor
Bounded temporal evidence for native-point filtering. Observations are indexed once per run (NeighborIndexBuilder); each frame then sums the points of its compatible neighbors (NeighborIndex::keep_mask) only to decide which of its own native points survive.
overlap
Feature-level (“any overlap”) mode for the MS1 acquisition gates.
params
Tunable parameters for the vertical-IM feature filter (Stage 1 of ALGORITHM.md).
pipeline
The per-frame denoising pipeline: Denoiser holds one run’s settings and prebuilt state, and runs every enabled stage on one frame at a time.
polygon
ddaPASEF/PASEF MS1 selection-polygon gate.
smooth
Box-averaging smoother in integer (scan, TOF index) space.
units
Physical equivalents of the raw-unit parameters, for the run log and the provenance record.
watershed
Watershed-segmentation centroider in integer (scan, TOF index) space.
windows
Plain per-run acquisition metadata the stages consume: frame metadata, PASEF isolation events, diaPASEF window schemes and prm-PASEF event windows.