Skip to content

Commit 7b9d3c4

Browse files
committed
FIX - MEEG: event editing
1 parent 21c2c3c commit 7b9d3c4

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

aa_modules/aamod_meeg_converttoeeglab.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@
8282
EEG.urevent = EEG.urevent(ind);
8383
case 'keepbeforeevent'
8484
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)) = [];
8990
case 'rename'
9091
for i = find(ind)
9192
EEG.event(i).type = op{2};
@@ -162,6 +163,14 @@
162163
EEG.event = EEG.event(ord);
163164
for i = 1:numel(EEG.event), EEG.event(i).urevent = i; end
164165
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
165174
case 'ignorebefore'
166175
EEG = pop_select(EEG,'nopoint',[0 EEG.event(ind(1)).latency-1]);
167176
beInd = find(strcmp({EEG.event.type},'boundary'),1,'first');

aa_modules/aamod_meeg_converttoeeglab.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'insertwithlatency:[<array of latencies>] - insert event with latencies'
2828
'insertwithtime:[<array of latencies>] - insert event with time'
2929
'inserteachbetween:<start event>:<step in sec>:<end event>' - insert events at each <step in sec> between <start event> and <end event>
30+
'prefixpattern:<pattern>:[<space-delimited list of prefixes>]' - prefix pattern matched in event name
3031
'ignorebefore' - remove heading data before the first occurence (excluding the event)
3132
'ignoreafter' - remove trailig data after the last occurence (including the event)
3233
-->

0 commit comments

Comments
 (0)