function x = mri_timecourse(images, roi, ref_frame, filter); x = []; for i= 1:length(images), x = [x, sum(images(i).data(roi))]; end; if (nargin>2) & (ref_frame>0), x = (x./sum(images(ref_frame).data(roi))-1)*100; end; if (nargin>3) & (filter>0), lp = exp(-(-4:1/filter:4).^2/2); lp = lp/sum(lp); baseline = conv(x, lp); w = (length(lp)-1)/2; x = x - baseline(w: length(x)+w-1); end; % plot(x);