Home > vbmeg > external > mne > mne_read_events.m

mne_read_events

PURPOSE ^

SYNOPSIS ^

function [eventlist] = mne_read_events(filename)

DESCRIPTION ^

 [eventlist] = mne_read_events(filename)

 Read an event list from a fif file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [eventlist] = mne_read_events(filename)
0002 %
0003 % [eventlist] = mne_read_events(filename)
0004 %
0005 % Read an event list from a fif file
0006 %
0007 
0008 %
0009 %   Author : Matti Hamalainen, MGH Martinos Center
0010 %   License : BSD 3-clause
0011 %
0012 %
0013 %   Revision 1.2  2008/08/21 18:03:16  msh
0014 %   Fixed possibility for closing the file twice
0015 %
0016 %   Revision 1.1  2008/06/16 17:27:50  msh
0017 %   Added mne_read_events and mne_write_events functions
0018 %
0019 %
0020 global FIFF;
0021 if isempty(FIFF)
0022    FIFF = fiff_define_constants();
0023 end
0024 
0025 me='MNE:mne_read_events';
0026 
0027 
0028 %
0029 % Open file
0030 %
0031 [ fid, tree ] = fiff_open(filename);
0032 %
0033 %   Find the desired block
0034 %
0035 events = fiff_dir_tree_find(tree,FIFF.FIFFB_MNE_EVENTS);
0036 if isempty(events)
0037   fclose(fid);
0038   error(me,'Could not find event data');
0039 end
0040 
0041 eventlist = [];
0042 for k = 1:events.nent
0043     kind = events.dir(k).kind;
0044     pos  = events.dir(k).pos;
0045     if kind == FIFF.FIFF_MNE_EVENT_LIST
0046       tag = fiff_read_tag(fid,pos);
0047       eventlist = tag.data;
0048       break;
0049     end
0050 end
0051 fclose(fid);
0052 if isempty(eventlist)
0053    error(me,'Could not find any events');
0054 else
0055    eventlist = reshape(eventlist',3,size(eventlist,1)/3)';
0056 end
0057 
0058 return;
0059

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005