mioXpektron.adaptive
Adaptive parameterization helpers for the mioXpektron pipeline.
Each estimator derives a value from data that would otherwise be a fixed constant. All functions are pure (no mutation of global state) and return plain Python / NumPy values that callers feed into the existing config dataclasses.
Usage is opt-in: every config keeps its current defaults; the new
auto_tune=True flag triggers adaptive estimation.
Functions
|
Build a |
|
Estimate |
|
Derive adaptive bootstrap peak-matching constants from observed channel statistics (noise, spacing, range). |
|
Estimate |
|
Estimate |
|
Place segment breakpoints at quantile boundaries of the reference mass range so each segment contains roughly equal calibrant counts. |
|
Estimate |
|
Estimate |
|
Derive |
|
Derive |
- mioXpektron.adaptive.estimate_autodetect_tolerance(files, reference_masses, *, sample_n=10, quantile=0.9)[source]
Estimate
autodetect_tol_dafrom observed peak widths near calibrant m/z values.Reads a sample of spectra, measures the FWHM of the strongest peak within +/-1 Da of each reference mass, and returns a tolerance equal to quantile of those widths (clamped to [0.05, 2.0] Da).
- mioXpektron.adaptive.estimate_outlier_threshold(residuals, *, target_false_rejection_rate=0.01, bounds=(2.0, 5.0))[source]
Derive
outlier_thresholdfrom observed residual spread.Uses the empirical quantile corresponding to
1 - target_false_rejection_rateof absolute z-scores (MAD-scaled), clamped to bounds.
- mioXpektron.adaptive.estimate_screening_thresholds(stability_df, *, ppm_quantile=0.85, valid_frac_quantile=0.2)[source]
Derive
screen_max_mean_abs_ppmandscreen_min_valid_fractionfrom a reference-mass stability table (output ofsummarize_reference_mass_stability).Returns a dict with keys
screen_max_mean_abs_ppmandscreen_min_valid_fraction.
- mioXpektron.adaptive.estimate_multisegment_breakpoints(reference_masses, n_segments=3)[source]
Place segment breakpoints at quantile boundaries of the reference mass range so each segment contains roughly equal calibrant counts.
- mioXpektron.adaptive.estimate_normalization_target(files, *, sample_n=20, mz_min=None, mz_max=None)[source]
Estimate
normalization_targetas the median raw TIC across a sample of spectra. Falls back to1e6on failure.
- mioXpektron.adaptive.estimate_mz_tolerance(files, *, sample_n=10, multiplier=3.0)[source]
Estimate
mz_tolerancefrom observed median m/z spacing, scaled by multiplier. Clamped to [0.01, 1.0].
- mioXpektron.adaptive.estimate_flat_params(files, *, sample_n=10)[source]
Estimate
savgol_windowand quantile thresholds forFlatParamsfrom the data.Returns a dict of keyword overrides suitable for
dataclasses.replace(FlatParams(), **result).
- mioXpektron.adaptive.estimate_denoise_params(files, *, sample_n=5)[source]
Estimate
hf_cutoff_fracandmax_peaksfor the denoise selection evaluator from pilot spectra.Returns a dict of keyword overrides for
compare_denoising_methods.
- mioXpektron.adaptive.estimate_bootstrap_heuristics(files, *, sample_n=10)[source]
Derive adaptive bootstrap peak-matching constants from observed channel statistics (noise, spacing, range).
Returns a dict whose keys match the
_BOOTSTRAP_*constant names in_models.py(without the leading underscore).
- mioXpektron.adaptive.auto_tune_calib_config(files, reference_masses, *, base_config=None, sample_n=10)[source]
Build a
FlexibleCalibConfigwith data-driven parameters.Starts from base_config (or the default) and replaces tolerance, screening values, and breakpoints with adaptive estimates. The caller can further override any field afterwards.
Returns a
FlexibleCalibConfiginstance.