function extr = calculateImageData(voxelList,des,smoothed)

dtype='PSTH';

switch dtype 
    case 'PSTH'
        V=des.xY.VY;
    case 'betas'
        V=des.Vbeta;
end;

if V(1).fname(1)~='D'
     for z=1:length(V) % Change Drive Letter!\
      	V(z).fname(1) = 'D';
     end; 
end

if (~smoothed)
  for z=1:length(V) % Change Drive Letter!\
      % D:....SUBJECTID\session\swfanders...
      % D:....SUBJECTID\session\wfanders...
      tmp = findstr(filesep,V(z).fname);
      V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end));
  end;
end

% rad = 0; % one voxel
% opt = 1; % xyz coordinates [mm]


vox = voxelList;
nRoi = size(vox,1);

nImg = numel(V);

for k=1:nImg
	extr(k) = struct(...
        'val',   repmat(NaN, [1 nRoi]),...
		'mean',  repmat(NaN, [1 nRoi]),...
		'sum',   repmat(NaN, [1 nRoi]),...
		'nvx',   repmat(NaN, [1 nRoi]),...
		'posmm', repmat(NaN, [3 nRoi]),...
		'posvx', repmat(NaN, [3 nRoi]));

    roicenter = round(inv(V(k).mat)*[vox, ones(nRoi,1)]');

	for l = 1:nRoi

%         if rad==0
            x = roicenter(1,l);
            y = roicenter(2,l);
            z = roicenter(3,l);
%         else
%             tmp = spm_imatrix(V(k).mat);
%             vdim = tmp(7:9);
%             vxrad = ceil((rad*ones(1,3))./(ones(nRoi,1)*vdim))';
%             [x y z] = ndgrid(-vxrad(1,l):sign(vdim(1)):vxrad(1,l), ...
%                       -vxrad(2,l):sign(vdim(2)):vxrad(2,l), ...
%                       -vxrad(3,l):sign(vdim(3)):vxrad(3,l));
%             sel = (x./vxrad(1,l)).^2 + (y./vxrad(2,l)).^2 + ...
%                   (z./vxrad(3,l)).^2 <= 1;
%             x = roicenter(1,l)+x(sel(:));
%             y = roicenter(2,l)+y(sel(:));
%             z = roicenter(3,l)+z(sel(:));
%         end;


		dat                 = spm_sample_vol(V(k), x, y, z,0);
		[maxv maxi]         = max(dat);
		tmp                 = V(k).mat*[x(maxi); y(maxi); z(maxi);1]; % Max Pos
		extr(k).val(l)      = maxv;
		extr(k).sum(l)      = sum(dat);
		extr(k).mean(l)     = nanmean(dat);
        extr(k).nvx(l)      = numel(dat);
		extr(k).posmm(:,l)  = tmp(1:3);
		extr(k).posvx(:,l)  = [x(maxi); y(maxi); z(maxi)]; % Max Pos
	end;

end;
end