[Eeglablist] insert events after some markers in EEG data

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Tue Oct 18 00:08:15 PDT 2016


Dear Elisa,

> I would like to add an event coded "33" 2.5 seconds after the onset of
all the events "13".

See below. This was tested so guaranteed to work.

% Obtain latency for event '13'.
allEventTypes = {EEG.event.type}';
eventIndex    = find(strcmp(allEventTypes, '13'));
eventLatency  = [EEG.event(eventIndex).latency]';

% Add event '33' which has latency of eventLatency + 2.5 sec.
for n = 1:length(eventLatency);
    numEvents = length(EEG.event); % Update the current length of EEG.event
    EEG.event(numEvents+1).type    = '33';
    EEG.event(numEvents+1).latency = eventLatency(n) + 0.5*EEG.srate;
    EEG.event(numEvents+1).urevent = numEvents+1;
end

% Sort events chronologically.
EEG = eeg_checkset(EEG, 'eventconsistency');

Makoto



On Sun, Oct 2, 2016 at 6:32 AM, Elisa Tatti <elisatatti at msn.com> wrote:

> Dear EEGLAB users,
>
> We have  EEG recordings with several markers and I would like to add an
> event coded "33" 2.5 seconds after the onset of all the events "13".
> In the EEGLABlist I read about a script to add events on the base of an
> already existent one but it doesn't work on my data (A_latencies is
> empty).  I suppose that this is because my events are coded as numbers and
> the examples provided here were with "characters" (see below):
>
> %Get the latencies (data point indices) for all 'A' type events...
> A_latencies=[EEG.event(find(strcmp('A',{EEG.event.type}))).latency];
>
> %for each A_latencies add a new event type '1' with a latency of (A_latencies(i)+1.5*EEG.srate)-1...
> for i=1:length(A_latencies);
>     n_events=length(EEG.event);
>     EEG.event(n_events+1).type='1';
>     EEG.event(n_events+1).latency=(A_latencies(i)+1.5*EEG.srate)-1;
>     EEG.event(n_events+1).urevent=n_events+1;
> end
>
> %check for consistency and reorder the events chronologically...
> EEG=eeg_checkset(EEG,'eventconsistency');
>
>
>
> I am starting learning matlab now, so I don't know how to adapt this
> script to my data. Can someone help me?!
>
> Thank you for your consideration.
>
>
> Elisa
>
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.
> ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>



-- 
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20161018/17adcf2e/attachment.html>


More information about the eeglablist mailing list