v2.0.0
Loading...
Searching...
No Matches
sts_cluster.cpp File Reference

Implementation of the cluster permutation tests and TFCE enhancement declared in sts_cluster.h. More...

#include "sts_cluster.h"
#include "sts_ttest.h"
#include "sts_ftest.h"
#include <QtConcurrent>
#include <QRandomGenerator>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
Include dependency graph for sts_cluster.cpp:

Go to the source code of this file.

Detailed Description

Implementation of the cluster permutation tests and TFCE enhancement declared in sts_cluster.h.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.2.0
Date
April 2026

Each permutation entry point first computes the observed statistic map (paired or one-sample t for the t-variants, one-way ANOVA F for the fTestPermutationTest) and derives the cluster-forming threshold from clusterAlpha through the inverse Student-t CDF. Connected supra-threshold components are extracted with a queue-based breadth-first search over the STSLIB::StatsAdjacency sparse graph and each component is assigned a cluster-mass equal to the sum of its t- or F-values.

The null distribution of the maximum absolute cluster-mass is then built by QtConcurrent::blockingMapped over nPermutations randomisations - exchangeable label shuffles for the two-sample test, Rademacher sign flips for the one-sample test, and group-label reassignments for the ANOVA test - with thread-local QRandomGenerator instances for reproducibility. Observed cluster p-values are the empirical exceedance probability under that null.

TFCE follows Smith & Nichols (2009): the statistic map is swept by nSteps thresholds and each supra-threshold connected component contributes \(\text{extent}^E \cdot h^H \cdot \Delta h\) to every sample it covers. Positive and negative tails are handled separately and recombined so signed enhancement is preserved.

Definition in file sts_cluster.cpp.