macro_eeg_model.simulation.eeg_analyzer#

Classes#

EEGAnalyzer

The EEGAnalyzer class is responsible computing the power spectrum of EEG data.

Module Contents#

class macro_eeg_model.simulation.eeg_analyzer.EEGAnalyzer[source]#

The EEGAnalyzer class is responsible computing the power spectrum of EEG data.

static calculate_power(data, sample_rate)[source]#

Applies the Fast Fourier Transform (FFT) to the EEG data to calculate the power spectrum. It returns the frequencies and the average power spectrum across epochs/samples per second.

Parameters:
  • data (numpy.ndarray) – The EEG data to be analyzed (a 3D array with dimensions (time, nodes, epochs)).

  • sample_rate (int) – The sample rate of the EEG data in Hz.

Returns:

A tuple containing:

  • frequencies (numpy.ndarray): The array of frequencies corresponding to the power spectrum.

  • power (numpy.ndarray): The calculated power spectrum for each frequency and node.

Return type:

tuple

Raises:

ValueError – If the user-defined frequencies are outside the valid range determined by the Nyquist frequency.

static plot_power(frequencies, power, nodes, plots_dir)[source]#

Visualizes the power spectrum of the EEG data (for each node/channel) as a line plot.

Parameters:
  • frequencies (numpy.ndarray) – The array of frequencies corresponding to the power spectrum.

  • power (numpy.ndarray) – The calculated power spectrum for each frequency and node.

  • nodes (list[str]) – The list of node/channel names corresponding to the data.

  • plots_dir (pathlib.Path) – The directory where the plots are saved.

Raises:

AssertionError – If the plots directory does not exist.