Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jinglescode/python-signal-processing
splearn: package for signal processing and machine learning with Python. Contains tutorials on understanding and applying signal processing.
https://github.com/jinglescode/python-signal-processing
machine-learning numpy python python-tutorial pytorch pytorch-tutorial scipy sequence signal-processing
Last synced: about 1 month ago
JSON representation
splearn: package for signal processing and machine learning with Python. Contains tutorials on understanding and applying signal processing.
- Host: GitHub
- URL: https://github.com/jinglescode/python-signal-processing
- Owner: jinglescode
- License: bsd-3-clause
- Created: 2020-11-30T02:00:51.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-16T09:05:55.000Z (over 2 years ago)
- Last Synced: 2024-10-31T08:42:07.718Z (about 2 months ago)
- Topics: machine-learning, numpy, python, python-tutorial, pytorch, pytorch-tutorial, scipy, sequence, signal-processing
- Language: Jupyter Notebook
- Homepage:
- Size: 24.9 MB
- Stars: 63
- Watchers: 3
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-datascience - Tutorials to get started on signal processing for machine learning
README
# Python Signal Processing [![Awesome](https://awesome.re/badge.svg)](https://awesome.re)
This repository contains tutorials on understanding and applying signal processing using NumPy and PyTorch.
**splearn** is a package for signal processing and machine learning with Python. It is built on top of [NumPy](https://numpy.org) and [SciPy](https://www.scipy.org), to provide easy to use functions from common signal processing tasks to machine learning.
## Contents
- [Tutorials](#tutorials)
- [Getting Started](#getting-started)
- [Datasets](#datasets)
- [Methods](#methods)---
## Tutorials
Signal processing can be daunting; we aim to bridge the gap for anyone who are new signal processings to get started, check out the [tutorials](https://github.com/jinglescode/python-signal-processing/tree/main/tutorials) to get started on signal processings.
### 1. Signal composition (time, sampling rate and frequency)
In order to begin the signal processing adventure, we need to understand what we are dealing with. In the first tutorial, we will uncover what is a signal, and what it is made up of. We will look at how the sampling rate and frequency can affect a signal. We will also see what happens when we combine multiple signals of different frequencies.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Signal%20composition%20-%20time%2C%20sampling%20rate%20and%20frequency.ipynb)
### 2. Fourier Transform
Now we know what are signals made of and we learned that combining multiple signals of various frequencies will jumbled up all the frequencies. In this tutorial, we will learn about Fourier Transform and how it can take a complex signal and decompose it to the frequencies that made it up.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Fourier%20Transform.ipynb)
### 3. Denoising with mean-smooth filter
We know that signals can be noisy, and this tutorial will focus on removing these noise. We learn to apply the simplest filter to perform denoising, the running mean filter. We will also understand what are edge effects.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Denoising%20with%20mean-smooth%20filter.ipynb)
### 4. Denoising with Gaussian-smooth filter
Next, we will look at a slight adaptation of the mean-smooth filter, the Gaussian smoothing filter. This tends to smooth the data to be a bit smoother compared to mean-smooth filter. This does not mean that one is better than the other, it depends on the specific applications. So, it is important to be aware of different filters type and how to use them.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Denoising%20with%20Gaussian-smooth%20filter.ipynb)
### 5. Canonical correlation analysis
Canonical correlation analysis (CCA) is applied to analyze the frequency components of a signal. In this tutorials, we use CCA for feature extraction and classification.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Canonical%20Correlation%20Analysis.ipynb)
### 6. Task-related component analysis
Task-related component analysis (TRCA) is a classification method originally for steady-state visual evoked potentials (SSVEPs) detection.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jinglescode/python-signal-processing/blob/main/tutorials/Task-Related%20Component%20Analysis.ipynb)
---
## Getting Started
### Installation
Currently, this has not been released. Use `git clone`, and install the dependencies:
```
git clone https://github.com/jinglescode/python-signal-processing.git
pip install -r requirements.txt
```Dependencies, see [requirements.txt](https://github.com/jinglescode/python-signal-processing/tree/main/requirements.txt).
### Usage
Let's generate a 2D-signal, sampled at 100-Hz. Design and apply a 4th-order bandpass Butterworth filter with a cutoff frequency between 5-Hz and 20-Hz.
```python
from splearn.data.generate import generate_signal
from splearn.filter.butter import butter_bandpasssignal_2d = generate_signal(
length_seconds=4,
sampling_rate=100,
frequencies=[[4,7,11,17,40, 50],[1, 3]],
plot=True
)signal_2d_filtered = butter_bandpass(
signal=signal_2d,
lowcut=5,
highcut=20,
sampling_rate=100,
type='sos',
order=4,
plot=True,
plot_xlim=[3,20]
)
```See [examples](https://github.com/jinglescode/python-signal-processing/tree/main/examples) for more examples.
---
## Datasets
Some dataset extraction code are provided, see [examples](https://github.com/jinglescode/python-signal-processing/tree/main/examples) to see how to use them.
- [BETA: A Large Benchmark Database Toward SSVEP-BCI Application](https://www.frontiersin.org/articles/10.3389/fnins.2020.00627/full)
- [A Benchmark Dataset for SSVEP-Based Brain–Computer Interfaces](https://ieeexplore.ieee.org/document/7740878)
- [A Comparison Study of Canonical Correlation Analysis Based Methods for Detecting Steady-State Visual Evoked Potentials](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0140703)
- [EEG dataset and OpenBMI toolbox for three BCI paradigms: an investigation into BCI illiteracy.](https://academic.oup.com/gigascience/article/8/5/giz002/5304369)#### Disclaimer on Datasets
We do not host or distribute these datasets, vouch for their quality or fairness, or claim that you have license to use the dataset. It is your responsibility to determine whether you have permission to use the dataset under the dataset's license.
If you're a dataset owner and wish to update any part of it (description, citation, etc.), or do not want your dataset to be included in this library, please get in touch through a GitHub issue. Thanks for your contribution to the ML community!
## Methods
A few methods have been included as they have been tested (within my limited time). They are by no means recommended or exhaustive.
- [Compact-CNN](https://arxiv.org/pdf/1803.04566.pdf)
- [Canonical Correlation Analysis (CCA)](http://en.wikipedia.org/wiki/Canonical_correlation)
- [Task-Related Component Analysis (TRCA)](https://ieeexplore.ieee.org/document/7904641)
- [Multi-Task SSVEP](https://jinglescode.github.io/ssvep-multi-task-learning/)
- [Convolutional correlation analysis for enhancing the performance of SSVEP-based brain-computer interface](https://ieeexplore.ieee.org/abstract/document/9261605/)
- [Time-domain-based CNN method (tCNN)](https://ieeexplore.ieee.org/abstract/document/9632600)If you wish to include your model, you are welcome to do so via pull request. Do check out how other models are implemented for reference. PyTorch models and sklearn/numpy methods only.