Matlab Help Index Technical Documentation Index

view_mesh

NAME ^

view_mesh - view a surface plot of hemodynamic data for a single condition

SYNOPSIS ^

function view_mesh(hvol, hoffset, ROIs, ROI, cond, timepoint)

DESCRIPTION ^

 view_mesh - view a surface plot of hemodynamic data for a single condition

 Usage: view_mesh(hvol, hoffset, ROIs, ROI, cond, <timepoint>)
 where:
    hvol - a hmean volume, as the output of convert_hvolume
    hoffset - h-offset volume, loaded from the h-offset bshorts
    ROIs - a ROI structure with at least two elements:
        nconditions - number conditions (excluding fixation)
        mesh_type - 1 for display in raw scanner units
                2 for display in percent signal change
    ROI - your ROI in the standard format
    cond - condition to plot; fixation is always condition 1
    timepoint - (optional) timepoint to plot for FIR analyses

 view_mesh allows the user to display the results of the FS-FAST program
 selxavg-sess for a particular ROI in the form of a "surface" plot, where
 high and low values are mapped to high and low points in a 3D space, 
 respectively.  Note that for this surface to be possible, your ROI
 must be rectangular, must be on only one slice, and must be contiguous.

 See also create_mesh_subplots for plotting of all conditions in one graph.

 This function is part of froi, available from http://froi.sourceforge.net,
 and is governed under the Artistic License.

 $Id: view_mesh.m,v 1.2 2003/09/23 18:52:26 nknouf Exp $

CROSS-REFERENCE INFORMATION ^

This function calls:

This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function view_mesh(hvol, hoffset, ROIs, ROI, cond, timepoint)
0002 % view_mesh - view a surface plot of hemodynamic data for a single condition
0003 %
0004 % Usage: view_mesh(hvol, hoffset, ROIs, ROI, cond, <timepoint>)
0005 % where:
0006 %    hvol - a hmean volume, as the output of convert_hvolume
0007 %    hoffset - h-offset volume, loaded from the h-offset bshorts
0008 %    ROIs - a ROI structure with at least two elements:
0009 %        nconditions - number conditions (excluding fixation)
0010 %        mesh_type - 1 for display in raw scanner units
0011 %                2 for display in percent signal change
0012 %    ROI - your ROI in the standard format
0013 %    cond - condition to plot; fixation is always condition 1
0014 %    timepoint - (optional) timepoint to plot for FIR analyses
0015 %
0016 % view_mesh allows the user to display the results of the FS-FAST program
0017 % selxavg-sess for a particular ROI in the form of a "surface" plot, where
0018 % high and low values are mapped to high and low points in a 3D space,
0019 % respectively.  Note that for this surface to be possible, your ROI
0020 % must be rectangular, must be on only one slice, and must be contiguous.
0021 %
0022 % See also create_mesh_subplots for plotting of all conditions in one graph.
0023 %
0024 % This function is part of froi, available from http://froi.sourceforge.net,
0025 % and is governed under the Artistic License.
0026 %
0027 % $Id: view_mesh.m,v 1.2 2003/09/23 18:52:26 nknouf Exp $
0028 
0029 %% argument checking
0030 if (nargin < 6)
0031     timepoint = 1;
0032 end
0033 
0034 %% ensure ROI has only one slice
0035 if (size(unique(ROI(:,1))) ~= [1 1])
0036     error('You must have only on slice in your ROI\n');
0037 end
0038 
0039 %% find the unique slice number
0040 slice = unique(ROI(:,1));
0041 
0042 %% find the unique x and y coordinates
0043 x = sort(unique(ROI(:,2)));
0044 y = sort(unique(ROI(:,3)));
0045 
0046 %% find the range of the x and y coordinates; this will allow us to determine
0047 %% if the ROI is a rectangle or not
0048 xrange = [x(1,1):x(end,1)];
0049 yrange = [y(1,1):y(end,1)];
0050 
0051 if (size(x) ~= [size(xrange,2) size(xrange,1)])
0052     error('Your ROI must be contiguous and in a rectange; error in your x direction\n');
0053 elseif (size(y) ~= [size(yrange,2) size(yrange,1)])
0054     error('Your ROI must be contiguous and in a rectange; error in your y direction\n');
0055 end
0056 
0057 %% get parameters from the input volume
0058 [numSlices, row, col, numConds] = size(hvol);
0059 hvoltemp = zeros(size(hvol));
0060 
0061 %% get the correct timepoint
0062 for i=1:(ROIs.nconditions + 1)
0063     hvoltemp(:,:,:,i) = squeeze(hvol(:,:,:,i,timepoint));
0064 end
0065 
0066 hvol = hvoltemp;
0067 clear hvoltemp;
0068 
0069 ROI = expandROI(ROI, [numSlices row col]);
0070 
0071 %% take only the points in our ROI
0072 for i=1:numConds
0073     htemp(i,:,:) = squeeze(hvol(slice,:,:,i).*ROI(slice,:,:));    
0074     hshow(i,:,:) = squeeze(htemp(i,x(1,1):x(end,1),y(1,1):y(end,1)));
0075 end
0076 
0077 if (ROIs.mesh_type == 2) %% percent signal change
0078     temp = squeeze(hoffset(slice,x(1,1):x(end,1),y(1,1):y(end,1)));
0079     hshow = ((squeeze(hshow(cond,:,:)))./(temp))*100;
0080     hsurf = surf(y, x, fliplr(hshow));
0081     zlabel('mean response (percent signal change)');
0082 elseif (ROIs.mesh_type == 1) %% scanner units
0083     hsurf = surf(y, x, fliplr(squeeze(hshow(cond,:,:))));
0084     zlabel('mean response (scanner units)');
0085 end
0086 
0087 %% setup viewing and labels
0088 view(140, 30);
0089 shading interp;
0090 xlabel('column');
0091 ylabel('row');
0092 title('surface plot');

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