sampling procedure in combination with ANOVA & spatio-temporal permutation test for unbalanced data

Hello everyone!

I’m running a two-way ANOVA on sensor-level spatiotemporal data (evoked responses) and correcting for multiple comparisons with cluster-based permutation tests.
This is my code:

def stat_fun(*args):
        # get f-values only.
        return f_mway_rm(data = np.swapaxes(args, 1, 0),
                         factor_levels = factor_levels, 
                         effects = effects, 
                         return_pvals = return_pvals
pthresh = 0.005
f_thresh = f_threshold_mway_rm(n_subjects, factor_levels, effects, pthresh)
F_obs, clusters, cluster_p_values, H0= spatio_temporal_cluster_test(data,
                                                                               adjacency = adjacency, 
                                                                               threshold = f_thresh, 
                                                                               tail = 1,
                                                                               stat_fun = stat_fun, 
                                                                               n_permutations = n_permutations, 
                                                                               buffer_size = None,
                                                                               seed = 77

I’m aware that f_mway_rm only takes data that is fully balanced, which is not the case for my data. I have a 2-level between-subjects factor (group with 31 subjects in one group and 38 in the other) and a 9-level within-subjects factor. I thought that maybe I could pick random samples and re-run the analysis an x-number of times, but aggregating the results would be problematic if the resulting clusters are always different.
Does anyone have an idea how I could solve this problem? Any tips would be appreciated!

Take care,

  • MNE version: 1.3.0
  • operating system: macOS 12.5.1