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
48namespace DISP3DLIB
49{
50
51class BrainSurface;
52
53//=============================================================================================================
63{
64public:
65 //=========================================================================================================
70
71 //=========================================================================================================
76
77 //=========================================================================================================
85 bool loadStc(const QString& path, int hemi);
86
87 //=========================================================================================================
93 bool isLoaded() const;
94
95 //=========================================================================================================
102 void applyToSurface(BrainSurface* surface, int timeIndex);
103
104 //=========================================================================================================
113 void computeInterpolationMatrix(BrainSurface* surface, int hemi, double cancelDist = 0.05);
114
115 //=========================================================================================================
121 void setColormap(const QString& name);
122
123 //=========================================================================================================
129 QString colormap() const
130 {
131 return m_colormap;
132 }
133
134 //=========================================================================================================
143 void setThresholds(float min, float mid, float max);
144
145 //=========================================================================================================
151 float thresholdMin() const
152 {
153 return m_threshMin;
154 }
155 float thresholdMid() const
156 {
157 return m_threshMid;
158 }
159 float thresholdMax() const
160 {
161 return m_threshMax;
162 }
163
164 //=========================================================================================================
170 int numTimePoints() const;
171
172 //=========================================================================================================
179 float timeAtIndex(int idx) const;
180
181 //=========================================================================================================
187 float tmin() const;
188
189 //=========================================================================================================
195 float tstep() const;
196
197 //=========================================================================================================
204 void getDataRange(double& minVal, double& maxVal) const;
205
206 //=========================================================================================================
213 void setStcData(const INVLIB::InvSourceEstimate& stc, int hemi);
214
215 //=========================================================================================================
222 void setInterpolationMatrix(QSharedPointer<Eigen::SparseMatrix<float>> mat, int hemi);
223
224 //=========================================================================================================
228 void updateThresholdsFromData();
229
230 //=========================================================================================================
236 QSharedPointer<Eigen::SparseMatrix<float>> interpolationMatLh() const
237 {
238 return m_interpolationMatLh;
239 }
240
241 //=========================================================================================================
247 QSharedPointer<Eigen::SparseMatrix<float>> interpolationMatRh() const
248 {
249 return m_interpolationMatRh;
250 }
251
252 //=========================================================================================================
260 Eigen::VectorXd sourceDataColumn(int timeIndex) const;
261
262private:
263 //=========================================================================================================
271 uint32_t valueToColor(double value, uint8_t alpha = 255) const;
272
275 bool m_hasLh = false;
276 bool m_hasRh = false;
277
278 QString m_colormap = "Hot";
279 float m_threshMin = 0.0f;
280 float m_threshMid = 0.5f;
281 float m_threshMax = 1.0f;
282
283 QSharedPointer<Eigen::SparseMatrix<float>> m_interpolationMatLh;
284 QSharedPointer<Eigen::SparseMatrix<float>> m_interpolationMatRh;
285
286 // ── Per-time-point color cache ─────────────────────────────────────
287 // Keyed by (hemi, vertexCount). The inner hash maps timeIndex →
288 // pre-computed packed-ABGR color buffer. Invalidated whenever the
289 // colormap, thresholds or source data change. This makes scrubbing
290 // and auto-loop playback effectively free after the first pass: only
291 // the per-vertex color blend + GPU upload happens, never the sparse
292 // interpolation matvec or the per-vertex colormap calculation.
293 using ColorCacheKey = QPair<int, int>;
294 using ColorCacheBucket = QHash<int, QVector<uint32_t>>;
295 mutable QHash<ColorCacheKey, ColorCacheBucket> m_colorCache;
296 void invalidateColorCache()
297 {
298 m_colorCache.clear();
299 }
300};
301
302} // namespace DISP3DLIB
303
304#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...
3-D brain visualisation using the Qt RHI rendering backend.
Renderable cortical surface mesh with per-vertex color, curvature data, and GPU buffer management.
void applyToSurface(BrainSurface *surface, int timeIndex)
QSharedPointer< Eigen::SparseMatrix< float > > interpolationMatLh() const
bool loadStc(const QString &path, int hemi)
void computeInterpolationMatrix(BrainSurface *surface, int hemi, double cancelDist=0.05)
QSharedPointer< Eigen::SparseMatrix< float > > interpolationMatRh() const
Source-space inverse-solution container with dense grid plus optional focal-dipole,...