# Hybrid Brain Waves

Visual Spatial Covert Attention is a cognitive effect that is produced when a person is looking into whatever it has in front of him, and some event appears on the visual field.  If the person decides to pay attention to the event without gazing at it,  a shift is produced in the  alpha band of the EEG signals (10 Hz) towards those electrodes located on the same side of the event location.

Visual Spatial Covert Attention effect

Events $(q) \$  are triggered one per second according to the timer $(\tau) \$  on each side of the screen, one after the other, being -1 for left, and 1 for right.  For each event, the brain signals will shift towards each side $(u) \$ and if a threshold is reached, the output of the system $(y) \$ will change to the side where the brain signals drifted.

EEG Channels

Each signal from each channel is band-passed to 8-12 hz and the power spectral density of all of them will be  vectorized and summed up (according to their relative position, as suggested by the the figure)

We are considering that the person always pays COVERT attention to the event, and the signal will drift to the same side where each event was triggered.

The model is: $\mathcal{H}=(C,f,D,g) \$

$x =\left[ \begin{array}{c} u\\ y\\ \tau\\ q\end{array} \right]$

$f(x) =\left[ \begin{array}{c} p(x) \\ 0\\ 1\\ 0\\ \end{array} \right]$

For this model, we will consider the brainwaves to be linear drifts to each direction.

$p(x) =\left[ \begin{array}{ll} 1 & q = 1 \\ -1 & q = -1 \\ \end{array} \right]$

$g(x) =\left[ \begin{array}{c} 0 \\ s(x) \\ 0\\ -q\\ \end{array} \right]$

$s(x) =\left[ \begin{array}{ll} 1 & u \ge h_{lower}\\ -1 & u \leq h_{upper} \\ \end{array} \right]$

The sets being:

$C:=\{ x \in \mathbf{R} \times \mathbf{R} \times [0,1] \times {0,1} \}$

$D:=\{ x \in \mathbf{R} \times \mathbf{R} \times [0,1] \times {0,1} : \tau = 1 \}$ $\cup$ $\{ x \in \mathbf{R} \times \mathbf{R} \times [0,1] \times {0,1}: y=-1, u \ge h_{upper} \}$ $\cup$ $\{ x \in \mathbf{R} \times \mathbf{R} \times [0,1] \times {0,1}: y=1, u \le h_{lower} \}$

Ok, let’s see the results on the simulation:

System’s Dynamics Simulation

It can be seen how the output of the system, adapts accordingly to the direction where the brainwaves drifted (left, right) based on the direction of the previous stimulation event.   The timer is only triggered the first time because the brainwaves are moving towards the stimulus’ direction (left) and the output is already there.

The output of the system is driven by the drift of the brainwaves.

If we plot $u$ against $y$  we see a sheared hysteresis characteristic plot.  The brainwaves affects the output of the system after the jump has occurred, so both signals end up being shifted by a lag.

In red, jumps are plotted from $D$  regions to their new positions after the jump.

Simulation Code:

function inC = C(x)
% check if x is in C
tau = x(3);
if  (tau >= 0) && (tau <= 1)
inC = 1;
else
inC = 0;
end
end

function inD = D(x)
% check if x is in D
global h_upper;
global h_lower;
tau = x(3);
u = x(1);
y = x(2);
if  (tau >= 1) || (y == -1 && u>=h_upper) || (y==1 && u<=h_lower)
inD = 1;
else
inD = 0;
end

end

function xdot = f(x)
% flow map

q=x(4);
y=x(2);

if (q==1)
udot = 1;
else
udot = -1;
end

xdot = [ udot; 0; 1; 0];

end


function xplus = g(x)
% jump map

global h_upper;
global h_lower;
u = x(1);
q = x(4);

% on jumps we are always over or bellow the bound.
if (u>=h_upper)
ydot = 1;
elseif (u<=h_lower)
ydot = -1;
else
ydot = x(2);
end
xplus = [0; ydot; 0; -q];

end



Finally, the run.m code


function hybridsystem()

global h_upper;

global h_lower;

h_upper = 0.5;

h_lower = -0.5;

% define initial conditions

x0 = [0; -1; 0; -1]

% simulation horizon

TSPAN = [0 10];

JSPAN = [0 20];

% Rule for OVERLAPS, what to choose when C and D collide?

% rule = 1 -> priority for jumps

% rule = 2 -> priority for flows,

% rule = 3 -> random priority

rule=1;

options = odeset('RelTol', 1e-6,'MaxStep', .1);

[t j x] = HyEQsolver( @f,@g,@C,@D,x0, TSPAN, JSPAN, rule, options);

% t continuous time

% j  discrete time

% x state variable for each (j,t)

figure(1);

clf

subplot(4,1,1);plotflows(t,j,x(:,1));

grid on;

ylabel('u');

&nbsp;

subplot(4,1,2);plotflows(t,j,x(:,2));

grid on;

axis([0 10 -1.5 1.5]);

ylabel('y');

&nbsp;

subplot(4,1,3);plotflows(t,j,x(:,3));

grid on;

ylabel('tau');

&nbsp;

subplot(4,1,4);plotflows(t,j,x(:,4));

grid on;

axis([0 10 -1.5 1.5]);

ylabel('q');

&nbsp;

figure(2);

plot(x(:,1),x(:,2),'-');

grid on;

ylabel('y: output');

xlabel('u: brain waves');

axis([-2 2 -2 2]);