[med-svn] [python-mne] 101/376: adding test for time frequency transform

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 77b8287611f49ee7e7d3d49c846d0db51eb270aa
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Mon Feb 28 21:37:03 2011 -0500

    adding test for time frequency transform
---
 mne/tests/test_tfr.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/mne/tests/test_tfr.py b/mne/tests/test_tfr.py
new file mode 100644
index 0000000..14d46a2
--- /dev/null
+++ b/mne/tests/test_tfr.py
@@ -0,0 +1,48 @@
+import numpy as np
+import os.path as op
+
+from numpy.testing import assert_allclose
+
+import mne
+from mne import fiff
+from mne import time_frequency
+
+raw_fname = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data',
+                'test_raw.fif')
+event_fname = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data',
+                'test-eve.fif')
+
+def test_time_frequency():
+    """Test IO for STC files
+    """
+    # Set parameters
+    event_id = 1
+    tmin = -0.2
+    tmax = 0.5
+
+    # Setup for reading the raw data
+    raw = fiff.setup_read_raw(raw_fname)
+    events = mne.read_events(event_fname)
+
+    include = []
+    exclude = raw['info']['bads'] + ['MEG 2443', 'EEG 053'] # bads + 2 more
+
+    # picks MEG gradiometers
+    picks = fiff.pick_types(raw['info'], meg='grad', eeg=False,
+                                    stim=False, include=include, exclude=exclude)
+
+    picks = picks[:2]
+    data, times, channel_names = mne.read_epochs(raw, events, event_id,
+                                    tmin, tmax, picks=picks, baseline=(None, 0))
+    epochs = np.array([d['epoch'] for d in data]) # as 3D matrix
+    evoked_data = np.mean(epochs, axis=0) # compute evoked fields
+
+    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)
+
+    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

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