23#ifndef MNE_FORWARD_SOLUTION_H
24#define MNE_FORWARD_SOLUTION_H
57#include <QSharedPointer>
104 QString t_sDistMeasure;
106 t_sDistMeasure = QString(
"cityblock");
116 t_kMeans.
calculate(this->matRoiGWhitened, this->nClusters, p_RegionDataOut.
roiIdx, p_RegionDataOut.
ctrs, p_RegionDataOut.
sumd, p_RegionDataOut.
D);
119 Eigen::MatrixXd newCtrs = Eigen::MatrixXd::Zero(p_RegionDataOut.
ctrs.rows(), this->matRoiG.cols());
120 for (qint32 c = 0; c < p_RegionDataOut.
ctrs.rows(); ++c) {
123 for (qint32 idx = 0; idx < p_RegionDataOut.
roiIdx.size(); ++idx) {
124 if (c == p_RegionDataOut.
roiIdx[idx]) {
125 newCtrs.row(c) += this->matRoiG.row(idx);
131 newCtrs.row(c) /= num;
133 p_RegionDataOut.
ctrs = newCtrs;
135 t_kMeans.
calculate(this->matRoiG, this->nClusters, p_RegionDataOut.
roiIdx, p_RegionDataOut.
ctrs, p_RegionDataOut.
sumd, p_RegionDataOut.
D);
139 return p_RegionDataOut;
145static Eigen::MatrixXd defaultD;
160 typedef QSharedPointer<MNEForwardSolution>
SPtr;
161 typedef QSharedPointer<const MNEForwardSolution>
ConstSPtr;
162 typedef std::unique_ptr<MNEForwardSolution>
UPtr;
183 bool force_fixed =
false,
185 const QStringList& include = FIFFLIB::defaultQStringList,
186 const QStringList& exclude = FIFFLIB::defaultQStringList,
187 bool bExcludeBads =
false);
252 qint32 p_iClusterSize,
253 Eigen::MatrixXd& p_D = defaultD,
256 QString p_sMethod =
"cityblock")
const;
288 const Eigen::MatrixXd& patch_areas = FIFFLIB::defaultConstMatrixXd,
289 bool limit_depth_chs =
false);
327 const QStringList& exclude = FIFFLIB::defaultQStringList)
const;
354 const QStringList& include = FIFFLIB::defaultQStringList,
355 const QStringList& exclude = FIFFLIB::defaultQStringList)
const;
374 Eigen::MatrixXd& gain,
376 Eigen::MatrixXd& p_outWhitener,
377 qint32& p_outNumNonZero)
const;
385 Eigen::MatrixXi triSelect = p_vecIdxSelection.transpose().replicate(3, 1).array() * 3;
386 triSelect.row(1).array() += 1;
387 triSelect.row(2).array() += 2;
388 Eigen::VectorXi retTriSelect(triSelect.cols() * 3);
389 for (
int i = 0; i < triSelect.cols(); ++i)
390 retTriSelect.block(i * 3, 0, 3, 1) = triSelect.col(i);
410 static bool read(QIODevice& p_IODevice,
412 bool force_fixed =
false,
413 bool surf_ori =
false,
414 const QStringList& include = FIFFLIB::defaultQStringList,
415 const QStringList& exclude = FIFFLIB::defaultQStringList,
416 bool bExcludeBads =
false);
432 bool write(QIODevice& p_IODevice)
const;
443 MNEForwardSolution reduce_forward_solution(qint32 p_iNumDipoles, Eigen::MatrixXd& p_D)
const;
452 static void restrict_gain_matrix(Eigen::MatrixXd& G,
const FIFFLIB::FiffInfo& info);
466 void convert_to_surf_ori();
498 Eigen::MatrixX3f getSourcePositionsByLabel(
const QList<FSLIB::FsLabel>& lPickedLabels,
541 return this->
nchan <= 0;
555 out <<
"#### MNE Forward Solution ####\n";
557 out <<
"\n source_ori: " << p_MNEForwardSolution.
source_ori << std::endl;
558 out <<
"\n coord_frame: " << p_MNEForwardSolution.
coord_frame << std::endl;
559 out <<
"\n nsource: " << p_MNEForwardSolution.
nsource << std::endl;
560 out <<
"\n nchan: " << p_MNEForwardSolution.
nchan << std::endl;
561 out <<
"\n sol:\n\t" << *p_MNEForwardSolution.
sol.data() << std::endl;
562 out <<
"\n sol_grad:\n\t" << *p_MNEForwardSolution.
sol_grad.data() << std::endl;
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
#define FIFFV_MNE_FIXED_ORI
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
Noise / data covariance matrix as stored under FIFFB_MNE_COV, with channel names, kind,...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
Minimal measurement-info subset (channel list, sampling rate, basic transforms) shared by FIFF reader...
K-means partitional clustering with multiple distance metrics, initialisations and empty-cluster poli...
Bi-hemispheric pair of FreeSurfer annotations (lh + rh) for one parcellation atlas.
MNELIB shared-library export/import macros and library build metadata.
Container pairing the left and right cortical source spaces of a subject.
Core MNE data structures (source spaces, source estimates, hemispheres).
std::ostream & operator<<(std::ostream &out, const MNELIB::MNEForwardSolution &p_MNEForwardSolution)
bool operator==(const MNEClusterInfo &a, const MNEClusterInfo &b)
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
FIFF noise / data covariance: matrix, channel names, kind, applied projectors, bads,...
QSharedPointer< FiffDirNode > SPtr
128-bit FIFF identifier: hardware machine ID plus creation time, stamped on every file and block.
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
Stripped FIFF measurement info: channel list, sampling rate, device→head transform and bad-channel li...
QSharedDataPointer< FiffNamedMatrix > SDPtr
QSharedPointer< FiffStream > SPtr
Container holding the lh and/or rh FsAnnotation for one parcellation atlas.
Container holding the lh and/or rh FsSurface for one subject and one surface kind.
Lloyd-style K-means clustering with configurable metric, seeding and replicates.
bool calculate(const Eigen::MatrixXd &X, qint32 kClusters, Eigen::VectorXi &idx, Eigen::MatrixXd &C, Eigen::VectorXd &sumD, Eigen::MatrixXd &D)
Output of a cluster-based forward solution computation for a single cortical region.
Input parameters for cluster-based forward solution computation on a single cortical region.
Eigen::MatrixXd matRoiGWhitened
Eigen::MatrixXd matRoiGOrig
RegionDataOut cluster() const
In-memory representation of an -fwd.fif forward solution.
FIFFLIB::fiff_int_t nsource
FIFFLIB::FiffInfoBase info
static FIFFLIB::FiffCov compute_depth_prior(const Eigen::MatrixXd &Gain, const FIFFLIB::FiffInfo &gain_info, bool is_fixed_ori, double exp=0.8, double limit=10.0, const Eigen::MatrixXd &patch_areas=FIFFLIB::defaultConstMatrixXd, bool limit_depth_chs=false)
MNELIB::MNESourceSpaces src
MNEForwardSolution cluster_forward_solution(const FSLIB::FsAnnotationSet &p_AnnotationSet, qint32 p_iClusterSize, Eigen::MatrixXd &p_D=defaultD, const FIFFLIB::FiffCov &p_pNoise_cov=defaultCov, const FIFFLIB::FiffInfo &p_pInfo=defaultInfo, QString p_sMethod="cityblock") const
FIFFLIB::fiff_int_t source_ori
MNEForwardSolution & operator=(const MNEForwardSolution &other)
void prepare_forward(const FIFFLIB::FiffInfo &p_info, const FIFFLIB::FiffCov &p_noise_cov, bool p_pca, FIFFLIB::FiffInfo &p_outFwdInfo, Eigen::MatrixXd &gain, FIFFLIB::FiffCov &p_outNoiseCov, Eigen::MatrixXd &p_outWhitener, qint32 &p_outNumNonZero) const
FIFFLIB::FiffCoordTrans mri_head_t
QSharedPointer< MNEForwardSolution > SPtr
MNEForwardSolution pick_channels(const QStringList &include=FIFFLIB::defaultQStringList, const QStringList &exclude=FIFFLIB::defaultQStringList) const
FIFFLIB::FiffNamedMatrix::SDPtr sol_grad
bool isFixedOrient() const
MNEForwardSolution & operator=(MNEForwardSolution &&other)=default
Eigen::VectorXi tripletSelection(const Eigen::VectorXi &p_vecIdxSelection) const
std::unique_ptr< MNEForwardSolution > UPtr
MNEForwardSolution(MNEForwardSolution &&other)=default
Eigen::MatrixX3f source_nn
QSharedPointer< const MNEForwardSolution > ConstSPtr
Eigen::MatrixX3f source_rr
FIFFLIB::FiffCov compute_orient_prior(float loose=0.2)
MNEForwardSolution pick_regions(const QList< FSLIB::FsLabel > &p_qListLabels) const
FIFFLIB::fiff_int_t coord_frame
FIFFLIB::fiff_int_t nchan
MNEForwardSolution pick_types(bool meg, bool eeg, const QStringList &include=FIFFLIB::defaultQStringList, const QStringList &exclude=FIFFLIB::defaultQStringList) const
FIFFLIB::FiffNamedMatrix::SDPtr sol
List of MNESourceSpace objects forming a subject source space.