This is an automated email from the git hooks/post-receive script. yoh pushed a commit to tag 0.4 in repository python-mne.
commit 34add6faf3bac0722285e0b6fdc3396a61a80804 Author: [email protected] <[email protected]> Date: Mon Jun 25 05:38:54 2012 -0400 ENH: proj support in compute_raw_psd --- mne/time_frequency/psd.py | 14 ++++++++++++-- mne/time_frequency/tests/test_psd.py | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mne/time_frequency/psd.py b/mne/time_frequency/psd.py index cc80874..32c5d47 100644 --- a/mne/time_frequency/psd.py +++ b/mne/time_frequency/psd.py @@ -4,11 +4,11 @@ import numpy as np import pylab as pl from ..parallel import parallel_func - +from ..fiff.proj import make_projector_info def compute_raw_psd(raw, tmin=0, tmax=np.inf, picks=None, fmin=0, fmax=np.inf, NFFT=2048, n_jobs=1, - plot=False): + plot=False, proj=False): """Compute power spectral density with multi-taper Parameters @@ -42,6 +42,9 @@ def compute_raw_psd(raw, tmin=0, tmax=np.inf, picks=None, plot: bool Plot each PSD estimates + proj : bool + Apply SSP projection vectors + Return ------ psd: array of float @@ -56,6 +59,13 @@ def compute_raw_psd(raw, tmin=0, tmax=np.inf, picks=None, else: data, times = raw[:, start:(stop + 1)] + if proj: + proj, _ = make_projector_info(raw.info) + if picks is not None: + data = np.dot(proj[picks][:, picks], data) + else: + data = np.dot(proj, data) + NFFT = int(NFFT) Fs = raw.info['sfreq'] diff --git a/mne/time_frequency/tests/test_psd.py b/mne/time_frequency/tests/test_psd.py index 5d70405..38a7936 100644 --- a/mne/time_frequency/tests/test_psd.py +++ b/mne/time_frequency/tests/test_psd.py @@ -27,8 +27,13 @@ def test_psd(): fmin, fmax = 2, 70 # look at frequencies between 5 and 70Hz NFFT = 124 # the FFT size (NFFT). Ideally a power of 2 psds, freqs = compute_raw_psd(raw, tmin=tmin, tmax=tmax, picks=picks, - fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1) + fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1, + proj=False) + psds_proj, freqs = compute_raw_psd(raw, tmin=tmin, tmax=tmax, picks=picks, + fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1, + proj=True) + assert_array_almost_equal(psds, psds_proj) assert_true(psds.shape == (len(picks), len(freqs))) assert_true(np.sum(freqs < 0) == 0) assert_true(np.sum(psds < 0) == 0) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
