Skip to content

Commit

Permalink
Merge branch 'hotfix/add_triExample'
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneCmb committed Jun 25, 2017
2 parents 2686c8d + 4a8b828 commit 3eda716
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
21 changes: 21 additions & 0 deletions examples/12_Fmin-FmaxOptimisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Search for the optimal [Fmin; Fmax]hz amplitude band."""
import matplotlib.pyplot as plt

from tensorpac import Pac, PacTriVec, PacSignals

plt.rc('text', usetex=True)
plt.rc('font', family='serif')

sf = 256.
data, time = PacSignals(fpha=[5, 7], famp=[60, 100], noise=2, ndatasets=30,
npts=6000, sf=sf, dpha=10)

trif, tridx = PacTriVec(fstart=30, fend=160, fwidth=5)

p = Pac(idpac=(1, 0, 0), fpha=[5, 7], famp=trif)
pac, _ = p.filterfit(sf, data, data, axis=1)

p.triplot(pac.mean(-1), trif, tridx, cmap='Spectral_r', rmaxis=True,
title=r'Optimal $[Fmin; Fmax]$hz band for amplitude')
# plt.savefig('triplot.png', dpi=600, bbox_inches='tight')
p.show()
3 changes: 2 additions & 1 deletion tensorpac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
Phase-Amplitude Coupling.
"""
from .pac import Pac
from .utils import PacSignals, PacVec, PacTriVec

__version__ = '0.4'
__all__ = ['Pac', 'PacSignals', 'PacVec', 'PacTriVec']
2 changes: 1 addition & 1 deletion tensorpac/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def pear(x, y, st='i...j, k...j->ik...'):
"""Pearson correlation for PAC data.
"""
print('XY : ', x.shape, y.shape)
# print('XY : ', x.shape, y.shape)
n = x.shape[-1]
# Distribution center :
mu_x = x.mean(-1, keepdims=True)
Expand Down
6 changes: 5 additions & 1 deletion tensorpac/visu.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def triplot(self, pac, fvec, tridx, xlabel='Starting frequency (hz)',
"""Triangular plot."""
pac, tridx = np.squeeze(pac), np.squeeze(tridx)
# ___________________ CHECKING ___________________
print(pac.shape, fvec.shape, tridx.shape)
# Check if pac is a raw vector :
if pac.ndim is not 1:
raise ValueError("The PAC variable must be a row vector.")
Expand All @@ -122,6 +121,11 @@ def triplot(self, pac, fvec, tridx, xlabel='Starting frequency (hz)',
return self._pacplot(rpac, xvec, yvec, xlabel, ylabel, cblabel,
bad=bad, **kwargs)

def show(self):
"""Display the figure."""
import matplotlib.pyplot as plt
plt.show()

def _pacplot(self, pac, xvec, yvec, xlabel='', ylabel='', cblabel='',
title='', cmap='viridis', vmin=None, vmax=None, under=None,
over=None, bad=None, pvalues=None, p=0.05, interp=None,
Expand Down

0 comments on commit 3eda716

Please sign in to comment.