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//=============================================================================================================
187{
189 float value;
190
192 explicit InvToken(InvTokenId _id) : id(_id), value(0.0f) {}
193 InvToken(InvTokenId _id, float _val) : id(_id), value(_val) {}
194};
195
196//=============================================================================================================
206{
207 bool includeGridData = true;
208 bool includeCouplings = true;
211 bool includePositions = true;
212 int maxSources = -1;
213 int maxTimePoints = -1;
214};
215
216//=============================================================================================================
224inline std::vector<int32_t> tokenIds(const std::vector<InvToken>& tokens)
225{
226 std::vector<int32_t> ids(tokens.size());
227 for (size_t i = 0; i < tokens.size(); ++i)
228 ids[i] = static_cast<int32_t>(tokens[i].id);
229 return ids;
230}
231
232//=============================================================================================================
240inline std::vector<float> tokenValues(const std::vector<InvToken>& tokens)
241{
242 std::vector<float> vals(tokens.size());
243 for (size_t i = 0; i < tokens.size(); ++i)
244 vals[i] = tokens[i].value;
245 return vals;
246}
247
248} // NAMESPACE INVLIB
249
250#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:240
std::vector< int32_t > tokenIds(const std::vector< InvToken > &tokens)
Definition inv_token.h:224
InvToken(InvTokenId _id, float _val)
Definition inv_token.h:193
InvTokenId id
Definition inv_token.h:188
InvToken(InvTokenId _id)
Definition inv_token.h:192
Tokenization options controlling layer inclusion and sub-sampling.
Definition inv_token.h:206