Skip to content

Python package for spectral analyses, looking at sampling rate conversion, spectral rescaling and peak detection.

Notifications You must be signed in to change notification settings

qbarthelemy/PySpectrum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PySpectrum

Code PythonVersion License

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.

Description

Sample-rate conversion (SRC)

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:

2D image

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

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.

Spectral processing

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.

Spectral rescaling

Many analyses require a normalization / standardization step of spectra, to remove inter-spectra variabilities.

See examples\rescale_simulated.py for the complete analysis.

Alpha peak detection in EEG spectrum

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.

Installation

From sources

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

Testing

Use pytest.

About

Python package for spectral analyses, looking at sampling rate conversion, spectral rescaling and peak detection.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages