<div dir="ltr">Dear James,<div><br></div><div>By the way, I tried hard to come up with a trick to spare the for loop. See my code below. I mean, what is this?? But it works like a charm.</div><div><br></div><div><div>    % extract event labels and time stamps</div><div>    allEventLabels = mobilab.allStreams.item{eventStreanIdx}.event.label;</div><div>    eventTimeStamp = mobilab.allStreams.item{eventStreanIdx}.timeStamp; % in second</div><div><br></div><div>    % import event markers and latency to EEG.event</div><div>    allEventLatency = num2cell((eventTimeStamp-EEG.urxmin)*1000);</div><div>    allUrevent      = num2cell(1:length(allEventLatency));</div><div>    EEG.event = struct('type', {}, 'latency',{}, 'urevent',{});</div><div>    [EEG.event(1,1:length(allEventLabels)).latency] = allEventLatency{:};</div><div>    [EEG.event(1,1:length(allEventLabels)).type]    = allEventLabels{:};</div><div>    [EEG.event(1,1:length(allEventLabels)).urevent] = allUrevent{:};</div><div>    EEG = eeg_checkset(EEG,'eventconsistency');</div></div><div><br></div><div>This is also a convenient trick which I often use.</div><div><br></div><div>allEvent = {EEG.event.type}';</div><div>targetIdx = find(strcmp(allEvent, 'target'));</div><div>targetLatency = allEvent(targetIdx).latency;</div><div><br></div><div>Makoto</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 6, 2015 at 6:19 AM, James Desjardins <span dir="ltr"><<a href="mailto:jdesjardins@brocku.ca" target="_blank">jdesjardins@brocku.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi Karlo,<br>
<br>
Once you load a data set, executing the following script at the command line should add the events that you are looking for...<br>
<br>
%Get the latencies (data point indices) for all 'A' type events...<br>
<font face="Courier New">A_latencies=[EEG.event(find(strcmp('A',{EEG.event.type}))).latency];<br>
<br>
%for each A_latencies add a new event type '1' with a latency of </font><font face="Courier New"><font face="Courier New">(A_latencies(i)+1.5*EEG.srate)-1...<br>
</font>for i=1:length(A_latencies);<br>
    n_events=length(EEG.event);<br>
    EEG.event(n_events+1).type='1';<br>
    EEG.event(n_events+1).latency=(A_latencies(i)+1.5*EEG.srate)-1;<br>
    EEG.event(n_events+1).urevent=n_events+1;<br>
end<br>
<br>
%check for consistency and reorder the events chronologically...<br>
EEG=eeg_checkset(EEG,'eventconsistency');<br>
</font><br>
<div><br>
<div style="font-family:Tahoma;font-size:13px">
<div><font><span style="font-size:10pt">
<div>James</div>
</span></font></div>
</div>
</div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>From:</b> <a href="mailto:eeglablist-bounces@sccn.ucsd.edu" target="_blank">eeglablist-bounces@sccn.ucsd.edu</a> [<a href="mailto:eeglablist-bounces@sccn.ucsd.edu" target="_blank">eeglablist-bounces@sccn.ucsd.edu</a>] on behalf of karlo gonzales [<a href="mailto:thats_karlo@yahoo.com" target="_blank">thats_karlo@yahoo.com</a>]<br>
<b>Sent:</b> February 5, 2015 5:16 PM<br>
<b>To:</b> EEGLAB List<br>
<b>Subject:</b> [Eeglablist] add events to the EEG data<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div style="color:#000;background-color:#fff;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px">
<div dir="ltr">Hi, </div>
<div dir="ltr"><br>
</div>
<div dir="ltr">We have an EEG data  with several events, which marked as 'A' and repeated every 5 sec. </div>
<div dir="ltr">what i am looking for is a way to add extra events to the data such as  event '1' and appears 1.5 sec after event 'A'. </div>
<div dir="ltr"><br>
</div>
<div dir="ltr">i am looking forward to hear from you.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Thanks in advance,</div>
<div dir="ltr">Karlo</div>
</div>
</div>
</div></div></div>
</div>
</div>

<br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.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.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>