[Eeglablist] Creating new event codes based on previous combination of event codes in each trial

Renzo Lanfranco renzo.lanfranco at gmail.com
Fri Sep 25 10:42:31 PDT 2020


Thanks, Cédric. I think I didn't express myself correctly. Sorry about that!

So, each epoch has a number of event codes, regarding stimulus class (first
event code), accuracy response (second event code), and awareness response
(third event code). What I'm trying to figure out is how to create a *new*
event code based on the stimulus class event code and on the awareness
response event code. A new event code in the same epoch, at time zero.
These are the events already found in each epoch:

stimulus_events = [11 12 13 14 15 16 21 22 23 24 25 26 31 32 33 34 35 36 41
42 43 44 45 46 51 52 53 53 54 56 61 62 63 64 65 66]; % located around time
zero
response_events = [71 72 73 74]; % accuracy responses not relevant for this
analysis
awareness_events = [81 82 83 84]; % located anywhere in the epoch after 300
ms post-stimulus presentation.

For example, if epoch 1's first event code is 11 (a stimulus event) and the
third event code is 81 (an awareness response event), I'd like to create a
new event code at time zero for that particular epoch called, let's say,
91. In other words to make a new list of event codes that comprise the
stimulus_event codes and the awareness_event code. Because all the epochs
have the same length but in this experiment trials varied in time length,
only the epoch's first three event codes are relevant as sometimes the
epoch segments included the stimulus event from the following trial.
Therefore, the code I'm trying to write (though unsuccessfully so far) has
to take every epoch (trial), read the first event code (stimulus_events
list above) and the third event code (awareness_events list above) and then
create a new event code (at time zero). This new event code is of course
arbitrary. It will have to be from a list of 144 event codes as it needs to
include all the possible combinations between those two lists
(length(stim_events)*length(awareness_events)), but that's something I can
define in an if statement, like in your example code, using:

if EEG.event(1).epoch(iEpoch) == 11 &&  EEG.event(3).epoch(iEpoch) == 81
......

I mean, that's the idea, but I've failed so far to create a code that can
do this succesfully in a For loop.

Thanks so much!
Renzo



On Thu, 24 Sep 2020 at 20:44, Cédric Cannard <ccannard at protonmail.com>
wrote:

> If I understand correctly, you want to predict the which stimulus was
> presented based on the response?
> And you basically need each row to have the stimulus and the response
> together
>
> If this is correct, maybe you something like this would work?
>
> new_events = [];
> for iEvent = 1:10
>     if iEvent == 1
>         trial = EEG.event(iEvent).epoch;
>         new_events(trial).stimulus = EEG.event(iEvent).type;
>         new_events(trial).stimulus_latency = 0;
>         new_events(trial).trial = trial;
>     elseif EEG.event(iEvent).epoch ~= EEG.event(iEvent-1).epoch
>         trial = EEG.event(iEvent).epoch;
>         new_events(trial).stimulus = EEG.event(iEvent).type;
>         new_events(trial).stimulus_latency = 0;
>         new_events(trial).trial = trial;
>     elseif EEG.event(iEvent).epoch == EEG.event(iEvent-1).epoch
>         new_events(trial).response = EEG.event(iEvent).type;
>         new_events(trial).response_latency = EEG.event(iEvent).latency -
> EEG.event(iEvent-1).latency;
>     end
> end
>
>
> Cédric
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, September 24, 2020 11:40 AM, LANFRANCO GUEVARA Renzo <
> renzo.lanfranco at gmail.com> wrote:
>
> Hi Cédric,
>
>
>
> Thanks for your reply. The decoding analysis assumes that the event codes
> at time zero refer to stimulus classes, as it often is. It’s not flexible
> enough to include other aspects that could be decoded such as responses –
> in the case of this experiment, awareness reports. So, by creating new
> event codes at time zero that comprise both the stimulus class and the
> awareness response given, I can sort the trials in the way this toolbox
> requires them. I know that this doesn’t make sense for most time-locked
> analyses, but it makes sense for this toolbox.
>
>
>
> For example, if all epochs (trials) go from -200 to +600 ms (time zero is
> stimulus presentation), and there’s an event code at time zero indicating
> what kind of stimulus was shown, and another event code somewhere between
> 400 and 600 ms indicating what key was pressed, I’d need to create a new
> event code (located at time zero) that accounts for both the stimulus that
> was presented **and** the response that was given later. That way, I can
> instruct the toolbox to define the classes to decode the right way. Because
> we’re trying to decode the stimulus classes for different awareness reports.
>
>
>
> Thanks so much!
>
>
>
> Best,
>
> Renzo
>
>
>
>
>
> *From: *Cédric Cannard <ccannard at protonmail.com>
> *Sent: *24 September 2020 19:25
> *To: *Renzo Lanfranco <renzo.lanfranco at gmail.com>
> *Cc: *Clement Lee <cll008 at eng.ucsd.edu>; EEGLAB List
> <eeglablist at sccn.ucsd.edu>
> *Subject: *RE: [Eeglablist] Creating new event codes based on previous
> combination of event codes in each trial
>
>
>
> Hi Renzo,
>
>
>
> Bringing all events to time 0 does not make any sense as EEG is time
> series data, if you lose the event's time information, they become useless.
> I really don't understand why the toolbox would require you to do that.
>
>
>
> There must be some mistake. Are you sure it is not just referring to the
> stimulus events regarding the event being at time 0? Normally, stimuli are
> at time 0, and responses are at X latency after stimulus. So when you epoch
> data in EEGLAB, you choose your epoch size (tags before and after stimulus)
> and it gives you all trials of same length, with the stimuli at time 0, and
> responses at for example +300 ms, + 450 ms, etc.
>
>
>
> Cédric
>
>
>
>
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Wednesday, September 23, 2020 5:18 PM, Renzo Lanfranco <
> renzo.lanfranco at gmail.com> wrote:
>
>
>
> Thanks, Clement and Cédric, this is really helpful.
>
>
>
> Indeed, I need to create a new event code for each epoch (trial) at
> stimulus onset (time zero) that puts together the information from the
> previous stimulus-related event code and the response-related event code.
> I’m using a decoding toolbox that requires the data to be submitted that
> way (all events at time zero). Your code, Cédric, is very helpful. Checking
> Clement’s link to the Wiki, I found some information that might indirectly
> help too (
> https://sccn.ucsd.edu/wiki/Chapter_03:_Event_Processing#Scripts_for_creating_new_events_based_on_context
> ).
>
>
>
> But you’re right, it’s better to keep all the different numbers. So I have
> a *new question* now: is there any way to move **all** the event codes in
> all the dataset's epochs to time zero? I know this may sound very messy,
> but I should be able to set up this decoding analysis this way too, without
> losing any event codes.
>
>
>
> Thanks so much for your help!
>
> Renzo
>
>
>
>
>
>
>
>
>
> *From: *Cédric Cannard <ccannard at protonmail.com>
> *Sent: *23 September 2020 23:37
> *To: *Clement Lee <cll008 at eng.ucsd.edu>
> *Cc: *Renzo Lanfranco <renzo.lanfranco at gmail.com>; EEGLAB List
> <eeglablist at sccn.ucsd.edu>
> *Subject: *Re: [Eeglablist] Creating new event codes based on previous
> combination of event codes in each trial
>
>
>
>
>
> Hi Renzo,
>
>
>
> I agree with Clement, you normally want to keep the event names as they
> refer to the same type of stimulus/response across epochs, and it is easier
> to analyze event-related activity like this than if they all have different
> numbers.
>
>
>
> So I wouldn't recommend it, but if you just want to just rename them in a
> linear growing manner (not sure how you want to rename them exactly), you
> can do so with something like this:
>
> for iEvent = 1:size(EEG.event,2)
>
>     EEG.event(iEvent).type = num2str(iEvent);
>
> end
>
>
>
>
>
> Cédric
>
>
>
>
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Wednesday, September 23, 2020 1:43 PM, Clement Lee <cll008 at eng.ucsd.edu>
> wrote:
>
>
>
> > Hi Renzo,
>
> >
>
> > What are you trying to accomplish by recoding the stimulus event to
> contain
>
> > information about the response? Depending on your goal, there may be
> easier
>
> > or more common pipelines to follow.
>
> > Have you looked through the EEGLAB wiki's tutorial pages?
>
> > https://sccn.ucsd.edu/wiki/I.Single_subject_data_processing_tutorial
>
> > https://sccn.ucsd.edu/wiki/I.Single_subject_data_processing_tutorial.
>
> > Particularly, Ch. 3 (
> https://sccn.ucsd.edu/wiki/Chapter_03:_Event_Processing
>
> > ) seems relevant in your case.
>
> >
>
> > Best,
>
> > Clement Lee
>
> > Applications Programmer
>
> > Swartz Center for Computational Neuroscience
>
> > Institute for Neural Computation, UC San Diego
>
> > 858-822-7535
>
> >
>
> > On Wed, Sep 23, 2020 at 12:20 PM Renzo Lanfranco
> renzo.lanfranco at gmail.com
>
> > wrote:
>
> >
>
> > > Hi everybody,
>
> > > Thanks in advance. I was hoping someone could lend me a hand. I need to
>
> > > perform the following analysis and don't know how:
>
> > > This is for an EEG decoding analysis, but the EEG data (Biosemi 64) was
>
> > > pre-processed in EEGLAB. Each epoch has two relevant event codes: the
>
> > > stimulus class code (printed at time zero) and a response type code
>
> > > (printed at the moment the participant pressed a key). Therefore, the
>
> > > second event code can vary in time whereas the first event code
> doesn't.
>
> > > What do I need to do?
>
> > > Based on these event codes, I need to create new event codes for every
>
> > > trial and print new codes at time zero that can comprise the previous
> event
>
> > > codes. For example, if event code at time zero can be 1, 2 or 3, and
>
> > > response code printed later can also be 4, 5 or 6., I now need to have
>
> > > event codes at time zeroes that account for all those combinations,
> e.g.
>
> > > 14, 15, 16, 24, 25, 26, 34, 35, and 36.
>
> > > Any ideas how can I accomplish this? I don't have much experience
> working
>
> > > with EEGLAB structures.
>
> > > Thanks so much,
>
> > > R
>
> > >
>
> > > 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
>
> >
>
> > 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
>
>
>
>
>
>
>
>
>
>
>
>
>



More information about the eeglablist mailing list