[med-svn] [python-mne] 102/376: more on time-frequency (test + fix)
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:22:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
yoh pushed a commit to annotated tag v0.1
in repository python-mne.
commit fabc50b0be5dc30165e3e07eaa720e9cee51da4d
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date: Tue Mar 1 11:18:05 2011 -0500
more on time-frequency (test + fix)
---
mne/tests/test_tfr.py | 13 +++++++++++--
mne/tfr.py | 5 +++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/mne/tests/test_tfr.py b/mne/tests/test_tfr.py
index 14d46a2..e3f59fe 100644
--- a/mne/tests/test_tfr.py
+++ b/mne/tests/test_tfr.py
@@ -40,9 +40,18 @@ def test_time_frequency():
frequencies = np.arange(4, 20, 5) # define frequencies of interest
Fs = raw['info']['sfreq'] # sampling in Hz
power, phase_lock = time_frequency(epochs, Fs=Fs, frequencies=frequencies,
- n_cycles=2)
+ n_cycles=2, use_fft=True)
assert power.shape == (len(picks), len(frequencies), len(times))
assert power.shape == phase_lock.shape
assert np.sum(phase_lock >= 1) == 0
- assert np.sum(phase_lock <= 0) == 0
\ No newline at end of file
+ assert np.sum(phase_lock <= 0) == 0
+
+ power, phase_lock = time_frequency(epochs, Fs=Fs, frequencies=frequencies,
+ n_cycles=2, use_fft=False)
+
+ assert power.shape == (len(picks), len(frequencies), len(times))
+ assert power.shape == phase_lock.shape
+ assert np.sum(phase_lock >= 1) == 0
+ assert np.sum(phase_lock <= 0) == 0
+
\ No newline at end of file
diff --git a/mne/tfr.py b/mne/tfr.py
index 3b47eb1..be4a5da 100644
--- a/mne/tfr.py
+++ b/mne/tfr.py
@@ -184,7 +184,8 @@ def time_frequency(epochs, Fs, frequencies, use_fft=True, n_cycles=25):
Returns
-------
power : 2D array
- Induced power (Channels x Frequencies x Timepoints)
+ Induced power (Channels x Frequencies x Timepoints).
+ Squared amplitude of time-frequency coefficients.
phase_lock : 2D array
Phase locking factor in [0, 1] (Channels x Frequencies x Timepoints)
"""
@@ -196,7 +197,7 @@ def time_frequency(epochs, Fs, frequencies, use_fft=True, n_cycles=25):
for e in range(n_epochs):
tfr = cwt_morlet(epochs[e, c, :].ravel(), Fs, frequencies,
use_fft=use_fft, n_cycles=n_cycles)
- psd[c,:,:] += np.abs(tfr)
+ psd[c,:,:] += np.abs(tfr)**2
plf[c,:,:] += tfr / psd[c,:,:]
psd /= n_epochs
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git
More information about the debian-med-commit
mailing list