[med-svn] [python-mne] 116/376: create separate module for time freq analysis

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:22:18 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 d281c2b1cfb8caf948fa60b751121c78b6060113
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Mon Mar 7 11:50:27 2011 -0500

    create separate module for time freq analysis
---
 examples/time_frequency/plot_time_frequency.py |  4 ++--
 mne/__init__.py                                |  1 -
 mne/time_frequency/__init__.py                 |  5 +++++
 mne/{ => time_frequency}/tests/test_tfr.py     | 14 +++++++-------
 mne/{ => time_frequency}/tfr.py                |  4 ++--
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/examples/time_frequency/plot_time_frequency.py b/examples/time_frequency/plot_time_frequency.py
index 6675318..f7cea4a 100644
--- a/examples/time_frequency/plot_time_frequency.py
+++ b/examples/time_frequency/plot_time_frequency.py
@@ -18,7 +18,7 @@ import numpy as np
 
 import mne
 from mne import fiff
-from mne import time_frequency
+from mne.time_frequency import induced_power
 from mne.datasets import sample
 
 ###############################################################################
@@ -52,7 +52,7 @@ evoked *= 1e13 # change unit to fT / cm
 
 frequencies = np.arange(7, 30, 3) # define frequencies of interest
 Fs = raw['info']['sfreq'] # sampling in Hz
-power, phase_lock = time_frequency(data, Fs=Fs, frequencies=frequencies,
+power, phase_lock = induced_power(data, Fs=Fs, frequencies=frequencies,
                                    n_cycles=2, n_jobs=1, use_fft=False)
 
 ###############################################################################
diff --git a/mne/__init__.py b/mne/__init__.py
index 64e7010..5b0ed2d 100644
--- a/mne/__init__.py
+++ b/mne/__init__.py
@@ -7,6 +7,5 @@ from .stc import read_stc, write_stc
 from .bem_surfaces import read_bem_surfaces
 from .inverse import read_inverse_operator, compute_inverse
 from .epochs import Epochs
-from .tfr import time_frequency
 from .label import label_time_courses, read_label
 import fiff
diff --git a/mne/time_frequency/__init__.py b/mne/time_frequency/__init__.py
new file mode 100644
index 0000000..b2674f5
--- /dev/null
+++ b/mne/time_frequency/__init__.py
@@ -0,0 +1,5 @@
+"""Time frequency analysis tools
+"""
+
+from .tfr import induced_power, single_trial_power
+
diff --git a/mne/tests/test_tfr.py b/mne/time_frequency/tests/test_tfr.py
similarity index 78%
rename from mne/tests/test_tfr.py
rename to mne/time_frequency/tests/test_tfr.py
index d9ca5e4..e701117 100644
--- a/mne/tests/test_tfr.py
+++ b/mne/time_frequency/tests/test_tfr.py
@@ -3,12 +3,12 @@ import os.path as op
 
 import mne
 from mne import fiff
-from mne import time_frequency
-from mne.tfr import cwt_morlet
+from mne.time_frequency import induced_power
+from mne.time_frequency.tfr import cwt_morlet
 
-raw_fname = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data',
+raw_fname = op.join(op.dirname(__file__), '..', '..', 'fiff', 'tests', 'data',
                 'test_raw.fif')
-event_fname = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data',
+event_fname = op.join(op.dirname(__file__), '..', '..', 'fiff', 'tests', 'data',
                 'test-eve.fif')
 
 def test_time_frequency():
@@ -31,14 +31,14 @@ def test_time_frequency():
                                     stim=False, include=include, exclude=exclude)
 
     picks = picks[:2]
-    epochs = mne.read_epochs(raw, events, event_id,
+    epochs = mne.Epochs(raw, events, event_id,
                                     tmin, tmax, picks=picks, baseline=(None, 0))
     data = epochs.get_data()
     times = epochs.times
 
     frequencies = np.arange(6, 20, 5) # define frequencies of interest
     Fs = raw['info']['sfreq'] # sampling in Hz
-    power, phase_lock = time_frequency(data, Fs=Fs, frequencies=frequencies,
+    power, phase_lock = induced_power(data, Fs=Fs, frequencies=frequencies,
                                        n_cycles=2, use_fft=True)
 
     assert power.shape == (len(picks), len(frequencies), len(times))
@@ -46,7 +46,7 @@ def test_time_frequency():
     assert np.sum(phase_lock >= 1) == 0
     assert np.sum(phase_lock <= 0) == 0
 
-    power, phase_lock = time_frequency(data, Fs=Fs, frequencies=frequencies,
+    power, phase_lock = induced_power(data, Fs=Fs, frequencies=frequencies,
                                        n_cycles=2, use_fft=False)
 
     assert power.shape == (len(picks), len(frequencies), len(times))
diff --git a/mne/tfr.py b/mne/time_frequency/tfr.py
similarity index 98%
rename from mne/tfr.py
rename to mne/time_frequency/tfr.py
index 986f45b..3847eae 100644
--- a/mne/tfr.py
+++ b/mne/time_frequency/tfr.py
@@ -162,7 +162,7 @@ def cwt_morlet(X, Fs, freqs, use_fft=True, n_cycles=7.0):
     else:
         coefs = _cwt_convolve(X, Ws, mode)
 
-    tfrs = np.empty((n_signals, n_frequencies, n_times))
+    tfrs = np.empty((n_signals, n_frequencies, n_times), dtype=np.complex)
     for k, tfr in enumerate(coefs):
         tfrs[k] = tfr
 
@@ -213,7 +213,7 @@ def single_trial_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7):
 
     return power
 
-def time_frequency(data, Fs, frequencies, use_fft=True, n_cycles=25,
+def induced_power(data, Fs, frequencies, use_fft=True, n_cycles=25,
                    n_jobs=1):
     """Compute time induced power and inter-trial phase-locking factor
 

-- 
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