





% THIS FILE CAN BE DOWNLOADED AT http://www.dsp.rice.edu/~nowak/fmri/fmri0.m
% fMRI detection
% R. Nowak
% 10/18/99

clear
clf

% load fMRI data and reference signal waveform

% loads 122 x 64 x 64 array called 'x', consisting of 122 brain images
% each image is 64x64 pixels 
load /home/nowak/public_html/fmri/fmri.mat

% loads 122 x 1 reference signal waveform 
load /home/nowak/public_html/fmri/ref.mat

% remove mean (nuissance parameter) from reference signal 
s = s - mean(s);

% compute "correlation" image
% correlate each pixel time-series with reference signal
% this image is an array of test statistics
t = zeros(64,64);
for i=1:64
for j=1:64
	t(i,j) = sum(x(:,i,j).*s);
end
end

% display correlation image
figure(1)
imagesc(t)
axis('square')
colormap('gray')

% compare test statistics to threshold (set at 35% of max value)
% array d consists of 0's and 1's, corresponding to 
% decide H_0 = no activation, decide H_1 = activation
gam = 0.35*max(max(t));
d = (t>gam);

% display detection results
% pseudo-color red indicates activity
% pseudo-color blue (weighted by mean pixel values) indicates regions
% with no activation
figure(2)
mx = reshape(mean(x),64,64)/max(max(mean(x)));
dmap(:,:,1) = d;
dmap(:,:,2) = (1-d).*mx;
dmap(:,:,3) = (1-d).*mx;
imagesc(dmap)
axis('square')



