53 const QString &rhPath,
61 , m_lhSurface(lhSurface)
62 , m_rhSurface(rhSurface)
63 , m_cancelDist(cancelDist)
75QSharedPointer<Eigen::SparseMatrix<float>> StcLoadingWorker::computeInterpolationMatrix(
76 const Eigen::MatrixX3f &matVertices,
77 Eigen::VectorXi &vecSourceVertices,
79 const QString &hemiLabel,
83 emit
progress(progressStart, QString(
"Computing %1 geodesic interpolation...").arg(hemiLabel));
86 std::vector<Eigen::VectorXi> vecNeighbors;
87 if (hemiLabel ==
"LH" && m_lhSurface) {
89 }
else if (hemiLabel ==
"RH" && m_rhSurface) {
90 vecNeighbors = m_rhSurface->computeNeighbors();
97 const int progressRange = progressEnd - progressStart;
98 auto progressCallback = [
this, &hemiLabel, progressStart, progressRange](
int current,
int total) {
99 int pct = progressStart + (progressRange * current) / total;
100 emit
progress(pct, QString(
"%1 geodesic interpolation %2/%3").arg(hemiLabel).arg(current).arg(total));
112 emit
progress(progressEnd, QString(
"%1 interpolation matrix ready").arg(hemiLabel));
120 emit
progress(0,
"Loading STC files...");
123 if (!m_lhPath.isEmpty()) {
124 QFile file(m_lhPath);
130 emit
error(QString(
"Failed to read LH STC file: %1").arg(m_lhPath));
134 emit
progress(5,
"Loading RH STC file...");
137 if (!m_rhPath.isEmpty()) {
138 QFile file(m_rhPath);
144 emit
error(QString(
"Failed to read RH STC file: %1").arg(m_rhPath));
148 if (!m_hasLh && !m_hasRh) {
149 emit
error(
"No STC data could be loaded.");
155 if (m_hasLh && m_lhSurface) {
156 Eigen::MatrixX3f matVertices = m_lhSurface->verticesAsMatrix();
157 Eigen::VectorXi vecSourceVertices = m_stcLh.vertices;
159 if (vecSourceVertices.size() > 0) {
160 m_interpMatLh = computeInterpolationMatrix(matVertices, vecSourceVertices, m_cancelDist,
166 if (m_hasRh && m_rhSurface) {
167 Eigen::MatrixX3f matVertices = m_rhSurface->verticesAsMatrix();
168 Eigen::VectorXi vecSourceVertices = m_stcRh.vertices;
170 if (vecSourceVertices.size() > 0) {
171 m_interpMatRh = computeInterpolationMatrix(matVertices, vecSourceVertices, m_cancelDist,
StcLoadingWorker class declaration.
GeometryInfo class declaration.
Interpolation class declaration.
BrainSurface class declaration.
static QSharedPointer< Eigen::SparseMatrix< float > > scdcInterpolationMat(const Eigen::MatrixX3f &matVertices, const std::vector< Eigen::VectorXi > &vecNeighborVertices, const Eigen::VectorXi &vecVertSubset, double(*interpolationFunction)(double), double dCancelDist, std::function< void(int, int)> progressCallback=nullptr)
scdcInterpolationMat Computes geodesic distances (SCDC) and builds the sparse interpolation matrix in...
static double cubic(const double dIn)
cubic Cubic hyperbola interpolation function.
Renderable cortical surface mesh with per-vertex color, curvature data, and GPU buffer management.
std::vector< Eigen::VectorXi > computeNeighbors() const
void error(const QString &message)
void progress(int percent, const QString &message)
void finished(bool success)
StcLoadingWorker(const QString &lhPath, const QString &rhPath, BrainSurface *lhSurface, BrainSurface *rhSurface, double cancelDist=0.05, QObject *parent=nullptr)
static bool read(QIODevice &p_IODevice, InvSourceEstimate &p_stc)