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 4f558427bc75fea759e2770fb3db760149915dea Author: Alexandre Gramfort <[email protected]> Date: Tue Dec 28 15:48:39 2010 -0500 working read_events --- examples/read_events.py | 20 +++++++++++++++++++ fiff/__init__.py | 3 ++- fiff/event.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/examples/read_events.py b/examples/read_events.py new file mode 100644 index 0000000..1bcab5f --- /dev/null +++ b/examples/read_events.py @@ -0,0 +1,20 @@ +"""Reading an event file +""" +print __doc__ + +import pylab as pl +import fiff + +fname = 'MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif' +# fname = 'sm02a5_raw.fif' + +event_list = fiff.read_events(fname) + +############################################################################### +# Show MEG data +pl.plot(times, data.T) +pl.xlabel('time (ms)') +pl.ylabel('MEG data (T)') +pl.show() + + diff --git a/fiff/__init__.py b/fiff/__init__.py index 1984433..552760e 100644 --- a/fiff/__init__.py +++ b/fiff/__init__.py @@ -2,5 +2,6 @@ from .constants import FIFF from .open import fiff_open from .evoked import read_evoked from .cov import read_cov -from .raw import setup_read_raw, read_raw_segment +from .raw import setup_read_raw, read_raw_segment, read_raw_segment_times +from .event import read_events diff --git a/fiff/event.py b/fiff/event.py new file mode 100644 index 0000000..6bfed59 --- /dev/null +++ b/fiff/event.py @@ -0,0 +1,51 @@ +"""IO with fif files containing events +""" + +# Author: Alexandre Gramfort <[email protected]> +# License: BSD Style. + +from .constants import FIFF +from .tree import dir_tree_find +from .tag import read_tag +from .open import fiff_open + + +def read_events(filename): + """Reads events from fif file + + Parameters + ---------- + filename: string + name of the fif file + + Returns + ------- + events: array, shape (n_events, 3) + The list of events + """ + + fid, tree, _ = fiff_open(filename) + + # Find the desired block + events = dir_tree_find(tree, FIFF.FIFFB_MNE_EVENTS) + + if len(events) == 0: + fid.close() + raise ValueError, 'Could not find event data' + + events = events[0] + + for d in events.directory: + kind = d.kind + pos = d.pos + if kind == FIFF.FIFF_MNE_EVENT_LIST: + tag = read_tag(fid, pos) + event_list = tag.data + fid.close() + break + else: + fid.close() + raise ValueError, 'Could not find any events' + + event_list = event_list.reshape(len(event_list) / 3, 3) + return event_list -- 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
