End-to-end NMR metabolomics preprocessing, modeling, and visualization in Python.
Install from PyPI, process Bruker FID folders, normalize and align spectra, fit PCA or OPLS-DA models, then inspect interactive Plotly outputs.
Install & Quick StartBrowse API
Read Bruker data, preprocess spectra, normalize intensities, calibrate shifts, and align peaks.
Fit PCA/OPLS-DA models, cross-validate and compute VIP scores.
Generate model plots, STOCSY exploration tools, peak-picking interfaces, and annotation helpers.
pip install metbit
from metbit import nmr_preprocessing, Normalization, pca
# Path to a Bruker project folder containing sample subfolders with "fid"
fid_dir = 'path/to/bruker_project'
# Preprocess NMR data: FFT, phasing, baseline correction, calibration
nmr = nmr_preprocessing(
fid_dir,
bin_size=0.0005,
auto_phasing=True,
baseline_correction=True,
baseline_type='corrector',
calibration=True,
calib_type='tsp',
)
# Get processed matrix and ppm axis
X = nmr.get_data() # pandas.DataFrame (samples x ppm)
ppm = nmr.get_ppm() # numpy.ndarray
# Normalize and fit PCA
X_norm = Normalization.pqn_normalization(X)
model = pca(X=X_norm, features_name=ppm, n_components=2)
model.fit()
model.plot_pca_scores().show()