Tensorpac 0.6.5
  • Install
  • API
  • Examples
  • Site
      • Installation
        • Requirements
        • Standard installation
        • Install the most up-to-date version
      • API
        • Compute phase-amplitude coupling
          • tensorpac.Pac
          • tensorpac.EventRelatedPac
          • tensorpac.PreferredPhase
        • Utility functions
          • tensorpac.utils.PSD
          • tensorpac.utils.ITC
          • tensorpac.utils.BinAmplitude
          • tensorpac.utils.PeakLockedTF
          • tensorpac.utils.pac_vec
          • tensorpac.utils.pac_trivec
        • Generate synthetic signals
          • tensorpac.signals.pac_signals_wavelet
          • tensorpac.signals.pac_signals_tort
        • Statistics
          • tensorpac.stats.test_stationarity
        • Individual methods
          • PAC methods
            • Tensor-based implementation
              • tensorpac.methods.mean_vector_length
              • tensorpac.methods.modulation_index
              • tensorpac.methods.heights_ratio
              • tensorpac.methods.norm_direct_pac
              • tensorpac.methods.phase_locking_value
              • tensorpac.methods.gauss_cop_pac
            • Numba-based implementation
              • tensorpac.methods.mean_vector_length_nb
              • tensorpac.methods.modulation_index_nb
              • tensorpac.methods.heights_ratio_nb
              • tensorpac.methods.norm_direct_pac_nb
              • tensorpac.methods.phase_locking_value_nb
          • Event Related PAC methods
            • tensorpac.methods.erpac
            • tensorpac.methods.ergcpac
          • Preferred phase
            • tensorpac.methods.preferred_phase
          • Surrogates methods
            • tensorpac.methods.swap_pha_amp
            • tensorpac.methods.swap_blocks
            • tensorpac.methods.time_lag
          • Normalization
            • tensorpac.methods.normalize
      • Examples
        • Tutorials
          • Phase-Amplitude Coupling tutorial on sEEG data
            • Download the data
            • Plot the raw data
            • Compute and plot Inter Trial Coherence
            • Compute and plot the Power Spectrum Density
            • Compute and plot the Event-Related PAC
            • Align time-frequency map based on alpha phase peak
            • Compute and compare PAC that is occurring during rest, planning and execution
            • Test if the alpha-gamma PAC is significant during motor planning
            • Binning gamma amplitude according to alpha phase
            • Identify the preferred phase
        • Phase-Amplitude coupling
          • README example
          • Comparison of the implemented PAC methods
            • Simulate artificial coupling
            • Extract phases and amplitudes
            • Compute, plot and compare PAC
          • Compare methods to correct PAC for spurious coupling
            • Simulate artificial coupling
            • Extract phases and amplitudes
            • Compute PAC and surrogates
          • Compare normalization types
            • Simulate artificial coupling
            • Extract phases and amplitudes
            • Recompute PAC and surrogates and switch the normalization types
          • Compare filtering properties
          • Long-range PAC
        • Event-Related Phase-Amplitude coupling
          • Event-Related Phase Amplitude Coupling
            • Generate a synthetic signal
            • Define an ERPAC object and extract the phase and the amplitude
          • Event-Related Phase Amplitude Coupling
            • Generate a synthetic signal
            • Define an ERPAC object and extract the phase and the amplitude
            • Compute the ERPAC using the two implemented methods and plot it
        • Statistics
          • Comparison of methods for correcting p-values for multiple comparisons
            • Simulate artificial coupling
            • Compute true PAC estimation and surrogates distribution
          • Identify stationary time-series using unit root test
            • Define a random dataset
            • Compute the statistical test
            • Plot each trial
          • Compute and plot the p-values
            • Simulate artificial coupling
            • Compute true PAC estimation and surrogates distribution
          • Compare PAC of two experimental conditions with cluster-based statistics
            • Simulate the data coming from two experimental conditions
            • Compute the single trial PAC on both datasets
            • Correct for multiple-comparisons using a cluster-based approach
            • Plot the significant clusters
        • Miscellaneous
          • Compute and plot the Power Spectrum Density (PSD)
          • Find the optimal bandwidth
          • Bin amplitude according to the phase
          • Align time-frequency representations according to phase peak
            • Simulate artificial coupling
            • Define the peak-locking object and realign TF representations
            • Plotting the realignment
          • Define frequency vectors
          • Compute and plot the Inter-Trial Coherence (ITC)
            • Generate a random data of shape (n_epochs, n_times)
            • Compute and plot the Power Spectrum Density (PSD)
            • Compute and plot the Inter-Trial Coherence (ITC)
          • Generate artificially coupled signals
          • Find the preferred phase (PP)
            • Generate synthetic signals (sake of illustration)
            • Extract phases, amplitudes and compute the preferred phase
            • Plot the preferred phase
      • Authors
      • Contributors
      • Cite Tensorpac
      • Community
        • Report an issue
        • Chat
  • Source

Note

Click here to download the full example code

Event-Related Phase Amplitude Coupling¶

Event-Related Phase-Amplitude Coupling (ERPAC) do not measure PAC across time cycle but instead, across trials (just as proposed JP. Lachaux with the PLV/PLS). Measuring across trials enable to have a real-time estimation of PAC.

In this example, we generate a signal that have a 10hz phase <->100 hz amplitude coupling first followed by a random noise.

import numpy as np

from tensorpac import EventRelatedPac
from tensorpac.signals import pac_signals_wavelet

import matplotlib.pyplot as plt

Generate a synthetic signal¶

in order to illustrate how the ERPAC does works, we are going to concatenate two signals. A first one with an alpha <-> gamma coupling during one second and then a second one which is going to be a one second random noise

# First signal consisting of a one second 10 <-> 100hz coupling
n_epochs = 300
n_times = 1000
sf = 1000.
x1, tvec = pac_signals_wavelet(f_pha=10, f_amp=100, n_epochs=n_epochs,
                               noise=.8, n_times=n_times, sf=sf)

# Second signal : one second of random noise
x2 = np.random.rand(n_epochs, 1000)

# now, concatenate the two signals across the time axis
x = np.concatenate((x1, x2), axis=1)
time = np.arange(x.shape[1]) / sf

Define an ERPAC object and extract the phase and the amplitude¶

use tensorpac.EventRelatedPac.filter method to extract phases and amplitudes

# define an ERPAC object
p = EventRelatedPac(f_pha=[9, 11], f_amp=(60, 140, 5, 1))

# method for correcting p-values for multiple comparisons
mcp = 'bonferroni'
# extract phases and amplitudes
erpac = p.filterfit(sf, x, method='circular', mcp=mcp).squeeze()
# get the p-values and squeeze unused dimensions
pvalues = p.pvalues.squeeze()
# set to nan everywhere it's not significant
erpac[pvalues > .05] = np.nan

vmin, vmax = np.nanmin(erpac), np.nanmax(erpac)

p.pacplot(erpac, time, p.yvec, xlabel='Time (second)',
          cmap='Spectral_r', ylabel='Amplitude frequency', title=p.method,
          cblabel='ERPAC', rmaxis=True, vmin=vmin, vmax=vmax)
plt.axvline(1., linestyle='--', color='k', linewidth=2)

p.show()
../../_images/sphx_glr_plot_erpac_stats_001.png

Total running time of the script: ( 0 minutes 7.979 seconds)

Download Python source code: plot_erpac_stats.py

Download Jupyter notebook: plot_erpac_stats.ipynb

Gallery generated by Sphinx-Gallery


Ban

  • Index
  • ·
  • Github
  • ·
  • Contributors
  • ·
  • Community
  • ·
  • Citation
  • ·
  • References

© Copyright 2019, Etienne Combrisson.