<div dir="ltr">Dear Elisa,<br><br>> I would like to add an event coded "33" 2.5 seconds after the onset of all the events "13".<br><br>See below. This was tested so guaranteed to work.<br><div><br></div><div><font color="#0000ff">% Obtain latency for event '13'.</font></div><div><font color="#0000ff">allEventTypes = {EEG.event.type}';</font></div><div><span style="color:rgb(0,0,255)">eventIndex    = find(strcmp(allEventTypes, '13'));</span><br></div><div><font color="#0000ff">eventLatency  = [EEG.event(eventIndex).latency]';</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff">% Add event '33' which has latency of eventLatency + 2.5 sec. </font></div><div><font color="#0000ff">for n = 1:length(eventLatency);</font></div><div><font color="#0000ff">    numEvents = length(EEG.event); % Update the current length of EEG.event</font></div><div><font color="#0000ff">    EEG.event(numEvents+1).type    = '33';</font></div><div><font color="#0000ff">    EEG.event(numEvents+1).latency = eventLatency(n) + 0.5*EEG.srate;</font></div><div><font color="#0000ff">    EEG.event(numEvents+1).urevent = numEvents+1;</font></div><div><font color="#0000ff">end</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff">% Sort events chronologically.</font></div><div><font color="#0000ff">EEG = eeg_checkset(EEG, 'eventconsistency');</font></div><div><font color="#0000ff"><br></font></div><div>Makoto</div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 2, 2016 at 6:32 AM, Elisa Tatti <span dir="ltr"><<a href="mailto:elisatatti@msn.com" target="_blank">elisatatti@msn.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div class="gmail-m_6721558189674963259hmmessage"><div dir="ltr"><div><div dir="ltr"><font size="3">Dear EEGLAB users,</font><div><font size="3"><br></font></div><div><span style="background-color:rgb(255,255,255)"><span style="line-height:21.3px"><font size="3">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".</font></span></span></div><div><span style="background-color:rgb(255,255,255)"><span style="line-height:21.3px"><font size="3">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):</font></span></span></div><div><span style="background-color:rgb(255,255,255)"><span style="line-height:21.3px"><font size="3"><br></font></span></span></div><div><pre style="white-space:pre-wrap"><font size="3">%Get the latencies (data point indices) for all 'A' type events...
A_latencies=[EEG.event(find(<wbr>strcmp('A',{EEG.event.type})))<wbr>.latency];

%for each A_latencies add a new event type '1' with a latency of (A_latencies(i)+1.5*EEG.srate)<wbr>-1...
for i=1:length(A_latencies);
    n_events=length(EEG.event);
    EEG.event(n_events+1).type='1'<wbr>;
    EEG.event(n_events+1).latency=<wbr>(A_latencies(i)+1.5*EEG.srate)<wbr>-1;
    EEG.event(n_events+1).urevent=<wbr>n_events+1;
end

%check for consistency and reorder the events chronologically...
EEG=eeg_checkset(EEG,'<wbr>eventconsistency');
</font></pre></div><div><font size="3"><br></font></div><div><span style="background-color:rgb(255,255,255)"><span style="line-height:21.3px"><font size="3"><br></font></span></span></div><div><span style="line-height:21.3px;background-color:rgb(255,255,255)"><font size="3">I am starting learning matlab now, so I don't know how to adapt this script to my data. Can someone help me?!</font></span></div><div><font size="3"><br></font></div><div><span style="line-height:21.3px"><font size="3">Thank you for your consideration.</font></span></div><span class="gmail-HOEnZb"><font color="#888888"><div><span style="line-height:21.3px"><font size="3"><br></font></span></div><div><span style="line-height:21.3px"><font size="3"><br></font></span></div><div><span style="line-height:21.3px"><font size="3">Elisa</font></span></div><div><font color="#444444"><span style="font-size:15px;line-height:21.3px"><br></span></font></div>                                       </font></span></div></div>                                      </div></div>
<br>______________________________<wbr>_________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/<wbr>eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.<wbr>ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.<wbr>edu</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</div></div></div>