Brain State in a Box (BSB & gBSB)
by David Turer, Roberta Borkowski, & Andy Byerly


PRELIMINARY MATLAB FUNCTIONS

The following function, abcd(L), produces a gray "checkerboard" plot of the given n1-by-n2 matrix L. Unlike the PCOLOR function, ABCD uses the last row and column of the matrix L. This function was last updated on March 31, 2001 by S. H. Żak.

MATLAB FUNCTION
You may download the Matlab code here.

function abcd(L)
% ABCD produces a gray "checkerboard" plot of the given n1-by-n2 matrix L.
% Unlike the PCOLOR function, ABCD uses the last row and column of
% the matrix L.
% last updated on March 31, 2001 by S. H. Żak
n1=size(L,1);
n2=size(L,2);
u=ones(n1,1);
v=ones(1,n2+1);
La=[L u;v];
pcolor(La)
colormap(gray)
axis('ij')
axis('square')
axis off

The following Matlab script creates the four equilibrium solutions, which are also the four characters that the (g)BSB algorithm attempts to identify. The following script also displays the four characters: "A", "B", "C", amp; "D".

MATLAB SCRIPT
A1=[1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 -1;-1 1 1 1 -1;-1 1 1 1 -1];
B1=[-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1];
C1=[-1 -1 -1 -1 -1;-1 1 1 1 1;-1 1 1 1 1;-1 1 1 1 1;-1 -1 -1 -1 -1];
D1=[-1 -1 -1 1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 -1 -1 1 1];

% Display equilibrium characters
hold on;
figure(1);
subplot(221);
abcd(A1);
title('Stored A');
subplot(222);
abcd(B1);
title('Stored B');
subplot(223);
abcd(C1);
title('Stored C');
subplot(224);
abcd(D1);
title('Stored D');


(The above picture is the output for the matlab script file. You may click on the picture to see a larger version of it.)

GENERAL BRAIN STATE IN A BOX ALGORITHM (gBSB)

The following gBSB Algorithm identifies the four characters shown above from a randomly integer valued 5 X 5 matrix.

MATLAB CODE
You may download the Matlab code here.

clc clear close all % Initialize equilibrium characters A1=[1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 -1;-1 1 1 1 -1;-1 1 1 1 -1]; B1=[-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1]; C1=[-1 -1 -1 -1 -1;-1 1 1 1 1;-1 1 1 1 1;-1 1 1 1 1;-1 -1 -1 -1 -1]; D1=[-1 -1 -1 1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 -1 -1 1 1]; % Initialize matrices to be used in calculations V = [A1(:) B1(:) C1(:) D1(:)]; b = rand*V(:,1)+rand*V(:,2)+rand*V(:,3)+rand*V(:,4); b = b/4; D = 1.1*eye(25); D = 1.1*D + 0.01*rand(25); lambda = -2*eye(25); alpha = 0.3; iter = 15; % Calculate gBSB weight matrix Vp=pinv(V); for i=1:size(V,2) B(:,i)=b; end W = 1.1*((D*V-B)*Vp+lambda*(eye(size(D))-V*Vp))+0.1*rand(25); % Select integer initial matrix and reshape to column vector x = sign(2*rand(5,5)-1); x = reshape(x,25,1); % Iterate calculations to update and display matrix for k = 1:iter figure(2) x = reshape(x,5,5); subplot(3,5,k); abcd(x); x = reshape(x,25,1); xtemp = (eye(25) + alpha*W)*x + alpha*b; for j = 1:25 x(j) = max(min(xtemp(j),1),-1); end end


RESULTS

The four characters "A", "B", "C", & "D" are all correctly identified using the gBSB algorithm. The iterations are shown below. This algorithm does not reach spurious states nearly as much as the BSB. Also, there does not seems to be nearly as many spurious states as the BSB. We were able to find one two spurious states for this gBSB.

Derivation of "A"
(click on picture for larger image)

Derivation of "B"
(click on picture for larger image)

Derivation of "C"
(click on picture for larger image)

Derivation of "C"
(click on picture for larger image)


BRAIN STATE IN A BOX ALGORITHM (BSB)

The BSB algorithm is a special case of the gBSB algorithm when W = V*V' and b = 0. The results, shown below, are not as successful as the gBSB algorithm.

MATLAB CODE
You may download the Matlab code here.

clc clear close all % Initialize equilibrium characters A1=[1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 -1;-1 1 1 1 -1;-1 1 1 1 -1]; B1=[-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1;-1 1 1 1 -1;-1 -1 -1 -1 1]; C1=[-1 -1 -1 -1 -1;-1 1 1 1 1;-1 1 1 1 1;-1 1 1 1 1;-1 -1 -1 -1 -1]; D1=[-1 -1 -1 1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 1 1 -1 1;-1 -1 -1 1 1]; % Initialize matrices to be used in calculations V = [A1(:) B1(:) C1(:) D1(:)]; alpha = 0.3; iter = 15; % Calculate BSB weight matrix W = V*V'; % Select integer initial matrix and reshape to column vector x = sign(2*rand(5,5)-1); x = reshape(x,25,1); % Iterate calculations to update and display matrix for k = 1:iter figure(2) x = reshape(x,5,5); subplot(3,5,k); abcd(x); x = reshape(x,25,1); xtemp = x + alpha*W*x; for j = 1:25 x(j) = max(min(xtemp(j),1),-1); %gfun(xtemp(j)) end end


RESULTS

Because b = 0, the complements of the equilibrium states are also achievable by the BSB algorithm. The "A" and "B" complements are shown below. Also, because the weight matrix does not eliminate spurious states, not every randomly generated input achieves one of the desired equilibrium states. Shown below are two seperate spurious states, which are linear combinations of the four desired equilibrium states, and one of the spurious state's complements. There are several spurious states for the BSB. There are certianly more spurious states found in the BSB then that gBSB.

Derivation of "A"
(click on picture for larger image)

Derivation of "!A"
(click on picture for larger image)

Derivation of "B"
(click on picture for larger image)

Derivation of "!B"
(click on picture for larger image)

Derivation of "C"
(click on picture for larger image)

Derivation of "D"
(click on picture for larger image)

Derivation of Spurious State
(click on picture for larger image)

Derivation of !Spurious State'
(click on picture for larger image)

Derivation of additional Spurious State

(click on picture for larger image)


DISCUSSION OF ALGORITHMS

The gBSB Algorithm is a better identifier of the pattern. However, the BSB Algorithm is computationally much faster than the gBSB algorithm. One thing to note from the above examples is that the input is a random integer (1, -1) matrix and not a noise distorted input of one of the desired states. As a result, the random matrix has a higher probability of achieving one of the spurious states. Therefore, should there only be a small amount of noise, the BSB algorithm would be more than sufficient in identifying the noisy input. Should the input have much greater noise, then the gBSB algorithm may be necessary, despite the greater computational times, in order to identify a desired equilibrium state.