[Eeglablist] add events to the EEG data

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Wed Feb 11 15:47:32 PST 2015


Dear James,

Ah ok... but looks like eeg_addnewevets() internally uses loop.
My point is this: as far as I know, this is the only way to enter multiple
variables to the multiple 'slots' in a structure.

> [EEG.event(1,1:length(allEventLabels)).latency] = allEventLatency{:};

Actually, I don't think it is necessary to exclude for loop this much. But,
if you are dealing with large number of events (for example, saccade onset
and offset for 1.5 hours of recording... it produced >50k events) this may
make a difference.

Makoto

On Sat, Feb 7, 2015 at 7:51 AM, James Desjardins <jdesjardins at brocku.ca>
wrote:

>  Hi Makoto! what is that?? :)
>
> I think that the "eeg_addnewevents" that Tarik brought up is the most
> elegant way of doing this without a loop at the command line (and I am
> going to use it from now on instead of those explicit loops).
>
> e.g.
>
> %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...
> EEG=eeg_addnewevents(EEG,{[(A_latencies+1.5*EEG.srate)-1]}, {'1'});
>
> %check for consistency and reorder the events chronologically...
> EEG=eeg_checkset(EEG,'eventconsistency');
>
>  James
>   ------------------------------
> *From:* eeglablist-bounces at sccn.ucsd.edu [eeglablist-bounces at sccn.ucsd.edu]
> on behalf of Makoto Miyakoshi [mmiyakoshi at ucsd.edu]
> *Sent:* February 7, 2015 1:10 AM
> *To:* James Desjardins
> *Cc:* EEGLAB List
> *Subject:* Re: [Eeglablist] add events to the EEG data
>
>   Dear James,
>
>  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.
>
>      % extract event labels and time stamps
>     allEventLabels = mobilab.allStreams.item{eventStreanIdx}.event.label;
>     eventTimeStamp = mobilab.allStreams.item{eventStreanIdx}.timeStamp; %
> in second
>
>      % import event markers and latency to EEG.event
>     allEventLatency = num2cell((eventTimeStamp-EEG.urxmin)*1000);
>     allUrevent      = num2cell(1:length(allEventLatency));
>     EEG.event = struct('type', {}, 'latency',{}, 'urevent',{});
>     [EEG.event(1,1:length(allEventLabels)).latency] = allEventLatency{:};
>     [EEG.event(1,1:length(allEventLabels)).type]    = allEventLabels{:};
>     [EEG.event(1,1:length(allEventLabels)).urevent] = allUrevent{:};
>     EEG = eeg_checkset(EEG,'eventconsistency');
>
>  This is also a convenient trick which I often use.
>
>  allEvent = {EEG.event.type}';
> targetIdx = find(strcmp(allEvent, 'target'));
> targetLatency = allEvent(targetIdx).latency;
>
>  Makoto
>
> On Fri, Feb 6, 2015 at 6:19 AM, James Desjardins <jdesjardins at brocku.ca>
> wrote:
>
>>  Hi Karlo,
>>
>> Once you load a data set, executing the following script at the command
>> line should add the events that you are looking for...
>>
>> %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');
>>
>>
>>  James
>>   ------------------------------
>> *From:* eeglablist-bounces at sccn.ucsd.edu [
>> eeglablist-bounces at sccn.ucsd.edu] on behalf of karlo gonzales [
>> thats_karlo at yahoo.com]
>> *Sent:* February 5, 2015 5:16 PM
>> *To:* EEGLAB List
>> *Subject:* [Eeglablist] add events to the EEG data
>>
>>    Hi,
>>
>>  We have an EEG data  with several events, which marked as 'A' and
>> repeated every 5 sec.
>> 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'.
>>
>>  i am looking forward to hear from you.
>>
>>  Thanks in advance,
>> Karlo
>>
>> _______________________________________________
>> 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
>



-- 
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/20150211/ae294b28/attachment.html>


More information about the eeglablist mailing list