nmrdenoise 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nmrdenoise
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A Python API for deep learning-based NMR denoising
5
5
  Author: Kinkini
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nmrdenoise"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  authors = [
9
9
  { name="Kinkini"},
10
10
  ]
@@ -1,4 +1,4 @@
1
1
  # src/nmrdenoise/__init__.py
2
2
  from .core import read_bruker, load_denoising_checkpoint, denoise_component, Autoencoder, Desperate
3
3
 
4
- __version__ = "0.2.0"
4
+ __version__ = "0.2.2"
@@ -258,19 +258,19 @@ class Desperate:
258
258
  ### from each using the chosen thresholding method
259
259
  for i in range(len(coeffs)):
260
260
  temp = coeffs[i]
261
- lam = calc_lamb(temp[0], region_spec) #lam comes from approx. component
261
+ lam = self.calc_lamb(temp[0], region_spec) #lam comes from approx. component
262
262
  if threshold == 'soft':
263
- fincomp0 = soft_threshold(temp[0], lam)
264
- fincomp1 = soft_threshold(temp[1], lam)
263
+ fincomp0 = self.soft_threshold(temp[0], lam)
264
+ fincomp1 = self.soft_threshold(temp[1], lam)
265
265
  if threshold == 'hard':
266
- fincomp0 = hard_threshold(temp[0], lam)
267
- fincomp1 = hard_threshold(temp[1], lam)
266
+ fincomp0 = self.hard_threshold(temp[0], lam)
267
+ fincomp1 = self.hard_threshold(temp[1], lam)
268
268
  if threshold == 'mod':
269
- fincomp0 = mod_thresh(temp[0], lam, alpha)
270
- fincomp1 = mod_thresh(temp[1], lam, alpha)
269
+ fincomp0 = self.mod_thresh(temp[0], lam, alpha)
270
+ fincomp1 = self.mod_thresh(temp[1], lam, alpha)
271
271
  if threshold == 'gar':
272
- fincomp0 = gar_threshold(temp[0], lam)
273
- fincomp1 = gar_threshold(temp[1], lam)
272
+ fincomp0 = self.gar_threshold(temp[0], lam)
273
+ fincomp1 = self.gar_threshold(temp[1], lam)
274
274
  coeffs[i] = (fincomp0, fincomp1)
275
275
  #print('Lambda = %5.3f'%lam)
276
276
  final = pywt.iswt(coeffs, wave) #recontrusct the final denoised spectrum
@@ -287,12 +287,12 @@ class Desperate:
287
287
  coeffin = np.copy(coeffs)
288
288
  for i in range(len(coeffs)):
289
289
  temp = coeffs[i]
290
- lam = calc_lamb(temp[0], region_spec) #lam comes from approx. component
290
+ lam = self.calc_lamb(temp[0], region_spec) #lam comes from approx. component
291
291
  if threshold == 'mod':
292
- fincomp0 = mod_thresh(temp[0], lam, alpha)
293
- fincomp1 = mod_thresh(temp[1][0], lam, alpha)
294
- fincomp2 = mod_thresh(temp[1][1], lam, alpha)
295
- fincomp3 = mod_thresh(temp[1][2], lam, alpha)
292
+ fincomp0 = self.mod_thresh(temp[0], lam, alpha)
293
+ fincomp1 = self.mod_thresh(temp[1][0], lam, alpha)
294
+ fincomp2 = self.mod_thresh(temp[1][1], lam, alpha)
295
+ fincomp3 = self.mod_thresh(temp[1][2], lam, alpha)
296
296
  coeffs[i] = (fincomp0, (fincomp1, fincomp2, fincomp3))
297
297
 
298
298
  final = pywt.iswt2(coeffs, wave)
@@ -330,14 +330,14 @@ class Desperate:
330
330
  lam = sig*np.sqrt(2*np.log(len(data)))
331
331
  return lam
332
332
 
333
- def hard_threshold(data, lam):
333
+ def hard_threshold(self, data, lam):
334
334
  """Hard Thresholding"""
335
335
  data_thr = np.copy(data)
336
336
  neg_idx = np.where(np.abs(data) < lam)
337
337
  data_thr[neg_idx] = 0
338
338
  return data_thr
339
339
 
340
- def soft_threshold(data, lam):
340
+ def soft_threshold(self, data, lam):
341
341
  """Soft Thresholding"""
342
342
  data_thr = np.copy(data)
343
343
  pos_idx = np.where(data > lam)
@@ -348,7 +348,7 @@ class Desperate:
348
348
  data_thr[neg_idx] = data[neg_idx] + lam
349
349
  return data_thr
350
350
 
351
- def mod_thresh(data, lam, alpha):
351
+ def mod_thresh(self, data, lam, alpha):
352
352
  """Modified thresholding using algorithm in:
353
353
  Wang and Dai, Proceedings of the 2018 International Symposium
354
354
  on Communication Engineering & Computer Science (CECS 2018), 2018, 481"""
@@ -359,7 +359,7 @@ class Desperate:
359
359
  data_thr[neg_idx] = (1-alpha)*(data[neg_idx]**5/lam**4)
360
360
  return data_thr
361
361
 
362
- def gar_threshold(data, lam):
362
+ def gar_threshold(self, data, lam):
363
363
  "garrote thresholding"
364
364
  data_thr = np.copy(data)
365
365
  pos_idx = np.where(np.abs(data) > lam)
@@ -368,7 +368,7 @@ class Desperate:
368
368
  data_thr[neg_idx] = 0
369
369
  return data_thr
370
370
 
371
- def consecutive(data, stepsize=1):
371
+ def consecutive(self, data, stepsize=1):
372
372
  """"
373
373
  basic function to blocks of consecutive number in an array
374
374
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nmrdenoise
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A Python API for deep learning-based NMR denoising
5
5
  Author: Kinkini
6
6
  Classifier: Programming Language :: Python :: 3
File without changes
File without changes