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

Cédric Cannard ccannard at protonmail.com
Thu Sep 24 12:44:39 PDT 2020


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](mailto:ccannard at protonmail.com)
> Sent: 24 September 2020 19:25
> To: [Renzo Lanfranco](mailto:renzo.lanfranco at gmail.com)
> Cc: [Clement Lee](mailto:cll008 at eng.ucsd.edu); [EEGLAB List](mailto: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](mailto:ccannard at protonmail.com)
>> Sent: 23 September 2020 23:37
>> To: [Clement Lee](mailto:cll008 at eng.ucsd.edu)
>> Cc: [Renzo Lanfranco](mailto:renzo.lanfranco at gmail.com); [EEGLAB List](mailto: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