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 //=========================================================================================================
182 static Eigen::MatrixXd tfce(
183 const Eigen::MatrixXd& statMap,
184 const Eigen::SparseMatrix<int>& adjacency,
185 double E = 0.5,
186 double H = 2.0,
187 int nSteps = 100);
188
189private:
190 //=========================================================================================================
194 static Eigen::MatrixXd computeTMap(
195 const QVector<Eigen::MatrixXd>& dataA,
196 const QVector<Eigen::MatrixXd>& dataB);
197
198 //=========================================================================================================
204 static QPair<Eigen::MatrixXi, QVector<double>> findClusters(
205 const Eigen::MatrixXd& tMap,
206 double threshold,
207 const Eigen::SparseMatrix<int>& adjacency,
208 StatsTailType tail);
209
210 //=========================================================================================================
214 static double permuteOnce(
215 const QVector<Eigen::MatrixXd>& allData,
216 int nA,
217 const Eigen::SparseMatrix<int>& adjacency,
218 double threshold,
219 StatsTailType tail);
220
221 //=========================================================================================================
225 static double inverseTCdf(double p, int df);
226
227 //=========================================================================================================
231 static Eigen::MatrixXd computeOneSampleTMap(
232 const QVector<Eigen::MatrixXd>& data);
233
234 //=========================================================================================================
238 static Eigen::MatrixXd computeFMap(
239 const QVector<QVector<Eigen::MatrixXd>>& conditions);
240
241 //=========================================================================================================
247 static QPair<Eigen::MatrixXi, QVector<double>> findClustersFlat(
248 const Eigen::MatrixXd& statMap,
249 double threshold,
250 const Eigen::SparseMatrix<int>& adjacency,
251 bool positiveOnly);
252
253 //=========================================================================================================
257 static double permuteOnceOneSample(
258 const QVector<Eigen::MatrixXd>& data,
259 const Eigen::SparseMatrix<int>& adjacency,
260 double threshold,
261 StatsTailType tail);
262
263 //=========================================================================================================
267 static double permuteOnceFTest(
268 const QVector<Eigen::MatrixXd>& allData,
269 const QVector<int>& groupSizes,
270 const Eigen::SparseMatrix<int>& adjacency,
271 double threshold);
272};
273
274} // namespace STSLIB
275
276#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)