Skip to main content

MNEClusterInfo

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_cluster_info.h>

class MNELIB::MNEClusterInfo

Per-cluster bookkeeping for a label-restricted clustering of a forward solution: contained vertices, representative dipole and mean orientation.

Cluster table used to compress and reconstruct a clustered leadfield.

src/examples/ex_inv_api/main.cpp
// Cluster the V1 sources within their aparc regions into groups of about 20 (k-means on the gain columns;
// squared Euclidean distance makes each centroid the mean of its sources)
const FsAnnotationSet aparc(data + "/subjects/sample/label/lh.aparc.annot", data + "/subjects/sample/label/rh.aparc.annot");
MatrixXd clusterMean; // 3 x 70 sources -> 3 x nClusters, averaging per orientation
const MNEForwardSolution clustered = fwd.cluster_forward_solution(aparc, 20, clusterMean, FiffCov(), FiffInfo(), "sqeuclidean");
const MNEClusterInfo& clusters = clustered.src.hemisphereAt(0)->cluster_info;
int assigned = 0;
for (const VectorXi& members : clusters.clusterVertnos) {
assigned += static_cast<int>(members.size());
}
clusters.write(tmp.filePath("v1-clusters.txt")); // plus centroids_v1-clusters.txt

Public Methods​

MNEClusterInfo()​

Default constructor.


clear()​

Initializes the cluster information.


isEmpty()​

Returns true if MNE cluster information contains no data.

Returns:

  • bool — true if MNE cluster information is empty.

numClust()​

Returns the number of clusters.

Returns:

  • qint32 — number of clusters.

write(p_sFileName)​

Writes the cluster info as text, and the centroid vertex numbers to centroids_<name> in the same directory.

Parameters:

  • p_sFileName : QString FileName to write to.

Example​

Used in examples​

ex_inv_api​

Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.

src/examples/ex_inv_api/main.cpp, line 169
const FsAnnotationSet aparc(data + "/subjects/sample/label/lh.aparc.annot", data + "/subjects/sample/label/rh.aparc.annot");
MatrixXd clusterMean; // 3 x 70 sources -> 3 x nClusters, averaging per orientation
const MNEForwardSolution clustered = fwd.cluster_forward_solution(aparc, 20, clusterMean, FiffCov(), FiffInfo(), "sqeuclidean");
const MNEClusterInfo& clusters = clustered.src.hemisphereAt(0)->cluster_info;
int assigned = 0;
for (const VectorXi& members : clusters.clusterVertnos) {
assigned += static_cast<int>(members.size());
}
clusters.write(tmp.filePath("v1-clusters.txt")); // plus centroids_v1-clusters.txt
ok &= expect(clustered.isClustered() && clusters.numClust() == clustered.nsource && assigned == 70 && clusters.numClust() >= 4 && (clustered.sol->data - fwd.sol->data * clusterMean).norm() <= 1e-9 * fwd.sol->data.norm() && QFile::exists(tmp.filePath("centroids_v1-clusters.txt")),
"MNEClusterInfo: every V1 source in one cluster, clustered gain is the cluster mean");

Authors of this file​