0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 function [types type_count]=list_event_types(EEG_or_fname,timelock_only)
0037
0038 if nargin<2,
0039 timelock_only=1;
0040 end
0041
0042 if ischar(EEG_or_fname),
0043 EEG=pop_loadset(EEG_or_fname);
0044 else
0045 EEG=EEG_or_fname;
0046 clear EEG_or_fname;
0047 end
0048
0049
0050 if isempty(EEG.epoch),
0051
0052 fprintf('set file contains continuous EEG data.\n');
0053 n_ev=length(EEG.event);
0054 n_types=0;
0055 types=[];
0056 type_count=[];
0057 for a=1:n_ev,
0058 ev_type=EEG.event(a).type;
0059 if ~isstr(ev_type)
0060 ev_type=num2str(ev_type);
0061 end
0062 if isempty(types),
0063 tf=0;
0064 else
0065 [tf, loc]=ismember(ev_type,types);
0066 end
0067 if tf
0068
0069 type_count(loc)=type_count(loc)+1;
0070 else
0071
0072 n_types=n_types+1;
0073 types{n_types}=ev_type;
0074 type_count(n_types)=1;
0075 end
0076 end
0077 else
0078
0079 fprintf('set file contains epoched EEG data.\n');
0080 n_ep=length(EEG.epoch);
0081 n_types=0;
0082 types=[];
0083 type_count=[];
0084 if timelock_only,
0085 for a=1:n_ep,
0086 if iscell(EEG.epoch(a).eventtype),
0087
0088
0089 n_type_this_ep=length(EEG.epoch(a).eventtype);
0090 else
0091 n_type_this_ep=1;
0092 end
0093 for b=1:n_type_this_ep,
0094 if iscell(EEG.epoch(a).eventlatency),
0095
0096
0097 ev_latency=EEG.epoch(a).eventlatency{b};
0098 ev_type=EEG.epoch(a).eventtype{b};
0099 else
0100 ev_latency=EEG.epoch(a).eventlatency(b);
0101 ev_type=EEG.epoch(a).eventtype;
0102 end
0103
0104 if ~ev_latency,
0105
0106
0107 if isempty(types)
0108 tf=0;
0109 else
0110 [tf loc]=ismember(ev_type,types);
0111 end
0112 if tf
0113
0114 type_count(loc)=type_count(loc)+1;
0115 else
0116
0117 n_types=n_types+1;
0118 if iscell(ev_type),
0119 types{n_types}=ev_type{1};
0120 else
0121 types{n_types}=ev_type;
0122 end
0123 type_count(n_types)=1;
0124 end
0125 end
0126 end
0127 end
0128 else
0129 for a=1:n_ep,
0130 if iscell(EEG.epoch(a).eventtype),
0131
0132
0133 n_type_this_ep=length(EEG.epoch(a).eventtype);
0134 else
0135 n_type_this_ep=1;
0136 end
0137 for b=1:n_type_this_ep,
0138 if iscell(EEG.epoch(a).eventlatency),
0139
0140
0141 ev_type=EEG.epoch(a).eventtype{b};
0142 else
0143 ev_type=EEG.epoch(a).eventtype;
0144 end
0145 [tf loc]=ismember(ev_type,types);
0146 if tf
0147
0148 type_count(loc)=type_count(loc)+1;
0149 else
0150
0151 n_types=n_types+1;
0152 types{n_types}=ev_type;
0153 type_count(n_types)=1;
0154 end
0155 end
0156 end
0157 end
0158 end
0159
0160 for a=1:n_types,
0161 fprintf('Event Type: ''%s'' (occurences=%d)\n',types{a},type_count(a));
0162 end