23#ifndef MNE_FORWARD_SOLUTION_H
24#define MNE_FORWARD_SOLUTION_H
57#include <QSharedPointer>
104 QString t_sDistMeasure;
106 t_sDistMeasure = QString(
"cityblock");
117 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(), p_RegionDataOut.
ctrs.cols());
120 for(qint32 c = 0; c < p_RegionDataOut.
ctrs.rows(); ++c)
124 for(qint32 idx = 0; idx < p_RegionDataOut.
roiIdx.size(); ++idx)
126 if(c == p_RegionDataOut.
roiIdx[idx])
128 newCtrs.row(c) += this->matRoiG.row(idx);
134 newCtrs.row(c) /= num;
136 p_RegionDataOut.
ctrs = newCtrs;
139 t_kMeans.
calculate(this->matRoiG, this->nClusters, p_RegionDataOut.
roiIdx, p_RegionDataOut.
ctrs, p_RegionDataOut.
sumd, p_RegionDataOut.
D);
143 return p_RegionDataOut;
149static Eigen::MatrixXd defaultD;
162 typedef QSharedPointer<MNEForwardSolution>
SPtr;
163 typedef QSharedPointer<const MNEForwardSolution>
ConstSPtr;
164 typedef std::unique_ptr<MNEForwardSolution>
UPtr;
185 bool force_fixed =
false,
187 const QStringList& include = FIFFLIB::defaultQStringList,
188 const QStringList& exclude = FIFFLIB::defaultQStringList,
189 bool bExcludeBads =
false);
248 qint32 p_iClusterSize,
249 Eigen::MatrixXd& p_D = defaultD,
252 QString p_sMethod =
"cityblock")
const;
283 const Eigen::MatrixXd &patch_areas = FIFFLIB::defaultConstMatrixXd,
284 bool limit_depth_chs =
false);
322 const QStringList& exclude = FIFFLIB::defaultQStringList)
const;
349 const QStringList& include = FIFFLIB::defaultQStringList,
350 const QStringList& exclude = FIFFLIB::defaultQStringList)
const;
369 Eigen::MatrixXd &gain,
371 Eigen::MatrixXd &p_outWhitener,
372 qint32 &p_outNumNonZero)
const;
380 Eigen::MatrixXi triSelect = p_vecIdxSelection.transpose().replicate(3,1).array() * 3;
381 triSelect.row(1).array() += 1;
382 triSelect.row(2).array() += 2;
383 Eigen::VectorXi retTriSelect(triSelect.cols()*3);
384 for(
int i = 0; i < triSelect.cols(); ++i)
385 retTriSelect.block(i*3,0,3,1) = triSelect.col(i);
405 static bool read(QIODevice& p_IODevice,
407 bool force_fixed =
false,
408 bool surf_ori =
false,
409 const QStringList& include = FIFFLIB::defaultQStringList,
410 const QStringList& exclude = FIFFLIB::defaultQStringList,
411 bool bExcludeBads =
true);
427 bool write(QIODevice& p_IODevice)
const;
438 MNEForwardSolution reduce_forward_solution(qint32 p_iNumDipoles, Eigen::MatrixXd& p_D)
const;
447 static void restrict_gain_matrix(Eigen::MatrixXd &G,
const FIFFLIB::FiffInfo &info);
484 Eigen::MatrixX3f getSourcePositionsByLabel(
const QList<FSLIB::FsLabel> &lPickedLabels,
527 return this->
nchan <= 0;
541 out <<
"#### MNE Forward Solution ####\n";
543 out <<
"\n source_ori: " << p_MNEForwardSolution.
source_ori << std::endl;
544 out <<
"\n coord_frame: " << p_MNEForwardSolution.
coord_frame << std::endl;
545 out <<
"\n nsource: " << p_MNEForwardSolution.
nsource << std::endl;
546 out <<
"\n nchan: " << p_MNEForwardSolution.
nchan << std::endl;
547 out <<
"\n sol:\n\t" << *p_MNEForwardSolution.
sol.data() << std::endl;
548 out <<
"\n sol_grad:\n\t" << *p_MNEForwardSolution.
sol_grad.data() << std::endl;
bool operator==(const BIDSPath &a, const BIDSPath &b)
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.
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
#define FIFFV_MNE_FIXED_ORI
Minimal measurement-info subset (channel list, sampling rate, basic transforms) shared by FIFF reader...
Noise / data covariance matrix as stored under FIFFB_MNE_COV, with channel names, kind,...
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
K-means partitional clustering with multiple distance metrics, initialisations and empty-cluster poli...
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.