metbit.nmr_preprocess
NMR and preprocessing module in metbit 7.3.10.
import metbit.nmr_preprocessClasses
nmr_preprocessing
Methods
__init__(self, data_path: str, bin_size: float=0.0003, auto_phasing: bool=False, fn_='acme', baseline_correction: bool=True, baseline_type: str='linear', calibration: bool=True, calib_type: str='tsp')
get_data(self)
get_ppm(self)
get_metadata(self)
get_phase(self)
Functions
read_fid(data_path: str)
remove_digital_filter(dic, data)
generate_ppm_scale(dic, data)
phasing(data, index, auto=True, fn='peak_minima', p0=0.0, p1=0.0)
bline(X: pd.DataFrame, lam: float=10000000.0, max_iter: int=30)
Baseline correction for 1D NMR spectra using asymmetric least squares (ALS).
Parameters: X (pd.DataFrame): DataFrame where rows are spectra, columns are PPM values. lam (float): Smoothing parameter (lambda). Higher = smoother baseline. max_iter (int): Max iterations for ALS.
Returns: pd.DataFrame: Baseline-corrected spectra (same shape as input).
calibrate(X, ppm, calib_type='tsp', custom_range=None)
Calibrate chemical shifts in NMR spectra using known reference peaks.
Parameters: X (np.ndarray or pd.DataFrame): NMR data matrix (rows: spectra, columns: PPM positions). ppm (np.ndarray): 1D array of chemical shift values. calib_type (str): 'tsp', 'glucose', 'alanine', or 'custom'. custom_range (tuple): Optional (start, end) PPM range for custom calibration.
Returns: pd.DataFrame: Calibrated NMR data matrix.