```The parametric statistic that is computed for each sample (and for
which the analytic probability of the null-hypothesis is computed) is
specified as
cfg.statistic       = 'indepsamplesT'     independent samples T-statistic,
'indepsamplesF'     independent samples F-statistic,
'indepsamplesregrT' independent samples regression coefficient T-statistic,
'indepsamplesZcoh'  independent samples Z-statistic for coherence,
'depsamplesT'       dependent samples T-statistic,
'depsamplesF'       dependent samples F-statistic,
'depsamplesregrT'   dependent samples regression coefficient T-statistic,
'actvsblT'          activation versus baseline T-statistic.

```1. 假如人造纤维缩水后能够复原。那么，如果同一根人造纤维，在60度测试后再在80度中测试，使用配对检验。如果同一批人造纤维的样品，一半测试60度，一半测试80度，则使用独立检验。
2.假设该产品一个100件，如果两名人员对这100件都测量了一次，那么可以把数据对应起来做配对检验。如果每人各随机测量了其中的50件，那么做独立检验。

```
```   'depsamplesT'       dependent samples T-statistic,
'depsamplesF'       dependent samples F-statistic,
'depsamplesregrT'   dependent samples regression coefficient T-statistic,```
```     上述三个是基于配对样本进行的T检测 和F检测，也就是说样本是相同的，只不过对不同的condation进行检测 找出差异

```
```   'indepsamplesT'     independent samples T-statistic,
'indepsamplesF'     independent samples F-statistic,
'indepsamplesregrT' independent samples regression coefficient T-statistic,
'indepsamplesZcoh'  independent samples Z-statistic for coherence,```
```    上述四个是针对独立样本进行检测，也就是说样本的是独立的，每个condition下面的样本都是不一样的。

F检测是对group的检测，可以是独立样本或者非独立样本

单边或者双边检测这个问题依赖于你对样本分布属性的认知，单边意味着你确定H0  双边意味着你啥都不知道  出来什么算什么，单侧是具有方向性，即大于或小于。双侧不具有方向性，结论是两者不同或者有差异，但我判断不出孰高孰低？

至于在Filedtrip里面， 提供了UO的概念 （unit of observation） 可能是subjects or trials
for example , one subject has two different kind of conditions, you should use independentsampleT
for example you have kinds of subjects, every subject has one conditionm you should use depentsampleT

how to do T Test in Filedtrip:

definition
t=|x1-x2|/(s/(n*0.5))

X1 and X2 are seperately the average mean of two datasets , in EEG you could say  X1 average of datapoint in one channel. x2 for another datasets
s is the diff mean between the channel1 and channel2, n is the datapoint number-1 in case to avoid the bais we have to choose n=n-1 .

herein the T is caculated for every channle

for cluster pemutation  you would choose the max t with a threshold as specified with cfg.clusteralpha
cluster statistic test are caulated by means of sum of T value in every cluster.

we only choose the max Tvalue as the cluster which is controlled by cfg.clusterstatistic.

How to do P value in filedtrip:

we collect all trilas of different conditions into one single set

now random draws from this sigle set as many as the same as the one condition( in fact you have to make the trials of different condition are same)

you could repaet this more than one thousand times to caculate the T value

as above  from the test statistic and the histogram, the proportion of test statistic is larger than the observed one
This proportion is the Monte Carlo significance probability, which is also called a p-value.
P value 意思是比目前观察到的值更极端的发生概率比较小（<0.05） 假设才能significance probability.

for the cfg parameter, it is explainded as below :

cfg.method = 'montecarlo'

we need to talk about the montecarlo method for random statistic.

In fact is very simple and nice, consider that you want value of pi.

in this figure , we generate 100000 random datapoint  and caculate the number of black shape
the mode datapoint and them accurate you obtain, this is called montecarlo method

y=x**2 x[0 1],  we generate as many random datapoint as we can in this area,
the datapoint located in the red area is the sum of datapoint.

we should know :

variance: 方差是各个数据与平均数之差的平方和的平均数,即s=(1/n)[(x1-x_)^2+(x2-x_)^2+...+(xn-x_)^2
stand variance :对方差进行开平方

cfg.tail to choose between a one-sided and a two-sided statistical test.
Choosing cfg.tail = 0 affects the calculations in three ways.
First, the sample-specific T-values are thresholded from below as well as from above.
This implies that both large negative and large positive T-statistics are selected for later clustering. Second, clustering is performed separately for thresholded positive and thresholded negative T-statistics. And third,
the critical value for the cluster-level test statistic (determined by cfg.alpha; see further) is now two-sided: negative cluster-level statistics must be compared with the negative critical value, and positive cluster-level

statistics must be compared with the positive critical value.
In EEG or MEG  it's better to take use of cfg.tail=0 two side test
which means we know the the significance for different conditions
however we can not say > or <

```
```cfg.tail  = -1, 0, or 1, left, two-sided, or right (default=1)

```
``` plus :about the IndesampleT and desampleT is always confused to someone like me .
I have cited the developers explaintion :

```
```regarding the error "could not
determine the parametric critical value for clustering", this is
caused by the value of cfg.clusterthreshold used. The default value
there is 'parametric', meaning that the statistics routine will ask
your 'statfun' to compute a parametric threshold for considering a
(time/frequency/channel)-voxel a cluster-member candidate. This can be
done by e.g. depsamplesT or indepsamplesT, as it is possible to
analytically compute a T value corresponding to p < 0.05. However, in
the case of the ROC statistic, no such parametric estimate can be
computed (or perhaps it can be in some way, I don't know, but at least
I know the FT implementation does not).

Fortunately, the statistics routines also allow you to use a
nonparametric threshold for cluster-member candidates, based on the
generated distribution of the test statistic under the null
hypothesis. To use this, simply specify cfg.clusterthreshold =
'nonparametric_individual' or cfg.clusterthreshold =
'nonparametric_common'. The difference between the two is that the
former computes a threshold per voxel, and the latter uses the same
threshold for all voxels. Which one is appropriate for you I don't
know. (Good reasons for using 'nonparametric_individual' might be a
strong variation of your test statistic with frequency. I know for a
fact this is the case with certain quantifications of phase-amplitude
coupling; these show much higher values in the low frequencies even
when computed on noise.)```
```Eelke

```
```Main effect of Group: Do a between-subjects analysis (using indepsamplesT) on the dependent variable cond1+cond2

Main effect of the within subjects factor: Do a within-subjects analysis of
cond1 versus cond2 (using depsamplesT), ignoring the Group variable.

Eric Maris

```
```I would call freqstatistics with either cfg.statistic
= 'depsamplesT' (when you have paired observations) or
cfg.statistic='indepsamplesT' (when the observations are unpaired).

```Jan-Mathijs

```
```To compare coherence between conditions across subjects (instead of
trials), you need a different statfun: depsamplesT (for a within-subjects
design; subjects have participated in all conditions) or indepsamplesT
(for a between-subjects design; subjects have participated in only one
condition). Typically, this type of test is performed using power as the
dependent variable, but exactly the same test is used for comparing
coherence in a multiple-subject study. However, you will have to specify
the cfg.parameter field when calling ft_freqstatistics such that it points
to the data field that contains your coherence data (importantly, for a
given reference channel).```
`Eric Maris`
```depsamplesT (for a within-subjects
design; subjects have participated in all conditions) or indepsamplesT
(for a between-subjects design; subjects have participated in only one
condition).```
```被试参与了所有condition  用 de

sample 是 trials ，我们看到pre 和 post用的是不同的trial 所以用了 in

sample 是 subject ， pre 和post对应的是同一个subject 所以是配对统计  用de

```