Hello community, here is the log from the commit of package python-tensorpac for openSUSE:Factory checked in at 2020-04-07 10:30:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tensorpac (Old) and /work/SRC/openSUSE:Factory/.python-tensorpac.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tensorpac" Tue Apr 7 10:30:26 2020 rev:2 rq:791712 version:0.6.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tensorpac/python-tensorpac.changes 2019-12-10 22:41:48.745822712 +0100 +++ /work/SRC/openSUSE:Factory/.python-tensorpac.new.3248/python-tensorpac.changes 2020-04-07 10:31:59.846551431 +0200 @@ -1,0 +2,6 @@ +Mon Apr 6 07:42:03 UTC 2020 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 0.6.3: + * no upstream changelog + +------------------------------------------------------------------- Old: ---- tensorpac-0.6.2.tar.gz New: ---- tensorpac-0.6.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tensorpac.spec ++++++ --- /var/tmp/diff_new_pack.GarRk9/_old 2020-04-07 10:32:01.526553619 +0200 +++ /var/tmp/diff_new_pack.GarRk9/_new 2020-04-07 10:32:01.530553624 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-tensorpac # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,8 +17,9 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} +%define skip_python2 1 Name: python-tensorpac -Version: 0.6.2 +Version: 0.6.3 Release: 0 Summary: Tensor-based phase-Amplitude coupling package License: BSD-3-Clause @@ -35,9 +36,12 @@ BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module joblib} +BuildRequires: %{python_module matplotlib} BuildRequires: %{python_module numpy >= 1.12} +BuildRequires: %{python_module pandas} BuildRequires: %{python_module pytest} BuildRequires: %{python_module scipy} +BuildRequires: %{python_module statsmodels} # /SECTION %python_subpackages @@ -48,6 +52,9 @@ %prep %setup -q -n tensorpac-%{version} chmod a-x LICENSE README.rst +# upstream tarball contains py3.7 cache files +rm -rf */__pycache__ +rm -rf */*/__pycache__ %build %python_build @@ -55,13 +62,11 @@ %install %python_install %python_expand chmod a-x %{buildroot}%{$python_sitelib}/*egg-info/* +%python_expand rm -r %{buildroot}%{$python_sitelib}/tensorpac/{tests,methods/tests} %python_expand %fdupes %{buildroot}%{$python_sitelib} -# Tests missing and no recent tags to download from github. See: -# https://github.com/EtienneCmb/tensorpac/issues/4 -# https://github.com/EtienneCmb/tensorpac/pull/5 -# %%check -# %%pytest +%check +%pytest %files %{python_files} %doc README.rst ++++++ tensorpac-0.6.2.tar.gz -> tensorpac-0.6.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/MANIFEST.in new/tensorpac-0.6.3/MANIFEST.in --- old/tensorpac-0.6.2/MANIFEST.in 2019-02-06 21:52:32.000000000 +0100 +++ new/tensorpac-0.6.3/MANIFEST.in 2020-03-18 17:25:40.000000000 +0100 @@ -1,3 +1,5 @@ include README.rst include LICENSE -include requirements.txt \ No newline at end of file +include requirements.txt + +recursive-include tensorpac *.* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/PKG-INFO new/tensorpac-0.6.3/PKG-INFO --- old/tensorpac-0.6.2/PKG-INFO 2019-09-10 11:51:54.000000000 +0200 +++ new/tensorpac-0.6.3/PKG-INFO 2020-03-25 07:57:28.000000000 +0100 @@ -1,13 +1,13 @@ Metadata-Version: 1.2 Name: tensorpac -Version: 0.6.2 +Version: 0.6.3 Summary: Tensor-based Phase-Amplitude Coupling Home-page: http://etiennecmb.github.io/tensorpac/ Author: Etienne Combrisson Author-email: e.combris...@gmail.com Maintainer: Etienne Combrisson License: BSD 3-Clause License -Download-URL: https://github.com/EtienneCmb/tensorpac/archive/v0.6.2.tar.gz +Download-URL: https://github.com/EtienneCmb/tensorpac/archive/v0.6.3.tar.gz Description: ========= Tensorpac ========= @@ -78,18 +78,6 @@ .. figure:: https://github.com/EtienneCmb/tensorpac/blob/master/docs/source/picture/readme.png :align: center - Contributors - ------------ - - * `Etienne Combrisson <http://etiennecmb.github.io>`_ - * `Karim Jerbi <http://www.karimjerbi.com>`_ - * Juan L.P. Soto - * Timothy C. Nest - * `Robin Ince <http://www.robinince.net/about.html>`_ - * `Andrea Brovelli <http://andrea-brovelli.net/>`_ - * `Aymeric Guillot <https://libm.univ-st-etienne.fr/fr/les-membres-du-libm/les-enseignants-chercheurs/guillot-aymeric.html>`_ - - Keywords: phase-amplitude coupling pac tensor oscillation meg eeg python Platform: any Classifier: Development Status :: 5 - Production/Stable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/README.rst new/tensorpac-0.6.3/README.rst --- old/tensorpac-0.6.2/README.rst 2019-08-06 14:20:40.000000000 +0200 +++ new/tensorpac-0.6.3/README.rst 2020-03-25 07:53:16.000000000 +0100 @@ -67,15 +67,3 @@ .. figure:: https://github.com/EtienneCmb/tensorpac/blob/master/docs/source/picture/readme.png :align: center - -Contributors ------------- - -* `Etienne Combrisson <http://etiennecmb.github.io>`_ -* `Karim Jerbi <http://www.karimjerbi.com>`_ -* Juan L.P. Soto -* Timothy C. Nest -* `Robin Ince <http://www.robinince.net/about.html>`_ -* `Andrea Brovelli <http://andrea-brovelli.net/>`_ -* `Aymeric Guillot <https://libm.univ-st-etienne.fr/fr/les-membres-du-libm/les-enseignants-chercheurs/guillot-aymeric.html>`_ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/setup.py new/tensorpac-0.6.3/setup.py --- old/tensorpac-0.6.2/setup.py 2019-09-10 11:39:55.000000000 +0200 +++ new/tensorpac-0.6.3/setup.py 2020-03-25 07:56:30.000000000 +0100 @@ -4,7 +4,7 @@ import os from setuptools import setup, find_packages -__version__ = "0.6.2" +__version__ = "0.6.3" NAME = 'tensorpac' AUTHOR = "Etienne Combrisson" MAINTAINER = "Etienne Combrisson" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/__init__.py new/tensorpac-0.6.3/tensorpac/__init__.py --- old/tensorpac-0.6.2/tensorpac/__init__.py 2019-09-10 11:40:03.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac/__init__.py 2020-03-25 07:56:41.000000000 +0100 @@ -14,4 +14,4 @@ logger = logging.getLogger('brainets') set_log_level('info') -__version__ = "0.6.2" +__version__ = "0.6.3" Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/__init__.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/__init__.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/config.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/config.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/filtering.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/filtering.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/gcmi.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/gcmi.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/io.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/io.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/memory.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/memory.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/methods.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/methods.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/normalize.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/normalize.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/pac.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/pac.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/pacstr.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/pacstr.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/signals.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/signals.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/spectral.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/spectral.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/stats.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/stats.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/surrogates.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/surrogates.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/utils.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/utils.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/__pycache__/visu.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/__pycache__/visu.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/methods/__pycache__/__init__.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/methods/__pycache__/__init__.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/methods/__pycache__/meth_erpac.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/methods/__pycache__/meth_erpac.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/methods/__pycache__/meth_pac.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/methods/__pycache__/meth_pac.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/methods/__pycache__/meth_pp.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/methods/__pycache__/meth_pp.cpython-37.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/methods/__pycache__/meth_surrogates.cpython-37.pyc and new/tensorpac-0.6.3/tensorpac/methods/__pycache__/meth_surrogates.cpython-37.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/methods/meth_pac.py new/tensorpac-0.6.3/tensorpac/methods/meth_pac.py --- old/tensorpac-0.6.2/tensorpac/methods/meth_pac.py 2019-08-26 09:29:35.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac/methods/meth_pac.py 2020-03-23 08:12:50.000000000 +0100 @@ -172,7 +172,7 @@ return pac -def _kl_hr(pha, amp, n_bins): +def _kl_hr(pha, amp, n_bins, mean_bins=True): """Binarize the amplitude according to phase values. This function is shared by the Kullback-Leibler Distance and the @@ -185,8 +185,9 @@ for i in np.unique(phad): # Find where phase take vecbin values : idx = phad == i + m = idx.sum() if mean_bins else 1. # Take the sum of amplitude inside the bin : - abin_pha = np.einsum('i...j, k...j->ik...', amp, idx) / idx.sum() + abin_pha = np.einsum('i...j, k...j->ik...', amp, idx) / m abin.append(abin_pha) return np.array(abin) @@ -201,7 +202,9 @@ Respectively the arrays of phases of shape (n_pha, ..., n_times) and the array of amplitudes of shape (n_amp, ..., n_times). p : float | .05 - P-value to use for thresholding + P-value to use for thresholding. Sub-threshold PAC values + will be set to 0. To disable this behavior (no masking), use ``p=1`` or + ``p=None``. Returns ------- @@ -216,35 +219,42 @@ """ npts = amp.shape[-1] # Normalize amplitude : - np.subtract(amp, np.mean(amp, axis=-1, keepdims=True), out=amp) - np.divide(amp, np.std(amp, axis=-1, keepdims=True), out=amp) + # Use the sample standard deviation, as in original Matlab code from author + amp = np.subtract(amp, np.mean(amp, axis=-1, keepdims=True)) + amp = np.divide(amp, np.std(amp, ddof=1, axis=-1, keepdims=True)) # Compute pac : pac = np.abs(np.einsum('i...j, k...j->ik...', amp, np.exp(1j * pha))) - pac *= pac / npts + + if p == 1. or p is None: + # No thresholding + return pac / npts + + s = pac**2 + pac /= npts # Set to zero non-significant values: - xlim = erfinv(1 - p)**2 - pac[pac <= 2 * xlim] = 0. + xlim = npts * erfinv(1 - p)**2 + pac[s <= 2 * xlim] = 0. return pac -def ps(pha, amp): +def ps(pha, pha_amp): """Phase Synchrony (Penny, 2008; Cohen, 2008). - In order to measure the phase synchrony, the phase of the amplitude must be - provided. + In order to measure the phase synchrony, the phase of the amplitude of the + higher-frequency signal must be provided, and not the amplitude as in most + other PAC functions. Parameters ---------- - pha, amp : array_like - Respectively the arrays of phases of shape (n_pha, ..., n_times) and - the array of amplitudes of shape (n_amp, ..., n_times). - n_bins : int | 18 - Number of bins to binarize the amplitude according to phase intervals + pha, pha_amp : array_like + Respectively the arrays of phases of shape (n_pha, ..., n_times) for + the lower frequency and the array of phase of the amplitude signal of + shape (n_pha_amp, ..., n_times) for the higher frequency. Returns ------- pac : array_like - Array of phase amplitude coupling of shape (n_amp, n_pha, ...) + Array of phase amplitude coupling of shape (n_pha_amp, n_pha, ...) References ---------- @@ -254,7 +264,8 @@ coupling in the human medial frontal cortex during decision making. Journal of cognitive neuroscience 21:390–402. """ - pac = np.einsum('i...j, k...j->ik...', np.exp(-1j * amp), np.exp(1j * pha)) + pac = np.einsum('i...j, k...j->ik...', np.exp(-1j * pha_amp), + np.exp(1j * pha)) return np.abs(pac) / pha.shape[-1] Binary files old/tensorpac-0.6.2/tensorpac/methods/tests/__pycache__/test_pac_methods.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/methods/tests/__pycache__/test_pac_methods.cpython-37-PYTEST.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/methods/tests/test_pac_methods.py new/tensorpac-0.6.3/tensorpac/methods/tests/test_pac_methods.py --- old/tensorpac-0.6.2/tensorpac/methods/tests/test_pac_methods.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/methods/tests/test_pac_methods.py 2020-03-23 08:12:50.000000000 +0100 @@ -0,0 +1,112 @@ +"""Test PAC methods.""" +import numpy as np +from tensorpac.methods.meth_pac import get_pac_fcn, pacstr +from tensorpac.methods.meth_surrogates import compute_surrogates, normalize +from tensorpac.methods.meth_pp import preferred_phase +from tensorpac.methods.meth_erpac import erpac, ergcpac, _ergcpac_perm + +n_pac_range = range(1, 7) +n_sur_range = range(4) +n_norm_range = range(1, 5) + +n_epochs = 5 +n_times = 1000 +n_pha_freqs = 2 +n_amp_freqs = 3 +n_bins = 18 +pval = .05 +n_perm = 2 + +pha = np.random.uniform(-np.pi, np.pi, (n_pha_freqs, n_epochs, n_times)) +amp = np.random.rand(n_amp_freqs, n_epochs, n_times) + + +class TestMethods(object): + """Test individual pac methods.""" + + @staticmethod + def _get_methods(): + meths = [] + q = 1 + while q is not None: + try: + meths += [get_pac_fcn(q, n_bins, pval)] + q += 1 + except ValueError as e: # noqa + q = None + return meths + + def test_pacstr(self): + """Test getting pas string name.""" + for p in n_pac_range: + for s in n_sur_range: + for n in n_norm_range: + names = pacstr((p, s, n)) + assert all([isinstance(k, str) for k in names]) + # test assert error + try: + pacstr((p + 1, s, n)) + except ValueError as e: # noqa + pass + try: + pacstr((p, s + 1, n)) + except ValueError as e: # noqa + pass + try: + pacstr((p, s, n + 1)) + except ValueError as e: # noqa + pass + + def test_pac_methods(self): + """Test individual pac methods.""" + for n, meth in enumerate(self._get_methods()): + if n + 1 == 6: # gc pac need additional multivariate axis + _pha = np.stack([np.sin(pha), np.cos(pha)], axis=-2) + _amp = amp[..., np.newaxis, :] + pac = meth(_pha, _amp) + elif n + 1 == 4: # Try with different values of p for coverage + pac = meth(pha, amp, p=0.5) + pac = meth(pha, amp, p=1) + pac = meth(pha, amp, p=None) + else: + pac = meth(pha, amp) + assert pac.shape == (n_amp_freqs, n_pha_freqs, n_epochs) + + def test_surrogates(self): + """Test computing surrogates.""" + fcn = get_pac_fcn(1, n_bins, pval) + s_shape = (n_perm, n_amp_freqs, n_pha_freqs, n_epochs) + for s in n_sur_range: + surro = compute_surrogates(pha, amp, s, fcn, n_perm, 1) + assert (surro is None) or (surro.shape == s_shape) + + def test_normalize(self): + """Test normalization.""" + for k in n_norm_range: + true_pac = np.random.rand(n_amp_freqs, n_pha_freqs) + perm_pac = np.random.rand(n_perm, n_amp_freqs, n_pha_freqs) + normalize(k, true_pac, perm_pac) + + def test_erpac(self): + """Test event-related PAC.""" + er_pha, er_amp = np.moveaxis(pha, -2, -1), np.moveaxis(amp, -2, -1) + # circular + er_circ, pv_circ = erpac(er_pha, er_amp) + assert er_circ.shape == pv_circ.shape + assert er_circ.shape == (n_amp_freqs, n_pha_freqs, n_times) + # gaussian copula + _pha = np.stack([np.sin(er_pha), np.cos(er_pha)], axis=-2) + _amp = er_amp[..., np.newaxis, :] + ergc_circ = ergcpac(_pha, _amp, smooth=None) + assert ergc_circ.shape == (n_amp_freqs, n_pha_freqs, n_times) + ergcpac(_pha, _amp, smooth=5) + # test erpac permutations + ergc_perm = _ergcpac_perm(_pha, _amp, smooth=None, n_perm=n_perm) + assert ergc_perm.shape == (n_perm, n_amp_freqs, n_pha_freqs, n_times) + + def test_preferred_phase(self): + """Test preferred phase method.""" + bin_amp, pp, fvec = preferred_phase(pha, amp, n_bins) + assert bin_amp.shape == (n_bins, n_amp_freqs, n_pha_freqs, n_epochs) + assert pp.shape == (n_amp_freqs, n_pha_freqs, n_epochs) + assert fvec.shape == (n_bins,) Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_gcmi.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_gcmi.cpython-37-PYTEST.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_io.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_io.cpython-37-PYTEST.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_pac.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_pac.cpython-37-PYTEST.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_signals.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_signals.cpython-37-PYTEST.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_stats.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_stats.cpython-37-PYTEST.pyc differ Binary files old/tensorpac-0.6.2/tensorpac/tests/__pycache__/test_utils.cpython-37-PYTEST.pyc and new/tensorpac-0.6.3/tensorpac/tests/__pycache__/test_utils.cpython-37-PYTEST.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_gcmi.py new/tensorpac-0.6.3/tensorpac/tests/test_gcmi.py --- old/tensorpac-0.6.2/tensorpac/tests/test_gcmi.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_gcmi.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,28 @@ +"""Test gcmi related functions.""" +import numpy as np + +from tensorpac.gcmi import copnorm, nd_mi_gg +from tensorpac.config import CONFIG + + +class TestGcmi(object): + """Test GCMI functions.""" + + def test_copnorm(self): + """Test Gaussian-copula normalization.""" + x = np.random.rand(10, 20, 30) + copnorm(x) + + def test_mi(self): + """Test computing MI.""" + rng = np.random.RandomState(0) + x = rng.rand(100, 1, 100) + y = rng.rand(100, 1, 100) + # basic config + nd_mi_gg(x, y) + # modified config + CONFIG['MI_DEMEAN'] = True + CONFIG['MI_BIASCORRECT'] = True + nd_mi_gg(x, y) + CONFIG['MI_BIASCORRECT'] = False + CONFIG['MI_DEMEAN'] = False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_io.py new/tensorpac-0.6.3/tensorpac/tests/test_io.py --- old/tensorpac-0.6.2/tensorpac/tests/test_io.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_io.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,42 @@ +"""Test I/O.""" +import logging + +from tensorpac.io import (set_log_level, is_pandas_installed, + is_statsmodels_installed, progress_bar) + +logger = logging.getLogger('tensorpac') + + +levels = ['profiler', 'debug', 'info', 'warning', 'error', 'critical'] + + +class TestIO(object): + """Test statistical functions.""" + + def test_log_level(self): + """Test setting the log level.""" + for l in levels: + set_log_level(l) + set_log_level(False) + set_log_level(True) + set_log_level(match="ok") + logger.info("show me ok") + logger.info("show me") + + def test_logger(self): + """Test logger levels.""" + set_log_level("profiler") + logger.profiler("profiler") + logger.debug("debug") + logger.info("info") + logger.warning("warning") + logger.critical("critical") + + def test_progress_bar(self): + """Test progress bar.""" + progress_bar(5, 10) + + def test_dependance(self): + """Test dependancies.""" + is_statsmodels_installed() + is_pandas_installed() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_pac.py new/tensorpac-0.6.3/tensorpac/tests/test_pac.py --- old/tensorpac-0.6.2/tensorpac/tests/test_pac.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_pac.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,174 @@ +"""Test tensorpac functions.""" +import numpy as np +import matplotlib + +from tensorpac import Pac, EventRelatedPac, PreferredPhase +from tensorpac.utils import pac_trivec + + +class TestPac(object): + """Tests for Pac, Erpac and Preferred phase.""" + + def test_id_pac_definition(self): + """Test Pac object definition.""" + nmeth, nsuro, nnorm = 6, 4, 5 + for k in range(nmeth): + for i in range(nsuro): + for j in range(nnorm): + p = Pac(idpac=(k + 1, i, j)) + str(p) + + def test_filtering_definition(self): + """Test filtering defintion.""" + dcomplex = ['hilbert', 'wavelet'] + cycle = (12, 24) + width = 12 + for k in dcomplex: + Pac(dcomplex=k, cycle=cycle, width=width) + + def test_spectral(self): + """Test filtering using the provided filters.""" + data = np.random.rand(3, 1000) + p = Pac() + dcomplex = ['hilbert', 'wavelet'] + for k in dcomplex: + p.dcomplex = k + p.filter(1024, data, n_jobs=1) + + def test_filter(self): + """Test filter method.""" + data = np.random.rand(2, 1000) + p = Pac() + p.filter(256, data, 'phase') + p.filter(256, data, 'phase', edges=2) + p.filter(256, data, 'amplitude') + + def test_fit(self): + """Test all Pac methods.""" + pha = np.random.rand(2, 7, 1024) + amp = np.random.rand(3, 7, 1024) + nmeth, nsuro, nnorm = 5, 4, 5 + p = Pac() + for k in range(nmeth): + for i in range(nsuro): + for j in range(nnorm): + p.idpac = (k + 1, i, j) + p.fit(pha, amp, n_jobs=1, n_perm=10) + + def test_filterfit(self): + """Test filtering test computing PAC.""" + data = np.random.rand(2, 1024) + p = Pac(idpac=(4, 0, 0)) + p.filterfit(1024, data, n_jobs=1) + p.idpac = (1, 1, 1) + p.filterfit(1024, data, data, n_jobs=1, n_perm=2) + p.dcomplex = 'wavelet' + p.filter(1024, data, n_jobs=1) + + def test_properties(self): + """Test Pac properties.""" + p = Pac() + # Idpac : + p.idpac + p.idpac = (2, 1, 1) + # Dcomplex : + p.dcomplex + p.dcomplex = 'wavelet' + # Cycle : + p.cycle + p.cycle = (12, 24) + # Width : + p.width + p.width = 12 + + def test_pac_comodulogram(self): + """Test Pac object definition. + + This test works locally but failed on travis... + """ + matplotlib.use('agg') + f, tridx = pac_trivec() + pac = np.random.rand(20, 10) + pval = np.random.rand(20, 10) + p = Pac(f_pha=np.arange(11), f_amp=np.arange(21)) + p.comodulogram(np.random.rand(10, 10, 20)) + p.comodulogram(pac, rmaxis=True, dpaxis=True, interp=(.1, .1)) + p.comodulogram(pac, plotas='contour', pvalues=pval) + p.comodulogram(pac, plotas='pcolor', pvalues=pval, levels=[.5, .7], + under='gray', over='red', bad='orange') + p = Pac(f_pha=np.arange(11), f_amp=f) + pac = np.random.rand(len(f)) + p.triplot(pac, f, tridx) + p.savefig('test_savefig.png') + p.show() + matplotlib.pyplot.close('all') + + +class TestErpac(object): + """Test EventRelatedPac class.""" + + def test_filter(self): + """Test function filter.""" + data = np.random.rand(7, 1000) + p = EventRelatedPac() + p.filter(256, data, 'phase') + p.filter(256, data, 'amplitude') + + def test_fit(self): + """Test function fit.""" + data = np.random.rand(100, 1000) + p = EventRelatedPac() + pha = p.filter(256, data, 'phase') + amp = p.filter(256, data, 'amplitude') + p.fit(pha, amp, method='circular') + p.fit(pha, amp, method='gc') + p.fit(pha, amp, method='gc', n_perm=2) + p.fit(pha, amp, method='gc', smooth=5) + p.surrogates, p.pvalues + + def test_filterfit(self): + """Test function filterfit.""" + p = EventRelatedPac() + x_pha = np.random.rand(100, 1000) + x_amp = np.random.rand(100, 1000) + p.filterfit(256, x_pha, x_amp=x_amp, method='circular') + p.filterfit(256, x_pha, x_amp=x_amp, method='gc') + + +class TestPreferredPhase(object): + """Test EventRelatedPac class.""" + + def test_filter(self): + """Test function filter.""" + data = np.random.rand(7, 1000) + p = PreferredPhase() + p.filter(256, data, 'phase') + p.filter(256, data, 'amplitude') + + def test_fit(self): + """Test function fit.""" + data = np.random.rand(100, 1000) + p = PreferredPhase() + pha = p.filter(256, data, 'phase') + amp = p.filter(256, data, 'amplitude') + p.fit(pha, amp) + + def test_filterfit(self): + """Test function filterfit.""" + p = PreferredPhase() + x_pha = np.random.rand(100, 1000) + x_amp = np.random.rand(100, 1000) + p.filterfit(256, x_pha, x_amp=x_amp) + + def test_polar_plot(self): + """Test the polar plot.""" + matplotlib.use('agg') + p = PreferredPhase(f_pha=[5, 7], f_amp=(60, 200, 10, 1)) + x_pha = np.random.rand(100, 1000) + x_amp = np.random.rand(100, 1000) + ampbin, pp, vecbin = p.filterfit(256, x_pha, x_amp=x_amp) + pp = np.squeeze(pp).T + ampbin = np.squeeze(ampbin).mean(-1) + p.polar(ampbin.T, vecbin, p.yvec, cmap='RdBu_r', interp=.1, + cblabel='Amplitude bins') + matplotlib.pyplot.close('all') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_signals.py new/tensorpac-0.6.3/tensorpac/tests/test_signals.py --- old/tensorpac-0.6.2/tensorpac/tests/test_signals.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_signals.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,25 @@ +"""Test random signals generation.""" +import numpy as np + +from tensorpac.signals import pac_signals_wavelet, pac_signals_tort + + +class TestSignals(object): + """Test random signals generation.""" + + def test_pac_signals_dtrials(self): + """Definition of artificially coupled signals using dPha/dAmp.""" + assert pac_signals_tort(f_pha=5, f_amp=130, sf=512, n_epochs=23, + chi=0.9, noise=2, dpha=35, damp=46) + + def test_pac_signals_bandwidth(self): + """Definition of artificially coupled signals using bandwidth.""" + assert pac_signals_tort(f_pha=[5, 7], f_amp=[30, 60], sf=200., + n_epochs=100, chi=0.5, noise=3., n_times=1000) + assert pac_signals_wavelet(f_pha=10, f_amp=57., n_times=1240, sf=256, + noise=.7, n_epochs=33, pp=np.pi / 4, + rnd_state=23) + + def test_default_args(self): + """Test default aurguments for pac_vec.""" + assert pac_signals_tort(chi=2., noise=11., dpha=120., damp=200.) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_stats.py new/tensorpac-0.6.3/tensorpac/tests/test_stats.py --- old/tensorpac-0.6.2/tensorpac/tests/test_stats.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_stats.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,19 @@ +"""Test stastical functions.""" +import numpy as np + +from tensorpac.stats import test_stationarity as stats_stationarity + +n_epochs = 8 +n_times = 200 +sf = 128. +pval = .05 +rng = np.random.RandomState(1) +data = rng.rand(n_epochs, n_times) + + +class TestStats(object): + """Test statistical functions.""" + + def test_stats_stationarity(self): + """Test the stationarity.""" + stats_stationarity(data, p=pval) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/tests/test_utils.py new/tensorpac-0.6.3/tensorpac/tests/test_utils.py --- old/tensorpac-0.6.2/tensorpac/tests/test_utils.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tensorpac-0.6.3/tensorpac/tests/test_utils.py 2019-10-07 16:13:11.000000000 +0200 @@ -0,0 +1,68 @@ +"""Test tensorpac utils.""" +import numpy as np +import matplotlib + +from tensorpac.utils import pac_vec, pac_trivec, PSD, BinAmplitude, PLV + + +class TestUtils(object): + """Test utility functions.""" + + def test_pac_vec(self): + """Definition of PAC vectors.""" + assert pac_vec() + assert pac_vec(f_pha=(1, 30, 2, 2), f_amp=(60, 200, 10, 5)) + assert pac_vec(f_pha=[1, 2], f_amp=np.arange(50)) + assert pac_vec(f_pha=np.array([[2, 4], [5, 7], [9, 10]]), + f_amp=np.array([[30, 60], [60, 90], [100, 200]]).T) + assert pac_vec(f_pha=[[1, 2], [5, 7]], f_amp=[60, 150]) + assert pac_vec(f_pha='lres', f_amp='lres') + assert pac_vec(f_pha='mres', f_amp='mres') + assert pac_vec(f_pha='hres', f_amp='hres') + + def test_trivec(self): + """Definition of triangular vectors.""" + assert pac_trivec(2, 200, 10) + + def test_psd(self): + """Test PSD.""" + # test definition + x = np.random.rand(10, 200) + psd = PSD(x, 128) + # test properties + psd.freqs + psd.psd + # test plotting + matplotlib.use('agg') + psd.plot(confidence=None, log=True, grid=True, interp=.1) + psd.plot(confidence=.95, log=False, grid=False, interp=None) + psd.show() + matplotlib.pyplot.close('all') + + def test_binned_amplitude(self): + """Test binned amplitude.""" + # test definition + x = np.random.rand(10, 200) + binamp = BinAmplitude(x, 128) + # test plot + binamp.plot(unit='rad') + binamp.plot(unit='deg') + binamp.show() + matplotlib.pyplot.close('all') + # test properties + binamp.phase + binamp.amplitude + + def test_plv(self): + """Test Phase-locking Value.""" + # test definition + x = np.random.rand(10, 200) + plv_1d = PLV(x, 128, f_pha=[2, 4]) + plv_2d = PLV(x, 128, f_pha=[[2, 4], [5, 7]]) + # test properties + plv_1d.plv + # test plot + plv_1d.plot() + plv_2d.plot() + plv_1d.show() + matplotlib.pyplot.close('all') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/utils.py new/tensorpac-0.6.3/tensorpac/utils.py --- old/tensorpac-0.6.2/tensorpac/utils.py 2019-08-20 12:20:55.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac/utils.py 2019-10-16 10:45:09.000000000 +0200 @@ -264,7 +264,7 @@ pha = self.filter(sf, x, 'phase', **kw) amp = self.filter(sf, x, 'amplitude', **kw) # binarize amplitude according to phase - self._amplitude = _kl_hr(pha, amp, n_bins).squeeze() + self._amplitude = _kl_hr(pha, amp, n_bins, mean_bins=False).squeeze() self.n_bins = n_bins def plot(self, unit='rad', **kw): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac/visu.py new/tensorpac-0.6.3/tensorpac/visu.py --- old/tensorpac-0.6.2/tensorpac/visu.py 2019-08-20 12:21:59.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac/visu.py 2019-10-16 11:00:33.000000000 +0200 @@ -172,8 +172,9 @@ if polar: ax.grid(True) ax.set_rlabel_position(0) - ax.set_thetamin(0) - ax.set_thetamax(360) + ax.set_thetamin(-180) + ax.set_thetamax(180) + ax.set_thetagrids([-135, -90, -45, 0, 45, 90, 135, 180]) return plt.gca() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac.egg-info/PKG-INFO new/tensorpac-0.6.3/tensorpac.egg-info/PKG-INFO --- old/tensorpac-0.6.2/tensorpac.egg-info/PKG-INFO 2019-09-10 11:51:54.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac.egg-info/PKG-INFO 2020-03-25 07:57:27.000000000 +0100 @@ -1,13 +1,13 @@ Metadata-Version: 1.2 Name: tensorpac -Version: 0.6.2 +Version: 0.6.3 Summary: Tensor-based Phase-Amplitude Coupling Home-page: http://etiennecmb.github.io/tensorpac/ Author: Etienne Combrisson Author-email: e.combris...@gmail.com Maintainer: Etienne Combrisson License: BSD 3-Clause License -Download-URL: https://github.com/EtienneCmb/tensorpac/archive/v0.6.2.tar.gz +Download-URL: https://github.com/EtienneCmb/tensorpac/archive/v0.6.3.tar.gz Description: ========= Tensorpac ========= @@ -78,18 +78,6 @@ .. figure:: https://github.com/EtienneCmb/tensorpac/blob/master/docs/source/picture/readme.png :align: center - Contributors - ------------ - - * `Etienne Combrisson <http://etiennecmb.github.io>`_ - * `Karim Jerbi <http://www.karimjerbi.com>`_ - * Juan L.P. Soto - * Timothy C. Nest - * `Robin Ince <http://www.robinince.net/about.html>`_ - * `Andrea Brovelli <http://andrea-brovelli.net/>`_ - * `Aymeric Guillot <https://libm.univ-st-etienne.fr/fr/les-membres-du-libm/les-enseignants-chercheurs/guillot-aymeric.html>`_ - - Keywords: phase-amplitude coupling pac tensor oscillation meg eeg python Platform: any Classifier: Development Status :: 5 - Production/Stable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tensorpac-0.6.2/tensorpac.egg-info/SOURCES.txt new/tensorpac-0.6.3/tensorpac.egg-info/SOURCES.txt --- old/tensorpac-0.6.2/tensorpac.egg-info/SOURCES.txt 2019-09-10 11:51:54.000000000 +0200 +++ new/tensorpac-0.6.3/tensorpac.egg-info/SOURCES.txt 2020-03-25 07:57:27.000000000 +0100 @@ -18,8 +18,43 @@ tensorpac.egg-info/dependency_links.txt tensorpac.egg-info/requires.txt tensorpac.egg-info/top_level.txt +tensorpac/__pycache__/__init__.cpython-37.pyc +tensorpac/__pycache__/config.cpython-37.pyc +tensorpac/__pycache__/filtering.cpython-37.pyc +tensorpac/__pycache__/gcmi.cpython-37.pyc +tensorpac/__pycache__/io.cpython-37.pyc +tensorpac/__pycache__/memory.cpython-37.pyc +tensorpac/__pycache__/methods.cpython-37.pyc +tensorpac/__pycache__/normalize.cpython-37.pyc +tensorpac/__pycache__/pac.cpython-37.pyc +tensorpac/__pycache__/pacstr.cpython-37.pyc +tensorpac/__pycache__/signals.cpython-37.pyc +tensorpac/__pycache__/spectral.cpython-37.pyc +tensorpac/__pycache__/stats.cpython-37.pyc +tensorpac/__pycache__/surrogates.cpython-37.pyc +tensorpac/__pycache__/utils.cpython-37.pyc +tensorpac/__pycache__/visu.cpython-37.pyc tensorpac/methods/__init__.py tensorpac/methods/meth_erpac.py tensorpac/methods/meth_pac.py tensorpac/methods/meth_pp.py -tensorpac/methods/meth_surrogates.py \ No newline at end of file +tensorpac/methods/meth_surrogates.py +tensorpac/methods/__pycache__/__init__.cpython-37.pyc +tensorpac/methods/__pycache__/meth_erpac.cpython-37.pyc +tensorpac/methods/__pycache__/meth_pac.cpython-37.pyc +tensorpac/methods/__pycache__/meth_pp.cpython-37.pyc +tensorpac/methods/__pycache__/meth_surrogates.cpython-37.pyc +tensorpac/methods/tests/test_pac_methods.py +tensorpac/methods/tests/__pycache__/test_pac_methods.cpython-37-PYTEST.pyc +tensorpac/tests/test_gcmi.py +tensorpac/tests/test_io.py +tensorpac/tests/test_pac.py +tensorpac/tests/test_signals.py +tensorpac/tests/test_stats.py +tensorpac/tests/test_utils.py +tensorpac/tests/__pycache__/test_gcmi.cpython-37-PYTEST.pyc +tensorpac/tests/__pycache__/test_io.cpython-37-PYTEST.pyc +tensorpac/tests/__pycache__/test_pac.cpython-37-PYTEST.pyc +tensorpac/tests/__pycache__/test_signals.cpython-37-PYTEST.pyc +tensorpac/tests/__pycache__/test_stats.cpython-37-PYTEST.pyc +tensorpac/tests/__pycache__/test_utils.cpython-37-PYTEST.pyc \ No newline at end of file