[med-svn] [python-mne] 24/52: ENH : adding temporal decimation factor to induced_power
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:23:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
yoh pushed a commit to annotated tag v0.2
in repository python-mne.
commit 7c23f792e2208a293331575ebcafe7094e02e7bc
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date: Thu Sep 29 15:22:09 2011 -0400
ENH : adding temporal decimation factor to induced_power
---
examples/time_frequency/plot_time_frequency.py | 11 ++++++-----
mne/time_frequency/tfr.py | 16 +++++++---------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/examples/time_frequency/plot_time_frequency.py b/examples/time_frequency/plot_time_frequency.py
index 601b16e..fdecfa4 100644
--- a/examples/time_frequency/plot_time_frequency.py
+++ b/examples/time_frequency/plot_time_frequency.py
@@ -26,9 +26,7 @@ from mne.datasets import sample
data_path = sample.data_path('..')
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_raw-eve.fif'
-event_id = 1
-tmin = -0.2
-tmax = 0.5
+event_id, tmin, tmax = 1, -0.2, 0.5
# Setup for reading the raw data
raw = fiff.Raw(raw_fname)
@@ -55,10 +53,13 @@ evoked_data = evoked_data[97:98, :]
frequencies = np.arange(7, 30, 3) # define frequencies of interest
Fs = raw.info['sfreq'] # sampling in Hz
+decim = 3
power, phase_lock = induced_power(data, Fs=Fs, frequencies=frequencies,
- n_cycles=2, n_jobs=1, use_fft=False)
+ n_cycles=2, n_jobs=1, use_fft=False,
+ decim=decim)
-power /= np.mean(power[:, :, times < 0], axis=2)[:, :, None] # baseline ratio
+# baseline corrections with ratio
+power /= np.mean(power[:, :, times[::decim] < 0], axis=2)[:, :, None]
###############################################################################
# View time-frequency plots
diff --git a/mne/time_frequency/tfr.py b/mne/time_frequency/tfr.py
index 6af02ec..8eee48f 100644
--- a/mne/time_frequency/tfr.py
+++ b/mne/time_frequency/tfr.py
@@ -299,7 +299,7 @@ def single_trial_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
def induced_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
- n_jobs=1):
+ decim=1, n_jobs=1):
"""Compute time induced power and inter-trial phase-locking factor
The time frequency decomposition is done with Morlet wavelets
@@ -308,20 +308,17 @@ def induced_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
----------
epochs : array
3D array of shape [n_epochs, n_channels, n_times]
-
Fs : float
sampling Frequency
-
frequencies : array
Array of frequencies of interest
-
use_fft : bool
Compute transform with fft based convolutions or temporal
convolutions.
-
n_cycles : int
The number of cycles in the wavelet
-
+ decim: int
+ Temporal decimation factor
n_jobs : int
The number of CPUs used in parallel. All CPUs are used in -1.
Requires joblib package.
@@ -335,7 +332,7 @@ def induced_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
Phase locking factor in [0, 1] (Channels x Frequencies x Timepoints)
"""
n_frequencies = len(frequencies)
- n_epochs, n_channels, n_times = epochs.shape
+ n_epochs, n_channels, n_times = epochs[:, :, ::decim].shape
# Precompute wavelets for given frequency range to save time
Ws = morlet(Fs, frequencies, n_cycles=n_cycles)
@@ -348,7 +345,8 @@ def induced_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
for c in range(n_channels):
X = np.squeeze(epochs[:, c, :])
- psd[c], plf[c] = _time_frequency(X, Ws, use_fft)
+ this_psd, this_plf = _time_frequency(X, Ws, use_fft)
+ psd[c], plf[c] = this_psd[:, ::decim], this_plf[:, ::decim]
else:
psd_plf = parallel(my_time_frequency(np.squeeze(epochs[:, c, :]),
@@ -358,7 +356,7 @@ def induced_power(epochs, Fs, frequencies, use_fft=True, n_cycles=7,
psd = np.zeros((n_channels, n_frequencies, n_times))
plf = np.zeros((n_channels, n_frequencies, n_times), dtype=np.complex)
for c, (psd_c, plf_c) in enumerate(psd_plf):
- psd[c, :, :], plf[c, :, :] = psd_c, plf_c
+ psd[c, :, :], plf[c, :, :] = psd_c[:, ::decim], plf_c[:, ::decim]
psd /= n_epochs
plf = np.abs(plf) / 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