Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot of ft_freqanalysis differ if cfg.keeptrials were set to 'yes' versus 'no' #670

Closed
suxpert opened this issue Feb 24, 2018 · 4 comments
Closed

Comments

@suxpert
Copy link

suxpert commented Feb 24, 2018

According to the tutorial, it seems that I need to add

cfg.keeptrials = 'yes';

when calling ft_freqanalysis if I want to perform some statistics using ft_freqstatistics.

But I found that before I set keeptrials to 'yes' and after, the figure plotted via ft_singleplotTFR have much differences. Is that OK? Which should I believe to be true?

@robertoostenveld
Copy link
Contributor

statistics needs repetitions to estimate the variance. Plotting needs an average. When you give trials to the plotting code instead of an average, it should compute an average on the fly, which should not be different from the average that is computed in freqanalysis itself.

Please be specific in which tutorial the problem applies and if possible upload screen shots that show the difference.

@suxpert
Copy link
Author

suxpert commented Feb 24, 2018

cfg            = [];
cfg.pad        = 'nextpow2';
% cfg.keeptrials = 'yes';
cfg.output     = 'pow';
cfg.foi        = 2: 140;
cfg.toi        = -0.2: 0.01: 0.6;
cfg.method     = 'mtmconvol';
cfg.taper      = 'hanning';
cfg.t_ftimwin  = ones(size(cfg.foi)) * 0.1;

cfg.trials = ctrl;
TFR_ctrl = ft_freqanalysis(cfg, epoch_data);


cfg = [];
cfg.baseline     = [-0.2, 0.05];
cfg.baselinetype = 'db'; 
cfg.zlim         = [-4, 4];
figure;
ft_singleplotTFR(cfg, TFR_ctrl);

Gives:
nokeeptrials

But with cfg.keeptrials = 'yes', I've got:
keeptrials

All others are the same.

@schoffelen
Copy link
Contributor

with keeptrials = 'yes', the baseline correction is applied to every single trial, with keeptrials = 'no', the baseline correction is only applied to the average. Since the baseline operation that you have specified is the result of a division, this yields different results. In general, first averaging, then baseline correcting makes more sense

@suxpert
Copy link
Author

suxpert commented Mar 4, 2018

If "first averaging, then baseline correcting" is the correct way, then how to perform statistics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants