PySpectrum is a Python package for spectral analyses:
- sampling rate conversion and its potential aliasing artifacts;
- spectral rescaling and spectral peak detection by robust log-log linear regression.
PySpectrum is distributed under the open source 3-clause BSD license.
In signal processing, sample-rate conversion (SRC) (also called resampling) is the process of changing the sampling rate of a discrete signal: downsampling or upsampling. SRC can generate aliasing artifacts when Nyquist–Shannon sampling theorem is not respected.
This module implements several functions to complete the Signal processing module of SciPy:
downsample
andupsample
for multidimensional arrays,upiirdn
the scipy.signal.upfirdn counterpart for IIR filtering, allowing fractional downsampling in sample domain contrary to scipy.signal.decimate.
Image downsampled without anti-aliasing filter shows aliasing artifacts. This kind of downsampling is present in max-pooling, strided-convolution and more generally in strided-layers. These architectural components are widely used in convolutional neural networks like ResNets, DenseNets, MobileNets, degrading performances in terms of shift-invariance and classification accuracy.
See examples\downsample_img.py
for the complete analysis.
Time series of this example is an electrocardiogram (ECG) signal, downsampled from 360 Hz to 180 Hz. Signal downsampled without anti-aliasing filter shows aliasing artifacts, ie. a huge artifact peak at 80 Hz. This kind of downsampling can be present in quickly coded drivers.
See examples\downsample_ecg.py
for the complete analysis.
This module implements several functions:
rescale
to rescale spectra using a robust log-log linear regression,detect_peak
to detect peak on spectra following a power law.
Many analyses require a normalization / standardization step of spectra, to remove inter-spectra variabilities.
See examples\rescale_simulated.py
for the complete analysis.
Automatic detection of alpha peak in the spectrum of an electroencephalogram (EEG), compared to peak finders provided by SciPy and MNE-Python.
See examples\find_peak_eeg.py
for the complete analysis.
To install PySpectrum as a standard module:
pip install path/to/PySpectrum
To install PySpectrum in editable / development mode, in the folder:
pip install poetry
poetry install
Use pytest
.