To model neural field dynamics, brain oscillations,
and their perturbations in the context of neurological biomarkers, we employ a
multi-faceted approach combining neural field equations, stochastic
differential equations (SDEs), and signal processing techniques.
Each component contributes uniquely to understanding and mapping
spatial-temporal brain activity, enhancing the accuracy of biomarker detection.
2.9. Computational Methods
Python code that runs the simulation:
python
Copiar
código
import
numpy as np
import
matplotlib.pyplot as plt
#
Parameters
L
= 100 # Length of the neural field (1D for simplicity)
T
= 100 # Time steps for the simulation
dx
= 1 # Spatial resolution
dt
= 0.1 # Time step
sigma
= 5 # Width of connectivity function
alpha
= 1 # Scaling factor for connectivity
noise_amplitude
= 0.05 # Amplitude of noise
electrode_positions
= [20, 50, 80] # Positions of electrodes for EEG measurement
#
Initialization
u
= np.zeros((L, T)) # Neural activity over space and time
I
= np.zeros(L) # External input, can be changed for stimulus
I[40:60]
= 1 # External input at specific locations
np.random.seed(42)
# Seed for reproducibility
#
Define the connectivity function (Gaussian)
def
connectivity(x, y, sigma, alpha):
return alpha * np.exp(-(x - y)**2 / (2 * sigma**2))
# Initialize connectivity matrix
W = np.array([[connectivity(x, y, sigma, alpha) for y in range(L)] for x in range(L)])
# Simulation loop
for t in range(1, T):
# Update neural activity with neural field dynamics and stochastic noise
du_dt = -u[:, t-1] + W @ np.tanh(u[:, t-1]) + I + noise_amplitude * np.random.randn(L)
u[:, t] = u[:, t-1] + du_dt * dt
# Calculate EEG signals at electrode positions using a dipole approximation
def calculate_eeg(u, positions):
eeg_signals = []
for pos in positions:
eeg_signal = np.sum(u[pos - 5:pos + 5], axis=0) # Summing local activity around each electrode
eeg_signals.append(eeg_signal)
return np.array(eeg_signals)
eeg_signals = calculate_eeg(u, electrode_positions)
# Plot neural field activity over time
plt.figure(figsize=(10, 6))
plt.imshow(u, aspect='auto', cmap='viridis', extent=[0, T*dt, 0, L])
plt.colorbar(label='Neural Activity')
plt.xlabel('Time')
plt.ylabel('Position')
plt.title('Neural Field Activity Over Time')
plt.show()
# Plot EEG signals at each electrode position
plt.figure(figsize=(10, 6))
for i, signal in enumerate(eeg_signals):
plt.plot(np.arange(T) * dt, signal, label=f'Electrode at position {electrode_positions[i]}')
plt.xlabel('Time')
plt.ylabel('EEG Signal Amplitude')
plt.legend()
plt.title('Simulated EEG Signals at Electrode Positions')
plt.show()
# Power Spectral Density (PSD) of EEG signals
plt.figure(figsize=(10, 6))
for i, signal in enumerate(eeg_signals):
psd = np.abs(np.fft.fft(signal))**2
freqs = np.fft.fftfreq(T, dt)
plt.plot(freqs[:T//2], psd[:T//2], label=f'Electrode at position {electrode_positions[i]}')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Power')
plt.legend()
plt.title('Power Spectral Density (PSD) of EEG Signals')
plt.show()
Explanation of Code
-
Neural Field Dynamics:
- o
A Gaussian connectivity function models localized neural interactions, promoting nearby excitation and distant inhibition.
- o
External input III is added at specific locations to simulate stimulus.
- o
Neural field dynamics are updated iteratively, including a tanh nonlinearity to simulate neuron firing and Gaussian noise to model stochastic effects.
-
EEG Signal Calculation:
- o
EEG signals are approximated by summing local neural activity around specific electrode positions, capturing nearby electric potentials in the field.
-
Visualization:
- o
Neural Field Activity Over Time: A heatmap showing the spatial-temporal evolution of neural activity.
- o
Simulated EEG Signals: EEG signals at each electrode position over time.
- o
Power Spectral Density (PSD): Frequency-domain representation of EEG signals, showing power distribution across different frequencies.