Skip to main content

SOUND & SSP-SIR algorithms for TMS-EEG artifact cleaning (MNE + MATLAB Engine)

Project description

pytep — Python TMS-EEG Processing

SOUND and SSP-SIR algorithms for TMS-EEG artifact cleaning, bridging MNE-Python and MATLAB Engine.

Requirements

  • Python ≥ 3.11
  • MATLAB (with a valid license)
  • MATLAB Engine for Python (matlabengine)
  • MNE-Python

Installation

# From the repository root
pip install -e .

# With notebook extras (jupyter, matplotlib, etc.)
pip install -e ".[notebooks]"

Quick Start

SOUND (Mutanen et al., 2018)

import mne
from pytep import apply_sound

# Load your data
raw = mne.io.read_raw_edf("your_data.edf", preload=True)
raw.set_montage("standard_1020")

# Apply SOUND
raw_clean = apply_sound(raw, iter_num=5, lambda_val=0.1)

SSP-SIR (Mutanen et al., 2016)

import mne
from pytep import apply_sspsir

# Load epoched data
epochs = mne.read_epochs("your_epochs-epo.fif", preload=True)

# Apply SSP-SIR
epochs_clean = apply_sspsir(epochs, pc=2, art_scale='automatic')

Sharing a MATLAB Engine session

import matlab.engine
from pytep import apply_sound, apply_sspsir

eng = matlab.engine.start_matlab()

raw_clean = apply_sound(raw, eng=eng)
epochs_clean = apply_sspsir(epochs, eng=eng, pc=2)

eng.quit()

API Reference

apply_sound(inst, eng=None, iter_num=5, lambda_val=0.1)

Parameter Type Description
inst Raw/Epochs MNE object with EEG data (montage required)
eng MatlabEngine Existing MATLAB session (optional)
iter_num int Number of SOUND iterations (default: 5)
lambda_val float Regularization parameter (default: 0.1)

apply_sspsir(inst, eng=None, art_scale='automatic', time_range=None, pc=1, M=None)

Parameter Type Description
inst Epochs Epoched MNE data (montage required)
eng MatlabEngine Existing MATLAB session (optional)
art_scale str 'automatic', 'manual', or 'manualConstant'
time_range list[float] [start_ms, end_ms] artifact window
pc int Number of artifact PCs to remove (default: 1)
M int/None SIR truncation dimension

References

  • SOUND: Mutanen, T. P., et al. (2018). Automatic and robust noise suppression in EEG and MEG: The SOUND algorithm. NeuroImage, 166, 135-151.
  • SSP-SIR: Mutanen, T. P., et al. (2016). Recovering TMS-evoked EEG responses masked by muscle artifacts. NeuroImage, 139, 157-166.

License

MIT

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

pytep_sound_sspsir-0.1.1.tar.gz (201.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytep_sound_sspsir-0.1.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file pytep_sound_sspsir-0.1.1.tar.gz.

File metadata

  • Download URL: pytep_sound_sspsir-0.1.1.tar.gz
  • Upload date:
  • Size: 201.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pytep_sound_sspsir-0.1.1.tar.gz
Algorithm Hash digest
SHA256 737bde9691353717de2e3e287e14b2b138a0ab7969e00d235be2f36451aa63e7
MD5 f83ed5ae461621ade911d56c5efcf266
BLAKE2b-256 5292bc372d65b1a05ac9ba006adcca350b0aa62cfd5b3f64ef5b8a84066b8ca1

See more details on using hashes here.

File details

Details for the file pytep_sound_sspsir-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytep_sound_sspsir-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8e3167b4885c8ccc9b7d21d6728f8c03ef9c7592a6d8170fa85814b02929a31
MD5 f9a7db3e12d467cd8bd718f0a8221d92
BLAKE2b-256 fa394317d2afb702d7341f5bfbf9e73e66de9a492a9cb3ff92aadae45bc29420

See more details on using hashes here.

Supported by

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