function [tc, sel_roi] = mri_roi_timecourse(images, tmap, scale, sgn); % function [tc, sel_roi] = mri_roi_timecourse(images, tmap, scale, sgn); % % Aug 2003, Farshad Moradi % California Institute of Technology % % User may define the region of interest by zooming the areas of % interest. Figure 1 shows the original t-map. Figure 2 depicts the % selected regions. Only voxels with significant t are selected. % % Example: % mri_roi_timecourse(images, t, [0 1.5 3], 1); % After user defines roi, plots the roi % tc = mri_roi_timecourse(images, t, [0 1.5 3], 1); % [tc, roi] = mri_roi_timecourse(images, t, [0 1.5 3], 1); % % Also saves ROI in a global variable (roi) global roi figure(1); if nargin<3, scale = [0, 3, 8]; sgn = 1; end; mri_display(images(1).data, tmap, scale); f = find(isnan(tmap)); tmap(f) = 0; roi = zeros(size(tmap)); keep = 1; while keep, disp('Zoom ROI'); zoom on; pause; ax = round(axis); [x1,y2,slice] = MosaicTo3D(images(1), ax(1), ax(3)); x2 = min(x1+max(ax(2)-ax(1),1), images(1).w); y1 = max(y2-(ax(4)-ax(3)), 1); %disp([ax x1 x2 y1 y2 slice]); figure(2); ax = floor(ax); keep = ax(1)~=0 | ax(3)~=0; if keep, t = images(1).data*0; t(x1:x2,y1:y2, slice) = 1; f = find(sgn*tmap0)))]); end; if nargout>=2, sel_roi = roi; end; function [x,y,slice] = MosaicTo3D(image, X, Y); if size(image.data, 3)>1, [a,b, mn] = size(image.data); m = floor(sqrt(mn)); n = ceil(mn / m); X = X-1; Y = b*n-Y; x = mod(X, a)+1; y = mod(Y, b)+1; i = floor(X/a); j = floor(Y/b); slice = i+j*m+1; else, x = X; y = Y; slice = 1; end; x = max(min(x, image.w),1); y = max(min(y, image.h),1); slice = max(min(slice, image.nslice),1);