v2.0.0
Loading...
Searching...
No Matches
sourceestimateoverlay.h
Go to the documentation of this file.
1//=============================================================================================================
26
27#ifndef SOURCEESTIMATEOVERLAY_H
28#define SOURCEESTIMATEOVERLAY_H
29
30//=============================================================================================================
31// INCLUDES
32//=============================================================================================================
33
34#include "../disp3D_global.h"
35
37#include <QVector>
38#include <QString>
39#include <QSharedPointer>
40#include <QHash>
41#include <QPair>
42#include <Eigen/Sparse>
43
44//=============================================================================================================
45// FORWARD DECLARATIONS
46//=============================================================================================================
47
48class BrainSurface;
49
50//=============================================================================================================
58{
59public:
60 //=========================================================================================================
65
66 //=========================================================================================================
71
72 //=========================================================================================================
80 bool loadStc(const QString &path, int hemi);
81
82 //=========================================================================================================
88 bool isLoaded() const;
89
90 //=========================================================================================================
97 void applyToSurface(BrainSurface *surface, int timeIndex);
98
99 //=========================================================================================================
108 void computeInterpolationMatrix(BrainSurface *surface, int hemi, double cancelDist = 0.05);
109
110 //=========================================================================================================
116 void setColormap(const QString &name);
117
118 //=========================================================================================================
124 QString colormap() const { return m_colormap; }
125
126 //=========================================================================================================
135 void setThresholds(float min, float mid, float max);
136
137 //=========================================================================================================
141 float thresholdMin() const { return m_threshMin; }
142 float thresholdMid() const { return m_threshMid; }
143 float thresholdMax() const { return m_threshMax; }
144
145 //=========================================================================================================
151 int numTimePoints() const;
152
153 //=========================================================================================================
160 float timeAtIndex(int idx) const;
161
162 //=========================================================================================================
168 float tmin() const;
169
170 //=========================================================================================================
176 float tstep() const;
177
178 //=========================================================================================================
185 void getDataRange(double &minVal, double &maxVal) const;
186
187 //=========================================================================================================
194 void setStcData(const INVLIB::InvSourceEstimate &stc, int hemi);
195
196 //=========================================================================================================
203 void setInterpolationMatrix(QSharedPointer<Eigen::SparseMatrix<float>> mat, int hemi);
204
205 //=========================================================================================================
209 void updateThresholdsFromData();
210
211 //=========================================================================================================
217 QSharedPointer<Eigen::SparseMatrix<float>> interpolationMatLh() const { return m_interpolationMatLh; }
218
219 //=========================================================================================================
225 QSharedPointer<Eigen::SparseMatrix<float>> interpolationMatRh() const { return m_interpolationMatRh; }
226
227 //=========================================================================================================
235 Eigen::VectorXd sourceDataColumn(int timeIndex) const;
236
237private:
238 //=========================================================================================================
246 uint32_t valueToColor(double value, uint8_t alpha = 255) const;
247
250 bool m_hasLh = false;
251 bool m_hasRh = false;
252
253 QString m_colormap = "Hot";
254 float m_threshMin = 0.0f;
255 float m_threshMid = 0.5f;
256 float m_threshMax = 1.0f;
257
258 QSharedPointer<Eigen::SparseMatrix<float>> m_interpolationMatLh;
259 QSharedPointer<Eigen::SparseMatrix<float>> m_interpolationMatRh;
260
261 // ── Per-time-point color cache ─────────────────────────────────────
262 // Keyed by (hemi, vertexCount). The inner hash maps timeIndex →
263 // pre-computed packed-ABGR color buffer. Invalidated whenever the
264 // colormap, thresholds or source data change. This makes scrubbing
265 // and auto-loop playback effectively free after the first pass: only
266 // the per-vertex color blend + GPU upload happens, never the sparse
267 // interpolation matvec or the per-vertex colormap calculation.
268 using ColorCacheKey = QPair<int, int>;
269 using ColorCacheBucket = QHash<int, QVector<uint32_t>>;
270 mutable QHash<ColorCacheKey, ColorCacheBucket> m_colorCache;
271 void invalidateColorCache() { m_colorCache.clear(); }
272};
273
274#endif // SOURCEESTIMATEOVERLAY_H
Library export/import macros and namespace marker for the disp3D library.
#define DISP3DSHARED_EXPORT
InvSourceEstimate value type — central source-space data container produced by every INVLIB inverse s...
Renderable cortical surface mesh with per-vertex color, curvature data, and GPU buffer management.
QSharedPointer< Eigen::SparseMatrix< float > > interpolationMatRh() const
void applyToSurface(BrainSurface *surface, int timeIndex)
QSharedPointer< Eigen::SparseMatrix< float > > interpolationMatLh() const
void computeInterpolationMatrix(BrainSurface *surface, int hemi, double cancelDist=0.05)
void setColormap(const QString &name)
bool loadStc(const QString &path, int hemi)
Source-space inverse-solution container with dense grid plus optional focal-dipole,...