|
82 | 82 | EEG.urevent = EEG.urevent(ind); |
83 | 83 | case 'keepbeforeevent' |
84 | 84 | ind = find(ind); |
85 | | - if ind(end) == numel(EEG.event), ind(end) = []; end |
86 | | - ind = ind(~strcmp({EEG.event(ind+1).type},op{2})); |
87 | | - EEG.event(ind) = []; |
88 | | - EEG.urevent(ind) = []; |
| 85 | + indCrit = find(strcmp({EEG.event.type},op{2})); |
| 86 | + indKeep = arrayfun(@(l) find(ind<l, 1, 'last'), indCrit); |
| 87 | + indOmit = setdiff(1:numel(ind),indKeep); |
| 88 | + EEG.event(ind(indOmit)) = []; |
| 89 | + EEG.urevent(ind(indOmit)) = []; |
89 | 90 | case 'rename' |
90 | 91 | for i = find(ind) |
91 | 92 | EEG.event(i).type = op{2}; |
|
162 | 163 | EEG.event = EEG.event(ord); |
163 | 164 | for i = 1:numel(EEG.event), EEG.event(i).urevent = i; end |
164 | 165 | EEG.urevent = rmfield(EEG.event,'urevent'); |
| 166 | + case 'prefixpattern' |
| 167 | + pfx = strsplit(op{3}(2:end-1),' '); |
| 168 | + if sum(ind) ~= numel(pfx), aas_log(aap, true, sprintf('You need %d prefixes in a space-delimited list',sum(ind))); end |
| 169 | + ind = find(ind); |
| 170 | + for n = 1:numel(ind) |
| 171 | + EEG.event(ind(n)).type = regexprep(EEG.event(ind(n)).type,['(' op{2} ')'],[pfx{n} '$1']); |
| 172 | + EEG.urevent(EEG.event(ind(n)).urevent).type = EEG.event(ind(n)).type; |
| 173 | + end |
165 | 174 | case 'ignorebefore' |
166 | 175 | EEG = pop_select(EEG,'nopoint',[0 EEG.event(ind(1)).latency-1]); |
167 | 176 | beInd = find(strcmp({EEG.event.type},'boundary'),1,'first'); |
|
0 commit comments