fieldtrip / website

This contains the content hosted on the FieldTrip website
http://www.fieldtriptoolbox.org
Other
39 stars 104 forks source link

ft_timelockanalysis with cfg.keeptrials - does it compute average as desribed in tutorial? #654

Closed KasiaRu closed 11 months ago

KasiaRu commented 1 year ago

Hello,

I was going through your tutorial (https://www.fieldtriptoolbox.org/workshop/natmeg/statistics/). The fragment: cfg = []; cfg.keeptrials = 'yes'; ERF_all = ft_timelockanalysis(cfg, data_stimlocked); disp(ERF_all)

implies that, when keeping trials (cfg.keeptrials = 'yes'), the ft_timelockanalysis function still computes the averages (avg), variance (var), degrees of freedom (dof), and keeps trialinfo. These outputs are displayed in your tutorial in the form of printed output below the 'disp(ERF_all)'. Here is a snippet:

image

I would like to clarify whether that is indeed the case, that when the configuration is to keep trials, the averages, variances, etc. are still computed? If so, could you please clarify whether it takes condition labels into account when averaging (i.e., averaging per 'condition' as per .trialinfo)?

From my testing and looking into the newest GitHub version of that function it seems that when the cfg input 'keeptrials' is 'yes', the averages etc. are not computed, instead, individual trials are returned. This is also implied in the commented section at the start of that function.

image image

I may be completely misunderstanding it, in which case I am terribly sorry.

Thank you.

schoffelen commented 1 year ago

hi @KasiaRu it could be that the matlab output as represented in the referenced tutorial is not in sync with the behavior of the current version of the code. Specifically indeed it may be true that currently ft_timelockanalysis with cfg.keeptrials = 'yes' does not output the average anymore. Please feel free to update said webpage to reflect current reality. There's an 'edit this page on github' towards the bottom of the page that will guide you through the process. Thanks for your input.

robertoostenveld commented 1 year ago

Dear KaisaRu,

You are referring to a tutorial from 9 years ago and was part of this workshop https://www.fieldtriptoolbox.org/workshop/natmeg/; it was (obviously) also designed for and with a FieldTrip version from back then. The ft_timelockanalysis function has been updated since, and - as you have observed and confirmed in the code - the average is presently not computed when keeptrials=no, but only when keeptrials=no.

The questions on how ft_timelockanalysis keeps track of conditions are better addressed on the mailing list.

best regards, Robert

KasiaRu commented 1 year ago

Thank you @schoffelen and @robertoostenveld!