0001 function [eventlist] = mne_read_events(filename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
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
0030
0031 [ fid, tree ] = fiff_open(filename);
0032
0033
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