[Mne analysis] two sample t-test with spatio_temporal_cluster_test

Dear all,

Similar to conducing a pair samples t-test on source data using spatio-temporal clustering, allowing the visualisation of clusters where condition A > condition B and vice versa, is it possible to run an independent samples t-test to visualise differences between two groups? The 2 samples permutation tests currently available are limited in that they plot F statistics that don?t give a direction of the difference between the groups. Basically, is it possible to identify clusters that differ significantly between the groups, as well as identify/visualise the direction in which they differ?

I am currently attempting to extract the cluster values for each participant to get an overall mean for each vertex within the cluster to compare between groups, but this seems very inefficient.

Cheers,
Talitha

Hi Talitha,

you can run the permutation clustering with a wide array of contrasts. This
might be what you are looking for:

http://martinos.org/mne/dev/auto_tutorials/plot_stats_cluster_spatio_temporal_2samp.html

I hope this helps,
Denis

Hi Dennis,
Thank you, this is the script I?ve been working from. The problem I am having though, is that as f-stats are >0, they do not indicate which group is larger than the other, which is what I would like to know. I have tried to use scipy.stats.ttest_ind but I get this error:
ValueError: could not broadcast input array from shape (1000) into shape (614520)

The command is:
T_obs, clusters, cluster_p_values, H0 = clu =\
spatio_temporal_cluster_test(all_data, connectivity=connectivity, n_jobs=2, stat_fun= scipy.stats.ttest_ind)

all_data is 2 lists (2 groups) of 16 and 19 participants, with 30 time points of 20484 vertices for each participant.

I hope that makes sense (and there is a possible work around!). Thanks again for you help,

Talitha

Ahh. For two conditions F should be the abs(T**2). You can just use a
t-test for indpendent samples here instead as statfun.

Thanks Dennis, I had included a ttest as the stat_fun in the previous command, though.

From what I understand, for a ttest, my code should look more like this:

#~ X1= np.abs(X1)
#~ X2 np.abs(X2)

print('Computing connectivity.')
connectivity = spatial_tris_connectivity(grade_to_tris(5))

# Note that X needs to be a list of multi-dimensional array of shape
# samples (subjects_k) x time x space, so we permute dimensions
X1 = np.transpose(X1, [2,1,0])
X2 = np.transpose(X2, [2,1,0])
all_data = [X2, X1]

p_threshold = 0.0001

#~ f_threshold = stats.distributions.f.ppf(1. - p_threshold / 2.,
    #~ len(X2) - 1, len(X1) - 1)

t_threshold = stats.distributions.t.ppf(p_threshold / 2.,
    len(X2) - 1, len(X1) - 1)

print('Clustering.')
T_obs, clusters, cluster_p_values, H0 = clu =\
spatio_temporal_cluster_test(all_data, connectivity=connectivity, n_jobs=2, threshod= t_threshold, stat_fun= scipy.stats.ttest_ind)

Commenting out the conversation of the data to absolute values, calculating a t_threshold, and including ttest_ind as the stat_fun? Sorry if I have misunderstood something.

Thanks,
Talitha

That does not look obviously wrong. Does it work?

Hi Dennis,

I get the same error for the spatio_temporal_cluster_test:
ValueError: could not broadcast input array from shape (1000) into shape (614520)

One of the problems could be that scipy.stats.ttest_ind returns both t and
p values - maybe this is causing your problems? You could try using:

def ttest_no_p(*args):
    tvals, _ = ttest_ind(*args)
    return tvals

and pass ttest_no_p as the stat_fun.

13.06.2017 01:25 ?Talitha Ford? <tcford at swin.edu.au> napisa?(a):

Hi Dennis,