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//=============================================================================================================
75{
76 Eigen::MatrixXd matTObs;
77 QVector<double> vecClusterStats;
78 QVector<double> vecClusterPvals;
79 Eigen::MatrixXi matClusterIds;
81};
82
83//=============================================================================================================
92{
93public:
94 //=========================================================================================================
109 const QVector<Eigen::MatrixXd>& dataA,
110 const QVector<Eigen::MatrixXd>& dataB,
111 const Eigen::SparseMatrix<int>& adjacency,
112 int nPermutations = 1024,
113 double clusterAlpha = 0.05,
114 double pThreshold = 0.05,
116
117 //=========================================================================================================
135 const QVector<Eigen::MatrixXd>& data,
136 const Eigen::SparseMatrix<int>& adjacency,
137 double threshold,
138 int nPermutations,
139 StatsTailType tail);
140
141 //=========================================================================================================
158 const QVector<QVector<Eigen::MatrixXd>>& conditions,
159 const Eigen::SparseMatrix<int>& adjacency,
160 double threshold,
161 int nPermutations);
162
163 //=========================================================================================================
180 static Eigen::MatrixXd tfce(
181 const Eigen::MatrixXd& statMap,
182 const Eigen::SparseMatrix<int>& adjacency,
183 double E = 0.5,
184 double H = 2.0,
185 int nSteps = 100);
186
187private:
188 //=========================================================================================================
192 static Eigen::MatrixXd computeTMap(
193 const QVector<Eigen::MatrixXd>& dataA,
194 const QVector<Eigen::MatrixXd>& dataB);
195
196 //=========================================================================================================
202 static QPair<Eigen::MatrixXi, QVector<double>> findClusters(
203 const Eigen::MatrixXd& tMap,
204 double threshold,
205 const Eigen::SparseMatrix<int>& adjacency,
206 StatsTailType tail);
207
208 //=========================================================================================================
212 static double permuteOnce(
213 const QVector<Eigen::MatrixXd>& allData,
214 int nA,
215 const Eigen::SparseMatrix<int>& adjacency,
216 double threshold,
217 StatsTailType tail);
218
219 //=========================================================================================================
223 static double inverseTCdf(double p, int df);
224
225 //=========================================================================================================
229 static Eigen::MatrixXd computeOneSampleTMap(
230 const QVector<Eigen::MatrixXd>& data);
231
232 //=========================================================================================================
236 static Eigen::MatrixXd computeFMap(
237 const QVector<QVector<Eigen::MatrixXd>>& conditions);
238
239 //=========================================================================================================
245 static QPair<Eigen::MatrixXi, QVector<double>> findClustersFlat(
246 const Eigen::MatrixXd& statMap,
247 double threshold,
248 const Eigen::SparseMatrix<int>& adjacency,
249 bool positiveOnly);
250
251 //=========================================================================================================
255 static double permuteOnceOneSample(
256 const QVector<Eigen::MatrixXd>& data,
257 const Eigen::SparseMatrix<int>& adjacency,
258 double threshold,
259 StatsTailType tail);
260
261 //=========================================================================================================
265 static double permuteOnceFTest(
266 const QVector<Eigen::MatrixXd>& allData,
267 const QVector<int>& groupSizes,
268 const Eigen::SparseMatrix<int>& adjacency,
269 double threshold);
270};
271
272} // namespace STSLIB
273
274#endif // STS_CLUSTER_H
STSLIB shared-library export macro and build-info accessors for the statistical-tests library.
#define STSSHARED_EXPORT
Definition sts_global.h:44
Shared enumerations describing tail direction and multiple-comparison correction strategy.
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:38
Per-call output of a cluster permutation test: observed statistic map, cluster masses,...
Definition sts_cluster.h:75
Eigen::MatrixXd matTObs
Definition sts_cluster.h:76
Eigen::MatrixXi matClusterIds
Definition sts_cluster.h:79
QVector< double > vecClusterStats
Definition sts_cluster.h:77
QVector< double > vecClusterPvals
Definition sts_cluster.h:78
Maris-Oostenveld cluster-mass permutation tests and Threshold-Free Cluster Enhancement on (channel,...
Definition sts_cluster.h:92
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)