Numerical Utilities#
EEGPrep includes the small numerical building blocks used by its signal and component workflows. They are standalone NumPy/SciPy functions and do not need MATLAB or an EEGLAB checkout.
Indexing and compatibility#
Array indices are zero-based. This applies to peak frames returned by
abspeak, assignments returned by hungarian and matcorr, permutation
vectors, matsel selections, and shuffle axes. Kernel peak coordinates
remain one-based because they describe the sampled coordinate system in the
EEGLAB formulas rather than Python array indices.
covary deliberately retains EEGLAB’s grand-mean centering before computing
column second moments; use NumPy’s variance functions when ordinary per-column
centering is intended. means uses the number of finite observations when
computing standard errors and leaves single-observation sample variances
undefined. This fixes the historical EEGLAB helper’s underestimated standard
errors when a group contains missing values. nan_std uses a centered
calculation so large constant offsets do not erase small physiological
variation through catastrophic cancellation.
quantile retains the midpoint empirical-probability rule used by the
current EEGLAB tests. Integer counts, axes, permutations, and selections must
be exact integers; fractional values are rejected instead of silently selecting
the wrong samples. Functions that have a meaningful complex-valued contract,
including PCA, interpolation, peak phase, and NaN-aware means, preserve complex
data. Real-only functions reject complex input instead of discarding its
imaginary component.
vectdata supports linear, cubic, and nearest-neighbor interpolation.
MATLAB’s legacy biharmonic griddata
v4 mode has no well-defined one-dimensional SciPy equivalent and raises
NotImplementedError rather than substituting a different interpolator.
Peaks, summaries, and transforms#
|
Return absolute peaks, zero-based frames, and signs for each epoch. |
|
Average-reference channel-major data and optionally transform ICA weights. |
|
Return EEGLAB's globally centered, unbiased column second moment. |
|
Return the minimum and maximum of a nonempty numeric array. |
|
Compute pairwise Euclidean distances between rows of point arrays. |
|
Return per-group means, standard errors, variances, and group IDs. |
|
Return means while ignoring NaNs along the selected dimension. |
|
Return sample standard deviations while ignoring NaNs. |
|
Return quantiles using MATLAB's midpoint empirical-probability rule. |
|
Interpolate along the final data axis and optionally smooth first. |
Kernels#
|
Return an EEGLAB-compatible Gaussian window with a unit peak. |
|
Return an EEGLAB-compatible two-dimensional Gaussian kernel. |
|
Return an EEGLAB-compatible three-dimensional Gaussian kernel. |
|
Return a sinusoidal carrier under an anisotropic Gaussian envelope. |
|
Return EEGLAB's sampled two-dimensional Laplacian kernel. |
Matching and component projections#
|
Return a zero-based column-to-row assignment and its total cost. |
|
Match rows after aligning map columns by common channel labels. |
|
Match rows of two matrices by absolute cosine correlation. |
|
Reorder and sign-correct rows of |
|
Compress channel-major data into its leading principal components. |
|
Expand component projections back into channel space. |
|
Return the inverse of a zero-based permutation vector. |
|
Return finite unique values, counts, and zero-based first indices. |
Low-level compatibility helpers#
|
Convert a rectangular nested sequence of numeric scalars to an array. |
|
Permute and scale rows so the output diagonal is one. |
|
Return |
|
Select zero-based channels, within-epoch frames, and epochs. |
|
Convert a NumPy-compatible matrix to nested Python scalar lists. |
|
Return MATLAB filenames below |
|
Shuffle one zero-based axis and return permutation and inverse indices. |