Matlab Help Index Technical Documentation Index

editOverlay

NAME ^

editOverlay(varargin) -- edit an ROI ("Overlay" was used early-on for "ROI")

SYNOPSIS ^

function r = editOverlay(varargin)

DESCRIPTION ^

 editOverlay(varargin) -- edit an ROI ("Overlay" was used early-on for "ROI")

 Usage: editOverlay('-base', 'path_to_base_volume_with_stem', '-inmask', ...
 'path_to_roi_with_stem', '-savedir', 'path_to_default_save_directory', ...
 <'-overlay'>, <'path_to_overlay_roi'>)

 editOverlay provides a graphical way for users to create ROIs.  The first
 step in creating an ROI is to threshold a statistical map; this is
 accomplished by either thresholdByFDR.m or thresholdStatMap.m; the output
 of these programs is an ROI that contains all voxels that pass a certain
 statistical threshold.  However, one commonly wants only a subset of these
 voxels and this is where editOverlay comes in.  editOverlay displays the
 input ROI on top of a base functional image.  On startup, all voxels
 in the input ROI are selected and colored as red.  You can clear all the
 voxels which will then color the voxels in the input ROI yellow.  Thus,
 selected voxels = red, deselected but in original ROI = yellow.  This
 is done so that you can create additional ROIs that are a subset of the
 input ROI.

 To name the functionals on which to display the ROI, use the '-base' option;
 this the path+stem to the set of functiona slices (in bshort format).  
 The parameter '-inmask' is the path to the input ROI, again with path+stem.
 To setup the default output save path, give the '-savedir' option; by 
 default, "edit_roi" and "make_roi" use the path to the ROI as the default
 save directory.  Finally, you can choose to have one ROI be an overlay on
 top of another ROI; the overlay voxels will be colored in red, while the
 other, underlying ROI will be colored in yellow.  To do this, give the
 '-overlay' option with path+stem.

 Modified from "editmask.m" in the Freesurfer/FS-FAST distribution
 Original version by Doug Greve can be found in fsfast/toolbox/editmask.m

 $Id: editOverlay.m,v 1.19 2003/09/18 16:58:53 nknouf Exp $

CROSS-REFERENCE INFORMATION ^

This function calls:

This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function r = editOverlay(varargin)
0002 % editOverlay(varargin) -- edit an ROI ("Overlay" was used early-on for "ROI")
0003 %
0004 % Usage: editOverlay('-base', 'path_to_base_volume_with_stem', '-inmask', ...
0005 % 'path_to_roi_with_stem', '-savedir', 'path_to_default_save_directory', ...
0006 % <'-overlay'>, <'path_to_overlay_roi'>)
0007 %
0008 % editOverlay provides a graphical way for users to create ROIs.  The first
0009 % step in creating an ROI is to threshold a statistical map; this is
0010 % accomplished by either thresholdByFDR.m or thresholdStatMap.m; the output
0011 % of these programs is an ROI that contains all voxels that pass a certain
0012 % statistical threshold.  However, one commonly wants only a subset of these
0013 % voxels and this is where editOverlay comes in.  editOverlay displays the
0014 % input ROI on top of a base functional image.  On startup, all voxels
0015 % in the input ROI are selected and colored as red.  You can clear all the
0016 % voxels which will then color the voxels in the input ROI yellow.  Thus,
0017 % selected voxels = red, deselected but in original ROI = yellow.  This
0018 % is done so that you can create additional ROIs that are a subset of the
0019 % input ROI.
0020 %
0021 % To name the functionals on which to display the ROI, use the '-base' option;
0022 % this the path+stem to the set of functiona slices (in bshort format).
0023 % The parameter '-inmask' is the path to the input ROI, again with path+stem.
0024 % To setup the default output save path, give the '-savedir' option; by
0025 % default, "edit_roi" and "make_roi" use the path to the ROI as the default
0026 % save directory.  Finally, you can choose to have one ROI be an overlay on
0027 % top of another ROI; the overlay voxels will be colored in red, while the
0028 % other, underlying ROI will be colored in yellow.  To do this, give the
0029 % '-overlay' option with path+stem.
0030 %
0031 % Modified from "editmask.m" in the Freesurfer/FS-FAST distribution
0032 % Original version by Doug Greve can be found in fsfast/toolbox/editmask.m
0033 %
0034 % $Id: editOverlay.m,v 1.19 2003/09/18 16:58:53 nknouf Exp $
0035 
0036 version = '$Id: editOverlay.m,v 1.19 2003/09/18 16:58:53 nknouf Exp $';
0037 r = 1;
0038 
0039 %% Print usage if there are no arguments %%
0040 if(nargin == 0)
0041   print_usage;
0042   return;
0043 end
0044 
0045 hcurrentfig = get(0,'CurrentFigure');
0046 
0047 %--------------- Initialize if needed -----------------%
0048 init = 0;
0049 flag = deblank(varargin{1});
0050 if(~isempty(strmatch(flag,'-init')) | isempty(hcurrentfig))
0051   init = 1;
0052   s = parse_args(varargin);
0053   if(isempty(s)) return; end
0054   s = check_params(s);
0055   if(isempty(s)) return; end
0056 
0057   %% define a value
0058   s.sliceNum = 0;
0059 
0060   % Load the base %
0061   fprintf('Loading base %s\n',s.baseid);
0062   s.base = fmri_ldbvolume(s.baseid);
0063   s.base = s.base(:,:,:,s.baseframe+1);
0064   if(isempty(s.base))
0065     fprintf('ERROR: cannot load %s\n',s.baseid);
0066     return;
0067   end
0068   s.volsize = size(s.base);
0069 
0070   % Convert to mosaic %
0071   s.base = vol2mos(permute(s.base,[2 3 1]));
0072   s.mossize = size(s.base);
0073 
0074   % Load the input mask (if specificied) or segment the base %
0075   if(~isempty(s.inmaskid))
0076     s.mask = textread([s.inmaskid '.roi']);
0077     s.mask = expandROI(s.mask, s.volsize);
0078     %%s.mask = fmri_ldbvolume(s.inmaskid);
0079     if(isempty(s.mask))
0080       fprintf('ERROR: could not load input mask %s\n',s.inmaskid);
0081       return;
0082     end
0083     s.mask = s.mask(:,:,:,1);
0084     s.mask = vol2mos(permute(s.mask,[2 3 1]));
0085     if(s.invertinmask) s.mask = ~s.mask; end
0086   else
0087     s.mask = zeros(size(s.base));
0088     if(s.segbase)
0089       meanbase = mean(reshape1d(s.base));
0090       ind = find(s.base > s.segthresh*meanbase);
0091       s.mask(ind) = 1;
0092       fprintf('Segmenting base %g %d\n',meanbase,length(ind));
0093     end
0094     if(s.invertinmask) s.mask = ~s.mask; end
0095     s.saveneeded = 1;
0096   end
0097 
0098   %% initialize the overlay
0099   if (~isempty(s.overlayid))
0100     s.overlay = textread([s.overlayid '.roi']);
0101     s.overlay = expandROI(s.overlay, s.volsize);
0102     %%s.overlay = fmri_ldbvolume(s.overlayid);
0103         if(isempty(s.overlay))
0104               fprintf('ERROR: could not load overlay %s\n',s.overlayid);
0105         return;
0106     end
0107     s.overlay = s.overlay(:,:,:,1);
0108     s.overlay = vol2mos(permute(s.overlay,[2 3 1]));
0109   else
0110       s.overlay = s.mask;
0111   end
0112 
0113   if(s.heqbase)
0114      fprintf('Equalizing Base Intesity Values\n');
0115      [histbase valbase] = hist(reshape1d(s.base),100);
0116      pbase = histbase/sum(histbase);
0117      pdfbase = cumsum(pbase);
0118      x = max(find(pdfbase < .98));
0119      x = valbase(ix);
0120      ind = find(s.base > x);
0121      s.base(ind) = x;
0122   end
0123 
0124   % Rescale Base to be between 1 and (s.ncmap-2) %
0125   minbase = min(reshape1d(s.base));
0126   maxbase = max(reshape1d(s.base));
0127   s.base = floor((s.ncmap-2)*(s.base-minbase)/(maxbase-minbase)) + 1;
0128   % Create the color map
0129   s.cmap = gray(s.ncmap); % Start with gray
0130   % Set the last entry to be color;
0131   s.cmap(end-1,:) = [.99 .99 0]; % raises a figure window here (why?)
0132   s.cmap(end,:) = [0.99 0 0]; % raises a figure window here (why?)
0133 
0134   s.displayimg = s.base .* (~s.mask) + ((s.ncmap-1)*s.mask);
0135 
0136   s.oldbase = s.base;
0137   s.base = s.base .* (~s.mask) + (s.ncmap-1)*s.mask;
0138   s.displayimg = s.base .* (~s.overlay);
0139   s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0140 
0141   s.overlay = squeeze(s.overlay);
0142 
0143   % Image the display image %
0144   s.himage = image(s.displayimg);
0145   set(s.himage,'EraseMode','none');
0146   axis image;
0147   s.hfig = gcf;
0148   s.haxis = gca;
0149   colormap(s.cmap);
0150   set(gcf,'pointer','crosshair');
0151 
0152   % Set up the call-back functions %
0153   set(gcf,'KeyPressFcn',          'editOverlay(''kbd'');');
0154   set(gcf,'WindowButtonDownFcn',  'editOverlay(''wbd'');');
0155   set(gcf,'WindowButtonUpFcn',    'editOverlay(''wbu'');');
0156   set(gcf,'WindowButtonMotionFcn','editOverlay(''wbm'');');
0157   s.nmarked = length(find(s.overlay==1));
0158 
0159   set(gcf,'UserData',s);
0160 
0161   fprintf('\n');
0162   fprintf(' ----------------------------------\n');
0163   fprintf(' For help press "h"\n');
0164   fprintf(' ------------ Help ----------------\n');
0165   printhelp;
0166   fprintf('\n');
0167   fprintf(' ------ Current State -------------\n');
0168   printstate(s);
0169   fprintf('\n');
0170 
0171   return;
0172 end
0173 %---------------------------------------------------------%
0174 %---------------------------------------------------------%
0175 %---------------------------------------------------------%
0176 
0177 %----------- Parse the call-back function ----------%
0178 s = get(gcf,'UserData');
0179 redraw = 0;
0180 switch(flag)
0181 
0182   case {'wbd','wbm'} % -------Window Button Down ------------ %
0183     if(strcmp(flag,'wbm') & ~s.mousedown) return; end
0184     if(s.editmode == 0) return; end
0185 
0186     xyz = get(gca,'CurrentPoint');
0187     c = round(xyz(1,1));
0188     r = round(xyz(1,2));
0189     if(r < 1 | r > size(s.base,1) | c < 1 | c > size(s.base,2))
0190       return;
0191     end
0192     s.cp = round([r c]);
0193     rlist = r-(s.brushsize-1):r+(s.brushsize-1);
0194     ind = find(rlist < s.mossize(1));
0195     rlist = rlist(ind);
0196 
0197     clist = c-(s.brushsize-1):c+(s.brushsize-1);
0198     ind = find(clist < s.mossize(2));
0199     clist = clist(ind);
0200 
0201     %fprintf('%d %d %g  %d\n',r,c,s.base(r,c),s.mask(r,c));
0202 
0203     for r = rlist,
0204       for c = clist,
0205         switch(s.editmode)
0206         case 1, s.overlay(r,c) = 1;
0207         case 2, s.overlay(r,c) = 0;
0208         case 3, s.overlay(r,c) = ~s.overlay(r,c);
0209         end
0210       end
0211     end
0212 
0213     %% so the overlay is a matrix of ones and zeros, ones where the
0214     %% there is an selected voxel.  The first line sets all of the
0215     %% selected voxels in the base to zero.  The second line
0216     %% then adds the overlay, multiplied by a scaling factor, so that
0217     %% the colormap works out.
0218     s.displayimg = s.base .* (~s.overlay);
0219     s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0220 
0221     s.nmarked = length(find(s.overlay==1));
0222 
0223     s.saveneeded = 1;
0224     s.mousedown = 1;
0225     redraw = 1; 
0226 
0227   case {'wbu'} % -------Window Button Up ------------ %
0228     %fprintf('Button Up\n');
0229     s.mousedown = 0;
0230 
0231   case {'kbd'} %----------- Keyboard -------------%
0232     c = get(s.hfig,'CurrentCharacter'); 
0233     switch(c)
0234       case {'b'},
0235         s.brushsize = s.brushsize + 1;
0236         if(s.brushsize > 8) s.brushsize = 1; end
0237         tmp = 2*(s.brushsize-1) + 1;
0238         fprintf('Brush Size: %d x %d\n',tmp,tmp);
0239     fprintf('\n');
0240         set(gcf,'UserData',s);
0241     return;
0242       case {'h'},
0243         fprintf('\n');
0244         printhelp;
0245         fprintf('\n');
0246         printstate(s);
0247         fprintf('\n');
0248       case {'a'},
0249     s.overlay = s.mask;
0250     s.displayimg = s.base .* (~s.overlay);
0251     s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0252     fprintf('All voxels marked\n');
0253         fprintf('\n');
0254     redraw = 1;
0255       case {'i'},
0256     s.overlay = computeIntersection(s.overlay, s.mask);
0257     s.displayimg = s.base .* (~s.overlay);
0258     s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0259     fprintf('Computed intersection of overlay and mask\n');
0260         fprintf('\n');
0261     redraw = 1;
0262       case {'c'},
0263     s.overlay = zeros(size(s.base));
0264     s.displayimg = s.base .* (~s.overlay);
0265     s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0266     fprintf('All voxels cleared\n');
0267         fprintf('\n');
0268     redraw = 1;
0269       case {'e'},
0270     title = 'Examine a particular slice';
0271     prompt = {'Slice number:'};
0272     lines = 1;
0273     def = {'1'};
0274     answer = inputdlg(prompt,title,lines,def);
0275     
0276     %% if we actually have a slice number
0277     if (~isempty(answer))
0278         s.sliceNum = sscanf(answer{1},'%d');
0279         if ((s.sliceNum <= 0) | (s.sliceNum > s.volsize(:,1)))
0280             msg = sprintf('Please enter a valid slice');
0281             errordlg(msg);    
0282         end
0283 
0284         %% save mosaics
0285         s.originalbase = s.base;
0286         s.originaloverlay = s.overlay;
0287         s.originalmask = s.mask;
0288         fprintf('setting display to slice %d\n',s.sliceNum);
0289         fprintf('\n');
0290        
0291         %% convert to volumes
0292         tmpbase = mos2vol(s.originalbase,[s.volsize(2) s.volsize(3) s.volsize(1)]);
0293         tmpoverlay = mos2vol(s.originaloverlay,[s.volsize(2) s.volsize(3) s.volsize(1)]);
0294         tmpmask = mos2vol(s.originalmask,[s.volsize(2) s.volsize(3) s.volsize(1)]);
0295             tmpbase = permute(tmpbase,[3 1 2]);
0296             tmpoverlay = permute(tmpoverlay,[3 1 2]);
0297             tmpmask = permute(tmpmask,[3 1 2]);
0298 
0299         %% get the current slice
0300         s.base = squeeze(tmpbase(s.sliceNum,:,:));
0301         s.overlay = squeeze(tmpoverlay(s.sliceNum,:,:));
0302         s.mask = squeeze(tmpmask(s.sliceNum,:,:));
0303 
0304         %% setup the new display image
0305         s.displayimg = s.base .* (~s.overlay);
0306         s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0307 
0308         %% display the new image
0309         s.himage = image(s.displayimg);
0310         set(s.himage,'EraseMode','none');
0311         axis image;
0312         s.hfig = gcf;
0313         s.haxis = gca;
0314         colormap(s.cmap);
0315         set(s.himage,'CData',s.displayimg);
0316         set(gcf,'UserData',s);
0317         redraw = 1;
0318         return;
0319     end
0320       case {'r'},
0321     fprintf('returning to mosaic view...\n');
0322 
0323     %% return to a mosaic view
0324     s.base = s.originalbase;
0325     s.mask = s.originalmask;
0326 
0327     %% mosaic to volume trickery
0328     tmpoverlay = mos2vol(s.originaloverlay,[s.volsize(2) s.volsize(3) s.volsize(1)]);
0329     tmpoverlay = permute(tmpoverlay,[3 1 2]);
0330     tmpoverlay(s.sliceNum,:,:) = s.overlay;
0331       s.overlay = vol2mos(permute(tmpoverlay,[2 3 1]));
0332 
0333     %% setup the mosaic display image
0334     s.displayimg = s.base .* (~s.overlay);
0335     s.displayimg = s.displayimg + (s.ncmap) * s.overlay;
0336 
0337     %% display the new image
0338     s.himage = image(s.displayimg);
0339     set(s.himage,'EraseMode','none');
0340     axis image;
0341     s.hfig = gcf;
0342     s.haxis = gca;
0343     colormap(s.cmap);
0344     set(s.himage,'CData',s.displayimg);
0345     set(gcf,'UserData',s);
0346     s.sliceNum = 0;
0347     redraw = 1;
0348     return;
0349       case {'m'},
0350         s.editmode = s.editmode + 1;
0351         if(s.editmode > 3) s.editmode = 0; end
0352         fprintf('Mode: %s\n',modename(s.editmode));
0353         fprintf('\n');
0354       case {'q'},
0355         if(s.saveneeded)
0356           resp = questdlg('Changes pending. Do you want to quit?',...
0357                           'Quit?','Quit','No','No');
0358           if(strcmp(resp,'No')) return; end
0359         end
0360         close(s.hfig);
0361         r = 0;
0362         return;
0363       case {'s'},
0364     %% we only can save when in mosaic view; probably could remove this
0365     %% restriction, but right now, more important things to do
0366     %%if (s.sliceNum)
0367     %%    fprintf('Must switch to mosaic view (\"r\") in order to save your ROI.\n');
0368     %%    return;
0369     %%end
0370 
0371         if(isempty(s.outmaskid))
0372           curdir = pwd;
0373           cd(s.savedir);
0374           [fname pname] = uiputfile('*.roi', 'Save Mask');
0375           cd(curdir);
0376           if(fname ~= 0)
0377             if(isempty(pname)) ud.savedir  = '.';
0378             else               ud.savedir  = pname;
0379             end
0380         if (~isempty(findstr('.roi',fname)))
0381         fname = fname(1:(end-4));
0382         end
0383             s.outmaskid = strcat(pname,fname);
0384           else return;  
0385           end
0386         end
0387         tmp = mos2vol(s.overlay,[s.volsize(2) s.volsize(3) s.volsize(1)]);
0388         tmp = permute(tmp,[3 1 2]);
0389         fprintf('Saving to %s\n',[s.outmaskid '.roi']);
0390     roimtx = compactROI(tmp);
0391     output = sprintf('save %s.roi roimtx -ASCII', s.outmaskid);
0392     eval(output);
0393         fprintf('Done\n');
0394         clear tmp;
0395         s.saveneeded = 0;
0396     s.outmaskid = '';
0397         set(gcf,'UserData',s);
0398         return;
0399       case {'t'},
0400         s.showbaseonly = ~ s.showbaseonly;
0401         if(s.showbaseonly) 
0402           s.displayimg = s.base;
0403         else
0404           s.displayimg = s.base .* (~s.overlay);
0405           s.displayimg = s.base .* (~s.overlay) + (s.ncmap)*s.overlay;
0406         end
0407         redraw = 1;
0408         figure(s.hfig);
0409         axes(s.haxis);
0410         fprintf('\n');
0411       case {'o'},
0412     fprintf('finding marked overlay voxels\n');
0413         fprintf('\n');
0414       case {'v'},
0415         fprintf('\n');
0416         fprintf('\n');
0417         printstate(s);
0418         fprintf('\n');
0419         fprintf('\n');
0420       case {'z'},
0421         zoom;
0422         s.zoomstate = ~ s.zoomstate;
0423         set(gcf,'UserData',s);
0424         if(s.zoomstate)
0425           fprintf('Zoom is on\n');
0426         else
0427           fprintf('Zoom is off\n');
0428         end
0429         fprintf('\n');
0430         return;
0431     end
0432 
0433 end % --- switch(flag) ----- %
0434 
0435 if(redraw)
0436   set(s.himage,'CData',s.displayimg);
0437 end
0438 
0439 set(gcf,'UserData',s);
0440 
0441 return;
0442 %--------------------------------------------------%
0443 %--------------------------------------------------%
0444 %--------------------------------------------------%
0445 
0446 %% compute the matrix intersection
0447 function intersection = computeIntersection(A, B)
0448     if (size(A) ~= size(B))
0449         oops(252);
0450     end
0451 
0452     [numRows, numCols] = size(A);
0453     intersection = zeros(numRows, numCols);
0454 
0455     for i=1:numRows
0456         for j=1:numCols
0457             if (A(i,j) == B(i,j))
0458                 intersection(i,j) = A(i,j);
0459             end
0460         end
0461     end
0462 return;
0463 
0464 %--------------------------------------------------%
0465 %% Print Usage
0466 function print_usage(dummy)
0467 
0468   fprintf(1,'USAGE:\n');
0469   fprintf(1,'  editmask\n');
0470   fprintf(1,'     -base     base volume  \n');
0471   fprintf(1,'     -inmask   load this roi\n');
0472   fprintf(1,'     -overlay  path to an overlay ROI to load on top of inmask\n');
0473   fprintf(1,'     -savedir  set the default save directory\n');
0474 return
0475 %--------------------------------------------------%
0476 
0477 %--------------------------------------------------%
0478 %% Default data structure
0479 function s = editmask_struct
0480   s.volsize        = [];
0481   s.mossize        = [];
0482   s.baseid         = '';
0483   s.base           = [];
0484   s.heqbase            = 0;
0485   s.inmaskid       = '';
0486   s.invertinmask   = 0;
0487   s.outmaskid      = '';
0488   s.savedir        = '';
0489   s.overlayid       = '';
0490   s.overlay       = [];
0491   s.mask           = [];
0492   s.overlay       = [];
0493   s.baseframe      = 0;
0494   s.hfig           = [];
0495   s.haxis          = [];
0496   s.himage         = [];
0497   s.ncmap          = 64;
0498   s.displayimg     = [];
0499   s.segbase        = 0;
0500   s.segthresh      = .75;
0501   s.cp             = [1 1]; % current point [r c]
0502   s.zoomstate      = 0;
0503   s.brushsize      = 2;
0504   s.mousedown      = 0;
0505   s.showbaseonly   = 0;
0506   s.savedir        = '.';
0507   s.editmode       = 0;
0508   s.nmarked        = 0;
0509   s.saveneeded     = 0;
0510 return;
0511 
0512 %--------------------------------------------------%
0513 % ----------- Parse Input Arguments ---------------%
0514 function s = parse_args(varargin)
0515 
0516   fprintf(1,'Parsing Arguments \n');
0517   s = editmask_struct;
0518 
0519   inputargs = varargin{1};
0520   ninputargs = length(inputargs);
0521 
0522   narg = 1;
0523   while(narg <= ninputargs)
0524 
0525     flag = deblank(inputargs{narg});
0526     narg = narg + 1;
0527     %fprintf(1,'Argument: %s\n',flag);
0528     if(~isstr(flag))
0529       flag
0530       fprintf(1,'ERROR: All Arguments must be a string\n');
0531       %%error;
0532     oops(150);
0533     end
0534 
0535     switch(flag)
0536 
0537       case {'-b','-base'},
0538         arg1check(flag,narg,ninputargs);
0539         s.baseid = inputargs{narg};
0540         narg = narg + 1;
0541 
0542       case {'-inmask'},
0543         arg1check(flag,narg,ninputargs);
0544         s.inmaskid = inputargs{narg};
0545         narg = narg + 1;
0546 
0547       case {'-savedir'},
0548     arg1check(flag,narg,ninputargs);
0549     s.savedir = inputargs{narg};
0550     narg = narg + 1;
0551 
0552       case {'-overlay'},
0553      arg1check(flag, narg, ninputargs);
0554     s.overlayid = inputargs{narg};
0555     narg = narg + 1;
0556 
0557       case '-verbose',
0558         s.verbose = 1;
0559 
0560       case {'-debug','-echo','-init'}, % ignore
0561 
0562       otherwise
0563         fprintf(2,'ERROR: Flag %s unrecognized\n',flag);
0564         s = [];
0565         return;
0566 
0567     end % --- switch(flag) ----- %
0568 
0569   end % while(narg <= ninputargs)
0570 
0571 return;
0572 %--------------------------------------------------%
0573 
0574 %--------------------------------------------------%
0575 %% Check that there is at least one more argument %%
0576 function arg1check(flag,nflag,nmax)
0577   if(nflag>nmax) 
0578     fprintf(1,'ERROR: Flag %s needs one argument',flag);
0579     oops(151);
0580   end
0581 return;
0582 
0583 %--------------------------------------------------%
0584 %% Check argument consistency, etc %%%
0585 function s = check_params(s)
0586   %fprintf(1,'Checking Parameters\n');
0587 
0588   if( isempty(s.baseid) )
0589     fprintf(2,'ERROR: No base volumes specified\n');
0590     s=[]; return;
0591   end
0592 return;
0593 
0594 %--------------------------------------------------%
0595 function name = modename(modeno)
0596   switch(modeno)
0597   case 0, name = 'No Edit'; 
0598   case 1, name = 'Set'; 
0599   case 2, name = 'Unset'; 
0600   case 3, name = 'Toggle'; 
0601   end
0602 return
0603 
0604 %--------------------------------------------------%
0605 function printstate(s)
0606   s.nmarked = length(find(s.overlay==1));
0607   tmp = 2*(s.brushsize-1) + 1;
0608   fprintf('Base Volume: %s\n',s.baseid);
0609   fprintf('Input  Mask Volume: %s\n',s.inmaskid);
0610   fprintf('Output Mask Volume: %s\n',s.outmaskid);
0611   fprintf('Total number of voxels:  %d\n',prod(s.volsize));
0612   fprintf('Number of voxels marked: %d\n',s.nmarked);
0613   fprintf('Brush Size: %d x %d\n',tmp,tmp);
0614   fprintf('Edit Mode: %s\n',modename(s.editmode));
0615   if(s.saveneeded)
0616     fprintf('Changes Pending\n');
0617   else
0618     fprintf('No Changes Pending\n');
0619   end
0620 return;
0621 
0622 %--------------------------------------------------%
0623 function printhelp
0624   fprintf('a - select all voxels\n');
0625   fprintf('c - clear all voxels\n');
0626   fprintf('e - examine a particular slice\n');
0627   fprintf('r - return to mosaic view\n');
0628   fprintf('i - compute the intersection of the underlying mask and the overlay\n');
0629   fprintf('b - change brush size (1x1,3x3,5x5,7x7,9x9,11x11,13x13,...)\n');
0630   fprintf('h - print help (this message)\n');
0631   fprintf('m - change edit mode\n');
0632   fprintf('    No Edit - button down does nothing\n');
0633   fprintf('    Set     - button down turns on mask at voxel\n');
0634   fprintf('    Unset   - button down turns off mask at voxel\n');
0635   fprintf('    Toggle  - button down toggels mask at voxel\n');
0636   fprintf('q - quit/exit\n');
0637   fprintf('s - save mask\n');
0638   fprintf('t - toggle mask on and off\n');
0639   fprintf('v - print the current state\n');
0640   fprintf('z - toggle zoom state. When zoom is on, use left\n');
0641   fprintf('    button to zoom in and right to zoom out\n');
0642 return;

Generated at 19:47:41 15-Oct-2003 by m2html © 2003