Skip to main content

Crate dnoise

Crate dnoise 

Source
Expand description

dnoise — denoise Bruker timsTOF .d folders with the iterative vertical-IM feature filter (Stage 1 of ALGORITHM.md). Reads via timsrust, re-encodes surviving points as a type-2 tdf_bin, and writes a new .d folder.

Two API tiers are exposed:

§Example

Run the vertical-IM filter over an in-memory frame:

use dnoise::{FilterParams, FlatFrame, filter_iterated};

// 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 keep = filter_iterated(&frame, &FilterParams::default());
assert!(keep.iter().all(|&k| k)); // the streak survives

Re-exports§

pub use error::DecodeError;
pub use error::DnoiseError;
pub use error::Result;
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::SmoothParams;
pub use params::Stages;
pub use params::WatershedParams;
pub use writer::Calibration;
pub use writer::DecodedFrame;
pub use writer::DenoiseStats;
pub use writer::FrameCtx;
pub use writer::Progress;
pub use writer::RunContext;
pub use writer::RunOptions;
pub use writer::SampleSpec;
pub use writer::denoise;
pub use writer::denoise_with_options;
pub use writer::denoise_with_progress;
pub use writer::process_frame_decoded;
pub use crop::CropGate;
pub use average::running_average;
pub use box_centroid::box_centroid;
pub use dia_ms1::DiaMs1Gate;
pub use dia_ms1::TofScanBox;
pub use dia_window::filter_per_window;
pub use dia_window::in_window_mask;
pub use filter::filter_iterated;
pub use filter::filter_once;
pub use frame::FlatFrame;
pub use halo::horizontal_halo_keep_mask;
pub use msms::combine_and_filter;
pub use polygon::PolygonGate;
pub use smooth::box_average;
pub use watershed::watershed_centroid;

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.
codec
Type-2 tdf_bin frame codec — encode/decode Bruker timsTOF frame records.
config
On-disk run configuration (dnoise.toml), shared by the CLI and the GUI.
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
Error types for the dnoise library.
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.
msms
ddaPASEF MS/MS denoising (precursor-centric).
params
Tunable parameters for the vertical-IM feature filter (Stage 1 of ALGORITHM.md).
polygon
ddaPASEF/PASEF MS1 selection-polygon gate.
smooth
Box-averaging smoother in integer (scan, TOF index) space.
watershed
Watershed-segmentation centroider in integer (scan, TOF index) space.
writer
Orchestration: copy the source .d, rewrite analysis.tdf_bin with filtered frames (re-encoded as type 2), and fix up the analysis.tdf SQLite database.

Enums§

Acquisition
Acquisition scheme of a .d run, detected from the Frames.MsMsType column. Drives the --preset auto gate selection (see the CLI): ddaPASEF wants the MS1 selection-polygon gate, diaPASEF the isolation-window gates.

Functions§

detect_acquisition
Detect the acquisition scheme of an input .d folder by inspecting the frame table (MsMsType): 9 anywhere = diaPASEF, else 8 = ddaPASEF, else MS1-only when every frame is MS1, else unknown. A cheap SQLite read, no frame decoding.
tof_half_width_for_ppm
Convert a mass tolerance in ppm to a TOF-index half-width for the vertical filter’s mz_half_width, evaluated at a reference m/z. The timsTOF calibration maps m/z to a fractional TOF index nonlinearly, so a fixed ppm corresponds to a different index width across the mass range; the vertical filter uses one constant index window, so we evaluate the width at ref_mz (defaulting to the midpoint of the acquired m/z range) and round up to at least 1.