Home > bioelectromagnetism > avw_view3.m

avw_view3

PURPOSE ^

AVW_VIEW3 - Create slices of Analyze file and overlay surface vertices

SYNOPSIS ^

function avw_view3(avw,FV),

DESCRIPTION ^

 AVW_VIEW3 - Create slices of Analyze file and overlay surface vertices
 
 avw_view3(avw,FV)
 
 avw - a struct, created by avw_img_read
 FV  - a surface struct with fields FV.vertices, FV.faces
 
 This provides a transparent 3D view of ortho slices, to
 provide a platform for overlay of mesh/tesselation vertices,
 given in FV.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function avw_view3(avw,FV),
0002 
0003 % AVW_VIEW3 - Create slices of Analyze file and overlay surface vertices
0004 %
0005 % avw_view3(avw,FV)
0006 %
0007 % avw - a struct, created by avw_img_read
0008 % FV  - a surface struct with fields FV.vertices, FV.faces
0009 %
0010 % This provides a transparent 3D view of ortho slices, to
0011 % provide a platform for overlay of mesh/tesselation vertices,
0012 % given in FV.
0013 %
0014 
0015 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
0016 
0017 % Licence:  GNU GPL, no express or implied warranties
0018 % History:  08/2002, Darren.Weber@flinders.edu.au
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 
0023 if ~exist('avw','var'),
0024     msg = sprintf('AVW_VIEW3: No input avw - see help avw_view\n');
0025     error(msg);
0026 end
0027 if ~exist('FV','var'),
0028     FV.vertices = [];
0029 end
0030 
0031 
0032 % GUI General Parameters
0033 GUIwidth  = 150;
0034 GUIheight = 50;
0035 
0036 name = 'AVW View 3D';
0037 if isfield(avw,'fileprefix'),
0038     if ~isempty(avw.fileprefix),
0039         format = strcat('%+',sprintf('%d',length(avw.fileprefix)+1),'s');
0040         name = strcat('AVW View 3D - ',sprintf(format,avw.fileprefix));
0041     end
0042 end
0043 
0044 GUI = figure('Name',name,'Tag','AVWVIEW3','units','characters',...
0045              'NumberTitle','off',...
0046              'MenuBar','figure','Position',[1 1 GUIwidth GUIheight]);
0047 movegui(GUI,'center');
0048 
0049 AVWVIEW3.gui = GUI;
0050 
0051 
0052 Font.FontName   = 'Helvetica';
0053 Font.FontUnits  = 'Pixels';
0054 Font.FontSize   = 12;
0055 Font.FontWeight = 'normal';
0056 Font.FontAngle  = 'normal';
0057 
0058 
0059 shading flat
0060 
0061 xdim = size(avw.img,1);
0062 ydim = size(avw.img,2);
0063 zdim = size(avw.img,3);
0064 
0065 SagSlice = 1;
0066 CorSlice = 1;
0067 AxiSlice = 1;
0068 if xdim > 1, SagSlice = floor(xdim/2); end
0069 if ydim > 1, CorSlice = floor(ydim/2); end
0070 if zdim > 1, AxiSlice = floor(zdim/2); end
0071 
0072 
0073 % data aspect should be proportional to image dimensions
0074 % Should check header for these values
0075 
0076 
0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0079 
0080 % The slice command swaps x/y axes - really annoying!
0081 G.H = slice(avw.img,SagSlice,CorSlice,AxiSlice,'nearest');
0082 set(G.H,'edgecolor','none','facealpha',.7);
0083 axis tight, daspect([1,1,1]);
0084 colormap('gray');
0085 xlabel('Coronal')
0086 ylabel('Sagittal')
0087 zlabel('Axial')
0088 view(3)
0089 
0090 %axis off
0091 
0092 % Overlay plot of surface vertices
0093 if ~isempty(FV.vertices),
0094     hold on;
0095     % The above slice command swaps x/y axes, so we have to
0096     % mess around here to get the vertices in the right place
0097     
0098     % rotate the vertices -90 degrees around Z
0099     FV.vertices = Rz(FV.vertices,-90,'degrees');
0100     % Now move vertices from axis origin to the true MRI volume center
0101     FV.vertices(:,1) = FV.vertices(:,1) + SagSlice;
0102     FV.vertices(:,2) = FV.vertices(:,2) + CorSlice;
0103     FV.vertices(:,3) = FV.vertices(:,3) + AxiSlice;
0104     % Now shift it according to the x/y flip
0105     FV.vertices(:,1) = FV.vertices(:,1) - (SagSlice - CorSlice);
0106     FV.vertices(:,2) = FV.vertices(:,2) - (CorSlice - SagSlice);
0107     
0108     %plot3(FV.vertices(:,1),FV.vertices(:,2),FV.vertices(:,3),'r.');
0109     patch('vertices',FV.vertices,'faces',FV.faces,...
0110           'FaceColor',[0.0 0.0 0.2],'Edgecolor','none',...
0111           'FaceAlpha',0.5);
0112 end
0113 
0114 rotate3d;
0115 
0116 
0117 
0118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0120 
0121 % Intensity Value at Mouse Click
0122 
0123 %G.Timval = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
0124 %    'Position',[.05 .90 .20 .05], 'HorizontalAlignment', 'center',...
0125 %    'BusyAction','queue',...
0126 %    'String','Image Intensity');
0127 %G.imval = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
0128 %    'Position',[.25 .90 .10 .05], 'HorizontalAlignment', 'right',...
0129 %    'BusyAction','queue',...
0130 %    'String','?');
0131 
0132 
0133 
0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0136 
0137 Font.FontWeight = 'bold';
0138 
0139 % OK: Return the avw!
0140 G.Bhdr = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0141     'Position',[.8 .95 .08 .04],...
0142     'String','HDR','BusyAction','queue',...
0143     'TooltipString','View the hdr parameters.',...
0144     'BackgroundColor',[0.0 0.0 0.5],...
0145     'ForegroundColor',[1 1 1], 'HorizontalAlignment', 'center',...
0146     'Callback',strcat('AVWVIEW3 = get(gcbf,''Userdata''); ',...
0147     'avw_view_hdr(AVWVIEW3.avw);',...
0148     'clear AVWVIEW3;'));
0149 
0150 % Cancel
0151 G.Bquit = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0152     'Position',[.9 .95 .08 .04],...
0153     'String','CLOSE','BusyAction','queue',...
0154     'BackgroundColor',[0.75 0.0 0.0],...
0155     'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0156     'Callback','close gcbf;');
0157 
0158 
0159 % Update the gui_struct handles for this gui
0160 AVWVIEW3.avw = avw;
0161 AVWVIEW3.FV = FV;
0162 AVWVIEW3.handles = G;
0163 set(AVWVIEW3.gui,'Userdata',AVWVIEW3);
0164 %set(AVWVIEW3.gui,'HandleVisibility','callback');
0165 
0166 return
0167

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003