Applying a Formula

Initialize NeuroAnalyzer
using NeuroAnalyzer
eeg = load("files/eeg.hdf")

In NeuroAnalyzer, you can apply any formula, operation, or function to EEG channels using the apply() function. This is useful for:

  • Computing channel averages or sums,
  • Applying custom functions (e.g., filtering, normalization),
  • Calculating power, phase, or connectivity metrics,
  • Preprocessing or transforming EEG data.

The apply() function applies a formula to specified EEG channels. The formula is written as a string and can include:

  • Built-in functions (e.g., mean, sum, max, min),
  • Custom operations (e.g., filtering, normalization),
  • Mathematical expressions (e.g., (obj .- mean(obj)) ./ std(obj)).

Key Points

  • The formula is applied channel-wise (e.g., compute the mean across channels).
  • The result is a new channel or transformed data.

Examples

Computing the average of Fp1 and Fp2 to create a virtual frontal channel:

result = apply(eeg,
               f = "mean(obj, dims=1)",
               ch = ["Fp1", "Fp2"])

eeg: The EEG dataset (as an OBJ object).
f: The formula to apply (as a string).
obj: The obligatory variable name that holds the NEURO object.
ch: List of channels to apply the formula to.

Computing the global average of all channels:

result = apply(eeg,
               f = "mean(obj, dims=1)",
               ch = "all")

Finding the maximum value across central channels (C3, Cz, C4):

result = apply(eeg,
               f = "maximum(obj, dims=1)",
               ch = ["C3", "Cz", "C4"])