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

Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms). More...

Classes

struct  AnnotateMusclParams
 Parameters for muscle artifact annotation. More...
struct  AnnotateAmplitudeParams
 Parameters for amplitude-based annotation. More...
struct  ArtifactDetectEcgParams
 ECG R-peak detection parameters (defined outside class to avoid Clang/GCC default-argument issues with nested structs). More...
struct  ArtifactDetectEogParams
 EOG blink / saccade detection parameters (defined outside class to avoid Clang/GCC default-argument issues with nested structs). More...
class  ArtifactDetect
 ECG and EOG physiological artifact event detection. More...
struct  BadChannelDetectParams
 Bad-channel detection parameters (defined outside class to avoid Clang/GCC default-argument issues with nested structs). More...
class  BadChannelDetect
 Automated detection of bad MEG/EEG channels using flat, variance, and correlation criteria. More...
struct  LofBadChannelParams
struct  BadChannelsMaxwellParams
 Parameters for SSS-based bad channel detection. More...
struct  BadChannelsMaxwellResult
 Result of SSS-based bad channel detection. More...
struct  BridgedElectrodeParams
struct  DerivationRule
 A single derivation rule mapping input channels (with weights) to one output channel. More...
class  ChannelDerivation
 Channel derivation and re-referencing utilities. More...
class  ConnectivityAec
 Amplitude Envelope Correlation connectivity. More...
class  CosineFilter
 Creates a cosine filter response in the frequency domain. More...
struct  CsdResult
 Result of a Cross-Spectral Density computation. More...
class  Csd
 Cross-Spectral Density (CSD) estimator. More...
struct  DpssResult
 Result of a DPSS taper computation. More...
class  Dpss
 Discrete Prolate Spheroidal Sequences (Slepian tapers). More...
class  EogRegression
 Remove EOG artifacts via linear regression. More...
struct  EpochExtractorParams
 Epoch extraction parameters (defined outside class to avoid Clang/GCC default-argument issues with nested structs). More...
class  EpochExtractor
 Segments continuous raw data into fixed-length epochs locked to events. More...
struct  InfomaxResult
class  ExtendedInfomax
struct  FilterChpiParams
 Parameters for cHPI notch filtering. More...
class  FilterIO
 Processes txt files which hold filter coefficients. More...
class  FilterParameter
 Named filter-design parameter descriptor holding a human-readable name and description (e.g. design method or filter type). More...
class  FilterKernel
 The FilterKernel class provides methods to create/design a FIR filter kernel. More...
struct  FineCalEntry
 Per-sensor fine calibration entry. More...
class  FineCalibration
 Fine calibration data for SSS. More...
class  FirFilter
 Discoverable façade over the FilterKernel FIR-filter engine. More...
struct  IcaResult
 Result of an ICA decomposition. More...
class  ICA
 Independent Component Analysis using the FastICA algorithm (deflationary, logcosh nonlinearity). More...
struct  IirBiquad
 Coefficients of one second-order IIR section (biquad). More...
class  IirFilter
 Butterworth IIR filter design and application using second-order sections. More...
struct  HeadPosEntry
 A head position entry (time, translation, rotation quaternion). More...
struct  MaxwellMoveCompParams
 Parameters for Maxwell movement compensation. More...
class  MaxwellMovementComp
 Maxwell movement compensation using SSS. More...
struct  MorletTfrResult
 Result of a Morlet TFR computation for one channel. More...
class  MorletTfr
 Complex Morlet wavelet time-frequency representation. More...
struct  MultitaperPsdResult
 Result of a multitaper PSD computation. More...
class  MultitaperPsd
 Multitaper power spectral density estimator using DPSS (Slepian) tapers. More...
struct  MultitaperTfrResult
 Result of a multitaper TFR computation. More...
class  MultitaperTfr
 Sliding-window multitaper time-frequency representation. More...
class  ParksMcClellan
 Parks-McClellan equiripple FIR filter design algorithm (Remez exchange). More...
struct  PeakFinderParams
class  PicardIca
 Independent Component Analysis using the Picard algorithm. More...
class  Resample
 Polyphase anti-aliased rational resampling for MEG/EEG data. More...
struct  SimulateStcParams
 Parameters for source time course simulation. More...
struct  SpectogramInputData
 Input parameters for short-time Fourier transform spectrogram computation. More...
class  Spectrogram
 Computes time-frequency spectrograms via short-time Fourier transform with configurable window and overlap. More...
struct  SSSParams
 Implements Signal Space Separation (SSS) and temporal SSS (tSSS) for MEG data. More...
class  SSS
struct  SurfaceLaplacianResult
 Result of a surface Laplacian (CSD) computation. More...
class  SurfaceLaplacian
 Surface Laplacian / Current Source Density (CSD) transformation. More...
struct  WelchPsdResult
 Result of a Welch PSD computation. More...
class  WelchPsd
 Welch's averaged-periodogram power spectral density estimator. More...
struct  XdawnResult
 Result of an xDAWN decomposition. More...
class  Xdawn
 Event-related response enhancement with xDAWN spatial filtering. More...
class  KMeans
 Lloyd-style K-means clustering with configurable metric, seeding and replicates. More...
class  Linalg
 Static Eigen-based linear-algebra helpers used across MATHLIB and the inverse solvers. More...
class  Numerics
 Static scalar/per-vector numerical helpers (GCD, log2, histograms, baseline rescaling). More...
class  SimplexAlgorithm
 Header-only Nelder–Mead simplex minimiser with templated cost and report functors. More...
struct  TaperedSpectraInputData
 Per-row input bundle for parallel multi-taper spectral estimation (data row, taper matrix, FFT length). More...
class  Spectral
 Static multi-taper spectra, PSD and CSD estimator for MEG/EEG time series. More...
struct  FitUser
 Cost-function workspace for Sphere::fit_sphere_simplex: holds the nx3 point cloud and a verbose-report flag. More...
class  Sphere
 3-D sphere value type with algebraic and Nelder–Mead best-fit factories. More...
class  Warp
 Thin-plate-spline 3-D warp fitted from landmark correspondences. More...
class  CircularBuffer
 Thread-safe lock-free circular (ring) buffer for producer-consumer data exchange between threads. More...
class  ICommand
 The ICommand interface provides the base class of every command of the command design pattern. More...
class  MNELogger
 Custom Qt message handler that formats and routes qDebug/qWarning/qCritical output to file or console. More...
class  IObserver
 The IObserver interface provides the base class of every observer of the observer design pattern. More...
class  Subject
 The Subject class provides the base class of every subject of the observer design pattern. More...
class  IOUtils
 Eigen matrix I/O utilities. More...
class  LayoutLoader
 Reads ANT .elc electrode files and MNE .lout 2-D channel layouts into Qt/STL containers. More...
struct  fitUserRec
 Workspace for sphere-fitting used by the layout maker, holding 3-D point coordinates and fit parameters. More...
class  LayoutMaker
 Make layout files from given 3D points. More...
struct  ElectrodePosition
 Represents an electrode position in a montage. More...
class  StandardMontage
 Standard EEG montage with named electrode positions. More...
struct  DigitizedPoint
 A single digitised point captured during the alignment session. More...
class  AcquiredPoints
 In-memory store of all points captured during a session. More...
struct  FastrakSample
 One decoded sample from a Fastrak ASCII stream. More...
class  FastrakParser
 Streaming parser for Fastrak / FastSCAN ASCII records. More...
struct  PolhemusSerialConfig
 Settings used to open a real Polhemus serial connection. More...
class  PolhemusConnection
 Polhemus digitizer connection (mock + serial-port backends). More...
class  PolhemusCoregistration
 Head–device coregistration engine driven by a Polhemus Fastrak. More...
struct  PythonRunnerResult
 Script execution result container. More...
struct  PythonRunnerConfig
 Script execution configuration. More...
class  PythonRunner
 Python script launcher with logging and progress support. More...
class  PythonTestHelper
struct  ReportSection
 A section in the report (title + HTML content). More...
class  Report
 Simple HTML report builder for MEG/EEG analysis results. More...
class  SelectionIO
 Reader/writer for MNE .sel channel-selection files and Brainstorm .mon montage files. More...

Typedefs

typedef CircularBuffer< int > CircularBuffer_int
typedef CircularBuffer< short > CircularBuffer_short
typedef CircularBuffer< char > CircularBuffer_char
typedef CircularBuffer< double > CircularBuffer_double
typedef CircularBuffer< QPair< int, int > > CircularBuffer_pair_int_int
typedef CircularBuffer< QPair< double, double > > CircularBuffer_pair_double_double
typedef CircularBuffer< Eigen::MatrixXd > CircularBuffer_Matrix_double
typedef CircularBuffer< Eigen::MatrixXf > CircularBuffer_Matrix_float
using fitUser = fitUserRec*
using PythonLineCallback = std::function<void(int channel, const QString& line)>
using PythonProgressCallback = std::function<void(float pct, const QString& msg)>

Enumerations

enum class  StimArtifactMode { Linear , Window }
 Mode for stimulus artifact repair. More...
enum class  KMeansDistance {
  SquaredEuclidean , CityBlock , Cosine , Correlation ,
  Hamming
}
 Distance metric for K-Means clustering. More...
enum class  KMeansStart { Sample , Uniform , Cluster }
 Initialization strategy for K-Means clustering. More...
enum class  KMeansEmptyAction { Error , Drop , Singleton }
 Action to take when a K-Means cluster becomes empty. More...
enum class  PointKind { Fiducial = 0 , Eeg , HeadShape }
 Logical category of a captured point. More...
enum class  FiducialId { LPA = 1 , NAS = 2 , RPA = 3 }
 Identifier for the three cardinal fiducials. More...

Functions

DSPSHARED_EXPORT FIFFLIB::FiffAnnotations annotateMusclZscore (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, double sfreq, const AnnotateMusclParams &params=AnnotateMusclParams())
 Detect muscle artifacts via high-frequency z-score and annotate bad segments.
DSPSHARED_EXPORT FIFFLIB::FiffAnnotations annotateAmplitude (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, double sfreq, const AnnotateAmplitudeParams &params=AnnotateAmplitudeParams())
 Annotate segments where amplitude exceeds thresholds or is too flat.
DSPSHARED_EXPORT QStringList findBadChannelsLof (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, const LofBadChannelParams &params=LofBadChannelParams())
 Detect bad channels using Local Outlier Factor (LOF).
DSPSHARED_EXPORT Eigen::VectorXd computeLofScores (const Eigen::MatrixXd &features, int k)
 Compute LOF scores for a feature matrix.
DSPSHARED_EXPORT BadChannelsMaxwellResult findBadChannelsMaxwell (const Eigen::MatrixXd &matData, const FIFFLIB::FiffInfo &info, const BadChannelsMaxwellParams &params=BadChannelsMaxwellParams())
 Detect bad MEG channels using SSS reconstruction residuals.
DSPSHARED_EXPORT Eigen::MatrixXd computeElectricalDistance (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info)
 Compute electrical distance matrix between EEG channels.
DSPSHARED_EXPORT QList< QPair< int, int > > computeBridgedElectrodes (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, const BridgedElectrodeParams &params=BridgedElectrodeParams())
 Detect bridged EEG electrodes.
DSPSHARED_EXPORT void setEegReference (Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, const QStringList &refChannels=QStringList(), bool projection=false)
 Re-reference EEG channels to average, specific channel(s), or REST.
DSPSHARED_EXPORT void addReferenceChannels (Eigen::MatrixXd &data, FIFFLIB::FiffInfo &info, const QStringList &chNames)
 Add reference channel(s) back as zero-filled rows.
DSPSHARED_EXPORT void setBipolarReference (Eigen::MatrixXd &data, FIFFLIB::FiffInfo &info, const QStringList &anodes, const QStringList &cathodes, bool dropOriginals=true)
 Create bipolar derivations from EEG channels.
DSPSHARED_EXPORT void filterChpi (Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, double sfreq, const QVector< double > &hpiFreqs, const FilterChpiParams &params=FilterChpiParams())
 Remove cHPI excitation signals from MEG data by notch filtering.
DSPSHARED_EXPORT void filterChpi (Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, double sfreq, const FilterChpiParams &params=FilterChpiParams())
 Overload that attempts to extract cHPI frequencies from FiffInfo.
DSPSHARED_EXPORT QList< QPair< int, double > > peakFinder (const Eigen::VectorXd &data, const PeakFinderParams &params=PeakFinderParams())
 Find peaks in a 1D signal.
DSPSHARED_EXPORT Eigen::VectorXd peakProminences (const Eigen::VectorXd &data, const QList< int > &peakIndices)
 Compute prominence of each peak.
DSPSHARED_EXPORT INVLIB::InvSourceEstimate simulateStc (const Eigen::VectorXi &activeVertices, const Eigen::VectorXi &allVertices, const SimulateStcParams &params=SimulateStcParams())
 Create a synthetic source time course.
DSPSHARED_EXPORT INVLIB::InvSourceEstimate simulateStcFromWaveforms (const Eigen::MatrixXd &waveforms, const Eigen::VectorXi &activeVertices, const Eigen::VectorXi &allVertices, float tmin=0.0f, float tstep=0.001f)
 Create a synthetic source time course from custom waveforms.
DSPSHARED_EXPORT FIFFLIB::FiffEvoked simulateEvoked (const MNELIB::MNEForwardSolution &fwd, const INVLIB::InvSourceEstimate &stc, const FIFFLIB::FiffInfo &info, const FIFFLIB::FiffCov &noiseCov, int nave=1, int seed=42)
 Simulate evoked data from a source estimate and forward model.
DSPSHARED_EXPORT FIFFLIB::FiffEvoked simulateEvokedNoiseless (const MNELIB::MNEForwardSolution &fwd, const INVLIB::InvSourceEstimate &stc, const FIFFLIB::FiffInfo &info)
 Simulate evoked data without noise.
DSPSHARED_EXPORT Eigen::MatrixXd makeSpharaProjector (const Eigen::MatrixXd &matBaseFct, const Eigen::VectorXi &vecIndices, int iOperatorDim, int iNBaseFct, int iSkip=0)
DSPSHARED_EXPORT void fixStimArtifact (Eigen::MatrixXd &data, const Eigen::MatrixXi &events, double sfreq, int eventId=-1, double tmin=0.0, double tmax=0.01, StimArtifactMode mode=StimArtifactMode::Linear)
 Repair stimulus artifacts by interpolating or zeroing data around events.
constexpr auto timeNowNow ()
constexpr auto dateToday ()
constexpr auto dateTimeNow ()
constexpr auto gitHash ()
constexpr auto gitHashLong ()
const char * buildDateTime ()
const char * buildHash ()
const char * buildHashLong ()

Detailed Description

Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).

Typedef Documentation

◆ CircularBuffer_char

Defines CircularBuffer of char type.

Definition at line 296 of file circularbuffer.h.

◆ CircularBuffer_double

Defines CircularBuffer of double type.

Definition at line 297 of file circularbuffer.h.

◆ CircularBuffer_int

Defines CircularBuffer of integer type.

Definition at line 294 of file circularbuffer.h.

◆ CircularBuffer_Matrix_double

Defines CircularBuffer of Eigen::MatrixXd type.

Definition at line 300 of file circularbuffer.h.

◆ CircularBuffer_Matrix_float

Defines CircularBuffer of Eigen::MatrixXf type.

Definition at line 301 of file circularbuffer.h.

◆ CircularBuffer_pair_double_double

Defines CircularBuffer of double Pair type.

Definition at line 299 of file circularbuffer.h.

◆ CircularBuffer_pair_int_int

Defines CircularBuffer of integer Pair type.

Definition at line 298 of file circularbuffer.h.

◆ CircularBuffer_short

Defines CircularBuffer of short type.

Definition at line 295 of file circularbuffer.h.

◆ fitUser

Definition at line 77 of file layoutmaker.h.

◆ PythonLineCallback

using UTILSLIB::PythonLineCallback = std::function<void(int channel, const QString& line)>

Line-level callback signature.

Parameters
channel0 = stdout, 1 = stderr.
lineThe text line (without trailing newline).

Definition at line 96 of file python_runner.h.

◆ PythonProgressCallback

using UTILSLIB::PythonProgressCallback = std::function<void(float pct, const QString& msg)>

Progress callback signature.

Parameters
pctProgress percentage 0.0 – 100.0.
msgOptional message accompanying the progress update.

Definition at line 105 of file python_runner.h.

Enumeration Type Documentation

◆ FiducialId

enum class UTILSLIB::FiducialId
strong

Identifier for the three cardinal fiducials.

Numerically aligned with the FIFF ident field used for cardinal points (1 = LPA, 2 = NAS, 3 = RPA).

Enumerator
LPA 
NAS 
RPA 

Definition at line 64 of file acquired_points.h.

◆ KMeansDistance

enum class UTILSLIB::KMeansDistance
strong

Distance metric for K-Means clustering.

Enumerator
SquaredEuclidean 

Squared Euclidean distance (default).

CityBlock 

Manhattan / city-block distance.

Cosine 

Cosine distance.

Correlation 

Correlation distance.

Hamming 

Hamming distance (binary data only).

Definition at line 76 of file kmeans.h.

◆ KMeansEmptyAction

enum class UTILSLIB::KMeansEmptyAction
strong

Action to take when a K-Means cluster becomes empty.

Enumerator
Error 

Treat as an error (default).

Drop 

Drop the empty cluster.

Singleton 

Replace with the farthest point from its centroid.

Definition at line 94 of file kmeans.h.

◆ KMeansStart

enum class UTILSLIB::KMeansStart
strong

Initialization strategy for K-Means clustering.

Enumerator
Sample 

Random sample of data points (default).

Uniform 

Uniform random within data range.

Cluster 

Sub-sample then cluster.

Definition at line 86 of file kmeans.h.

◆ PointKind

enum class UTILSLIB::PointKind
strong

Logical category of a captured point.

Maps onto the FIFF point-kind constants on export (FIFFV_POINT_CARDINAL / FIFFV_POINT_EEG / FIFFV_POINT_EXTRA).

Enumerator
Fiducial 

Anatomical landmark (NAS / LPA / RPA).

Eeg 

Named EEG electrode contact.

HeadShape 

Free head-shape point (continuous mode).

Definition at line 51 of file acquired_points.h.

◆ StimArtifactMode

enum class UTILSLIB::StimArtifactMode
strong

Mode for stimulus artifact repair.

Enumerator
Linear 

Linear interpolation across the artifact window.

Window 

Zero-pad (set to zero) the artifact window.

Definition at line 42 of file stim_artifact.h.

Function Documentation

◆ addReferenceChannels()

DSPSHARED_EXPORT void UTILSLIB::addReferenceChannels ( Eigen::MatrixXd & data,
FIFFLIB::FiffInfo & info,
const QStringList & chNames )

Add reference channel(s) back as zero-filled rows.

When EEG data was recorded with a physical reference electrode, that channel is implicit (all zeros after re-referencing). This function adds it back explicitly so it can participate in average re-referencing or source localization.

Parameters
[in,out]dataData matrix. Rows are added at the end.
[in,out]infoMeasurement info. New EEG channels are appended.
[in]chNamesNames of the reference channel(s) to add.

◆ annotateAmplitude()

DSPSHARED_EXPORT FIFFLIB::FiffAnnotations UTILSLIB::annotateAmplitude ( const Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
double sfreq,
const AnnotateAmplitudeParams & params = AnnotateAmplitudeParams() )

Annotate segments where amplitude exceeds thresholds or is too flat.

Scans each channel independently:

  • If any sample exceeds dPeakMax or falls below dPeakMin, that time point is annotated.
  • If peak-to-peak amplitude in a sliding window < dFlatMin, the window is annotated as "BAD_flat".
Parameters
[in]dataRaw data matrix (n_channels × n_times).
[in]infoMeasurement info (for channel names).
[in]sfreqSampling frequency in Hz.
[in]paramsDetection parameters.
Returns
FiffAnnotations with bad entries.

◆ annotateMusclZscore()

DSPSHARED_EXPORT FIFFLIB::FiffAnnotations UTILSLIB::annotateMusclZscore ( const Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
double sfreq,
const AnnotateMusclParams & params = AnnotateMusclParams() )

Detect muscle artifacts via high-frequency z-score and annotate bad segments.

Algorithm:

  1. Bandpass filter data in muscle frequency band (default 110–140 Hz).
  2. Compute Hilbert envelope (approximated via absolute value of filtered signal).
  3. Compute z-score of the envelope across time for each MEG channel.
  4. Average z-score across channels.
  5. Threshold: mark time points where average z-score > threshold.
  6. Merge adjacent annotations and apply minimum duration.
Parameters
[in]dataRaw data matrix (n_channels × n_times).
[in]infoMeasurement info.
[in]sfreqSampling frequency in Hz.
[in]paramsDetection parameters.
Returns
FiffAnnotations with "BAD_muscle" entries.

◆ buildDateTime()

const char * UTILSLIB::buildDateTime ( )

Returns build date and time.

Definition at line 32 of file utils_global.cpp.

◆ buildHash()

const char * UTILSLIB::buildHash ( )

Returns abbreviated build git hash.

Definition at line 36 of file utils_global.cpp.

◆ buildHashLong()

const char * UTILSLIB::buildHashLong ( )

Returns full build git hash.

Definition at line 40 of file utils_global.cpp.

◆ computeBridgedElectrodes()

DSPSHARED_EXPORT QList< QPair< int, int > > UTILSLIB::computeBridgedElectrodes ( const Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
const BridgedElectrodeParams & params = BridgedElectrodeParams() )

Detect bridged EEG electrodes.

Finds pairs of EEG channels whose electrical distance falls below the threshold, indicating a physical or gel bridge.

Parameters
[in]dataData matrix (n_channels x n_times).
[in]infoFiffInfo with channel types.
[in]paramsDetection parameters.
Returns
List of bridged electrode pairs as (channel_index_1, channel_index_2) using indices into info.chs.

◆ computeElectricalDistance()

DSPSHARED_EXPORT Eigen::MatrixXd UTILSLIB::computeElectricalDistance ( const Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info )

Compute electrical distance matrix between EEG channels.

Electrical distance is defined as the standard deviation of the difference signal between two channels, normalised by the geometric mean of their individual standard deviations. Bridged electrodes will have near-zero electrical distance.

Parameters
[in]dataData matrix (n_channels x n_times).
[in]infoFiffInfo with channel types.
Returns
Electrical distance matrix (n_eeg x n_eeg), with EEG channel indices stored in the order they appear in info.

◆ computeLofScores()

DSPSHARED_EXPORT Eigen::VectorXd UTILSLIB::computeLofScores ( const Eigen::MatrixXd & features,
int k )

Compute LOF scores for a feature matrix.

Pure algorithmic LOF implementation operating on feature vectors.

Parameters
[in]featuresFeature matrix (n_points x n_features).
[in]kNumber of neighbours.
Returns
LOF score for each point (n_points x 1). Values > 1 indicate outliers.

◆ dateTimeNow()

auto UTILSLIB::dateTimeNow ( )
constexpr

Returns build date and time (time preprocessor was run). Must be called in compiled function to return correctly.

Definition at line 61 of file buildinfo.h.

◆ dateToday()

auto UTILSLIB::dateToday ( )
constexpr

Returns build date (time preprocessor was run). Must be called in compiled function to return correctly.

Definition at line 51 of file buildinfo.h.

◆ filterChpi() [1/2]

DSPSHARED_EXPORT void UTILSLIB::filterChpi ( Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
double sfreq,
const FilterChpiParams & params = FilterChpiParams() )

Overload that attempts to extract cHPI frequencies from FiffInfo.

Tries to read HPI coil frequencies from the FiffInfo metadata. Because the FiffInfo HPI frequency storage varies across file versions, this overload may not always succeed. If frequencies cannot be determined, a warning is logged and no filtering is applied. In that case, use the explicit-frequency overload instead.

Parameters
[in,out]dataData matrix (n_channels x n_times). Modified in-place.
[in]infoMeasurement info.
[in]sfreqSampling frequency in Hz.
[in]paramsFiltering parameters.

◆ filterChpi() [2/2]

DSPSHARED_EXPORT void UTILSLIB::filterChpi ( Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
double sfreq,
const QVector< double > & hpiFreqs,
const FilterChpiParams & params = FilterChpiParams() )

Remove cHPI excitation signals from MEG data by notch filtering.

Applies a zero-phase Butterworth band-stop (notch) filter at each specified cHPI frequency. Only MEG channels are filtered by default.

Parameters
[in,out]dataData matrix (n_channels x n_times). Modified in-place.
[in]infoMeasurement info (used to identify MEG channels if bMegOnly is true).
[in]sfreqSampling frequency in Hz.
[in]hpiFreqsList of cHPI excitation frequencies in Hz. Typical Elekta/MEGIN system: {83, 143, 203, 263, 293}.
[in]paramsFiltering parameters.

◆ findBadChannelsLof()

DSPSHARED_EXPORT QStringList UTILSLIB::findBadChannelsLof ( const Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
const LofBadChannelParams & params = LofBadChannelParams() )

Detect bad channels using Local Outlier Factor (LOF).

Computes features for each channel (standard deviation, kurtosis, max absolute amplitude) and applies the LOF algorithm to identify outlier channels. LOF compares the local density of a point's neighbourhood to the densities of its neighbours.

Parameters
[in]dataData matrix (n_channels x n_times).
[in]infoFiffInfo with channel types.
[in]paramsLOF parameters.
Returns
List of bad channel names.

◆ findBadChannelsMaxwell()

DSPSHARED_EXPORT BadChannelsMaxwellResult UTILSLIB::findBadChannelsMaxwell ( const Eigen::MatrixXd & matData,
const FIFFLIB::FiffInfo & info,
const BadChannelsMaxwellParams & params = BadChannelsMaxwellParams() )

Detect bad MEG channels using SSS reconstruction residuals.

Computes the SSS reconstruction of the data, then flags channels whose residual (difference between original and reconstructed) is anomalously large relative to the population of channels.

Parameters
[in]matDataMEG data (n_channels x n_times). Should include all channels (MEG and non-MEG).
[in]infoMeasurement info with channel positions.
[in]paramsDetection parameters.
Returns
Detection result with bad channel names, indices, residuals, z-scores.

◆ fixStimArtifact()

DSPSHARED_EXPORT void UTILSLIB::fixStimArtifact ( Eigen::MatrixXd & data,
const Eigen::MatrixXi & events,
double sfreq,
int eventId = -1,
double tmin = 0.0,
double tmax = 0.01,
StimArtifactMode mode = StimArtifactMode::Linear )

Repair stimulus artifacts by interpolating or zeroing data around events.

For each event sample, the data in the window [event + tmin_samples, event + tmax_samples] is either linearly interpolated from the boundary values or set to zero.

Parameters
[in,out]dataData matrix (n_channels x n_times). Modified in-place.
[in]eventsEvent matrix (Nx3: [sample, before, after]). Only the sample column (col 0) is used to locate artifact windows.
[in]sfreqSampling frequency in Hz.
[in]eventIdIf >= 0, only process events where column 2 (after) matches this value. If < 0, process all events. Default: -1.
[in]tminStart of artifact window in seconds relative to event (negative = before event). Default: 0.0 (event onset).
[in]tmaxEnd of artifact window in seconds relative to event. Default: 0.01 (10 ms after event).
[in]modeRepair mode (Linear interpolation or zero-padding). Default: StimArtifactMode::Linear.

◆ gitHash()

auto UTILSLIB::gitHash ( )
constexpr

Returns short version of the hash of the current git commit

Definition at line 70 of file buildinfo.h.

◆ gitHashLong()

auto UTILSLIB::gitHashLong ( )
constexpr

Returns entire hash of the current git commit

Definition at line 83 of file buildinfo.h.

◆ makeSpharaProjector()

DSPSHARED_EXPORT Eigen::MatrixXd UTILSLIB::makeSpharaProjector ( const Eigen::MatrixXd & matBaseFct,
const Eigen::VectorXi & vecIndices,
int iOperatorDim,
int iNBaseFct,
int iSkip = 0 )

Constructs a SPHARA operator.

Parameters
[in]matBaseFctThe SPHARA basis functions.
[in]vecIndicesThe indices of the positions in the final oeprator which are to be filled with the basis functions weights (i.e. these indices could respond to the indices of gradioemteres in a VectorView system).
[in]iOperatorDimThe dimensions of the final SPHARA operator. Make sure that these correspond to the dimensions of the data matrix you want tol multiply with the SPHARA operator.
[in]iNBaseFctThe number of SPHARA basis functions to take.
[in]iSkipThe value to skip when reading the vecIndices variabel. I.e. use this when dealing with VectorView triplets, which include two gradiometers.
Returns
Returns the final SPHARA operator with dimensions (iOperatorDim,iOperatorDim).

◆ peakFinder()

DSPSHARED_EXPORT QList< QPair< int, double > > UTILSLIB::peakFinder ( const Eigen::VectorXd & data,
const PeakFinderParams & params = PeakFinderParams() )

Find peaks in a 1D signal.

A peak is a sample that is strictly greater than both its neighbours. Additional filtering by height, distance, and prominence can be applied.

Parameters
[in]data1D signal (row vector or VectorXd).
[in]paramsPeak detection parameters.
Returns
List of (peak_index, peak_value) pairs, sorted by index.

◆ peakProminences()

DSPSHARED_EXPORT Eigen::VectorXd UTILSLIB::peakProminences ( const Eigen::VectorXd & data,
const QList< int > & peakIndices )

Compute prominence of each peak.

Prominence is the vertical distance from a peak to the highest valley on either side before reaching a higher peak.

Parameters
[in]data1D signal.
[in]peakIndicesIndices of detected peaks.
Returns
Prominence value for each peak.

◆ setBipolarReference()

DSPSHARED_EXPORT void UTILSLIB::setBipolarReference ( Eigen::MatrixXd & data,
FIFFLIB::FiffInfo & info,
const QStringList & anodes,
const QStringList & cathodes,
bool dropOriginals = true )

Create bipolar derivations from EEG channels.

Creates new bipolar channels by subtracting cathode from anode for each pair. The original channels are replaced with the bipolar derivations.

Parameters
[in,out]dataData matrix. Replaced with bipolar derivation rows.
[in,out]infoMeasurement info. Updated with new bipolar channel info.
[in]anodesList of anode channel names.
[in]cathodesList of cathode channel names (same length as anodes).
[in]dropOriginalsIf true, remove the original anode/cathode channels from the output (default: true).

◆ setEegReference()

DSPSHARED_EXPORT void UTILSLIB::setEegReference ( Eigen::MatrixXd & data,
const FIFFLIB::FiffInfo & info,
const QStringList & refChannels = QStringList(),
bool projection = false )

Re-reference EEG channels to average, specific channel(s), or REST.

Only modifies rows corresponding to EEG channels (kind == FIFFV_EEG_CH). Non-EEG channels are left untouched.

Parameters
[in,out]dataData matrix (n_channels x n_times). Modified in-place.
[in]infoMeasurement info (used to identify EEG channels).
[in]refChannelsReference channel name(s).
  • Empty or "average" -> average reference (mean of all good EEG channels).
  • Single channel name -> re-reference to that channel.
  • Multiple channel names -> re-reference to mean of those channels.
[in]projectionIf true, add an SSP projector for average reference instead of modifying data. (default: false — modify data directly)

◆ simulateEvoked()

FiffEvoked UTILSLIB::simulateEvoked ( const MNELIB::MNEForwardSolution & fwd,
const INVLIB::InvSourceEstimate & stc,
const FIFFLIB::FiffInfo & info,
const FIFFLIB::FiffCov & noiseCov,
int nave = 1,
int seed = 42 )

Simulate evoked data from a source estimate and forward model.

Projects the source estimate through the forward model to generate sensor-space data, optionally adding noise from a noise covariance.

Equivalent to MNE-Python's mne.simulation.simulate_evoked().

Parameters
[in]fwdForward solution (gain matrix).
[in]stcSource time course.
[in]infoMeasurement info (for output channel info).
[in]noiseCovNoise covariance for additive noise (optional).
[in]naveNumber of averages (noise scaled by 1/sqrt(nave)).
[in]seedRandom seed for noise generation.
Returns
Simulated evoked data.

Definition at line 146 of file simulate.cpp.

◆ simulateEvokedNoiseless()

FiffEvoked UTILSLIB::simulateEvokedNoiseless ( const MNELIB::MNEForwardSolution & fwd,
const INVLIB::InvSourceEstimate & stc,
const FIFFLIB::FiffInfo & info )

Simulate evoked data without noise.

Projects source estimate through forward model (no noise added).

Parameters
[in]fwdForward solution.
[in]stcSource time course.
[in]infoMeasurement info.
Returns
Simulated noiseless evoked data.

Definition at line 197 of file simulate.cpp.

◆ simulateStc()

DSPSHARED_EXPORT INVLIB::InvSourceEstimate UTILSLIB::simulateStc ( const Eigen::VectorXi & activeVertices,
const Eigen::VectorXi & allVertices,
const SimulateStcParams & params = SimulateStcParams() )

Create a synthetic source time course.

Generates an InvSourceEstimate with Gaussian-envelope waveforms at specified source vertices. Each active source has a Gaussian temporal profile centered at different times.

Parameters
[in]activeVerticesVertex indices for active sources.
[in]allVerticesFull vertex index vector for the source space.
[in]paramsSimulation parameters (sfreq, tmin, duration).
Returns
Simulated source estimate.

◆ simulateStcFromWaveforms()

DSPSHARED_EXPORT INVLIB::InvSourceEstimate UTILSLIB::simulateStcFromWaveforms ( const Eigen::MatrixXd & waveforms,
const Eigen::VectorXi & activeVertices,
const Eigen::VectorXi & allVertices,
float tmin = 0.0f,
float tstep = 0.001f )

Create a synthetic source time course from custom waveforms.

Parameters
[in]waveformsWaveform data (n_active_sources x n_times).
[in]activeVerticesVertex indices for the active sources.
[in]allVerticesFull vertex index vector.
[in]tminStart time (s).
[in]tstepTime step (s).
Returns
Simulated source estimate with zeros at inactive vertices.

◆ timeNowNow()

auto UTILSLIB::timeNowNow ( )
constexpr

Returns build time (time preprocessor was run). Must be called in compiled function to return correctly.

Definition at line 42 of file buildinfo.h.