[FieldTrip] Problems with Parametric T-test Statistics of a single subject

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Fri Sep 1 12:27:18 CEST 2023

Hi Nova,

Welcome on board!

My name is Nova and I am new to FieldTrip. I am currently working on the parametric statistics of the ERP data (obtained from 32 electrodes) but I face some problems. I have tried googling and reading the tutorials and posts on mailing lists, but I still can't solve the problems. Could you please assist me in finding the solutions?

I can give it a try.

Here are the problems:
I would like to perform the parametric statistics on the ERP data, I have 2 sets of data called dataresponse and databaseline (each has 270 trials, with dimensions 270x32x584 double). I calculated the ERPs of each dataset by averaging the signals over the number of trials. I would like to compare both data of one subject on the channel level. On the tutorial website, it was on the group level. I tried to adjust my codes for the cfg.design, but I still can't find the solutions.

In order to calculate the statistics on channel electrode 10, I used the ttest2 function on MATLAB with this script:
[h,p] = ttest2(avgdataresponse.avg(10,:), avgdatabaseline.avg(10,:),'alpha',0.05);
%avgdataresponse and avgdatabaseline are the average over trials,

then I obtained the h=1, p= 1.323e-04.

Let me get this straight, I think that based on the above, you computed a t-score (and corresponding p-value) between 2 time series, i.e. between the amplitude values (over time) of a single channel’s signal from the response and the baseline variables. Was this intended, because typically it is not a comparison that one would do?

However, when I tried with Fieldtrip function, I obtained different numbers.

1) When using the "ft_statfun_indepsamplesT" function with this script, I obtained NaN for stat, critval, and prob. Does it have to do with the cfg.design? What is the correct cfg.design for the parametric T-test on a channel level for a single subject?
cfg = [];
cfg.channel     = 'Audio10';
cfg.latency     = [0.017 0.6];
cfg.avgovertime = 'yes';
cfg.parameter   = 'avg';
cfg.method      = 'analytic';
cfg.statistic   = 'ft_statfun_indepsamplesT';
cfg.alpha       = 0.05;
cfg.correctm    = 'no';

n_dataresponse = size(dataresponse.trial, 1); %number of trials in data response (since the number of trials is the same as that of databaseline, I use one of them)

cfg.design(1,1:2*n_dataresponse) = [ones(1,n_databaseline), ones(1,n_dataresponse)*2];
cfg.design(2,1:2*n_dataresponse) = [1:n_dataresponse 1:n_dataresponse];
cfg.ivar             = 1;
stat = ft_timelockstatistics(cfg, avgdataresponse, avgdatabaseline);

2. When I change the parameter: cfg.parameter   = 'trial' and stat = ft_timelockstatistics(cfg, dataresponse, databaseline);
I obtained the p-value = 0.040. Is this p-value correct? or is it still wrong because of my cfg.design?

cfg.parameter = ‘avg’ in combination with avgdataresponse/avgdatabaseline is not going to work, because the function expects data in the input which have the original observations present (in your case the indivdual trials)

Next to this, you do something completely different (as compared to the above), because (when using dataresponse/databaseline) now 1) the input data are single observations, and 2) you specify to average across time.

3. I tried also with "ft_statfun_depsamplesT" with the same configuration as no.1 and added the cfg.uvar =2, I obtained errors:
Error using ft_statfun_depsamplesT (line 78)
Invalid specification of the design array.

Error in ft_statistics_analytic (line 94)
  [stat, cfg] = statfun(cfg, dat, design);

Error in ft_timelockstatistics (line 185)
  [stat, cfg] = statmethod(cfg, dat, design);

Is there a significant design array for a particular parametric T-test? What is the specification of the design array for independent and dependent T-test? (I tried searching about it but I couldn't find the answers.)

This is because you cannot input an average into the statistics function, and then use a design that specifies the individual trials. In that sense ft_statfun_depsamplesT is correct: the design is invalid

4. When I still use "ft_statfun_depsamplesT" but changing cfg.parameter = 'trial' and stat = ft_timelockstatistics(cfg, dataresponse, databaseline); I acquired the p value = 0.0989.

The difference between ft_statfun_depsamplesT and ft_statfun_indpesamplesT is the same as the difference between a paired (ttest) and unpaired (ttest2) t-test.

Why is the p-value still different than the one obtained from the ttest2 function? What should I change in order to obtain a similar value as what is acquired on the ttest2 Matlab function? Based on the tutorial, the p-value should be the same.

If you want ttest2 to behave the same as ft_timelockstatistics (with cfg.statistic = ‘ft_statfun_indepsamplesT’, + the specified latency, and average across time as per your specification), you need to extract from databaseline and dataresponse the relevant samples, i.e. something like

x1 = mean(databaseline.trial(:,10, tbeg:tend),3);
x2 = mean(dataresponse.trial(:,10, tbeg:tend),3);

and then use x1 and x2 as input to ttest2. tbeg and tend can be obtained as: tbeg = nearest(databaseline.time,0.017), and tend = nearest(databaseline.time, 0.6)

Good luck and happy computing,

I would really appreciate any help and advice on these problems.
Thank you very much and have a great day.

Best regards,
Nova Resfita

Nova Resfita, M.Sc.
PhD student
Medizinische Hochschule Hannover
Institut für AudioNeuroTechnologie (VIANNA)
OE 8891, M20, Ebene 01, Raum 2220
Stadtfelddamm 34
30625 Hannover

Tel.: +49 511 532-7270
Email: Resfita.Nova at mh-hannover.de<mailto:Sollmann.Lea at mh-hannover.de>
Web: <https://urldefense.com/v3/__http://www.neuroprostheses.com/__;!!HJOPV4FYYWzcc1jazlU!6NmIRxmwMH2BGQeJpQjL_UdFTljNLDILpnfphX9NMxnYsEwmHbU4FgErbLsshcSwuH4GBACoOhorFap0BMLtlrKc0IF8auc4Tw$> https://urldefense.com/v3/__http://www.neuroprostheses.com__;!!HJOPV4FYYWzcc1jazlU!8TkyVCyXkHBS9PILPbjHcVr3KPTWvmb1M2p0dwr9zq_FEBGt9QvRhXYXKwiy5wHdzSZJnjjKtzRjai26-5uxpbfwqaklZwd9iiPwBg$ <https://urldefense.com/v3/__https://www.neuroprostheses.com/AK/Main.html__;!!HJOPV4FYYWzcc1jazlU!6NmIRxmwMH2BGQeJpQjL_UdFTljNLDILpnfphX9NMxnYsEwmHbU4FgErbLsshcSwuH4GBACoOhorFap0BMLtlrKc0IHCWoKhaQ$>

fieldtrip mailing list

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

More information about the fieldtrip mailing list