function status = QA(inDir)
%
% QA(inDir)
%
% Souheil J. Inati  
% Dartmouth College 2000

% Create the name of the first file in inDir
firstfile = fullfile(inDir,'I.001');

% Read the header
[su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(firstfile);

nX =  im_hdr.imatrix_X; % X Voxels
nY =  im_hdr.imatrix_Y; % Y Voxels
nZ =  im_hdr.slquant;   % Z Voxels
volSize = [nX nY nZ];
adwcount = im_hdr.user9;

% Loop over the volumes until there is no more looping to be done.

% Loop over the passes (volumes)
% Initialize
done = 0;
imageVol = zeros(nX,nY,nZ);
vec = zeros(adwcount,1);

xa = floor(nX/2-15);
xb = ceil(nX/2+15);
ya = floor(nY/2-15);
yb = ceil(nY/2+15);
za = floor(nZ/2-2);
zb = ceil(nZ/2+2);
nx = xb-xa+1;
ny = yb-ya+1;
nz = zb-za+1;
subVol = zeros(nx,ny,nz);

for i = 1:adwcount
  % Read in the volume
  [imageVol, lastfile] = GE_readVolume(inDir, i+1, volSize, 16, ...
				       im_offset);
  subVol = imageVol(xa:xb,ya:yb,za:zb);
vec(i) = mean(subVol(:));
  % Done with vol
  fprintf('volnum = %d\tread %s\n',i,lastfile);

end % Run loop

figure
plot(im_hdr.tr*1E-6*(1:adwcount),vec/mean(vec))
r = axis;
text((r(2)+r(1))/2, (r(3)+r(4))/2+0.2*(r(4)-r(3)), sprintf('Mean Signal = %f\nStandard Dev = %f',mean(vec(75:adwcount)),std(vec(75:adwcount)/mean(vec(75:adwcount)))));
title(inDir)

return








