Tensorpac
Phase-Amplitude Coupling under Python
Install / Use
/learn @EtienneCmb/TensorpacREADME
========= Tensorpac
.. image:: https://github.com/EtienneCmb/tensorpac/workflows/Tensorpac/badge.svg :target: https://github.com/EtienneCmb/tensorpac/workflows/Tensorpac
.. image:: https://travis-ci.org/EtienneCmb/tensorpac.svg?branch=master :target: https://travis-ci.org/EtienneCmb/tensorpac
.. image:: https://circleci.com/gh/EtienneCmb/tensorpac/tree/master.svg?style=svg :target: https://circleci.com/gh/EtienneCmb/tensorpac/tree/master
.. image:: https://ci.appveyor.com/api/projects/status/0arxtw05583gc3e2/branch/master?svg=true :target: https://ci.appveyor.com/project/EtienneCmb/tensorpac/branch/master
.. image:: https://codecov.io/gh/EtienneCmb/tensorpac/branch/master/graph/badge.svg :target: https://codecov.io/gh/EtienneCmb/tensorpac
.. image:: https://badge.fury.io/py/tensorpac.svg :target: https://badge.fury.io/py/tensorpac
.. image:: https://pepy.tech/badge/tensorpac :target: https://pepy.tech/project/tensorpac
.. image:: https://badges.gitter.im/EtienneCmb/tensorpac.svg :target: https://gitter.im/EtienneCmb/tensorpac?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
.. image:: https://zenodo.org/badge/93316276.svg :target: https://zenodo.org/badge/latestdoi/93316276
.. figure:: https://github.com/EtienneCmb/tensorpac/blob/master/docs/source/picture/tp.png :align: center
Description
Tensorpac is an Python open-source toolbox for computing Phase-Amplitude Coupling (PAC) using tensors and parallel computing for an efficient, and highly flexible modular implementation of PAC metrics both known and novel. Check out our documentation <http://etiennecmb.github.io/tensorpac/>_ for details.
Installation
Tensorpac uses NumPy, SciPy and joblib for parallel computing. To get started, just open your terminal and run :
.. code-block:: console
$ pip install tensorpac
Code snippet & illustration
.. code-block:: python
from tensorpac import Pac from tensorpac.signals import pac_signals_tort
Dataset of signals artificially coupled between 10hz and 100hz :
n_epochs = 20 # number of trials n_times = 4000 # number of time points sf = 512. # sampling frequency
Create artificially coupled signals using Tort method :
data, time = pac_signals_tort(f_pha=10, f_amp=100, noise=2, n_epochs=n_epochs, dpha=10, damp=10, sf=sf, n_times=n_times)
Define a Pac object
p = Pac(idpac=(6, 0, 0), f_pha='hres', f_amp='hres')
Filter the data and extract pac
xpac = p.filterfit(sf, data)
plot your Phase-Amplitude Coupling :
p.comodulogram(xpac.mean(-1), cmap='Spectral_r', plotas='contour', ncontours=5, title=r'10hz phase$\Leftrightarrow$100Hz amplitude coupling', fz_title=14, fz_labels=13)
p.show()
.. figure:: https://github.com/EtienneCmb/tensorpac/blob/master/docs/source/picture/readme.png :align: center
Cite Tensorpac
Tensorpac software has been published in PLoS Computational Biology <https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1008302>_
Use the following Bibtex entry to cite it :
.. code-block:: latex
@article{combrisson_tensorpac_2020,
title = {Tensorpac: {An} open-source {Python} toolbox for tensor-based phase-amplitude coupling measurement in electrophysiological brain signals},
volume = {16},
issn = {1553-7358},
shorttitle = {Tensorpac},
doi = {10.1371/journal.pcbi.1008302},
language = {eng},
number = {10},
journal = {PLoS computational biology},
author = {Combrisson, Etienne and Nest, Timothy and Brovelli, Andrea and Ince, Robin A. A. and Soto, Juan L. P. and Guillot, Aymeric and Jerbi, Karim},
month = oct,
year = {2020},
pmid = {33119593},
pmcid = {PMC7654762},
pages = {e1008302},
}
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
