[FieldTrip] Help needed for timelock analysis

Francisco Javier Quirant Agulló FJQUIAGU at upv.edu.es
Fri Nov 18 11:44:46 CET 2022


Hi Jan-Mathijs,

First thank you again for your patience and the suggested links. I apologize as trying to be concise I’ve fallen way short. Lets try this again with more organized information. Also apologies for any typos as English is my second language.

Goal: As stated in my initial mail the objective is to characterize source estimation methods through metrics. Some of this metrics are derived from a Resolution matrix that is obtained with the inverse kernel and the leadfield matrix (R = KL). Resolution matrices for all source points get averaged in a so called empirical Resolution matrix from where the metrics get extracted.

Steps: To obtain this matrix all source model points have to “activate”. This is achieved by dividing the brain volume in patches (following Desikan-Killiani’s atlas) that activate in different trials or sessions. With Brainstorm a step signal of 1000 samples and fs= 500Hz gets generated and forced upon those patches, so for every source point within them this is the source signal. There are 68 patches that activate in different trials or sessions, from each of these a EEG (64 electrode cap) gets simulated using a BEM model calculated with Brainstorm default/tutorial files. Some amount of noise is added, random noise in the source signals distribution and a combination of pink+white noise as sensor noise when obtaining the EEG signals. At the end of the day there are 68 different source activation maps with their associated EEG level signals. With this EEG signals different estimations (dSPM, eLORETA, sLORETA…) will be performed and Resolution matrices obtained for each of them.

From here the EEG files get exported to matlab to calculate eLORETA using FieldTrip. eLORETA needs as input the data covariance calculated through ft_timelockanalysis to get the results in the time domain, this is at least what I understand after reading the function information and the tutorials. When calling the function using the code from the first mail and independently of the EEG signals used I get the same covariance distribution and hence, the exact same source map after applying eLORETA. The step signal is the same, true, but the activation region within the brain is different and so they are the EEG level signals.

Why EEG signals derived from different brain activation regions get the same covariance distribution when calling ft_timelockanalysis?



Files and aditional information:

[https://res-geo.cdn.office.net/assets/mail/file-icon/png/generic_16x16.png]files.mat<https://upvedues-my.sharepoint.com/:u:/g/personal/fjquiagu_upv_edu_es/EdO01tlTC69Bi6p42iMb63EB9xV8o9BWTZhZ8uWE50KHNg?e=TWKEsU> contains the matlab variables where
- data: is merely a template struc for the code.
- eeg_01/02/03: these are 3 different EEG level signals for the activation of 3 different brain regions.
- vol: headmodel employed for all inverse problem related calculations.
- elec: sensor information for EEG channels.
- sourcemodel_and_leadfield: kind of self explanatory, merely a crappy demo for quick calculations.

In [https://res-geo.cdn.office.net/assets/mail/file-icon/png/generic_16x16.png] code_example.m<https://upvedues-my.sharepoint.com/:u:/g/personal/fjquiagu_upv_edu_es/EdYcnPUx2r5Bl-EAfx-0pBsB0vW0X2Vg-FHzKwD5g8OuBQ?e=oPU19A> there is a demo of what i am doing in matlab using the previous variables.



I hope everything is more clear now. Thank you again for your time and patience.


Greetings,

Javier

De: fieldtrip <fieldtrip-bounces at science.ru.nl> En nombre de Schoffelen, J.M. (Jan Mathijs) via fieldtrip
Enviado el: viernes, 18 de noviembre de 2022 7:50
Para: FieldTrip discussion list <fieldtrip at science.ru.nl>
CC: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl>
Asunto: Re: [FieldTrip] Help needed for timelock analysis

Hi Javier,

Sorry to repeat my self, but you are still not clear.

You ask ‘why is it giving me always the same result despite being completely different EEG signals’.

I don’t understand what ‘it’ is, and I see nowhere in your messages what you mean with ‘completely different EEG signals’. It’s all still Spanish to me.

Different channels? Different simulations? Different step functions? Different noise? How did you do the simulations? How do the simulated signals look? What forward model was used in the simulation? Did you simulate enough variability in the sources’ time courses in order to have a chance to observe spatiotemporal variability at the scalp level? What did you expect from the call to ft_timelockanalysis?

Also, please refer to http://www.catb.org/~esr/faqs/smart-questions.html and https://www.fieldtriptoolbox.org/faq/how_to_ask_good_questions_to_the_community/

Good luck,

Jan-Mathijs



On 17 Nov 2022, at 18:04, Francisco Javier Quirant Agulló via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi Jan,

Sorry for not being clear enough. The question is, how should I apply the timelock function properly? Or, why is it giving me always the same result despite being completely different EEG signals?

Thanks and greetings,
Javier

De: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> En nombre de Schoffelen, J.M. (Jan Mathijs) via fieldtrip
Enviado el: jueves, 17 de noviembre de 2022 17:19
Para: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
CC: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl<mailto:janmathijs.schoffelen at donders.ru.nl>>
Asunto: Re: [FieldTrip] Help needed for timelock analysis

Hi Javier,

What is your question? I don’t manage to distill it from your e-mail.

Best wishes,

Jan-Mathijs




On 17 Nov 2022, at 15:42, Francisco Javier Quirant Agulló via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hello everyone,

 My name is Javier, I am a student of Biomedical engineering and I am working currently on my final master's project. The project aims to compare various inverse algorithms with some metrics and characterize them.



Right now what I am doing is generating a step signal at source level in 68 different brain sections and obtaining simulated EEG signals with fs = 500 Hz & 2s length (1000 samples) and some noise added. The initial steps are performed using BrainStorm and EEGs are exported to matlab to apply eLORETA and sLORETA with Fieldtrip.



For this I am trying to calculate the time domain information for the signals withft_timelockanalysis and use the results in ft_sourceanalysis. I realized that the source results were identical for the different EEGs (each one for a particular brain section), while the EEGs seem right the output of the ft_timelockanalysis is the same for all signals. Checking the function information I saw a note in line 45 that says: “% FIXME if input is one raw trial, the covariance is not computed correctly”. Tried dividing the EEG in 4 trials but no difference whatsoever. Spent some time also checking results within the function but haven’t made any progress.



I think I may be using the data with an incorrect format or a wrong cfg, any help would be much apreciated. Follows the code.
-----------------------------------
data.trial{1} = real(eeg_01.F);% No idea why but EEGs from BrainStorm convert to complex in matlab
data.time{1} = eeg_01.Time;

save('temp.mat','data');cfg = [];    % This section only when I divide in trials (obviously)
cfg.trialdef.triallength = 0.5;
cfg.datafile = 'temp.mat';
cfg.trialdef.eventtype = 'none';
cfg= ft_definetrial(cfg);
data = ft_preprocessing(cfg);
delete 'temp.mat'

cfg = [];
cfg.covariance = 'yes';
cfg.keeptrials = 'yes';       % I comment these two lines for single trial
cfg.trials = 'all'
data_cov = ft_timelockanalysis(cfg, data);

cfg.layout = 'EEG1010.lay';
ft_topoplotER(cfg,data_cov);   % This to plot the result, I get the same for all EEG files.

-----------------------------------
Here you have the mat file with all variables and 3 of the EEGs already loaded: [https://res-geo.cdn.office.net/assets/mail/file-icon/png/generic_16x16.png] files.mat<https://urldefense.com/v3/__https:/upvedues-my.sharepoint.com/:u:/g/personal/fjquiagu_upv_edu_es/EUPygCCic5NEiZak0leUSHsBSJAOKw9aJ_-ae7oibQIhNQ?e=TPWOkC__;!!HJOPV4FYYWzcc1jazlU!7ZVGIVpHujMhbuqj07PjD4_tJOJIGEhEa9EXa1hIOo6IqWXpztkw-y9kXyF9UpcjBTlphhjSrdqGapjwDYPr0saXmetMS6Y5taMH_w$>






I hope everything is clear enought.



Greetings,
Javier
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!7ZVGIVpHujMhbuqj07PjD4_tJOJIGEhEa9EXa1hIOo6IqWXpztkw-y9kXyF9UpcjBTlphhjSrdqGapjwDYPr0saXmetMS6ZuT5is3Q$<https://urldefense.com/v3/__https:/doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!7ZVGIVpHujMhbuqj07PjD4_tJOJIGEhEa9EXa1hIOo6IqWXpztkw-y9kXyF9UpcjBTlphhjSrdqGapjwDYPr0saXmetMS6ZuT5is3Q$>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!9mv2ZfhmgyQM2cnKYVMi4KmXT2iM-rhDIoKMzszsxvPMLkizmdbFnBJZbfr8a7_O7W5Ao7KPkHOOjvFSJDVKT_VMd2W0uunQbr0MTA$<https://urldefense.com/v3/__https:/doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!9mv2ZfhmgyQM2cnKYVMi4KmXT2iM-rhDIoKMzszsxvPMLkizmdbFnBJZbfr8a7_O7W5Ao7KPkHOOjvFSJDVKT_VMd2W0uunQbr0MTA$>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20221118/b73f3868/attachment.htm>


More information about the fieldtrip mailing list