The Denoising algorithm is essentially derived from singular value decomposition (SVD). By first constructing a partial circulant matrix using the spectral data, the noise components are discriminated after SVD of the matrix. A smoother spectrum is reconstructed from a low-rank approximation of the matrix using only the signal components.
The code is completely written in Python
, with numerical support by the standard packages SciPy
and NumPy
.
It offers two operational modes, i.e., layman and expert.
In the layman mode, the code works out-of-the-box once a user has fed with an input spectrum.
Afterwards, it will autonomously produce the optimal smoothed spectrum.
Whereas with the expert mode, the user owns full control of the code.
He/She is able to fine-tune every denoising parameters during the process.
This can especially be useful in certain scenarios, e.g., debugging.
Python 3
SciPy
,NumPy
Matplotlib
(optional, only if visualization is needed)
class Denoiser(mode = "layman"|"expert")
- mode: current running mode
- s: singular values
- U: left singular vectors
- r: rank of the approximating matrix
denoise(sequence, layer, gap, rank)
- arguments
- sequence: noisy data sequence
- layer: number of rows of the constructed matrix
- gap: (expected only in expert mode) boundary level difference of the sequence, right - left
- rank: (expected only in expert mode) rank of the approximating matrix
- return
- denoised: smoothed sequence
Imagine now a clean sinc signal is corrupted by an additive Gaussian white noise, which results in a noisy sequence of length 5000
.
To denoise the sequence, we just need two lines.
denoiser = Denoiser() # instantiate the class
denoised_sequence = denoiser.denoise(sequence, 1000) # 1000 defines the number of rows of the constructed matrix
The denoising performance at different signal-to-noise ratios (SNRs) is demonstrated in the figure below. Note that when the noise is absent, the signal is perfectly restored. When the signal is absent, the noise mean is returned, which agrees with one's intuition.
X.C. Chen et al., Phys. Rev. E 99, 063320 (2019).
An Open Access is kindly provided by the University of Groningen.
This repository is licensed under the GNU GPLv3.