Functions
calibrate(X, ppm, calib_type='tsp', custom_range=None, custom_target=None)
Calibrate chemical shifts in NMR spectra using known reference peaks.
Parameters:
XNMR data matrix (rows: spectra, columns: PPM positions).ppm1D array of chemical shift values (same order as X columns).calib_typeOne of 'tsp', 'acetate', 'glucose', 'alanine', 'formate', or 'custom'.custom_range (tuple[float, float] | None): For 'custom', the (start_ppm, end_ppm) region to search for the peak. custom_target (float | None): For 'custom', the target ppm to calibrate the detected peak to (e.g., 0.91).
Returns: pd.DataFrame: Calibrated NMR data matrix with same shape and columns as input.
Notes:
otherwise falls back to the highest peak.
calibrate(X, ppm, calib_type='custom', custom_range=(0.89, 1.20), custom_target=0.91)
Examples: >>> import numpy as np >>> import pandas as pd >>> import metbit >>> ppm = np.linspace(-0.5, 10.0, 2000) >>> spectra = np.random.rand(10, 2000) >>> calibrated = metbit.nmr.calibrate(spectra, ppm, calib_type='tsp') >>> calibrated_custom = metbit.nmr.calibrate( ... spectra, ppm, calib_type='custom', ... custom_range=(0.89, 1.20), custom_target=0.91 ... )