A (work in progress) module to calculate phase-amplitude coupling in Python.
This code is ALMOST ready for general use.
Not yet uploaded to pypi (...soon). To install:
git clone https://github.com/voytekresearch/pacpy
into the directory of your choice.- At the command line, cd into that choice directory
- and type
pip install .
We assume Anaconda is installed. Tested on Linux (Ubuntu 4.10), OS X (10.10.4), and Windows 9.
The wrapper for MATLAB can be found at, https://github.com/voytekresearch/pacmat
An example of calculating PAC from two simulated voltage signals using the phase-locking value (PLV) method:
>>> import numpy as np
>>> from scipy.signal import hilbert
>>> from pacpy.pac import plv
>>> t = np.arange(0, 10, .001) # Define time array
>>> lo = np.sin(t * 2 * np.pi * 6) # Create low frequency carrier
>>> hi = np.sin(t * 2 * np.pi * 100) # Create modulated oscillation
>>> hi[np.angle(hilbert(lo)) > -np.pi*.5] = 0 # Clip to 1/4 of cycle
>>> plv(lo, hi, (4,8), (80,150)) # Calculate PAC
0.998263840824846