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 ce9c4284d88947b045f6f2a822051c6fd2c9beb1 Author: Alexandre Gramfort <[email protected]> Date: Wed Jan 19 16:58:05 2011 -0500 better example of reading evoked data --- examples/plot_read_epochs.py | 75 ++++++++++++++++++++++++++++++++++++++++++++ examples/read_epochs.py | 45 -------------------------- mne/epochs.py | 4 +-- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/examples/plot_read_epochs.py b/examples/plot_read_epochs.py new file mode 100644 index 0000000..cbf28b9 --- /dev/null +++ b/examples/plot_read_epochs.py @@ -0,0 +1,75 @@ +""" +================================== +Reading epochs from a raw FIF file +================================== + +This script shows how to read the epochs from a raw file given +a list of events. For illustration, we compute the evoked responses +for both MEG and EEG data by averaging all the epochs. + +""" +# Authors: Alexandre Gramfort <[email protected]> +# Matti Hamalainen <[email protected]> +# +# License: Simplified BSD + +print __doc__ + +import os +import numpy as np + +import mne +from mne import fiff + +############################################################################### +# Set parameters +raw_fname = os.environ['MNE_SAMPLE_DATASET_PATH'] +raw_fname += '/MEG/sample/sample_audvis_raw.fif' +event_fname = os.environ['MNE_SAMPLE_DATASET_PATH'] +event_fname += '/MEG/sample/sample_audvis_raw-eve.fif' +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) + +# Set up pick list: MEG + STI 014 - bad channels (modify to your needs) +include = [] # or stim channel ['STI 014'] +exclude = raw['info']['bads'] + ['MEG 2443', 'EEG 053'] # bads + 2 more + +# MEG +meg_picks = fiff.pick_types(raw['info'], meg=True, eeg=False, stim=False, + include=include, exclude=exclude) +meg_data, times, channel_names = mne.read_epochs(raw, events, event_id, + tmin, tmax, picks=meg_picks) +meg_epochs = np.array([d['epoch'] for d in meg_data]) # build 3D matrix +meg_evoked_data = np.mean(meg_epochs, axis=0) # compute evoked fields + +# EEG +eeg_picks = fiff.pick_types(raw['info'], meg=False, eeg=True, stim=False, + include=include, exclude=exclude) +eeg_data, times, channel_names = mne.read_epochs(raw, events, event_id, + tmin, tmax, picks=eeg_picks) +eeg_epochs = np.array([d['epoch'] for d in eeg_data]) # build 3D matrix +eeg_evoked_data = np.mean(eeg_epochs, axis=0) # compute evoked potentials + +############################################################################### +# View evoked response +import pylab as pl +pl.clf() +pl.subplot(2, 1, 1) +pl.plot(times, meg_evoked_data.T) +pl.xlim([times[0], times[-1]]) +pl.xlabel('time (ms)') +pl.ylabel('Magnetic Field (T)') +pl.title('MEG evoked field') +pl.subplot(2, 1, 2) +pl.plot(times, eeg_evoked_data.T) +pl.xlim([times[0], times[-1]]) +pl.xlabel('time (ms)') +pl.ylabel('Potential (V)') +pl.title('EEG evoked potential') +pl.subplots_adjust(0.175, 0.04, 0.94, 0.94, 0.2, 0.33) +pl.show() diff --git a/examples/read_epochs.py b/examples/read_epochs.py deleted file mode 100644 index a06a675..0000000 --- a/examples/read_epochs.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -================================== -Reading epochs from a raw FIF file -================================== -""" -# Authors: Alexandre Gramfort <[email protected]> -# Matti Hamalainen <[email protected]> -# -# License: Simplified BSD - -print __doc__ - -import mne -from mne import fiff - -############################################################################### -# Set parameters -raw_fname = 'MNE-sample-data/MEG/sample/sample_audvis_raw.fif' -event_name = 'MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif' -event_id = 1 -tmin = -0.2 -tmax = 0.5 -pick_all = True - -# Setup for reading the raw data -raw = fiff.setup_read_raw(raw_fname) -events = mne.read_events(event_name) - -if pick_all: - # Pick all - picks = range(raw['info']['nchan']) -else: - # Set up pick list: MEG + STI 014 - bad channels (modify to your needs) - include = ['STI 014']; - want_meg = True - want_eeg = False - want_stim = False - picks = fiff.pick_types(raw['info'], want_meg, want_eeg, want_stim, - include, raw['info']['bads']) - -data, times, channel_names = mne.read_epochs(raw, events, event_id, - tmin, tmax, picks=picks) - -# for epoch in data: - \ No newline at end of file diff --git a/mne/epochs.py b/mne/epochs.py index 4a99c94..ca3b9ac 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -158,7 +158,7 @@ def read_epochs(raw, events, event_id, tmin, tmax, picks=None, data[0]['epoch'].shape[1]) # Remember to close the file descriptor - raw['fid'].close() - print 'File closed.' + # raw['fid'].close() + # print 'File closed.' return data, times, ch_names -- 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
