1

I have epoched data in EEGLAB, however, the event codes are incorrect. I have a stimtrack channel which recorded the audio sent within the experiment so I am trying to rename my event codes according to which stimulus was sent within each trial.

I have epoched this channel on its own so that I can correlate each epoch with a stimulus array used in the experiment. I have used the following code to epoch the data using all the stimulus codes (1-3) although whilst the timing of these is correct, the codes are not

[OUTEEG, indexes] = pop_epoch(EEG);

How do I loop through all the epochs I have to then use the following code to identify correlations between the epochs and the audio stimuli.

all_coefs = [];
for j=1:141
    epoch = OUTEEG.epoch(j); #THIS IS THE LINE OF CODE I AM STUCK ON ESSENTIALLY.
    coefs = [];
    for i=1:20
        two_stim = twohz(i,:);
        a = corrcoef(epoch, two_stim); 
        coefs = [coefs; {a}];
    end
end

Thank you!

sallicap
  • 75
  • 1
  • 7
  • As someone unfamiliar with the EEGLAB toolbox, I'd have to ask for more information about the nature and shape of your data. I assume that `OUTEEG` is some kind of object or struct, but I don't know what goes inside `OUTEEG.epoch`. Presumably it's a timeseries data, but again, I don't know the shape or size of the data you are trying to retrieve. – mimocha Jul 22 '20 at 13:27
  • Dear mimocha, thank you for your comment! Yes OUTEEG is a struct which contains all the information about a dataset including the epochs/events. I am essentially trying to extract the timeseries data for each epoch individually to then correlate with my stimuli, however, I seem to be unable to find a function which will allow me to do so.... – sallicap Jul 22 '20 at 13:54
  • Again, I'll still have to wait for more information, preferably as an edit to your question. I have no idea of the `size` of `OUTEEG.epoch` (i.e. is it a matrix? a row vector? a scalar?). Meanwhile, you want to use the output with `corrcoef(X, Y)`, a function that takes in two column vectors (which I see `two_stim` is a row vector, but matlab handled that for you). Provide more information and I'm confident I can help you. :) – mimocha Jul 22 '20 at 14:16
  • Thank you! You're a lifesaver :) I think I shall change my approach a bit. I have my stimtrak channel & I have my auditory stimuli so I just need to find which part of the channel = which stimulus. I already have the events so it is just a question of finding the order of the stimuli. The stimuli and the channels are both in matrices (or arrays if Python is easier). Would you have an idea as how to go about doing this? :) – sallicap Jul 22 '20 at 21:57
  • So to recap, referring to the [documentations on EEG data structures](https://sccn.ucsd.edu/wiki/A05:_Data_Structures#EEG.epoch), each `OUTEEG.epoch` is actually a struct of 1 epoch. Based on your code (`j=1:141`), you have 141 epochs of data, and you want to calculate the correlation between each of your "epoch data", and each of your 20 "stimuli data" (`i=1:20`). – mimocha Jul 22 '20 at 23:15
  • **My problem now is, this is the limits of my understanding in neuroscience.** I really can't help you through all the technical terms, but if you can provide a concrete explanation of what data you have (*size of the matrix, please*), and what you want to do with it in terms of statistical analysis / MATLAB code; I can help you then. – mimocha Jul 22 '20 at 23:15
  • Thank you! In fact my problem is now less neuroscience-based and more matlab based. The channel in question has the size (1x699880) and my stimuli are around (1x7000). Is there some way to "find" those 1x7000 arrays within the 1x699880 array in order to determine the order of my stimuli (knowing which array corresponds to which stimulus)? Thank you so much for your help so far - unfortunately I am novice when it comes to actually fiddling around with things on Matlab! – sallicap Jul 23 '20 at 09:28
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/218438/discussion-between-mimocha-and-sallicap). – mimocha Jul 23 '20 at 13:21

0 Answers0