From 116b0859bb19ec07068f03ad5ad3d6c25412662e Mon Sep 17 00:00:00 2001 From: Christian Ludwig Date: Fri, 29 Sep 2023 18:24:05 +0100 Subject: [PATCH] fixed documentation for pypi release; v. 0.9.11 --- metabolabpy/__init__.py | 2 +- metabolabpy/nmr/nmrData.py | 16 ++++++++++------ metabolabpy/nmr/nmrDataSet.py | 18 ++++++++++++++++++ metabolabpy/nmr/procPars.py | 31 +++++++++++++++++++++++++------ upload_pypi.sh | 8 +------- 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/metabolabpy/__init__.py b/metabolabpy/__init__.py index ea28bdd..a2687a9 100644 --- a/metabolabpy/__init__.py +++ b/metabolabpy/__init__.py @@ -1,4 +1,4 @@ __author__ = 'Christian Ludwig (C.Ludwig@bham.ac.uk)' __credits__ = 'Christian Ludwig (C.Ludwig@bham.ac.uk)' -__version__ = '0.9.9' +__version__ = '0.9.11' __license__ = 'GPLv3' diff --git a/metabolabpy/nmr/nmrData.py b/metabolabpy/nmr/nmrData.py index 1b3d615..8b66ded 100644 --- a/metabolabpy/nmr/nmrData.py +++ b/metabolabpy/nmr/nmrData.py @@ -343,7 +343,7 @@ def autobaseline1d(self, lam=1e6, alg='rolling_ball', max_iter=50, alpha=0.1, be if alg == 'irsqr': baseline_fitter = Baseline(spc, check_finite=False) baseline, params = baseline_fitter.irsqr(spc, lam=lam, quantile=quantile) # poly_order=poly_order, method='imodpoly') - if alg == 'airpls': + if alg == 'irsqr': baseline_fitter = Baseline(spc, check_finite=False) baseline, params = baseline_fitter.airpls(spc, 1e5) # poly_order=poly_order, method='imodpoly') #baseline = airpls(spc, lam=lam, max_iter=max_iter) @@ -386,11 +386,8 @@ def autobaseline1d(self, lam=1e6, alg='rolling_ball', max_iter=50, alpha=0.1, be elif alg == 'noise_median': baseline = noise_median(spc) elif alg == 'snip': - print('111111') baseline_fitter = Baseline(spc, check_finite=False) - print('222222') baseline, params = baseline_fitter.snip(spc, 32, decreasing=True, extrapolating_window=34, smooth_window=8) - print(f'len(spc): {len(spc)}, len(baseline): {len(baseline)}') elif alg == 'adaptive_minimax': baseline_fitter = Baseline(spc, check_finite=False) poly_order = 4 @@ -810,7 +807,7 @@ def conv(self, fid): win[k] = math.cos((math.pi * (k - ws2)) / (2 * ws2 + 2)) s_win += win[k] - fid2 = np.convolve(win, fid) / s_win + fid2 = np.convolve(fid, win) / s_win # Extrapolation of first sw2 data points idx = np.linspace(2 * ws2 - 1, 0, 2 * ws2, dtype='int') idx2 = np.linspace(0, 2 * ws2 - 1, 2 * ws2, dtype='int') @@ -1279,6 +1276,12 @@ def proc_spc1d(self, reset_spline=False): def proc_spc2d(self, test_quad_2d=False, no_abs=False): fid = np.copy(self.fid) + if self.proc.n_points[0] < len(fid[0]): + self.proc.n_points[0] = len(fid[0]) + + if self.proc.n_points[1] < len(fid): + self.proc.n_points[1] = len(fid) + if self.proc.mult_factor[0] == 0: self.proc.mult_factor[0] = self.proc.n_points[0] / len(self.fid[0]) @@ -2298,7 +2301,8 @@ def wavewat(self, fid): fida = np.zeros(2*npts2, dtype='complex128') fida[npts2:npts2 + npts - gd] = fid[gd:] fida[npts2 - npts +gd:npts2] = np.flip(fid[gd:]) - fid2 = pywt.mra(data=fida, wavelet=self.proc.ww_wavelet, transform='dwt') + ww_wavelet = self.proc.ww_wavelet_type + self.proc.ww_wavelet_type_number + fid2 = pywt.mra(data=fida, wavelet=ww_wavelet, transform='dwt') fid3 = np.zeros(2*npts2, dtype='complex128') n_mra = len(fid2) for k in range(self.proc.ww_start, n_mra): diff --git a/metabolabpy/nmr/nmrDataSet.py b/metabolabpy/nmr/nmrDataSet.py index 4b69e37..54c10c4 100644 --- a/metabolabpy/nmr/nmrDataSet.py +++ b/metabolabpy/nmr/nmrDataSet.py @@ -51,6 +51,24 @@ def __init__(self): self.hsqc_spin_sys_connected = True self.data_set_name = '' self.data_set_number = '' + self.baseline_algs = ['irsqr', 'arpls', 'asls', 'aspls', 'derpsalsa', 'drpls', 'iarpls', 'iasls', 'psalsa', 'mpls', + 'mor', 'imor', 'mormol', 'amormol', 'rolling_ball', 'mwmv', 'tophat', 'mpspline', 'jbcd', + 'noise_median', 'snip', 'adaptive_minimax', 'swima', 'ipsa', 'ria', 'dietrich', + 'std_distribution', 'fastchrom', 'cwt_br', 'fabc', 'beads', 'poly', 'modpoly', 'imodpoly', + 'penalized_poly', 'quant_reg', 'goldindec', ] + self.default_baseline_alg = 'rolling_ball' + self.default_lam = 1e5 + self.default_max_iter = 50 + self.default_alpha = 0.1 + self.default_beta = 10 + self.default_gamma = 15 + self.default_beta_mult = 0.98 + self.default_gamma_mult = 0.94 + self.default_half_window = 4096 + self.default_smooth_half_window = 16 + self.default_quantile = 0.3 + self.default_poly_order = 4 + self.default_add_ext = 2 # end __init__ def add_peak(self, start_end=np.array([], dtype='float64'), peak_label=''): diff --git a/metabolabpy/nmr/procPars.py b/metabolabpy/nmr/procPars.py index 93632b7..69f3dbb 100644 --- a/metabolabpy/nmr/procPars.py +++ b/metabolabpy/nmr/procPars.py @@ -30,7 +30,7 @@ def __init__(self): self.ssb = np.array([0.0, 0.0, 0.0]) self.axis_nucleus = np.array([' ', ' ', ' '], dtype='str') self.aunmp = str('') - self.poly_order = 4 + self.poly_order = 24 self.water_suppression = 0 self.gibbs = np.array([True, True, False]) self.conv_extrapolation_size = np.array([32, 0, 0]) @@ -92,22 +92,41 @@ def __init__(self): "Wavewat": 3 } self.data_type = '' - self.autobaseline_alg = 'jbcd' - self.autobaseline_lam = 1e6 + self.autobaseline_alg = 'rolling_ball' + self.autobaseline_lam = 1e5 self.autobaseline_max_iter = 50 self.autobaseline_alpha = 0.1 self.autobaseline_beta = 10 self.autobaseline_gamma = 15 self.autobaseline_beta_mult = 0.98 self.autobaseline_gamma_mult = 0.94 - self.autobaseline_half_window = None + self.autobaseline_half_window = 4096 self.autobaseline_quantile = 0.3 self.autobaseline_poly_order = 4 - self.autobaseline_smooth_half_window = 32 + self.autobaseline_smooth_half_window = 16 self.autobaseline_add_ext = 2 self.ww_start = 9 self.ww_zf = 16 - self.ww_wavelet = 'rbio6.8' + self.ww_wavelet_type = 'db' + self.ww_wavelet_type_number = '10' + self.ww_wavelet_number = 11 + self.wavelet_names = ['bior', 'coif', 'db', 'dmey', 'haar', 'rbio', 'sym'] + self.wavelet_numbers = { + 'bior': ['1.1', '1.3', '1.5', '2.2', '2.4', '2.6', '2.8', '3.1', '3.3', '3.5', '3.7', '3.9', '4.4', '5.5', + '6.8'], 'cgau': ['1', '2', '3', '4', '5', '6', '7', '8'], + 'coif': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17'], + 'db': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', + '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', + '36', '37', '38'], 'dmey': [''], 'haar': [''], + 'rbio': ['1.1', '1.3', '1.5', '2.2', '2.4', '2.6', '2.8', '3.1', '3.3', '3.5', '3.7', '3.9', '4.4', '5.5', + '6.8'], + 'sym': ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', + '20']} + self.wavelet_default = {'bior': 11, 'coif': 11, 'db': 9, 'dmey': 0, + 'haar': 0, 'rbio': 11, 'sym': 7} + self.wavelet_start_default = {'bior': 9, 'coif': 7, 'db': 9, 'dmey': 7, + 'haar': 7, 'rbio': 9, 'sym': 9} + # end __init__ def __str__(self): # pragma: no cover diff --git a/upload_pypi.sh b/upload_pypi.sh index b544d4d..4584973 100755 --- a/upload_pypi.sh +++ b/upload_pypi.sh @@ -1,10 +1,4 @@ #!/bin/bash -conda activate pypi -python setup.py sdist -twine upload --repository-url https://test.pypi.org/legacy/ dist/* -#pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple metabolabpy==0.6.1 - -conda deactivate -#comment +twine upload -u __token__ -p $ml_token $1