Skip to main content
PLOS Computational Biology logoLink to PLOS Computational Biology
. 2020 Oct 29;16(10):e1008302. doi: 10.1371/journal.pcbi.1008302

Tensorpac: An open-source Python toolbox for tensor-based phase-amplitude coupling measurement in electrophysiological brain signals

Etienne Combrisson 1,2,*, Timothy Nest 1,3, Andrea Brovelli 2, Robin A A Ince 4, Juan L P Soto 5, Aymeric Guillot 6, Karim Jerbi 1,7,8,*
Editor: Dina Schneidman-Duhovny9
PMCID: PMC7654762  PMID: 33119593

Abstract

Despite being the focus of a thriving field of research, the biological mechanisms that underlie information integration in the brain are not yet fully understood. A theory that has gained a lot of traction in recent years suggests that multi-scale integration is regulated by a hierarchy of mutually interacting neural oscillations. In particular, there is accumulating evidence that phase-amplitude coupling (PAC), a specific form of cross-frequency interaction, plays a key role in numerous cognitive processes. Current research in the field is not only hampered by the absence of a gold standard for PAC analysis, but also by the computational costs of running exhaustive computations on large and high-dimensional electrophysiological brain signals. In addition, various signal properties and analyses parameters can lead to spurious PAC. Here, we present Tensorpac, an open-source Python toolbox dedicated to PAC analysis of neurophysiological data. The advantages of Tensorpac include (1) higher computational efficiency thanks to software design that combines tensor computations and parallel computing, (2) the implementation of all most widely used PAC methods in one package, (3) the statistical analysis of PAC measures, and (4) extended PAC visualization capabilities. Tensorpac is distributed under a BSD-3-Clause license and can be launched on any operating system (Linux, OSX and Windows). It can be installed directly via pip or downloaded from Github (https://github.com/EtienneCmb/tensorpac). By making Tensorpac available, we aim to enhance the reproducibility and quality of PAC research, and provide open tools that will accelerate future method development in neuroscience.


This is a PLOS Computational Biology Software paper.

Introduction

The study of electrophysiology is innately challenging due to the immense complexity of oscillatory phenomena organized at many distinct spatial and temporal scales. While common assays for measuring brain function like fMRI are able to considerably reduce the temporal complexity of functional brain dynamics, scientists interested in electrophysiology must grapple with a dizzying array of plausibly meaningful features in the spectral domain. For decades, neuroscientists have sought to isolate cognitive and task-related changes in brain oscillations by examining spectral features such as power, amplitude, and phase across frequencies and brain regions. However, increasing attention has been given to more complex and dynamic properties of neural oscillations [16]. A prominent example of such dynamic oscillatory phenomena is Cross-Frequency Coupling (CFC) [7] which has been observed both at the phase-level [810], and at the amplitude level [1113]. A slightly more recent, and arguably less well characterized phenomenon, Phase-Amplitude Coupling (PAC), provides a metric to identify and quantify synchronization between the phase of low-frequency oscillations and the amplitude of high-frequency oscillations.

Over the last decade, PAC has been shown to mediate a variety of task-related and cognitive functions including attention and decision-making [14, 15], learning and memory [1622], motor and visuomotor tasks [10, 2329], as well as mental disorders such as Parkinson disease and schizophrenia [3037]. It has been proposed that PAC reflects the regulation of high frequency local computations by a larger network, oscillating at lower frequencies [38]. PAC might therefore contribute to coordinate neural activity by using a “hold and release” mechanism of gamma oscillations [29].

In order to quantify PAC, a number of methodologies and implementations have been proposed [14, 35, 3946] and compared [45, 46]. Until now, there is still no gold standard on which method is the best alternative, even though the Modulation Index [46] is probably the most widely adopted due to its noise tolerance and amplitude independence. In addition, it has been shown that PAC can be computed in an event-related manner [47]. Nevertheless, there is still no consensus on the minimal data length (i.e. the number of cycles) that is required or the most appropriate filtering methods [48, 49]. It has also recently been shown that spurious PAC can occur for a variety of reasons that may be difficult to systematically control [48, 5052]. Among them we can mention the absence of a clear peak in the power spectrum density (PSD) of the phase, the choice of the filter bandwidth or the nonstationarity.

To date, a handful of established brain data analysis toolboxes provide built-in functionalities to compute PAC, these include Matlab-based packages such as Fieldtrip [53], Brainstorm [54] and EEGLAB [55]. The open-science Python research community has also proposed a few PAC tools, including pacpy (https://github.com/voytekresearch/pacpy/) or pactools [41], with the latter supporting MNE-Python inputs [56]. While the available tools are extremely valuable, and although some of them provide multiple methods for PAC computation, existing tools do not always include time-resolved PAC measurements and often have limited options for visualization and statistical assessment. In addition, computational time remains a challenge that can severely limit PAC analyses at a time when data dimensionality and data-driven analyses are drastically increasing in neuroscience research.

Here, we present Tensorpac, a cross-platform open-source Python toolbox, distributed under a BSD-3-Clause license, dedicated to the measurement of phase-amplitude relationships. This includes an array of functions to compute PAC and event-related PAC (ERPAC) alongside innovative features such as the estimation of the preferred-phase with polar plotting and exhaustive exploratory analysis across the full frequency space. Tensorpac also ships with additional tools in order to assess the reliability of the estimation such as power spectral density (PSD), Inter-Trial Coherence (ITC) and statistics. Crucially, what distinguishes Tensorpac even more from other available tools, is the combination of parallel computing and tensor-based implementation of the algorithms which drastically reduces computation time and opens up the possibility to compute PAC on large multidimensional arrays.

Design, implementation and results

In principle, estimating PAC consists in quantifying the coupling between slow-wave phase with the amplitude of higher frequency signals. As a bidirectional coupling measure, however, it is impossible to say whether PAC high-amplitude rhythms are led by slow oscillations or the contrary. Accordingly, we denote by f1f2 the PAC between a phase centered in f1 and the amplitude centered in f2.

Estimation of a corrected phase-amplitude coupling

Estimating PAC is usually assessed in four steps, illustrated in Fig 1. First, the instantaneous phases of slower oscillations and amplitudes of faster oscillations are extracted. Second, the true coupling measure between those phases and amplitudes is computed. Third, a null distribution of surrogate values of the measure in the absence of coupling is estimated. This is usually assessed by swapping either amplitude or phase time-blocks, cut at a random time-point. Finally, the true coupling measure is corrected by subtracting the mean and dividing by the standard deviation of the surrogate null distribution. This step improves the robustness and the sensibility of the measure.

Fig 1. Estimation process of a corrected 10↔100hz PAC.

Fig 1

For illustration, here simulated raw data contains a coupling between a 10 hz phase and a 100 hz amplitude. First, the raw data is respectively filtered with bandpass filters centered on 100hz and 10hz. Then, the complex analytic form of each signal is obtained using the Hilbert transform. The phase is extracted from the 10Hz signal (angle of analytic signal) and power from the 100Hz signal (amplitude of analytic signal). An uncorrected PAC measure is obtained from these two signals. To estimate the null distribution of the measure in the absence of any genuine coupling, the amplitude signal is split into two blocks at a random time point and the temporal order of those two blocks is swapped. Then, the PAC is estimated using this swapped version of amplitude and the originally extracted phase. By repeating this process and cutting at a random point, for example 200 times, we can obtain a distribution of surrogate values for which there is no genuine coupling. Finally, a corrected PAC estimate is obtained through z-score normalization of the uncorrected PAC using this distribution.

Generating coupled signals

For the implementation and validation of coupling methods, we used synthetic signals with controllable coupling frequencies. To this end, we included in the toolbox two ways to simulate synthetic signals that can be imported from tensorpac.signals: pac_signals_tort which is a method based on pure sines summation and modulation [46] and pac_signals_wavelet which extract the phase from a random distribution leading to more complex signals [41]. Both methods, illustrated in Fig 2, provide fine-grained control over the coupling frequency pair of (phase, amplitude), the amount of coupling and noise such as data length and sampling frequency.

Fig 2. Synthetic signals to simulate phase-amplitude coupling.

Fig 2

Illustration of synthetic signals that can be generated to simulate phase-amplitude coupling (left column) and associated comodulogram (right column). A: First row shows an example of a signal that contains a 5↔120hz coupling defined as proposed by Tort et al. [46]. B: Bottom signal also contains a 5↔20hz coupling but defined as proposed in Dupré la Tour et al. [41].

Extracting the instantaneous phase and the amplitude

Since there is no consensus about whether the Hilbert or wavelet transforms constitutes a gold standard for extracting the phase and the amplitude, Tensorpac implements both. The Hilbert transform has to be applied on pre-filtered signals. For filtering, we implemented a Python equivalent to the two-way zero-phase lag finite impulse response (FIR) Least-Squares filter implemented in the EEGLAB toolbox [55]. Filter orders are frequency dependent and are defined as a function of the number of cycles (by default 3 cycles are used for the phase and 6 cycles for the amplitude [57]). The phase and the amplitude are respectively obtained by taking the angle and the absolute value of the Hilbert transform applied to the complex analytic filtered signals. Both components can also be obtained by convolving with a Morlet’s wavelets [58] with a default width of 7, a default value broadly used in electrophysiological data analyses.

Implemented PAC methodologies

Here, we describe the main PAC estimation methods currently available in Tensorpac, which include the Mean Vector Length, Modulation Index, Height-Ratio, normalized direct-PAC, phase-locking value and Gaussian-copula PAC (new validated methods will be continually added and documented online). In the following, we denote by x(t) a time-series of length N, fϕ = [fϕ1, fϕ2] and fA = [fA1, fA2] the frequency bands respectively for extracting the phase ϕ(t) and the amplitude a(t).

Mean Vector Length: The Mean Vector Length (MVL) was introduced by Canolty et al. [39] and is defined as the modulus of the average complex vector formed by combining the phase and amplitude signals:

MVL=1N|k=1Na(k)ejϕ(k)| (1)

Note that authors also proposed to normalize the MVL by computing surrogates using a time lag.

Modulation Index: Originally the Kullback-Leibler distance is used in information theory to measure dissimilarities between two probability distributions. Tort et al. 2010 [46] elegantly proposed an adaptation for measuring PAC which consists of defining a probability distribution of amplitudes as a function of phase and then comparing this distribution to a uniform one. To this end, the phase ϕ(t) is first cut into n slices. For example, if n = 18, the phase is binned into 18 bins of 20° each. Then, the mean of the amplitude a(t) is taken inside each bin and is denoted by 〈a(t)〉ϕ. Through this binning operation, the phase and the amplitude are linked and can be said to be coupled. Finally, the probability distribution P is obtained by dividing the amplitude inside each bin by the sum over the bins:

P(j)=aϕ(j)k=1naϕ(k) (2)

where ∀j ∈ ⟦1, n⟧, P(j) represent the normalized amplitude inside a bin. This distribution is then used to compute PAC using either the modulation index either the heights ratio.

The modulation index (MI) is obtained using Kullback-Leibler distance which measure how the probability distribution of amplitudes P diverges from a uniform distribution Q:

MI=DKL(P,Q)log(n) (3)

where

DKL(P,Q)=k=1nP(k)log(P(k)Q(k)) (4)

Note that for a uniform distribution, ∀k ∈ ⟦1, n⟧, Q(k) = 1/n and therefore the MI formula can be written to:

MI=1+1log(n)k=1nP(k)log(P(k)) (5)

Heights Ratio: Starting from the same probability density distribution of amplitudes, the Heights Ratio (HR) [42] is defined by:

MI=hmax-hminhmax (6)

where hmax and hmin are respectively the maximum and the minimum of the distribution.

Normalized direct PAC: The ndPac [59] is similar to the MVL with two exceptions. First, this method uses a z-scored normalized amplitude and secondly, includes a statistical test. This test uses a closed-form statistical threshold given by:

xth=2×N×(erf-1(1-p))2 (7)

With p the confidence level, N the number of time points and erf−1 the inverse error function. In order to find this threshold, the amplitude is assumed to be normally distributed (zero mean and unit variance) and the phase is assumed to be uniformly distributed between −π and π. To this end, the mean and deviation across time points of the amplitude are used to perform a z-score normalization in order to approximate the original assumptions. Finally, every value of coupling exceeding this threshold is considered as reliable, at a given confidence level. Otherwise, if the value of coupling is below this threshold it is set to zero.

Phase-Locking Value: The phase-locking value (PLV) [45, 60] looks only at the phase consistency across trials. The PLV consists of extracting the phase of the amplitude ϕa, subtracting it from the phase of slower oscillations, projecting the resultant time series into the complex circle and finally, calculating the mean of the length vector:

PLV=1N|k=1Nej(ϕ(k)-ϕa(k))| (8)

Gaussian-Copula PAC: Mutual Information (MI) can be used to quantify pairwise statistical dependence between many different types of variables on a common and meaningful effect size scale (bits) [61]. However, MI can be difficult to estimate in practice as it requires sampling the full joint distribution of the two considered variables, each of which can themselves be multivariate. Gaussian-Copula Mutual Information (GCMI) is a recently proposed semi-parametric estimation technique [62] which has some advantages for estimating MI from neural data. GCMI exploits the fact that mutual information is copula entropy: MI does not depend on the marginal distributions of the variables, but only on the copula function which describes their dependence. GCMI therefore first transforms the inputs to be standard normal. This copula-normalisation step involves calculating the inverse standard normal cumulative density function (CDF) value of the empirical CDF value of each sample, separately for each input dimension, before using a parametric, bias-corrected, Gaussian MI estimator. This provides a lower bound estimate of the MI, without making any assumption on the marginal distributions of the input variables. GCMI is rank-based, robust and scales well with multidimensional variables as the Gaussian model reduces the curse of dimensionality that faces other methods such as those involving binning.

In the case of PAC, the phase ϕ(t) and the amplitude a(t) are still extracted using the Hilbert transform or using wavelets. The rank normalization is first applied on the amplitude a(t). To preserve the cyclic nature of phase, it is represented as points on the unit circle of the complex plane, represented as a 2d variable for GCMI. This 2d variable is built by concatenating the sine and cosine of the phase ϕ(t), [sin(ϕ(t)), cos(ϕ(t))] projecting it into the unit circle (or alternatively by normalizing away the amplitude of the complex value). The copula normalization procedure is then applied to each dimension of this 2d variable. PAC is measured as the GCMI between the copula-normalized 1d high-frequency amplitude and the 2d representation of low-frequency phase:

gcPAC=I(a(t);[sin(ϕ(t)),cos(ϕ(t))]) (9)

Since the gcPAC is rank-based, it is, by construction, invariant to overall amplitude shifts which means that a power increase does not lead to an increase of coupling. Note that measuring PAC using mutual-information has already been proposed using nearest-neighbour estimators [43]. Similarly to the other measures, Tensorpac provides a tensor-based implementation of the GCMI computed between two continuous variables.

While there is still no gold standard for choosing the most appropriate PAC method, some of them are by construction less suitables for measuring genuine coupling. In particular those for which an increase of power would also lead to an increase of coupling (amplitude dependency). Therefore, we recommend choosing methods like the MI, HR or gcPAC which are all not affected by the magnitude of amplitude. The main PAC methods implemented in Tensorpac are presented in Fig 3.

Fig 3. Comparison of the main PAC methods currently implemented in Tensorpac.

Fig 3

The comodulograms were computed using the A: MVL, B: MI, C: HR, D: ndPac, E: PLV and F: gcPAC, from 20 trials of simulated data containing a 10↔100hz phase-amplitude coupling. The data is available in Tensorpac and can be used to validate and benchmark other methods.

Statistical analysis of PAC

The absence of PAC in a signal could be related to several parameters that have been previously described [45]. Each one of the proposed PAC methodologies presents some advantages or limitations and may not be appropriate for all types of analysis. These methods exhibit differences in terms of robustness to noise, as well as modulation width, neither of which are necessarily amplitude independent [46]. In addition, PAC estimations may be biased due to limited amounts of data being available.

Generally, these limitations can be taken into account by computing a surrogate null distribution and using this to correct or normalize the PAC measure. To this end, several methods exist, all based on a common idea: introducing a small change into the data such that the temporal characteristics of the time-series are preserved but the relationship between the phase and the amplitude is disrupted. Among existing methods, [39] introduced a time lag to the amplitude, while [46] swap amplitude and phase trials and [57] swap time blocks, cut at a random point. The latter method, with only two blocks, has been described as the most conservative strategy to generate the distribution of PAC that can be observed by chance [48]. Finally, this null distribution is then used to perform non-parametric inference or to correct the measure estimated from the data (usually by subtracting the mean and divide by the deviation of this distribution). An example of a corrected PAC is presented in Fig 4.

Fig 4. Comparison between corrected and uncorrected PAC.

Fig 4

A: PAC comodulogram is computed for several (phase, amplitude) pairs. B: For each of those pairs, we estimate the distribution of surrogates and plot the mean comodulogram of these permutations. Note that both uncorrected and surrogate PAC comodulograms exhibit a spurious peak in the very low frequency phase. C: The true 10↔100hz coupling is finally retrieved by subtracting the mean of the surrogate distribution (panel B) from the uncorrected PAC (panel A).

Finally, the null distribution can also be used in order to infer the p-value. Indeed, the p-value is defined as the proportion of surrogates that are exceeded by the true value of coupling. For a comodulogram that contains several phase and amplitude frequencies, Tensorpac also includes a correction for multiple-comparisons. By default, it uses the maximum statistics which provides a threshold that controls family-wise error rate [63, 64]. The procedure consists in taking the maximum of the surrogates over all of the computed phases and amplitudes and using this distribution of maxima to infer the p-value.

Event-related phase-amplitude coupling (ERPAC)

One issue that has been raised is that, since PAC is computed across time, non-stationary signals can cause the appearance of spurious coupling [48]. An illustrative example taken from the same study explains that if there is an induced phase locking of lower frequencies and simultaneously a high frequency power increase, a coupling between them is going to be observed. Interestingly, a complementary approach to the time-averaged PAC has been proposed and consists of computing time-resolved PAC across trials [47]. Accordingly, the Event-Related PAC (ERPAC) measure is based on a circular-linear correlation [65] which evaluates the Pearson correlation, across trials, of the amplitude at and with the sine and cosine of the phase ϕt. We denote by c(x, y) the Pearson correlation between two variables x and y, rsx = c(sin(ϕt), at), rcx = c(cos(ϕt), at) and rsc = c(sin(ϕt), cos(ϕt)) hence, the circular-linear correlation ρcl is defined as:

ρcl=rsx2+rcx2-2rsxrcxrsc1-rsc2 (10)

In contrast to the original Matlab version [47], we implemented a tensor-based version of the ERPAC (tensorpac.EventRelatedPac). Similarly to the gcPAC, we also introduce the Gaussian-Copula Event-Related PAC which this time measures the information shared by the phase and the amplitude across trials, at each time point illustrated in the Fig 5. It is noteworthy that a measure of event-related PAC has been proposed using a mutual information framework [43]. In addition, it has also been proposed to compute PAC using the power spectrum on sliding windows [66].

Fig 5. Example of event-related phase-amplitude coupling (ERPAC).

Fig 5

We first generate 300 one-second trials each containing a 10↔100hz coupling. Next, one-second of random noise is appended to these signals. The depicted A: ERPAC and B: gcERPAC represents time-resolved PAC estimation over the two-second window, computed with a phase between [9, 11] hz and for multiple amplitudes.

Additional cross-frequency tools

Distribution of amplitudes and preferred phase

The preferred-phase (PP) is defined as the phase for which the distribution of amplitudes is maximum. This can be used to find out if amplitudes are aligned at a specific phase angle [28]. To compute the PP (tensorpac.PreferredPhase), the probability density distribution of amplitudes is first generated according to a number of phase slices (just as the modulation index and heights ratio). Then, the phase bin for which the amplitude is maximum is defined as the preferred phase. Usually, the preferred phase is reported using a histogram (see Fig 6A), where a specific phase and a specific amplitude band have been used. Here, we introduce a new plotting method where, still for a single phase, but now binned amplitudes in consecutive frequency bands can be observed using a polar representation (Fig 6B). This provides a more fine-grained representation where the preferred phase can be observed with a wide range of amplitude frequencies. Both methods and visualizations are available in Tensorpac (tensorpac.PreferredPhase.pacplot and tensorpac.PreferredPhase.polar).

Fig 6. Estimation of the preferred phase.

Fig 6

Illustrative example of the preferred phase estimation based on 100 trials generated with coupling between 6hz↔100hz and where the amplitude is locked to the 6hz phase at 45° (π/4). A: The 100 hz amplitude is first binned according to the phase using 18 slices of 20° each. The sum of the amplitude inside each slice is plotted as a histogram and the preferred phase is identified as the phase for which the amplitude is maximum (45°). B: An alternative polar visualization available in Tensorpac displays the strength across multiple amplitude frequency bands. Phase is binned as before, but now multiple amplitude signals from different bands are calculated for each phase bin. In these polar plots, the angle represents the phase of the low-frequency (here 6Hz), and the radial axis represents different frequencies considered for the amplitude signal. The color depicts the average value of the amplitude of a given frequency inside the corresponding phase bin. The preferred 45° phase for the 6hz↔100hz PAC is clear in this representation.

Phase / amplitude frequency interval optimization

When choosing the parameters to use in PAC analysis, researchers are often confronted with important decisions related to parameter selection. Even if the frequency bands for phase and amplitude are chosen based on a scientific hypothesis or previous reports in the literature, it is often impossible to know what the optimal frequency intervals are in the data one is analyzing. One might argue that it makes little sense to compute theta-gamma coupling in canonical frequency bands for example using 4-7 Hz (theta phase) and 30-70 Hz (gamma amplitude) if these bands don’t really capture key oscillatory modulations in the data at hand. We therefore reasoned that it would be useful to (a) be able to check for the presence of peaks in the power spectrum to potentially guide the choice of the bandwidth for filtering [48], and (b) to automatically search for the best frequency intervals in a data-driven manner. Tensorpac provides functionalities that can help address these issues. First of all, a standard tool to compute the Power Spectrum Density (PSD) is available and adapted for standard electrophysiological data formats, i.e. datasets organized as an array with the number of epochs as rows and the number of time points as columns (See example in Fig 7A). This can be used to identify prominent peaks either for the low or high frequency components. More importantly, in order to address the question of how to optimize the selection of the starting and ending frequencies for the intervals to use for PAC computation, Tensorpac allows for the possibility of defining triangular vectors and computing PAC for a range of starting and ending frequencies (PAC(Fmin, Fmax)). In addition, this triangular search can be used to find the best interval for the amplitude or for the phase. The visualization of the results (tensorpac.Pac.triplot) can be used to determine the hotspots within a triangular representation of PAC, i.e. determining the Fmin/Fmax combination that corresponds to PAC peak (see Fig 7B): The x-axis determines the starting frequency (Fmin) and the y-axis the ending frequency (Fmax). The maximum coupling that emerges from this triangular representation can be taken as an indication for the optimal frequency interval to use [Fmin, Fmax]. Note here that the standard comodulogram often used in PAC analyses is obtained by computing PAC in successive (phase, amplitude) pairs of bands with pre-defined bandwidths. While useful for identifying coupling the comodulogram is not suitable for identifying the optimal starting and ending frequencies to use. Taken together, the PSD tool and this exhaustive Fmin/Fmax search for best frequency bounds are valuable tools that can guide decisions regarding parameter selection in PAC analyses.

Fig 7. Investigation of the presence of a phase peak and data-driven exploration of the optimal bandwidth.

Fig 7

In this example, we first generated a 6↔70hz phase-amplitude coupling. A: The PSD retrieves the presence of the phase peak around 6hz. B: For a fixed phase filtered in [5, 7] hz, we search for the optimal amplitude band, defined as the bandwidth for which the PAC is maximum. The triangular freq-freq representation depicts coupling strength across many possible combinations of amplitude frequency bounds, where the x-axis corresponds to the starting frequency and the y-axis to the ending frequency. Here, the PAC is maximum for an amplitude range of [61, 79] hz.

As a side note, the choice of the filter bandwidth for the phase and amplitude is still debated. While some previous studies recommended filtering the amplitude with a bandwidth twice as large as the one used for phase (2:1 ratio) [48], a recent study suggests that a 1:1 ratio might be better as this could prevent smearing [67].

Statistical test of stationarity

As mentioned earlier, stationary signals are a prerequisite for calculating phase-amplitude coupling. Tensorpac includes a function (tensorpac.stats.test_stationarity) to perform an Augmented Dickey-Fuller test (ADF) [68]] to test the stationarity of time-series. The null hypothesis of the ADF test is that there is a unit root in the time-series. Said differently, H0 represents a non-stationary signal. Tensorpac uses the Statsmodels Python package [69] and returns a dataframe that contains, for each epoch, the p-values, a boolean if H0 has been accepted or rejected, the statistical test and critical values at 0.05 and 0.01.

Tensor-based implementation

Traditionally, phase-amplitude coupling measures are implemented in a vector fashion where only a single time-series is processed at a time. This is the most straightforward implementation and the easiest to read, however computing PAC on relatively large datasets can be dramatically slow, especially when the number of dimensions increases (i.e the number of trials, phases and amplitudes). In Tensorpac, all of the implemented PAC methods have been adapted in order to support multidimensional computations and thereby decrease computing time. This was made possible by using the NumPy function einsum which uses the Einstein summation convention in order to perform linear algebraic array operations. In order to illustrate the gains in terms of computing time, we compared the vector-based and the tensor-based implementations on simulated data (100 trials and 3000 time points). We then computed a comodulogram with 26 phases and 24 amplitudes. Fig 8 presents the comparison of computing time per method (Fig 8A) and the ratio (Fig 8B). The tensor-based implementation is between 6 times to more than 12 times faster than the vector-based one depending on the PAC method that is used. This gain in terms of computation time would be obviously even larger when considering an increasing number of phases and amplitudes or if the permutations for assessing statistics have to be measured.

Fig 8. Computation time of the vector and tensor-based implementations.

Fig 8

We first generate a relatively small dataset composed of 100 trials of 3000 time points each. We then evaluated the comodulogram by extracting 26 phases and 24 amplitudes. The comodulogram is then either computed using one-dimensional time-series (vector-based) or directly using multidimensional arrays (tensor-based). Computing time is compared as a function of PAC method (A) or as a ratio where the computing time using tensors is divided by the one using vectors (B).

The case of spurious cross-frequency coupling

Previous research has established that non-oscillations, non-stationary signals and sharp waveforms (e.g the mu rhythm in sensorimotor areas) can all produce spurious PAC even in the absence of true phase-amplitude coupling [48, 52, 70, 71]. While considering non-oscillations is an important aspect of brain data analysis [50, 72], the fact that it can also produce non-existent couplings is problematic for future work on cross-frequency coupling. Most of the standard PAC methods rely on an instantaneous estimation of the phase and amplitude using Hilbert transform or Morlet wavelets. However, both approaches can introduce spurious PAC from sharp waveform features. A few methods, not based on instantaneous estimations of phase and amplitude, have been introduced to tackle the issue of spurious PAC. These include for example auto-regressive models [41] and bispectral approaches [73]. The default instantaneous signal decompositions in phase and amplitude included in Tensorpac at the time of publication do not solve the ongoing debate on spurious versus genuine PAC, nevertheless the package provides a robust and convenient framework for the incorporation of additional PAC methods which may be developed to address this issue in the future.

More generally, when using Hilbert or wavelets, several guidelines and precautions have been proposed in order to limit spurious PAC and control the accuracy of an estimation [48]. First, a visual inspection of the time-series could be performed in order to exclude non-stationary signals. In addition, a clear peak at the phase frequency should be visible in the PSD to warrant further exploration of PAC (this can be examined in Tensorpac using tensorpac.utils.PSD). Still, the Fourier transform decomposes a signal in a sum of sines and cosines which means that it can only partially capture non-oscillatory features [70, 72]. Instead, one might consider using a matching pursuit algorithm or an empirical mode decomposition since both do not make the assumption of a sinusoidal basis [72]. In addition to these two alternatives, a method based on cycle-by-cycle analysis has recently been proposed in order to extract temporal features [72]. In principle, if a peak in the PSD is observed at the frequency of the phase, the width of this peak should be used to then extract the instantaneous phase. When filtering the amplitude, the width of the frequency band should be large enough to contain the side bands of the lower frequency band. In practice, it means that if the band used for low frequency phase is [8, 10]Hz, the bandwidth of the amplitude should be at least 20Hz. The presence of coupling can also be further explored by binning the amplitude according to phase slices (tensorpac.utils.BinAmplitude). In absence of coupling the distribution should be uniform while in presence of coupling, this distribution of amplitude should be closer to a normal distribution. Tensorpac also includes the possibility to realign time-frequency representations based on a phase peak (tensorpac.utils.PeakLockedTF). If a coupling exists, a rhythmic pattern of higher frequency (e.g. gamma) amplitude bursts should be observed.

Documentation and API provision

Tensorpac is a Python 3 package and is distributed under a BSD-3-Clause license. This package relies on NumPy [74], SciPy [75], Joblib for parallel computing and Matplotlib for plotting. In addition, Pandas [76] and Statsmodels [69] are required if the stationarity test is to be performed. We also provide full documentation for the package (https://etiennecmb.github.io/tensorpac) which is automatically built using sphinx. This documentation also explains how to install Tensorpac. An API tab is accessible from this documentation and describes the most up-to-date implemented functions and descriptions (using NumPy doc convention). It also features a gallery of examples, built with sphinx-gallery, which demonstrate the use of Tensorpac’s main classes and functions and a step-by-step tutorial based on real intracranial EEG data recorded during a center-out motor task [23]. For beginners or non-python users that want to cross the open-source bridge, we added a public Gitter chat for answering questions. Finally, the code follows PEP8 and Flake8 guidelines for code readability. We also added a suite of unit-tests (smoke tests and functionnal tests) that are systematically launched on Linux and Windows systems. Finally, Tensorpac functionalities can easily be combined with other open-source brain data analysis and visualization tools developed by our group including visbrain [77, 78] and Neuropycon [79].

Availability and future directions

This paper introduces the workflow and functionalities of Tensorpac, a free and open-source Python toolbox with a tensor-based implementation of both time-averaged and trial-averaged phase-amplitude coupling measures. In addition to those most frequently used methods we also presented some unique features such as the preferred phase or an exhaustive research of frequency bounds. As spurious coupling can be observed in many scenarios, we also provide additional tools and statistics to control both the reliability of an estimation. The latest version of Tensorpac is hosted on Github (https://github.com/EtienneCmb/tensorpac) but can also be installed via the pip command from a regular terminal. Tensorpac comes with an online documentation that describes installation options, also for contributors, the functionalities and illustrative examples. We plan to continue adding new methods to the Tensorpac toolbox and we encourage collaborative development and contributions from the community. In particular, we welcome contributions of new methods of PAC estimation but also tools that can help control the reliability of PAC metrics and reduce spurious detections.

Financial disclosure statement

EC and AB were supported by the French National Agency (ANR-18-CE28-0016-01)). http://anr.fr.

EC was also supported by funding via a Natural Sciences and Engineering Research Council of Canada (NSERC). https://www.nserc-crsng.gc.ca/.

JLPS acknowledge support from the Brazilian Ministry of Education (CAPES grant 1719-04-1) and the Fulbright Commission to J.L.P. Soto.

https://www.iie.org/programs/capes.

KJ was supported by funding from the Canada Research Chairs program and a Discovery Grant (RGPIN-2015-04854) from NSERC (Canada), a New Investigators Award from FQNT (2018-NC-206005) and an IVADO-Apogée fundamental research project grant. This research is also supported in part by the FRQNT Strategic Clusters Program (2020-RS4-265502—Centre UNIQUE—Union Neurosciences & Artificial Intelligence—Quebec).

http://www.frqnt.gouv.qc.ca/.

https://ivado.ca/.

TC acknowledges support through the Centre de Recherches Mathématiques (CRM).

RAAI was supported by the Wellcome Trust [214120/Z/18/Z].

https://wellcome.ac.uk/.

The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript

Data Availability

The data used to showcase and validate the implemented functionalities of the software are generated on the fly (not loaded from a repository). The exact same data can be accessed through the scripts that replicate the paper figures. These have been made available here: https://github.com/EtienneCmb/tensorpac/tree/master/paper.

Funding Statement

EC and AB were supported by the French National Agency (ANR-18-CE28-0016-01) (http://anr.fr). EC was also supported by funding via a Natural Sciences and Engineering Research Council of Canada (NSERC) (https://www.nserc-crsng.gc.ca). JLPS acknowledge support from the Brazilian Ministry of Education (CAPES grant 1719-04-1) and the Fulbright Commission to JLP Soto (https://www.iie.org/programs/capes). KJ was supported by funding from the Canada Research Chairs program and a Discovery Grant (RGPIN-2015-04854) from NSERC (Canada), a New Investigators Award from FQNT (2018-NC-206005) and an IVADO-Apogée fundamental research project grant (http://www.frqnt.gouv.qc.ca/). This research is also supported in part by the FRQNT Strategic Clusters Program (2020-RS4-265502 - Centre UNIQUE - Union Neurosciences & Artificial Intelligence - Quebec) (https://ivado.ca/). TC acknowledges support through the Centre de Recherches Mathématiques (CRM). RAAI was supported by the Wellcome Trust (214120/Z/18/Z) (https://wellcome.ac.uk/). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

References

  • 1. Buzsaki G. Rhythms of the Brain. Oxford University Press; 2006. [Google Scholar]
  • 2. Dalal SS, Vidal JR, Hamamé CM, Ossandón T, Bertrand O, Lachaux JP, et al. Spanning the rich spectrum of the human brain: slow waves to gamma and beyond. Brain Structure and Function. 2011;216(2):77 10.1007/s00429-011-0307-z [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3. Luo L, Rodriguez E, Jerbi K, Lachaux JP, Martinerie J, Corbetta M, et al. Ten years of Nature Reviews Neuroscience: insights from the highly cited. Nature Reviews Neuroscience. 2010;11(10):718–726. 10.1038/nrn2912 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4. Jung J, Jerbi K, Ossandon T, Ryvlin P, Isnard J, Bertrand O, et al. Brain responses to success and failure: direct recordings from human cerebral cortex. Human brain mapping. 2010;31(8):1217–1232. 10.1002/hbm.20930 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5. Oswald V, Zerouali Y, Boulet-Craig A, Krajinovic M, Laverdière C, Sinnett D, et al. Spontaneous brain oscillations as neural fingerprints of working memory capacities: A resting-state MEG study. Cortex. 2017;97:109–124. 10.1016/j.cortex.2017.09.021 [DOI] [PubMed] [Google Scholar]
  • 6. Lachaux JP, Jerbi K, Bertrand O, Minotti L, Hoffmann D, Schoendorff B, et al. BrainTV a novel approach for online mapping of human brain functions. Biological research. 2007;40(4):401–413. 10.4067/S0716-97602007000500004 [DOI] [PubMed] [Google Scholar]
  • 7. Jensen O, Colgin LL. Cross-frequency coupling between neuronal oscillations. Trends in Cognitive Sciences. 2007;11(7):267–269. 10.1016/j.tics.2007.05.003 [DOI] [PubMed] [Google Scholar]
  • 8. Belluscio MA, Mizuseki K, Schmidt R, Kempter R, Buzsaki G. Cross-Frequency Phase-Phase Coupling between Theta and Gamma Oscillations in the Hippocampus. Journal of Neuroscience. 2012;32(2):423–435. 10.1523/JNEUROSCI.4122-11.2012 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9. Darvas F, Miller KJ, Rao RP, Ojemann JG. Nonlinear phase–phase cross-frequency coupling mediates communication between distant sites in human neocortex. Journal of Neuroscience. 2009;29(2):426–435. 10.1523/JNEUROSCI.3688-08.2009 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10. Voytek B, Canolty RT, Shestyuk A, Crone N, Parvizi J, Knight RT. Shifts in gamma phase–amplitude coupling frequency from theta to alpha over posterior cortex during visual tasks. Frontiers in human neuroscience. 2010;4:191. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11. Friston KJ. Another neural code? Neuroimage. 1997;5(3):213–220. [DOI] [PubMed] [Google Scholar]
  • 12. Shirvalkar PR, Rapp PR, Shapiro ML. Bidirectional changes to hippocampal theta-gamma comodulation predict memory for recent spatial episodes. Proceedings of the National Academy of Sciences. 2010;107(15):7054–7059. 10.1073/pnas.0911184107 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13. Siegel M, Warden MR, Miller EK. Phase-dependent neuronal coding of objects in short-term memory. Proceedings of the National Academy of Sciences. 2009;106(50):21341–21346. 10.1073/pnas.0908193106 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14. Cohen MX, Elger CE, Fell J. Oscillatory activity and phase–amplitude coupling in the human medial frontal cortex during decision making. Journal of cognitive neuroscience. 2008;21(2):390–402. [DOI] [PubMed] [Google Scholar]
  • 15. Szczepanski SM, Crone NE, Kuperman RA, Auguste KI, Parvizi J, Knight RT. Dynamic changes in phase-amplitude coupling facilitate spatial attention control in fronto-parietal cortex. PLoS biology. 2014;12(8):e1001936 10.1371/journal.pbio.1001936 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16. Axmacher N, Henseler MM, Jensen O, Weinreich I, Elger CE, Fell J. Cross-frequency coupling supports multi-item working memory in the human hippocampus. Proceedings of the National Academy of Sciences. 2010;107(7):3228–3233. 10.1073/pnas.0911531107 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17. Fell J, Axmacher N. The role of phase synchronization in memory processes. Nature reviews neuroscience. 2011;12(2):105 10.1038/nrn2979 [DOI] [PubMed] [Google Scholar]
  • 18. Lega B, Burke J, Jacobs J, Kahana MJ. Slow-theta-to-gamma phase–amplitude coupling in human hippocampus supports the formation of new episodic memories. Cerebral Cortex. 2014;26(1):268–278. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19. Lisman JE, Jensen O. The theta-gamma neural code. Neuron. 2013;77(6):1002–1016. 10.1016/j.neuron.2013.03.007 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20. Maris E, van Vugt M, Kahana M. Spatially distributed patterns of oscillatory coupling between high-frequency amplitudes and low-frequency phases in human iEEG. Neuroimage. 2011;54(2):836–850. 10.1016/j.neuroimage.2010.09.029 [DOI] [PubMed] [Google Scholar]
  • 21. Tort ABL, Komorowski RW, Manns JR, Kopell NJ, Eichenbaum H. Theta–gamma coupling increases during the learning of item–context associations. Proceedings of the National Academy of Sciences. 2009;106(49):20942–20947. 10.1073/pnas.0911331106 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22. van der Meij R, Kahana M, Maris E. Phase–amplitude coupling in human electrocorticography is spatially distributed and phase diverse. Journal of Neuroscience. 2012;32(1):111–123. 10.1523/JNEUROSCI.4816-11.2012 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23. Combrisson E, Perrone-Bertolotti M, Soto JL, Alamian G, Kahane P, Lachaux JP, et al. From intentions to actions: Neural oscillations encode motor processes through phase, amplitude and phase-amplitude coupling. NeuroImage. 2017;147:473–487. 10.1016/j.neuroimage.2016.11.042 [DOI] [PubMed] [Google Scholar]
  • 24. Daume J, Gruber T, Engel AK, Friese U. Phase-amplitude coupling and long-range phase synchronization reveal frontotemporal interactions during visual working memory. Journal of Neuroscience. 2017;37(2):313–322. 10.1523/JNEUROSCI.2130-16.2016 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25. Newman EL, Gillet SN, Climer JR, Hasselmo ME. Cholinergic blockade reduces theta-gamma phase amplitude coupling and speed modulation of theta frequency consistent with behavioral effects on encoding. Journal of Neuroscience. 2013;33(50):19635–19646. 10.1523/JNEUROSCI.2586-13.2013 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 26.Soto JL, Jerbi K. Investigation of cross-frequency phase-amplitude coupling in visuomotor networks using magnetoencephalography. In: Engineering in Medicine and Biology Society (EMBC), 2012 Annual International Conference of the IEEE. IEEE; 2012. p. 1550–1553. Available from: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6346238. [DOI] [PubMed]
  • 27. von Nicolai C, Engler G, Sharott A, Engel AK, Moll CK, Siegel M. Corticostriatal coordination through coherent phase-amplitude coupling. Journal of Neuroscience. 2014;34(17):5938–5948. 10.1523/JNEUROSCI.5007-13.2014 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28. Watrous AJ, Deuker L, Fell J, Axmacher N. Phase-amplitude coupling supports phase coding in human ECoG. Elife. 2015;4:e07886 10.7554/eLife.07886 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29. Yanagisawa T, Yamashita O, Hirata M, Kishima H, Saitoh Y, Goto T, et al. Regulation of Motor Representation by Phase-Amplitude Coupling in the Sensorimotor Cortex. The Journal of Neuroscience. 2012;32(44):15467–15475. 10.1523/JNEUROSCI.2929-12.2012 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30. De Hemptinne C, Swann NC, Ostrem JL, Ryapolova-Webb ES, San Luciano M, Galifianakis NB, et al. Therapeutic deep brain stimulation reduces cortical phase-amplitude coupling in Parkinson’s disease. Nature neuroscience. 2015;18(5):779 10.1038/nn.3997 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31. De Hemptinne Cd, Ryapolova-Webb ES, Air EL, Garcia PA, Miller KJ, Ojemann JG, et al. Exaggerated phase amplitude coupling in the primary motor cortex in Parkinson disease. Proceedings of the National Academy of Sciences. 2013. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32. Kirihara K, Rissling AJ, Swerdlow NR, Braff DL, Light GA. Hierarchical organization of gamma and theta oscillatory dynamics in schizophrenia. Biological psychiatry. 2012;71(10):873–880. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33. López-Azcárate J, Tainta M, Rodríguez-Oroz MC, Valencia M, González R, Guridi J, et al. Coupling between beta and high-frequency activity in the human subthalamic nucleus may be a pathophysiological mechanism in Parkinson’s disease. Journal of Neuroscience. 2010;30(19):6667–6677. 10.1523/JNEUROSCI.5459-09.2010 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34. Moran LV, Hong LE. High vs low frequency neural oscillations in schizophrenia. Schizophrenia bulletin. 2011;37(4):659–663. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35. Özkurt TE, Schnitzler A. A critical note on the definition of phase–amplitude cross-frequency coupling. Journal of Neuroscience methods. 2011;201(2):438–443. 10.1016/j.jneumeth.2011.08.014 [DOI] [PubMed] [Google Scholar]
  • 36. Shimamoto SA, Ryapolova-Webb ES, Ostrem JL, Galifianakis NB, Miller KJ, Starr PA. Subthalamic nucleus neurons are synchronized to primary motor cortex local field potentials in Parkinson’s disease. Journal of Neuroscience. 2013;33(17):7220–7233. 10.1523/JNEUROSCI.4676-12.2013 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37. van Wijk BC, Beudel M, Jha A, Oswal A, Foltynie T, Hariz MI, et al. Subthalamic nucleus phase–amplitude coupling correlates with motor impairment in Parkinson’s disease. Clinical Neurophysiology. 2016;127(4):2010–2019. 10.1016/j.clinph.2016.01.015 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 38. Canolty RT, Knight RT. The functional role of cross-frequency coupling. Trends in cognitive sciences. 2010;14(11):506–515. 10.1016/j.tics.2010.09.001 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 39. Canolty RT. High Gamma Power Is Phase-Locked to Theta. science. 2006;1128115(1626):313. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40. Dvorak D, Fenton AA. Toward a proper estimation of phase amplitude coupling in neural oscillations. Journal of Neuroscience Methods. 2014;225:42–56. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 41. La Tour TD, Tallot L, Grabot L, Doyère V, Van Wassenhove V, Grenier Y, et al. Non-linear auto-regressive models for cross-frequency coupling in neural time series. PLoS computational biology. 2017;13(12):e1005893. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 42. Lakatos P. An Oscillatory Hierarchy Controlling Neuronal Excitability and Stimulus Processing in the Auditory Cortex. Journal of Neurophysiology. 2005;94(3):1904–1911. 10.1152/jn.00263.2005 [DOI] [PubMed] [Google Scholar]
  • 43. Martínez-Cancino R, Heng J, Delorme A, Kreutz-Delgado K, Sotero RC, Makeig S. Measuring transient phase-amplitude coupling using local mutual information. NeuroImage. 2019;185:361–378. 10.1016/j.neuroimage.2018.10.034 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 44. Nakhnikian A, Ito S, Dwiel LL, Grasse LM, Rebec GV, Lauridsen LN, et al. A novel cross-frequency coupling detection method using the generalized Morse wavelets. Journal of Neuroscience Methods. 2016;269:61–73. 10.1016/j.jneumeth.2016.04.019 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 45. Penny WD, Duzel E, Miller KJ, Ojemann JG. Testing for nested oscillation. Journal of Neuroscience Methods. 2008;174(1):50–61. 10.1016/j.jneumeth.2008.06.035 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 46. Tort ABL, Komorowski R, Eichenbaum H, Kopell N. Measuring Phase-Amplitude Coupling Between Neuronal Oscillations of Different Frequencies. Journal of Neurophysiology. 2010;104(2):1195–1210. 10.1152/jn.00106.2010 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 47. Voytek B, D’Esposito M, Crone N, Knight RT. A method for event-related phase/amplitude coupling. NeuroImage. 2013;64:416–424. 10.1016/j.neuroimage.2012.09.023 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 48. Aru J, Aru J, Priesemann V, Wibral M, Lana L, Pipa G, et al. Untangling cross-frequency coupling in neuroscience. Current Opinion in Neurobiology. 2015;31:51–61. 10.1016/j.conb.2014.08.002 [DOI] [PubMed] [Google Scholar]
  • 49. Soto JLP, Prado FVD, Combrisson E, Jerbi K. Estimation of narrowband amplitude and phase from electrophysiology signals for phase-amplitude coupling studies: a comparison of methods. bioRxiv. 2018; p. 392886. [Google Scholar]
  • 50. Jensen O, Spaak E, Park H. Discriminating valid from spurious indices of phase-amplitude coupling. Eneuro. 2016;3(6). 10.1523/ENEURO.0334-16.2016 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 51. Cole SR, van der Meij R, Peterson EJ, de Hemptinne C, Starr PA, Voytek B. Nonsinusoidal beta oscillations reflect cortical pathophysiology in Parkinson’s disease. Journal of Neuroscience. 2017;37(18):4830–4840. 10.1523/JNEUROSCI.2208-16.2017 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 52. Kramer MA, Tort AB, Kopell NJ. Sharp edge artifacts and spurious coupling in EEG frequency comodulation measures. Journal of neuroscience methods. 2008;170(2):352–357. 10.1016/j.jneumeth.2008.01.020 [DOI] [PubMed] [Google Scholar]
  • 53. Oostenveld R, Fries P, Maris E, Schoffelen JM. FieldTrip: open source software for advanced analysis of MEG, EEG, and invasive electrophysiological data. Computational intelligence and neuroscience. 2011;2011:1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 54. Tadel F, Baillet S, Mosher JC, Pantazis D, Leahy RM. Brainstorm: a user-friendly application for MEG/EEG analysis. Computational intelligence and neuroscience. 2011;2011:8. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 55. Delorme A, Makeig S. EEGLAB: an open source toolbox for analysis of single-trial EEG dynamics including independent component analysis. Journal of neuroscience methods. 2004;134(1):9–21. 10.1016/j.jneumeth.2003.10.009 [DOI] [PubMed] [Google Scholar]
  • 56. Gramfort A, Luessi M, Larson E, Engemann DA, Strohmeier D, Brodbeck C, et al. MEG and EEG data analysis with MNE-Python. Frontiers in neuroscience. 2013;7:267 10.3389/fnins.2013.00267 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 57. Bahramisharif A, van Gerven MAJ, Aarnoutse EJ, Mercier MR, Schwartz TH, Foxe JJ, et al. Propagating Neocortical Gamma Bursts Are Coordinated by Traveling Alpha Waves. Journal of Neuroscience. 2013;33(48):18849–18854. 10.1523/JNEUROSCI.2455-13.2013 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 58. Tallon-Baudry C, Bertrand O, Delpuech C, Pernier J. Stimulus specificity of phase-locked and non-phase-locked 40 Hz visual responses in human. The Journal of Neuroscience. 1996;16(13):4240–4249. 10.1523/JNEUROSCI.16-13-04240.1996 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 59. Ozkurt TE. Statistically Reliable and Fast Direct Estimation of Phase-Amplitude Cross-Frequency Coupling. Biomedical Engineering, IEEE Transactions on. 2012;59(7):1943–1950. 10.1109/TBME.2012.2194783 [DOI] [PubMed] [Google Scholar]
  • 60. Lachaux JP, Rodriguez E, Martinerie J, Varela FJ, others. Measuring phase synchrony in brain signals. Human brain mapping. 1999;8(4):194–208. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 61. Cover TM, Thomas JA. Elements of information theory. New York: Wiley; 1991. [Google Scholar]
  • 62. Ince RAA, Giordano BL, Kayser C, Rousselet GA, Gross J, Schyns PG. A statistical framework for neuroimaging data analysis based on mutual information estimated via a gaussian copula: Gaussian Copula Mutual Information. Human Brain Mapping. 2017;38(3):1541–1573. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 63. Holmes AP, Blair R, Watson J, Ford I. Nonparametric analysis of statistic images from functional mapping experiments. Journal of Cerebral Blood Flow & Metabolism. 1996;16(1):7–22. 10.1097/00004647-199601000-00002 [DOI] [PubMed] [Google Scholar]
  • 64. Nichols TE, Holmes AP. Nonparametric permutation tests for functional neuroimaging: a primer with examples. Human brain mapping. 2002;15(1):1–25. 10.1002/hbm.1058 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 65. Zar JH, others. Biostatistical analysis. Pearson Education India; 1999. [Google Scholar]
  • 66. Samiee S, Baillet S. Time-resolved phase-amplitude coupling in neural oscillations. NeuroImage. 2017;159:270–279. 10.1016/j.neuroimage.2017.07.051 [DOI] [PubMed] [Google Scholar]
  • 67. Zandvoort CS, Nolte G. Understanding phase-amplitude coupling from bispectral analysis. bioRxiv. 2020. [DOI] [PubMed] [Google Scholar]
  • 68. Choi I, Chul Ahn B. Testing the null of stationarity for multiple time series. Journal of Econometrics. 1999;88(1):41–77. 10.1016/S0304-4076(98)00021-9 [DOI] [Google Scholar]
  • 69.Seabold S, Perktold J. Statsmodels: Econometric and statistical modeling with python. In: 9th Python in Science Conference; 2010.
  • 70. Lozano-Soldevilla D, ter Huurne N, Oostenveld R. Neuronal oscillations with non-sinusoidal morphology produce spurious phase-to-amplitude coupling and directionality. Frontiers in computational neuroscience. 2016;10:87. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 71. Gerber EM, Sadeh B, Ward A, Knight RT, Deouell LY. Non-sinusoidal activity can produce cross-frequency coupling in cortical signals in the absence of functional interaction between neural sources. PloS one. 2016;11(12):e0167351 10.1371/journal.pone.0167351 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 72. Cole SR, Voytek B. Brain oscillations and the importance of waveform shape. Trends in cognitive sciences. 2017;21(2):137–149. 10.1016/j.tics.2016.12.008 [DOI] [PubMed] [Google Scholar]
  • 73. Kovach CK, Oya H, Kawasaki H. The bispectrum and its relationship to phase-amplitude coupling. Neuroimage. 2018;173:518–539. 10.1016/j.neuroimage.2018.02.033 [DOI] [PubMed] [Google Scholar]
  • 74. Harris CR, Millman KJ, van der Walt SJ, Gommers R, Virtanen P, Cournapeau D, et al. Array programming with NumPy. Nature. 2020;585(7825):357–362. 10.1038/s41586-020-2649-2 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 75.Jones E, Oliphant T, Peterson P, others. SciPy: Open source scientific tools for Python; 2001. Available from: http://www.scipy.org/.
  • 76. McKinney W. pandas: a foundational Python library for data analysis and statistics. Python for High Performance and Scientific Computing. 2011; p. 1–9. [Google Scholar]
  • 77. Combrisson E, Vallat R, Eichenlaub JB, O’Reilly C, Lajnef T, Guillot A, et al. Sleep: An Open-Source Python Software for Visualization, Analysis, and Staging of Sleep Data. Frontiers in Neuroinformatics. 2017;11 10.3389/fninf.2017.00060 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 78. Combrisson E, Vallat R, O’Reilly C, Jas M, Pascarella A, Saive Al, et al. Visbrain: A Multi-Purpose GPU-Accelerated Open-Source Suite for Multimodal Brain Data Visualization. Frontiers in Neuroinformatics. 2019;13 10.3389/fninf.2019.00014 [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 79. Meunier D, Pascarella A, Altukhov D, Jas M, Combrisson E, Lajnef T, et al. NeuroPycon: An open-source Python toolbox for fast multi-modal and reproducible brain connectivity pipelines. NeuroImage. 2020; p. 117020 10.1016/j.neuroimage.2020.117020 [DOI] [PubMed] [Google Scholar]
PLoS Comput Biol. doi: 10.1371/journal.pcbi.1008302.r001

Decision Letter 0

Dina Schneidman-Duhovny

25 Jun 2020

Dear Dr. Combrisson,

Thank you very much for submitting your manuscript "Tensorpac : an open-source Python toolbox for tensor-based Phase-Amplitude Coupling measurement in electrophysiological brain signals" for consideration at PLOS Computational Biology.

As with all papers reviewed by the journal, your manuscript was reviewed by members of the editorial board and by several independent reviewers. In light of the reviews (below this email), we would like to invite the resubmission of a significantly-revised version that takes into account the reviewers' comments.

We cannot make any decision about publication until we have seen the revised manuscript and your response to the reviewers' comments. Your revised manuscript is also likely to be sent to reviewers for further evaluation.

When you are ready to resubmit, please upload the following:

[1] A letter containing a detailed list of your responses to the review comments and a description of the changes you have made in the manuscript. Please note while forming your response, if your article is accepted, you may have the opportunity to make the peer review history publicly available. The record will include editor decision letters (with reviews) and your responses to reviewer comments. If eligible, we will contact you to opt in or out.

[2] Two versions of the revised manuscript: one with either highlights or tracked changes denoting where the text has been changed; the other a clean version (uploaded as the manuscript file).

Important additional instructions are given below your reviewer comments.

Please prepare and submit your revised manuscript within 60 days. If you anticipate any delay, please let us know the expected resubmission date by replying to this email. Please note that revised manuscripts received after the 60-day due date may require evaluation and peer review similar to newly submitted manuscripts.

Thank you again for your submission. We hope that our editorial process has been constructive so far, and we welcome your feedback at any time. Please don't hesitate to contact us if you have any questions or comments.

Sincerely,

Dina Schneidman-Duhovny

Software Editor

PLOS Computational Biology

Dina Schneidman-Duhovny

Software Editor

PLOS Computational Biology

***********************

Reviewer's Responses to Questions

Comments to the Authors:

Please note here if the review is uploaded as an attachment.

Reviewer #1: This paper describes a Python based toolbox to estimate, most of all, phase-amplitude

coupling. This area of research has recently attracted much interest and

therefore the toolbox is potentually useful for a large number of researchers.

The paper is very well written and, perhaps with one exception to be discussed

below, free of errors. In addition to implementing existing methods,

the authors developed a new visualization technique shown in Fig.6B which

is really nice. I still have some objections which should be addressed by the authors.

Major

1. The authors present a formula to estimate a treshold written as 2 × ((1 − )^−1)^2.

For a z-scored variable, the threshold would be the square root of that. Perhaps it is meant

to be the threshold for the square of the z-scored MVL value, but here the authors should

be more specific of what exactly is thresholded. Also, writing the exponent -1 in the formula

after the brackets for the argument of erf is confusing. That looks like 1/erf(1-p). Finally, to my opinion this z-scoring and the statistical interpretion as a Gaussian distribution with zero mean and

unit standard deviation doesn't make sense. The distribution of MLV under the null hypothesis

isn't even remotely close to a Gaussian distribution. I don't blame the authors. They just implemented

methods proposed by others, but a warning remark would be helpful.

2. The corrected PAC shown in Fig.4C is constructed by subtracting the mean and dividing by

the standard deviation of the surrogates, right? At least, this is how understand

the sentence "... usually by subtracting the mean and divide by the deviation of this distribution" on p.13. But why are the results so small? Not any of the shown results would survive the threshold discussed above. As stated above, I doubt that the threshold is based on accurate statistics, but I would still expect values in the order of 1 even when the null hypothesis is true, and I would expect very high values for real effects like in Fig.3 ndPAC. If it is not normalized here, why does the difference between Fig.4.A and Fig.4.B has values larger than 0.3 in the central peak? Finally, I also wonder whether MVL is interpretable without any normalization because the results will depend on overall signal amplitude.

Details:

1. As far as I know, what is called PLV in this paper, is usually called ITC (inter trial coherence)

and what is called PS here I would call PLV. Perhaps terminology varies. Just check.

2. Last equation of section "Kullback-Leibler distance:"

Brackets are missing. It should read log(P(k)) and not log(PK).

3. p.11 "This distribution is then

used to compute PAC using either the KLD." Or the normalized MVL?

ent peaks"

Reviewer #2: Uploaded as an attachment

Reviewer #3: == SUMMARY ==

The authors present an open-source toolbox ‘tensorpac’ for calculation of phase-amplitude coupling (PAC) measures. The toolbox features large speed gains in PAC-computation due to the usage of tensors in contrast to vector-based computation. Given clarifications regarding advantages with respect other existing toolboxes for PAC and statistical analysis, as well as extending the documentation, I believe this a valuable methodological contribution.

== DETAILS ==

The authors list 4 points as main advantages of their toolbox:

(1) higher computational efficiency because of tensor computations and parallelization

EVIDENCE: In Fig. 8, large gains in computation time are seen. Since at the core, the gains are achieved by relying on the Einstein summation representation, it would be interesting to expand on this in section 3.

It is neat that the scripts producing the figures are included and the figures can all be reproduced for run-time comparisons. The authors list pacpy (which seems not actively supported anymore) and pactools as comparisons to their toolbox. As pactools also offers parallelization, it is of interest to compare potential speed gains directly to pactools, not only vector-based usage in a loop of tensorpac functions.

(2) the implementation of all most widely used PAC methods in one package

EVIDENCE: According to documentation of pactools, there also numerous methods to calculate the comodulogram are implemented, even more than tensorpac, e.g. driven auto-regressive methods and bispectra, which makes the statement that other packages offer a ’limited choice of PAC computations’ not backed up. A more elaborate discussion of the criteria for selecting the chosen methods implemented in ‘tensorpac’ and highlighting improvements over existing packages would be helpful.

The authors stay agnostic to which metric should be used, but possibly there are cases for which each metric has advantages (briefly alluded to in section 1.4) and the brief descriptions of the metrics could be expanded in that respect.

From the API documentation, there is also a Gaussian Copula Mutual information PAC/ERP-PAC function, but it is not discussed in the paper, maybe it would be of interest to include in the manuscript.

(3) advantages for the statistical analysis of PAC measures

EVIDENCE: the authors provide methods for computing signal stationarity and surrogate null distributions. An often-desired outcome of PAC analysis is to derive a significance level of obtained comodulogram values, disentangling genuine PAC from spurious PAC. It would be helpful to provide discussion of it in the article (some functions for inferring p-values are present in the toolbox), as well as treatment of multiple comparison correction (cluster-based?) and overfitting & hyperparameter selection, for instance in the context of the proposed triangular search for optimizing frequency intervals.

(4) extended PAC visualization capabilities.

EVIDENCE: the toolbox provides visualization of comodulograms, frequency-amplitude histograms and polar plots, which are easy to produce and helpful visualizations. As a user, I would find peak/trough-locked (to slow oscillation) time domain & time-frequency plots useful in addition.

Minor

------

- the ‘<->’ arrow could be substituted by a proper arrow for increased readability

- there is some inconsistency in referring to KL-divergence. ‘KL-distance’ ‘distance of Kullback-Leibler’

- in the context of PAC, changing the labels/subsections from KLD to Modulation index could be considered for familarity

- p.6 and following, sometimes there is no space after lots of formulas ‘MIformula’ ‘amplitudes Pdiverges’

- sometimes an abbreviation is introduced, only to be used once or twice (e.g. PLV, PS, etc) -> use full name throughout for better readability?

- Fig.3: I would recommend using the full name of the measure in the subplot titles. Also, here it is noticeable that the scale of the measures is different, maybe the authors could comment on boundedness or ranges of measures in the description of the measures

- figure labels and legends are small at times

- p.6 ‘Height-Ration’ -> Height-Ratio

== SOFTWARE & WEBSITE ==

- the toolbox has a clearly indicated license (BSD-3) and I was able to install the toolbox via pip without errors, dependencies are clearly stated.

- statement of need: The high-level description on the documentation page could be expanded to highlight the speed gains by using tensor so they are clearer at first sight. (I think it is a nice selling point)

- tutorial link: at the moment there is only a GIF ‘under construction’... it would be good to have just a simple example placed there, maybe the one from the nice Fig.1 illustration? Or delete this link and have only the examples page?

- examples: The examples include nice illustrations, but the high-level text could be extended to clarify the purpose of the example, e.g. for “Compute p-values” the text only says: ‘For the visualization, we used a comodulogram.’, for ‘Compare surrogate methods’ -> ‘Surrogates are used to generate a chance ditribution in order to correct the PAC estimation.’. Extension to something like ‘This example illustrates how …’ would be informative for users, especially novice.

- the API documentation is too brief. For instance, the documentation for the ‘ndpac’ method just reads “Normalized direct Pac.“ or ’swap_pha_amp’ : “Swap phase / amplitude trials.” It would be good to include a brief rationale for each function that would clarify what happens to the input.

- the main PAC methods have very short function names, possible it could enhance readability giving them slightly more descriptive names? e.g.: hr -> heights_ratio, ps -> phase_synchrony etc

- some of the function names are in camel case (BinAmplitude) and some have snake_case, unification would be good.

- testing: the tests currently included test basic input output relations (smoke tests), but it would be helpful to include functional tests of PAC computation for synthetic signals, for which the ground truth is known.

- paper figures scripts: I needed to adjust the path in other to reproduce the figures from the paper in order for the script not to crash; the path could be changed to a relative one, so this does not happen

- reference for mvl method is cut short in the API doc

**********

Have all data underlying the figures and results presented in the manuscript been provided?

Large-scale datasets should be made available via a public repository as described in the PLOS Computational Biology data availability policy, and numerical data that underlies graphs or summary statistics should be provided in spreadsheet form as supporting information.

Reviewer #1: Yes

Reviewer #2: Yes

Reviewer #3: Yes

**********

PLOS authors have the option to publish the peer review history of their article (what does this mean?). If published, this will include your full peer review and any attached files.

If you choose “no”, your identity will remain anonymous but your review may still be made public.

Do you want your identity to be public for this peer review? For information about this choice, including consent withdrawal, please see our Privacy Policy.

Reviewer #1: Yes: Guido Nolte

Reviewer #2: No

Reviewer #3: No

Figure Files:

While revising your submission, please upload your figure files to the Preflight Analysis and Conversion Engine (PACE) digital diagnostic tool, https://pacev2.apexcovantage.com. PACE helps ensure that figures meet PLOS requirements. To use PACE, you must first register as a user. Then, login and navigate to the UPLOAD tab, where you will find detailed instructions on how to use the tool. If you encounter any issues or have any questions when using PACE, please email us at figures@plos.org.

Data Requirements:

Please note that, as a condition of publication, PLOS' data policy requires that you make available all data used to draw the conclusions outlined in your manuscript. Data must be deposited in an appropriate repository, included within the body of the manuscript, or uploaded as supporting information. This includes all numerical values that were used to generate graphs, histograms etc.. For an example in PLOS Biology see here: http://www.plosbiology.org/article/info%3Adoi%2F10.1371%2Fjournal.pbio.1001908#s5.

Reproducibility:

To enhance the reproducibility of your results, PLOS recommends that you deposit laboratory protocols in protocols.io, where a protocol can be assigned its own identifier (DOI) such that it can be cited independently in the future. For instructions, please see http://journals.plos.org/compbiol/s/submission-guidelines#loc-materials-and-methods

Attachment

Submitted filename: Review of Combrisson et al. 2020 - PLoS Comp. Bio.pdf

PLoS Comput Biol. doi: 10.1371/journal.pcbi.1008302.r003

Decision Letter 1

Dina Schneidman-Duhovny

2 Sep 2020

Dear Dr. Combrisson,

We are pleased to inform you that your manuscript 'Tensorpac : an open-source Python toolbox for tensor-based Phase-Amplitude Coupling measurement in electrophysiological brain signals' has been provisionally accepted for publication in PLOS Computational Biology.

Before your manuscript can be formally accepted you will need to complete some formatting changes, which you will receive in a follow up email. A member of our team will be in touch with a set of requests.

Please note that your manuscript will not be scheduled for publication until you have made the required changes, so a swift response is appreciated.

IMPORTANT: The editorial review process is now complete. PLOS will only permit corrections to spelling, formatting or significant scientific errors from this point onwards. Requests for major changes, or any which affect the scientific understanding of your work, will cause delays to the publication date of your manuscript.

Should you, your institution's press office or the journal office choose to press release your paper, you will automatically be opted out of early publication. We ask that you notify us now if you or your institution is planning to press release the article. All press must be co-ordinated with PLOS.

Thank you again for supporting Open Access publishing; we are looking forward to publishing your work in PLOS Computational Biology. 

Best regards,

Dina Schneidman

Software Editor

PLOS Computational Biology

***********************************************************

Reviewer's Responses to Questions

Comments to the Authors:

Please note here if the review is uploaded as an attachment.

Reviewer #1: The authors have addressed by concerns.

Reviewer #2: Combrisson et al. have provided a thorough revision of the manuscript and successfully addressed all of my concerns with much detail. In particular, the additional text concerning the interpretation of measured PAC is well written and is effective in highlighting the utility of specific Tensorpac methods in that regard. I also appreciate that the authors provided new tutorials with real iEEG data, which will help new users navigate the process of performing PAC analyses on their data. The updating of code for the generation of the main figures is also very useful.

As for the issue with integration of Numba/Cython into the code pipeline, it is helpful to see that this decreased the computational time of several of the functionalities -- especially since the speed of Tensorpac is a key selling point. However, I also agree with the authors that several of the issues of combining JobLib and Numba/Cython still have not been worked out by the developers. As the authors suggest, they could consider this integration as a longitudinal endeavor as the code libraries are further developed, potentially leading to further increases in computational efficiency of Tensorpac in the future.

Overall, I am enthusiastic about the publication of this work, and in my opinion, Tensorpac represents a valuable contribution to the field of computational and systems neuroscience.

Reviewer #3: I thank the authors for the reply to my comments, which addressed all my concerns. I also enjoyed reading the thoughtful replies to the comments of other reviewers & the inclusion of the paragraph about spurious PAC & inclusion of a real data example tutorial.

I now recommend this article for publication.

**********

Have all data underlying the figures and results presented in the manuscript been provided?

Large-scale datasets should be made available via a public repository as described in the PLOS Computational Biology data availability policy, and numerical data that underlies graphs or summary statistics should be provided in spreadsheet form as supporting information.

Reviewer #1: Yes

Reviewer #2: Yes

Reviewer #3: Yes

**********

PLOS authors have the option to publish the peer review history of their article (what does this mean?). If published, this will include your full peer review and any attached files.

If you choose “no”, your identity will remain anonymous but your review may still be made public.

Do you want your identity to be public for this peer review? For information about this choice, including consent withdrawal, please see our Privacy Policy.

Reviewer #1: Yes: Guido Nolte

Reviewer #2: No

Reviewer #3: No

PLoS Comput Biol. doi: 10.1371/journal.pcbi.1008302.r004

Acceptance letter

Dina Schneidman-Duhovny

20 Oct 2020

PCOMPBIOL-D-20-00589R1

Tensorpac : an open-source Python toolbox for tensor-based Phase-Amplitude Coupling measurement in electrophysiological brain signals

Dear Dr Combrisson,

I am pleased to inform you that your manuscript has been formally accepted for publication in PLOS Computational Biology. Your manuscript is now with our production department and you will be notified of the publication date in due course.

The corresponding author will soon be receiving a typeset proof for review, to ensure errors have not been introduced during production. Please review the PDF proof of your manuscript carefully, as this is the last chance to correct any errors. Please note that major changes, or those which affect the scientific understanding of the work, will likely cause delays to the publication date of your manuscript.

Soon after your final files are uploaded, unless you have opted out, the early version of your manuscript will be published online. The date of the early version will be your article's publication date. The final article will be published to the same URL, and all versions of the paper will be accessible to readers.

Thank you again for supporting PLOS Computational Biology and open-access publishing. We are looking forward to publishing your work!

With kind regards,

Laura Mallard

PLOS Computational Biology | Carlyle House, Carlyle Road, Cambridge CB4 3DN | United Kingdom ploscompbiol@plos.org | Phone +44 (0) 1223-442824 | ploscompbiol.org | @PLOSCompBiol

Associated Data

    This section collects any data citations, data availability statements, or supplementary materials included in this article.

    Supplementary Materials

    Attachment

    Submitted filename: Review of Combrisson et al. 2020 - PLoS Comp. Bio.pdf

    Attachment

    Submitted filename: response_to_reviewers.pdf

    Data Availability Statement

    The data used to showcase and validate the implemented functionalities of the software are generated on the fly (not loaded from a repository). The exact same data can be accessed through the scripts that replicate the paper figures. These have been made available here: https://github.com/EtienneCmb/tensorpac/tree/master/paper.


    Articles from PLoS Computational Biology are provided here courtesy of PLOS

    RESOURCES