v2.0.0
Loading...
Searching...
No Matches
INVLIB Namespace Reference

Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting). More...

Classes

class  InvBeamformer
 Computed beamformer spatial filter container. More...
class  InvBeamformerCompute
 Core beamformer math. More...
class  InvDICS
 DICS beamformer (frequency-domain). More...
class  InvLCMV
 LCMV beamformer (time-domain). More...
class  InvDipoleFit
 High-level driver for sequential dipole fitting. More...
struct  dipoleFitFuncsRec
 Forward field computation function pointers and client data for MEG and EEG dipole fitting. More...
struct  FitDipUserRec
 Workspace for the dipole fitting objective function, holding forward model, measured field, and fit limits. More...
class  InvDipoleFitData
 Dipole fit workspace holding sensor geometry, forward model, noise covariance, and projection data. More...
class  InvDipoleFitSettings
 Dipole Fit setting implementation. More...
class  InvDipoleForward
 Stores forward field matrices and SVD decomposition for magnetic dipole fitting. More...
class  InvEcd
 Single equivalent current dipole with position, orientation, amplitude, and goodness-of-fit. More...
struct  bdipEcd
 Binary-format dipole record for file I/O, storing fitted dipole parameters and error estimates. More...
class  InvEcdSet
 Holds a set of Electric Current Dipoles. More...
class  InvGuessData
 Precomputed guess point grid with forward fields for initial dipole position candidates. More...
class  InvHpiDataUpdater
 Preprocesses raw HPI coil data (SSP projection, compensation, sinusoidal model fitting) before dipole localization. More...
struct  CoilParam
 Estimated dipole parameters (position, moment, goodness-of-fit) for a single HPI coil. More...
struct  HpiFitResult
 Complete HPI fit output: per-coil dipole parameters, head-to-device transform, fit error, and head movement distance. More...
class  InvHpiFit
 HPI Fit algorithms. More...
struct  DipFitError
 Residual error and moment vector from a single magnetic dipole fit iteration. More...
struct  HPISortStruct
 Helper for sorting HPI coil dipole fits by matching each fit to the nearest expected coil position. More...
class  InvHpiFitData
 HPI Fit algorithm data structure. More...
class  InvHpiModelParameters
 Configuration parameters for the HPI signal model (line frequency, coil frequencies, sample rate, buffer size). More...
class  InvSensorSet
 Stores MEG sensor geometry (positions, orientations, weights, coil count) for a single sensor type. More...
class  InvSensorSetCreator
 Builds InvSensorSet objects from FiffInfo channel definitions, applying SSP projections and compensation. More...
class  InvSignalModel
 Generates the forward sinusoidal model matrix for HPI coil signals at known drive frequencies. More...
struct  InvConnectivity
 Pairwise source connectivity matrix with measure, directionality, and frequency/time metadata. More...
struct  InvFocalDipole
 Single focal dipole with free 3D position, moment, and fit-quality metrics. More...
struct  InvSourceCoupling
 N-tuple of correlated grid sources with orientations and correlation matrix. More...
class  InvSourceEstimate
 Source estimation. More...
struct  InvToken
 One element of a tokenised neural-source representation. More...
struct  InvTokenizeOptions
 Tokenization options controlling layer inclusion and sub-sampling. More...
class  InvMinimumNorm
 Minimum norm estimation. More...
class  InvDipole
 Stores position, orientation, and correlation of a single current dipole estimated by RAP MUSIC. More...
struct  InvDipolePair
 Pair of correlated dipole indices and orientations found by the RAP MUSIC scanning step. More...
class  InvPwlRapMusic
 Powell-accelerated RAP MUSIC variant using gradient-free optimization for refined dipole fitting. More...
struct  Pair
 Index pair representing two grid points evaluated together in the RAP MUSIC subspace scan. More...
class  InvRapMusic
 RAP MUSIC (Recursively Applied and Projected Multiple Signal Classification) source localization algorithm. More...

Typedefs

using dipoleFitFuncs = dipoleFitFuncsRec*
 Pointer alias for dipoleFitFuncsRec, used throughout the dipole fitting module.
typedef struct INVLIB::bdipEcd bdipEcdRec
typedef struct INVLIB::Pair Pair
 Index pair representing two grid points evaluated together in the RAP MUSIC subspace scan.

Enumerations

enum class  BeamformerWeightNorm { None = 0 , UnitNoiseGain , NAI , UnitNoiseGainInv }
enum class  BeamformerPickOri { None = 0 , Normal , MaxPower , Vector }
enum class  BeamformerInversion { Matrix = 0 , Single }
enum class  Accuracy : int { high = 2 , medium = 1 , low = 0 }
enum class  InvTokenId : int32_t {
  Pad = 0 , Bos = 1 , Eos = 2 , Sep = 3 ,
  MetaBegin = 10 , MetaEnd = 11 , GridBegin = 20 , GridEnd = 21 ,
  GridRow = 22 , CouplingBegin = 30 , CouplingEnd = 31 , GroupBegin = 32 ,
  GroupEnd = 33 , FocalBegin = 40 , FocalEnd = 41 , DipoleBegin = 42 ,
  DipoleEnd = 43 , ConnBegin = 50 , ConnEnd = 51 , ConnEntryBegin = 52 ,
  ConnEntryEnd = 53 , PosBegin = 60 , PosEnd = 61 , MethodUnknown = 100 ,
  MethodMNE = 101 , MethodDSPM = 102 , MethodSLORETA = 103 , MethodELORETA = 104 ,
  MethodLCMV = 105 , MethodDICS = 106 , MethodSAM = 107 , MethodMixedNorm = 108 ,
  MethodGammaMAP = 109 , MethodDipoleFit = 110 , MethodRapMusic = 111 , MethodPwlRapMusic = 112 ,
  SpaceUnknown = 150 , SpaceSurface = 151 , SpaceVolume = 152 , SpaceMixed = 153 ,
  SpaceDiscrete = 154 , OrientUnknown = 170 , OrientFixed = 171 , OrientFree = 172 ,
  OrientLoose = 173 , Amplitude = 200 , Vertex = 201 , TimeVal = 202 ,
  FreqVal = 203 , PosX = 204 , PosY = 205 , PosZ = 206 ,
  MomX = 207 , MomY = 208 , MomZ = 209 , Goodness = 210 ,
  ChiSquared = 211 , Correlation = 212 , ConnValue = 213 , GridIndex = 214 ,
  ValidTrue = 250 , ValidFalse = 251 , DirectedTrue = 252 , DirectedFalse = 253 ,
  NSources = 280 , NTimes = 281 , NGroups = 282 , NDipoles = 283 ,
  NMeasures = 284 , NIndices = 285 , NFreeDof = 286 , TStep = 287 ,
  MeasCoh = 300 , MeasImCoh = 301 , MeasPlv = 302 , MeasPli = 303 ,
  MeasWpli = 304 , MeasGranger = 305 , MeasPdc = 306 , MeasDtf = 307 ,
  MeasCorrelation = 308 , MeasCrossCorr = 309 , MeasOther = 310 , QuantBinBase = 1000
}
enum class  InvEstimateMethod {
  Unknown = 0 , MNE , dSPM , sLORETA ,
  eLORETA , LCMV , DICS , SAM ,
  MixedNorm , GammaMAP , DipoleFit , RapMusic ,
  PwlRapMusic
}
enum class  InvSourceSpaceType {
  Unknown = 0 , Surface , Volume , Mixed ,
  Discrete
}
enum class  InvOrientationType { Unknown = 0 , Fixed , Free , Loose }

Functions

INVSHARED_EXPORT const char * buildDateTime ()
INVSHARED_EXPORT const char * buildHash ()
INVSHARED_EXPORT const char * buildHashLong ()
INVSHARED_EXPORT std::vector< InvTokentokenize (const InvSourceEstimate &estimate, const InvTokenizeOptions &options=InvTokenizeOptions())
 Serialise an InvSourceEstimate into a flat token sequence.
INVSHARED_EXPORT InvSourceEstimate fromTokens (const std::vector< InvToken > &tokens)
 Reconstruct an InvSourceEstimate from a token sequence.
std::vector< int32_t > tokenIds (const std::vector< InvToken > &tokens)
std::vector< float > tokenValues (const std::vector< InvToken > &tokens)

Detailed Description

Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).

Typedef Documentation

◆ bdipEcdRec

◆ dipoleFitFuncs

Pointer alias for dipoleFitFuncsRec, used throughout the dipole fitting module.

Definition at line 106 of file inv_dipole_fit_data.h.

◆ Pair

typedef struct INVLIB::Pair INVLIB::Pair

Index pair representing two grid points evaluated together in the RAP MUSIC subspace scan.

Declares a pair structure for index combinations used in RAP MUSIC algorithm.

Enumeration Type Documentation

◆ Accuracy

enum class INVLIB::Accuracy : int
strong
Enumerator
high 
medium 
low 

Definition at line 78 of file inv_sensor_set.h.

◆ BeamformerInversion

enum class INVLIB::BeamformerInversion
strong

Method for inverting the beamformer denominator matrix G^H Cm^{-1} G.

Enumerator
Matrix 

Full matrix inversion per source.

Single 

Scalar (diagonal) inversion per source.

Definition at line 77 of file inv_beamformer_settings.h.

◆ BeamformerPickOri

enum class INVLIB::BeamformerPickOri
strong

Orientation picking mode for beamformer filters.

Enumerator
None 

Keep all orientations (3 per source for free, 1 for fixed).

Normal 

Extract surface normal component only (Z in local coords).

MaxPower 

Optimal orientation via max eigenvalue of power matrix.

Vector 

Return the full 3-component vector solution.

Definition at line 65 of file inv_beamformer_settings.h.

◆ BeamformerWeightNorm

enum class INVLIB::BeamformerWeightNorm
strong

Weight normalization strategy for beamformer spatial filters.

References:

  • Sekihara & Nagarajan, "Adaptive Spatial Filters for Electromagnetic Brain Imaging", 2008.
  • Van Veen et al., IEEE Trans. Biomed. Eng. 44(9), 867-880, 1997.
Enumerator
None 

No normalization (raw unit-gain filter).

UnitNoiseGain 

Normalize by sqrt(diag(W @ W^H)), Sekihara 2008.

NAI 

Neural Activity Index: unit-noise-gain + noise subspace normalization.

UnitNoiseGainInv 

Rotation-invariant unit-noise-gain via sqrtm(inner)^{-0.5}.

Definition at line 53 of file inv_beamformer_settings.h.

◆ InvEstimateMethod

enum class INVLIB::InvEstimateMethod
strong

Enumerates the inverse estimation method that produced a source estimate.

Enumerator
Unknown 
MNE 
dSPM 
sLORETA 
eLORETA 
LCMV 
DICS 
SAM 
MixedNorm 
GammaMAP 
DipoleFit 
RapMusic 
PwlRapMusic 

Definition at line 49 of file inv_types.h.

◆ InvOrientationType

enum class INVLIB::InvOrientationType
strong

Enumerates the orientation constraint used during source estimation.

Enumerator
Unknown 
Fixed 
Free 
Loose 

Definition at line 83 of file inv_types.h.

◆ InvSourceSpaceType

enum class INVLIB::InvSourceSpaceType
strong

Enumerates the source space type underlying a source estimate.

Enumerator
Unknown 
Surface 
Volume 
Mixed 
Discrete 

Definition at line 70 of file inv_types.h.

◆ InvTokenId

enum class INVLIB::InvTokenId : int32_t
strong

Token vocabulary for the InvSourceEstimate tokenization format.

IDs are organised into ranges: 0..9 Special tokens (PAD, BOS, EOS, SEP) 10..19 Metadata section markers 20..29 Grid section markers 30..39 Coupling section markers 40..49 Focal-dipole section markers 50..59 Connectivity section markers 60..69 Positions section markers 100..149 Method labels 150..169 Source-space labels 170..189 Orientation labels 200..249 Value-carrier tokens (id + continuous float) 250..279 Boolean tokens 280..299 Dimension/size tokens (id + int-as-float) 300..349 Connectivity measure name tokens 1000+ Reserved for external quantisation bins

Enumerator
Pad 
Bos 

Beginning of sequence.

Eos 

End of sequence.

Sep 

Separator (between modalities, optional).

MetaBegin 
MetaEnd 
GridBegin 
GridEnd 
GridRow 

Marks the start of one source's time-course.

CouplingBegin 
CouplingEnd 
GroupBegin 

Start of one N-tuple coupling group.

GroupEnd 
FocalBegin 
FocalEnd 
DipoleBegin 

Start of one focal dipole.

DipoleEnd 
ConnBegin 
ConnEnd 
ConnEntryBegin 

Start of one connectivity measure.

ConnEntryEnd 
PosBegin 
PosEnd 
MethodUnknown 
MethodMNE 
MethodDSPM 
MethodSLORETA 
MethodELORETA 
MethodLCMV 
MethodDICS 
MethodSAM 
MethodMixedNorm 
MethodGammaMAP 
MethodDipoleFit 
MethodRapMusic 
MethodPwlRapMusic 
SpaceUnknown 
SpaceSurface 
SpaceVolume 
SpaceMixed 
SpaceDiscrete 
OrientUnknown 
OrientFixed 
OrientFree 
OrientLoose 
Amplitude 

Source amplitude at one (source, time) sample.

Vertex 

Vertex / grid index.

TimeVal 

Time in seconds.

FreqVal 

Frequency in Hz.

PosX 

3-D position x component (m).

PosY 

3-D position y component (m).

PosZ 

3-D position z component (m).

MomX 

Dipole moment x component (Am).

MomY 

Dipole moment y component (Am).

MomZ 

Dipole moment z component (Am).

Goodness 

Goodness-of-fit (0..1).

ChiSquared 

Chi-squared fit quality.

Correlation 

Coupling correlation value.

ConnValue 

Pairwise connectivity value.

GridIndex 

Grid reference index inside a coupling group.

ValidTrue 
ValidFalse 
DirectedTrue 
DirectedFalse 
NSources 

Number of grid sources.

NTimes 

Number of time samples.

NGroups 

Number of coupling groups.

NDipoles 

Number of focal dipoles.

NMeasures 

Number of connectivity measures.

NIndices 

Number of indices in a coupling group.

NFreeDof 

Degrees of freedom.

TStep 

Time step (s) — grid sampling interval.

MeasCoh 
MeasImCoh 
MeasPlv 
MeasPli 
MeasWpli 
MeasGranger 
MeasPdc 
MeasDtf 
MeasCorrelation 
MeasCrossCorr 
MeasOther 

Unrecognised metric (name not preserved in token stream).

QuantBinBase 

Bins occupy IDs [QuantBinBase .. QuantBinBase + numBins - 1].

Definition at line 99 of file inv_token.h.

Function Documentation

◆ buildDateTime()

const char * INVLIB::buildDateTime ( )

Returns build date and time.

Definition at line 46 of file inv_global.cpp.

◆ buildHash()

const char * INVLIB::buildHash ( )

Returns abbreviated build git hash.

Definition at line 50 of file inv_global.cpp.

◆ buildHashLong()

const char * INVLIB::buildHashLong ( )

Returns full build git hash.

Definition at line 54 of file inv_global.cpp.

◆ fromTokens()

INVSHARED_EXPORT InvSourceEstimate INVLIB::fromTokens ( const std::vector< InvToken > & tokens)

Reconstruct an InvSourceEstimate from a token sequence.

Parses a token stream previously produced by tokenize() and rebuilds the InvSourceEstimate fields (metadata, grid data, positions, couplings, focal dipoles, connectivity). Unknown or out-of-order tokens are silently skipped.

Parameters
[in]tokensThe token sequence to decode.
Returns
The reconstructed source estimate.
See also
tokenize, InvToken

◆ tokenIds()

std::vector< int32_t > INVLIB::tokenIds ( const std::vector< InvToken > & tokens)
inline

Extract just the integer token IDs from a token sequence (discarding continuous values). Useful for feeding into a purely discrete embedding table.

Parameters
[in]tokensThe token sequence.
Returns
Vector of int32_t token IDs.

Definition at line 261 of file inv_token.h.

◆ tokenize()

INVSHARED_EXPORT std::vector< InvToken > INVLIB::tokenize ( const InvSourceEstimate & estimate,
const InvTokenizeOptions & options = InvTokenizeOptions() )

Serialise an InvSourceEstimate into a flat token sequence.

Converts the full multimodal content of an InvSourceEstimate (grid amplitudes, positions, couplings, focal dipoles, connectivity matrices) into a linear sequence of InvToken elements. Each token carries a vocabulary ID and an optional continuous float value.

The options parameter controls which data layers are emitted and allows sub-sampling of dense grids to fit context-limited attention windows.

Parameters
[in]estimateThe source estimate to tokenize.
[in]optionsControls layer inclusion and sub-sampling (default: all layers, no sub-sampling).
Returns
A vector of InvToken representing the serialised estimate.
See also
fromTokens, InvTokenizeOptions, InvToken

◆ tokenValues()

std::vector< float > INVLIB::tokenValues ( const std::vector< InvToken > & tokens)
inline

Extract just the continuous values from a token sequence (discarding IDs). Useful as the real-valued branch in a hybrid discrete-continuous embedding.

Parameters
[in]tokensThe token sequence.
Returns
Vector of float values.

Definition at line 277 of file inv_token.h.