v2.0.0
Loading...
Searching...
No Matches
inv_token.h
Go to the documentation of this file.
1//=============================================================================================================
23
24#ifndef INV_TOKEN_H
25#define INV_TOKEN_H
26
27//=============================================================================================================
28// INCLUDES
29//=============================================================================================================
30
31#include <cstdint>
32#include <vector>
33
34//=============================================================================================================
35// DEFINE NAMESPACE INVLIB
36//=============================================================================================================
37
38namespace INVLIB
39{
40
41//=============================================================================================================
62enum class InvTokenId : int32_t
63{
64 // --- Special tokens ---
65 Pad = 0,
66 Bos = 1,
67 Eos = 2,
68 Sep = 3,
69
70 // --- Section markers (paired begin / end) ---
72 MetaEnd = 11,
73
75 GridEnd = 21,
76 GridRow = 22,
77
82
87
89 ConnEnd = 51,
92
94 PosEnd = 61,
95
96 // --- Method labels (one-hot from InvEstimateMethod) ---
98 MethodMNE = 101,
110
111 // --- Source-space labels (one-hot from InvSourceSpaceType) ---
117
118 // --- Orientation labels (one-hot from InvOrientationType) ---
123
124 // --- Value-carrier tokens (paired with float in InvToken::value) ---
125 Amplitude = 200,
126 Vertex = 201,
127 TimeVal = 202,
128 FreqVal = 203,
129 PosX = 204,
130 PosY = 205,
131 PosZ = 206,
132 MomX = 207,
133 MomY = 208,
134 MomZ = 209,
135 Goodness = 210,
138 ConnValue = 213,
139 GridIndex = 214,
140
141 // --- Boolean tokens ---
146
147 // --- Dimension tokens (carry size as int-in-float) ---
148 NSources = 280,
149 NTimes = 281,
150 NGroups = 282,
151 NDipoles = 283,
152 NMeasures = 284,
153 NIndices = 285,
154 NFreeDof = 286,
155 TStep = 287,
156
157 // --- Connectivity-measure name tokens ---
158 MeasCoh = 300,
160 MeasPlv = 302,
161 MeasPli = 303,
162 MeasWpli = 304,
164 MeasPdc = 306,
165 MeasDtf = 307,
168 MeasOther = 310,
169
170 // --- Quantization bin base (for fully discrete tokenisation) ---
172};
173
174//=============================================================================================================
189{
191 float value;
192
194 : id(InvTokenId::Pad)
195 , value(0.0f)
196 {
197 }
198 explicit InvToken(InvTokenId _id)
199 : id(_id)
200 , value(0.0f)
201 {
202 }
203 InvToken(InvTokenId _id, float _val)
204 : id(_id)
205 , value(_val)
206 {
207 }
208};
209
210//=============================================================================================================
222{
223 bool includeGridData = true;
224 bool includeCouplings = true;
227 bool includePositions = true;
228 int maxSources = -1;
229 int maxTimePoints = -1;
230};
231
232//=============================================================================================================
240inline std::vector<int32_t> tokenIds(const std::vector<InvToken>& tokens)
241{
242 std::vector<int32_t> ids(tokens.size());
243 for (size_t i = 0; i < tokens.size(); ++i)
244 ids[i] = static_cast<int32_t>(tokens[i].id);
245 return ids;
246}
247
248//=============================================================================================================
256inline std::vector<float> tokenValues(const std::vector<InvToken>& tokens)
257{
258 std::vector<float> vals(tokens.size());
259 for (size_t i = 0; i < tokens.size(); ++i)
260 vals[i] = tokens[i].value;
261 return vals;
262}
263
264} // NAMESPACE INVLIB
265
266#endif // INV_TOKEN_H
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
std::vector< float > tokenValues(const std::vector< InvToken > &tokens)
Definition inv_token.h:256
std::vector< int32_t > tokenIds(const std::vector< InvToken > &tokens)
Definition inv_token.h:240
InvToken(InvTokenId _id, float _val)
Definition inv_token.h:203
InvTokenId id
Definition inv_token.h:190
InvToken(InvTokenId _id)
Definition inv_token.h:198
Tokenization options controlling layer inclusion and sub-sampling.
Definition inv_token.h:222