metbit.nmr_preprocess
NMR and preprocessing module in metbit 8.6.0.
import metbit.nmr_preprocessClasses
nmr_preprocessing
A class for preprocessing NMR data. This class handles the following preprocessing steps: 1. Reading FID files 2. Zero-filling 3. Fourier Transform 4. Phasing 5. Baseline correction 6. Calibration 7. Data storage in a pandas DataFrame 8. Data visualization 9. Data export
Parameters:
data_pathstrPath to the directory containing FID files.
bin_sizefloatSize of the bins for zero-filling (default: 0.0003).
auto_phasingboolIf True, automatic phasing is applied (default: True).
fn_strFunction name for phasing (default: 'acme').
baseline_correctionboolIf True, baseline correction is applied (default: True).
baseline_typestrType of baseline correction to apply (default: 'linear').
Options'corrector', 'constant', 'explicit', 'median', 'solvent filter'.calibrationboolIf True, calibration is applied (default: True).
calib_typestrType of calibration to apply (default: 'tsp').
Options'tsp', 'acetate', 'glucose', 'alanine', 'formate'.custom_rangetupleOptional (start, end) PPM range for custom calibration.
export_pathstrPath to save the processed data (default: None).
export_formatstrFormat to save the processed data (default: 'csv').
export_namestrName of the exported file (default: 'processed_nmr_data').
Attributes:
nmr_datapd.DataFrameProcessed NMR data.
ppmnp.ndarrayPPM scale.
dic_arraydictDictionary containing metadata from the FID files.
phase_datapd.DataFrameDataFrame containing phase information.
Methods:
get_data() : pd.DataFrame Returns the processed NMR data. get_ppm() : np.ndarray Returns the PPM scale. get_metadata() : dict Returns the metadata from the FID files. get_phase() : pd.DataFrame Returns the phase information. plot_data() : None Plots the processed NMR data. export_data() : None Exports the processed NMR data to a specified format.
Example:
>>> fid = 'dev/launch/data/test_nmr_data' >>> nmr = nmr_preprocessing(fid, bin_size=0.0005, auto_phasing=False, fn_='acme', baseline_correction=True, baseline_type='corrector', calibration=True, calib_type='glucose') >>> data = nmr.get_data() >>> ppm = nmr.get_ppm() >>> metadata = nmr.get_metadata()