v2.0.0
Loading...
Searching...
No Matches
sts_cluster.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef STS_CLUSTER_H
36#define STS_CLUSTER_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "sts_global.h"
43#include "sts_types.h"
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QVector>
50#include <QPair>
51
52//=============================================================================================================
53// EIGEN INCLUDES
54//=============================================================================================================
55
56#include <Eigen/Core>
57#include <Eigen/SparseCore>
58
59//=============================================================================================================
60// DEFINE NAMESPACE STSLIB
61//=============================================================================================================
62
63namespace STSLIB
64{
65
66//=============================================================================================================
73 Eigen::MatrixXd matTObs;
74 QVector<double> vecClusterStats;
75 QVector<double> vecClusterPvals;
76 Eigen::MatrixXi matClusterIds;
78};
79
80//=============================================================================================================
87{
88public:
89 //=========================================================================================================
104 const QVector<Eigen::MatrixXd>& dataA,
105 const QVector<Eigen::MatrixXd>& dataB,
106 const Eigen::SparseMatrix<int>& adjacency,
107 int nPermutations = 1024,
108 double clusterAlpha = 0.05,
109 double pThreshold = 0.05,
111
112 //=========================================================================================================
130 const QVector<Eigen::MatrixXd>& data,
131 const Eigen::SparseMatrix<int>& adjacency,
132 double threshold,
133 int nPermutations,
134 StatsTailType tail);
135
136 //=========================================================================================================
153 const QVector<QVector<Eigen::MatrixXd>>& conditions,
154 const Eigen::SparseMatrix<int>& adjacency,
155 double threshold,
156 int nPermutations);
157
158 //=========================================================================================================
175 static Eigen::MatrixXd tfce(
176 const Eigen::MatrixXd& statMap,
177 const Eigen::SparseMatrix<int>& adjacency,
178 double E = 0.5,
179 double H = 2.0,
180 int nSteps = 100);
181
182private:
183 //=========================================================================================================
187 static Eigen::MatrixXd computeTMap(
188 const QVector<Eigen::MatrixXd>& dataA,
189 const QVector<Eigen::MatrixXd>& dataB);
190
191 //=========================================================================================================
197 static QPair<Eigen::MatrixXi, QVector<double>> findClusters(
198 const Eigen::MatrixXd& tMap,
199 double threshold,
200 const Eigen::SparseMatrix<int>& adjacency,
201 StatsTailType tail);
202
203 //=========================================================================================================
207 static double permuteOnce(
208 const QVector<Eigen::MatrixXd>& allData,
209 int nA,
210 const Eigen::SparseMatrix<int>& adjacency,
211 double threshold,
212 StatsTailType tail);
213
214 //=========================================================================================================
218 static double inverseTCdf(double p, int df);
219
220 //=========================================================================================================
224 static Eigen::MatrixXd computeOneSampleTMap(
225 const QVector<Eigen::MatrixXd>& data);
226
227 //=========================================================================================================
231 static Eigen::MatrixXd computeFMap(
232 const QVector<QVector<Eigen::MatrixXd>>& conditions);
233
234 //=========================================================================================================
240 static QPair<Eigen::MatrixXi, QVector<double>> findClustersFlat(
241 const Eigen::MatrixXd& statMap,
242 double threshold,
243 const Eigen::SparseMatrix<int>& adjacency,
244 bool positiveOnly);
245
246 //=========================================================================================================
250 static double permuteOnceOneSample(
251 const QVector<Eigen::MatrixXd>& data,
252 const Eigen::SparseMatrix<int>& adjacency,
253 double threshold,
254 StatsTailType tail);
255
256 //=========================================================================================================
260 static double permuteOnceFTest(
261 const QVector<Eigen::MatrixXd>& allData,
262 const QVector<int>& groupSizes,
263 const Eigen::SparseMatrix<int>& adjacency,
264 double threshold);
265};
266
267} // namespace STSLIB
268
269#endif // STS_CLUSTER_H
Shared enumerations describing tail direction and multiple-comparison correction strategy.
STSLIB shared-library export macro and build-info accessors for the statistical-tests library.
#define STSSHARED_EXPORT
Definition sts_global.h:44
Statistical testing (t-tests, F-tests, cluster permutation, multiple comparison correction).
StatsTailType
Direction of the alternative hypothesis for a t- or F-test (left, right, or two-sided).
Definition sts_types.h:37
Per-call output of a cluster permutation test: observed statistic map, cluster masses,...
Definition sts_cluster.h:72
Eigen::MatrixXd matTObs
Definition sts_cluster.h:73
Eigen::MatrixXi matClusterIds
Definition sts_cluster.h:76
QVector< double > vecClusterStats
Definition sts_cluster.h:74
QVector< double > vecClusterPvals
Definition sts_cluster.h:75
Maris-Oostenveld cluster-mass permutation tests and Threshold-Free Cluster Enhancement on (channel,...
Definition sts_cluster.h:87
static StatsClusterResult permutationTest(const QVector< Eigen::MatrixXd > &dataA, const QVector< Eigen::MatrixXd > &dataB, const Eigen::SparseMatrix< int > &adjacency, int nPermutations=1024, double clusterAlpha=0.05, double pThreshold=0.05, StatsTailType tail=StatsTailType::Both)
static Eigen::MatrixXd tfce(const Eigen::MatrixXd &statMap, const Eigen::SparseMatrix< int > &adjacency, double E=0.5, double H=2.0, int nSteps=100)
static StatsClusterResult oneSamplePermutationTest(const QVector< Eigen::MatrixXd > &data, const Eigen::SparseMatrix< int > &adjacency, double threshold, int nPermutations, StatsTailType tail)
static StatsClusterResult fTestPermutationTest(const QVector< QVector< Eigen::MatrixXd > > &conditions, const Eigen::SparseMatrix< int > &adjacency, double threshold, int nPermutations)