Cluster-based permutation tests when two-sided: max_cluster_sums with negative t-values

Hi all, and thanks so much for your amazing work,

I’m trying to use spatio-temporal cluster permutation tests, for two-sided tests (t-values being potentially negative or positive), and I wonder whether the computation of “max_cluster_sums” in the “_do_permutations()” function is 100% okay with “negative” clusters, as it is defined (so far) as follows:

# Find cluster on randomized stats
out = _find_clusters(t_obs_surr, threshold=threshold, tail=tail,
                     max_step=max_step, adjacency=adjacency,
                     partitions=partitions, include=include,
                     t_power=t_power, stat_cluster=stat_cluster)
perm_clusters_sums = out[1]

if len(perm_clusters_sums) > 0:
    max_cluster_sums[seed_idx] = np.max(perm_clusters_sums)
    max_cluster_sums[seed_idx] = 0

progress_bar.update(seed_idx + 1)

I wonder whether the computation of max_cluster_sums shouldn’t instead consider the absolute value of the cluster sums, as follows:

max_cluster_sums[seed_idx] = np.max(np.abs(perm_clusters_sums))

Following Maris & Oostenveld (2007):

clusters are calculated under the permutation distribution of the maximum (absolute value) cluster-level statistic

I’m not sure I’m not missing something myself, and that’s why I did not report it as a bug on the Github channel, but for me, as it is, a cluster with maximum absolute value but negative, would not be considered as maximum.

Example on one permutation to visualize the issue:

perm_clusters_sums = [ 4.138  3.7055   4.273  3.550 -5.942  -6.785 -4.612 -4.080 -4.589 -4.968 -4.280 -3.714 -3.699]
max_cluster_sums = 4.273

Shouldn’t the retained t-value for this permutation be 6.785?

I hope the issue is clear enough, thanks in advance for your feedback!