Skip to main content

Easy digital signal processing

Project description

CI CI

ezDSP: Easy Digital Signal Processing

ezDSP is a digital signal processing toolbox written in PyTorch (./src/ezdsp/nn/). However, ezDSP not only processes torch.tensors (CPU & GPU) but also handles numpy.ndarray and pd.DataFrame, enabling a consistent and intensive workflow.

Installation

$ pip install ezdsp
$ python ./example.py # ./example_outputs/ will be generated.

Samples

Normalization, Resampling, Noise Addition, Filtering, Hilbert Transformation

Wavelet Transformation

Power Spectrum Density

Phase-Amplitude Coupling

fixme

Quick Start

import ezdsp as ed

# Parameters
SRC_FS = 1024  # Source sampling frequency
TGT_FS = 512   # Target sampling frequency
FREQS_HZ = [10, 30, 100]  # Frequencies in Hz
LOW_HZ = 20    # Low frequency for bandpass filter
HIGH_HZ = 50   # High frequency for bandpass filter
SIGMA = 10     # Sigma for Gaussian filter
SIG_TYPES = [
    "uniform",
    "gauss",
    "periodic",
    "chirp",
    "ripple",
    "meg",
    "tensorpac",
] # Available signal types


# Demo Signal
xx, tt, fs = ed.demo_sig(
    t_sec=T_SEC, fs=SRC_FS, freqs_hz=FREQS_HZ, sig_type="chirp"
)
# xx is either of torch.tensor (on cpu / cuda), numpy.ndarray, or pd.DataFrame.

# Normalization
xx_norm = ed.norm.z(xx)
xx_minmax = ed.norm.minmax(xx)

# Resampling
xx_resampled = ed.resample(xx, fs, TGT_FS)

# Noise addition
xx_gauss = ed.add_noise.gauss(xx)
xx_white = ed.add_noise.white(xx)
xx_pink = ed.add_noise.pink(xx)
xx_brown = ed.add_noise.brown(xx)

# Filtering
xx_filted_bandpass = ed.filt.bandpass(xx, fs, low_hz=LOW_HZ, high_hz=HIGH_HZ)
xx_filted_bandstop = ed.filt.bandstop(xx, fs, low_hz=LOW_HZ, high_hz=HIGH_HZ)
xx_filted_gauss = ed.filt.gauss(xx, sigma=SIGMA)

# Hilbert Transformation
phase, amplitude = ed.hilbert(xx) # or envelope

# Wavelet Transformation
wavelet_coef, wavelet_freqs = ed.wavelet(xx, fs)

# Power Spetrum Density
psd, psd_freqs = ed.psd(xx, fs)

# Phase-Amplitude Coupling
pac, freqs_pha, freqs_amp = ed.pac(x_3d, fs) # This function is computationally demanding. Please monitor the RAM/VRAM usage.

Alias

mngs.dsp has the same functionalities.

Contact

Yusuke Watanabe (ywata1989@gmail.com).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezdsp-1.3.2.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

ezdsp-1.3.2-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file ezdsp-1.3.2.tar.gz.

File metadata

  • Download URL: ezdsp-1.3.2.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for ezdsp-1.3.2.tar.gz
Algorithm Hash digest
SHA256 6ba6d8a95b5a02f8379fffb664f3f7521fee5f29b491bf45871b6172c32dcef5
MD5 273e4e19a0d768e952e515170ed5f95f
BLAKE2b-256 6fed840efc763cf64f105ccfc39d781580a660df80f9306995a9fa8f0d12b661

See more details on using hashes here.

File details

Details for the file ezdsp-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: ezdsp-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for ezdsp-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dfc83ba9e8593321a975b90035ab2e78551b9443a3a08d3bf11b1e064fd51b72
MD5 5657a3c8a6aa3cfa467b17f3ac3529d5
BLAKE2b-256 6ffef397733a34e2834b91bbf4c915d3c6f1161bb11332139952d82cab32d9e7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page