[Eeglablist] add events to the EEG data
Makoto Miyakoshi
mmiyakoshi at ucsd.edu
Fri Feb 6 22:10:10 PST 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150206/ae217069/attachment.html>
More information about the eeglablist
mailing list