Calculate source space clustering with 1 time point

Hello MNE community,

I am working with source localization in surface EEG. I used LCMV and eLORETA and want to compare two specific time points of the Source Estimates between two conditions. I explored different alternatives and decided to use spatiotemporal clusters ( spatio_temporal_cluster_1samp_test) to assess the difference between the conditions. I am only interested in spatial differences, so I discarded the time axis and shaped my data as (subjects × time × sources loc) = 23 × 1 × 81924.

So, I was wondering if there are any restrictions on using the spatio_temporal_cluster functions. I was able to run my code, but I see the brain empty (white), so I am not sure whether there are truly no clusters, there is a problem in the way I plotted, or if I am making a conceptual error and should use another approach/function. Here is my code.

def statistics_source_space(list_files_per_condition, save_dir_averages, method, time_points, n_permutations, lowpass, overwrite):

input_data = {‘condition1’: [], ‘condition2’:[]}
for file in list_files_per_condition:
      stc = io.read_source_estimates(file, ‘’, lowpass, method, morphed=True)
      vertices = stc.vertices  # store vertices once ideally

       if ‘condition1’ in file:
           idx = stc.time_as_index(time_points[‘condition1’])
           input_data[‘condition1’].append(stc.data[:, idx])
       elif ‘condition2’ in file:
          idx =stc.time_as_index(time_points[‘condition2’])
          input_data[‘condition2’].append(stc.data[:, idx])
     read_fsaverage_dir = r’C:\Sourcelocalization\data\grand_averages’
     forward = io.read_forward(‘fsaverage.fif’, read_fsaverage_dir)
     adjacency = spatial_src_adjacency(forward[‘src’])
     n_subjects = len(input_data[‘condition1’])
     #Convert to arrays with shape (subjects, 1,vertices) for cluster test
     cond1_data = np.stack(input_data[‘condition1’], axis=0)
     cond2_data =   np.stack(input_data[‘condition2’], axis=0)
     X = cond1_data - cond2_data
     X = np.transpose(X, [0, 2, 1]) # subject x time x source (size = 23 x 1 x 81924)
     #Set up cluster analysis
     p_threshold = 0.05
     t_threshold = -stats.distributions.t.ppf(p_threshold / 2,   n_subjects - 1)
     seed = 10
     print(‘Clustering.’)
     #Cluster permutation 1000 permutations
     T_obs, clusters, cluster_p_values, H0 = clu = mne.stats.spatio_temporal_cluster_1samp_test(X, adjacency=adjacency,n_permutations=n_permutations,threshold=t_threshold, seed=seed, n_jobs=12)


     stc_all_cluster_vis = summarize_clusters_stc(clu, vertices=vertices,subject=‘fsaverage’)

     colormap = ‘hot’
     brain = stc_all_cluster_vis.plot(hemi=‘both’, views=‘lat’, colormap=colormap,size=(600, 600), background=‘w’, colorbar=False,smoothing_steps=3)

This is my output

This is the resulting plot

Many thanks,
Christian

Looking at your output, you have two clusters, both of which are significant. The reason that you don’t see anything in the plot is probably because colors are given to the number of samples “wide” a cluster is, which in your case is always exactly 1 timepoint. So the visualization has no meaningful colors to assign and this probably triggers and edge-case where it breaks.