Matlab Help Index Technical Documentation Index

displayOverlap

NAME ^

displayOverlap -- display an overlap map on a set of base functionals

SYNOPSIS ^

function displayOverlap(varargin)

DESCRIPTION ^

 displayOverlap -- display an overlap map on a set of base functionals

 Usage: displayOverlap(base, overlapROI, numROIs, display, roiNames)

 Takes an overlap map "overlapROI" and displays it on
 the base functionals "base".  "numROIs" gives the total number
 of ROIs; this is used in selecting the correct colormap
 If "display" is set to 'mosaic', all slices are displayed in a mosaic view.
 if it is a number, only that slice number is displayed (indexed starting
 with 1).  "roiNames" is a cell array containing the names of the ROIs used
 and are found in the "overlapROI.info" file in the roi directory.

 $Id: displayOverlap.m,v 1.6 2003/09/15 15:52:18 nknouf Exp $

CROSS-REFERENCE INFORMATION ^

This function calls:

This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function displayOverlap(varargin)
0002 % displayOverlap -- display an overlap map on a set of base functionals
0003 %
0004 % Usage: displayOverlap(base, overlapROI, numROIs, display, roiNames)
0005 %
0006 % Takes an overlap map "overlapROI" and displays it on
0007 % the base functionals "base".  "numROIs" gives the total number
0008 % of ROIs; this is used in selecting the correct colormap
0009 % If "display" is set to 'mosaic', all slices are displayed in a mosaic view.
0010 % if it is a number, only that slice number is displayed (indexed starting
0011 % with 1).  "roiNames" is a cell array containing the names of the ROIs used
0012 % and are found in the "overlapROI.info" file in the roi directory.
0013 %
0014 % $Id: displayOverlap.m,v 1.6 2003/09/15 15:52:18 nknouf Exp $
0015 
0016 % License:    Perl Artistic License
0017 % History:    Sept 11, 2003: initial release
0018 
0019 %% setup callback functions
0020 set(gcf,'KeyPressFcn',          'displayOverlap(''kbd'');');
0021 
0022 %% run through the following if we are given 5 arguments
0023 if (nargin == 5)
0024     o.originalbase = varargin{1};
0025     o.originaloverlapROI = varargin{2};
0026     o.numROIs = varargin{3};
0027     o.display = varargin{4};
0028     o.roiNames = varargin{5};
0029     [o.numSlices, o.xsize, o.ysize] = size(o.originalbase);
0030 
0031 %% get dimensions
0032 [numSlices, xSize, ySize] = size(o.originalbase);
0033 
0034 %% error checking
0035 if (~strncmp(o.display,'mosaic',6) & ~(o.display <= numSlices))
0036     oops(254);
0037 end
0038 
0039 o.ncmap = 64;
0040 o.cmap = gray(o.ncmap);
0041 
0042 switch o.display
0043     case 'mosaic',
0044         o.overlapROI = o.originaloverlapROI;
0045         o.base = o.originalbase;
0046         %% scale the base
0047         o.base = rescaleVolume(o.base, o.ncmap);    
0048 
0049         %% form the correct colormap
0050         o.overlapcmap = getcolormap(o.numROIs);
0051         o.cmap = [o.cmap; o.overlapcmap];
0052 
0053         %% reshape the data into mosaics
0054         o.base = vol2mos(permute(o.base, [2 3 1]));
0055         o.overlapROI = vol2mos(permute(o.overlapROI, [2 3 1]));
0056 
0057         %% find the nonzero elements in the o.overlapROI
0058         ind = find(o.overlapROI ~= 0);
0059 
0060         %% set those elements in the base to be ncmap
0061         %% this sets the offset correct for the colormap
0062         o.base(ind) = o.ncmap;
0063 
0064         %% combine base and overlapROI together
0065         composite = o.base + o.overlapROI;
0066 
0067         %% display result
0068         o.himage = image(composite);
0069         o.hfig = gcf;
0070         o.haxis = gca;
0071         colormap(o.cmap);
0072         set(gcf,'UserData',o);
0073         return;
0074     otherwise,
0075         o.overlapROI = o.originaloverlapROI;
0076         o.base = o.originalbase;
0077 
0078         %% scale the o.base
0079         o.base = rescaleVolume(o.base, o.ncmap);    
0080 
0081         %% form the correct colormap
0082         o.overlapcmap = getcolormap(o.numROIs);
0083         o.cmap = [o.cmap; o.overlapcmap];
0084 
0085         %% get the correct slice
0086         o.base = squeeze(o.base(o.display, :, :));
0087         o.overlapROI = squeeze(o.overlapROI(o.display, :, :));
0088 
0089         %% transpose?
0090         %%o.overlapROI = o.overlapROI';
0091 
0092         %% find the nonzero elements in the o.overlapROI
0093         ind = find(o.overlapROI ~= 0);
0094 
0095 
0096         %% set those elements in the o.base to be ncmap
0097         %% this sets the offset correct for the colormap
0098         o.base(ind) = o.ncmap;
0099 
0100         %% combine o.base and o.overlapROI together
0101         composite = o.base + o.overlapROI;
0102 
0103         %% display result
0104         o.himage = image(composite);
0105         o.hfig = gcf;
0106         o.haxis = gca;
0107         colormap(o.cmap);
0108         set(gcf,'UserData',o);
0109         return;
0110 end
0111 end
0112 
0113 %% parse the callback function
0114 o = get(gcf,'UserData');
0115 flag = deblank(varargin{1});
0116 
0117 switch(flag)
0118     case {'kbd'},
0119     c = get(o.hfig,'CurrentCharacter');
0120     switch(c)
0121         case 's', %% want to change a slice
0122             title = 'Enter a slice number';
0123             prompt = {'Slice number:'};
0124             lines = 1;
0125             def = {'1'};
0126             answer = inputdlg(prompt,title,lines,def);
0127     
0128             %% if we actually have a slice number
0129             if (~isempty(answer))
0130                 sliceNum = sscanf(answer{1},'%d');
0131                 if ((sliceNum <= 0) | (sliceNum > o.numSlices))
0132                     msg = sprintf('Please enter a valid slice');
0133                     errordlg(msg);    
0134                 end
0135                 fprintf('setting display to slice %d\n',sliceNum);
0136                 fprintf('\n');
0137                 displayOverlap(o.originalbase,o.originaloverlapROI,o.numROIs,sliceNum, o.roiNames);
0138             end
0139         case 'l', %% legend
0140             returnLegend(o.numROIs);
0141             fprintf('\n');
0142         case 'r', %% display ROI names
0143             displayroiNames(o.roiNames);
0144             fprintf('\n');
0145         case 'm', %% set to mosaic
0146             fprintf('setting display to mosaic\n');
0147             fprintf('\n');
0148             displayOverlap(o.originalbase,o.originaloverlapROI,o.numROIs,'mosaic', o.roiNames);
0149         case 'h', %% give help info
0150             s = sprintf('Keypress Commands:\n');
0151             s = sprintf('%sh - this help information\n',s);
0152             s = sprintf('%sl - display legend\n',s);
0153             s = sprintf('%sm - display mosaic view\n',s);
0154             s = sprintf('%sq - quit\n',s);
0155             s = sprintf('%sr - list names of ROIs\n',s);
0156             s = sprintf('%ss - select a specific slice\n',s);
0157             msgbox(s,'displayOverlap Help','help');
0158             fprintf('\n');
0159         case 'q', %% quit
0160             hoverlap = gcf;
0161             close(hoverlap);
0162             return;
0163     end    
0164 end
0165 
0166 %% takes cell array and outputs names into matlab window
0167 function displayroiNames(roiNames)
0168     [numROIs, junk] = size(roiNames);
0169     
0170     fprintf('\n');
0171     for i=1:numROIs
0172         fprintf('condition %d - %s\n', i, roiNames{i});
0173     end
0174 return;
0175 
0176 %% outputs legend depending on the number of ROIs
0177 function returnLegend(numROIs)
0178     switch (numROIs)
0179         case 2,
0180             fprintf('\nblue   - condition 1\n');
0181             fprintf('red    - condition 2\n');
0182             fprintf('white  - conditions 1 & 2\n');
0183             return;
0184         case 3,
0185             fprintf('\nblue    - condition 1\n');
0186             fprintf('red     - condition 2\n');
0187             fprintf('yellow  - condition 3\n');
0188             fprintf('purple  - conditons 1 & 2\n');
0189             fprintf('green   - conditions 1 & 3\n');
0190             fprintf('orange  - conditions 2 & 3\n'); 
0191             fprintf('white   - conditions 1, 2 & 3\n');
0192             return;
0193     end
0194 return;
0195 
0196 %% rescales the volume to be between 0 and ncmap
0197 function outVol = rescaleVolume(inVol, ncmap)
0198     minvol = min(reshape1d(inVol));
0199     maxvol = max(reshape1d(inVol));
0200 
0201     outVol = floor(ncmap*(inVol - minvol)/(maxvol - minvol)) + 1;
0202 return;

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