[FieldTrip] Looped ft_sourcenalysis

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Mon Jul 22 12:43:41 CEST 2024


Hi Monika,

I think that a lot of implicit pointers are given in this thread: https://mailman.science.ru.nl/pipermail/fieldtrip/2023-August/042194.html<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fpipermail%2Ffieldtrip%2F2023-August%2F042194.html&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C4c6c8db44c4342a3397708dcaa3b2717%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638572418240044056%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=63jWwrSsr3Q5GCNdTvC%2BXKQTLd1ZSysjhrTBx4KAF%2Fw%3D&reserved=0> (please explore the different messages in the thread)

In general it is not recommended to compute beamformer (lcmv) spatial filters using single data in a loop.

Also, if you only have 19 channels I would seriously consider not do do source analysis, and stick to the channel level to try and answer your scientific question.

Best wishes,
Jan-Mathijs

On 19 Jul 2024, at 13:20, Monika via fieldtrip <fieldtrip at science.ru.nl> wrote:

Hello All again!

I have read some articles and i have a question about using ft_sourceanalysis.

I don't want to perform source analysis on averaged data from all epochs, because  i want to create a matrix where i will have reconstructed source data for each ROI from atlas. I need my data to be epoched, and not power, since i want to do multiple operations on this matrix. So the matrix will look like
ROI 1 signal value for 1st time point | signal value for 2nd time point .....
ROI 2 signal value for 1st time point | signal value for 2nd time point .....
ROI 3 signal value for 1st time point | signa value for 2nd time point .....

In this situation should i do the source analysis in loop separately for all trials? I did not see this approach in any tutorial (if there is one like that i didnt found it). Is it a good idea?
 I understand that ft_sourceanalysis perform source analysis on averaged data from default, but if i pass separate epochs in loop and then concatenate the source data can i then perform interpolation and parcellation to atlas each epoch separately?
I want to do this for baseline period and stimulus period separately, so i can then compare if there were any significant changes.

I also wonder if there maybe is some quicker approach, since on my computer ft_sourceanalysis is taking long time even for one epoch (i have 19 electrodes and computing each one is taking long), so if i have 1000 epochs it will take hours to complete.

If this is complete nonsense please let me know.
Im passing my loop code below.

Best regards and thank you for your help.
Monika



%%%code
%that is only for baseline, the same idea will go to stimulus data
source_baseline_all = cell(1, length(data_baseline.trial));
source_stimulus_all = cell(1, length(data_stimulus.trial));
%source analysis for each trial
for i = 1:length(data_baseline.trial)
%creating temporary structure containing only one trial in loop
temp_data = data_baseline;
temp_data.trial = {data_baseline.trial{i}};
temp_data.time = {data_baseline.time{i}};
temp_data.sampleinfo = data_baseline.sampleinfo(i, :);
temp_data.trialinfo = data_baseline.trialinfo(i, :);
cfg = [];
cfg.method = 'lcmv';
cfg.headmodel = headmodel;
cfg.sourcemodel = sourcemodel;
cfg.lcmv.keepfilter = 'yes';
cfg.lcmv.fixedori = 'yes';
source_baseline_all{i} = ft_sourceanalysis(cfg, temp_data);
end

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

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


More information about the fieldtrip mailing list