📄 avw_view.m
字号:
function [ varargout ] = avw_view(avw,parent,command),
% avw_view - create and navigate ortho views of Analyze 7.5 volume
%
% [ avw ] = avw_view([avw], [parent], [command])
%
% avw - a struct, created by avw_read; if omitted, a gui file locator will
% prompt for a .hdr file.
%
% parent - an optional handle to the gui that calls this gui, useful for
% updating the UserData field of the parent. The avw structure may be
% returned to the parent, if possible.
%
% command - an optional string, such as 'init' or various callback
% commands, 'init' is the default.
%
% The navigation is by sliders, mouse clicks and arrow keys. Right mouse
% clicks on any ortho-view will show a command menu, for simple block
% region of interest (ROI) calculations, image zoom, and save image. The
% ROI calculations are returned into avw.stats.
%
% Fiducial points can be selected, which are returned into 'avw.fiducials'
% in the base workspace. These points are given in several coordinate
% frameworks (voxels, mm, and meters), with values given relative to an
% origin located at the "center" of the MRI volume (see avw_center, which
% returns abs and corner values, abs used here).
%
% The AC location can be selected and the values are returned into 'avw.ac'
% in the base workspace. These points are given in voxels, mm & meters; for
% the latter, the values are given as offsets from the "center" of the MRI
% volume (see avw_center).
%
% +X is left (L), +Y is anterior (A), +Z is superior (S), the default LAS
% orientation of the Analyze 7.5 format. The coordinate system is left
% handed. This is the radiological convention, as opposed to the
% neurological convention (RAS). The latter can be emulated by using the
% 'Flip L/R' button.
%
% Example of loading and viewing the SPM T1 template:
% avw = avw_read('T1')
% avw = avw_view(avw);
%
% Similarly, just 'avw_view' can be typed at the command prompt and you can
% use the gui file locator to select any .hdr file.
%
% See also, avw_read, avw_img_read, avw_hdr_read
%
% $Revision: 1.12 $ $Date: 2004/04/08 20:09:34 $
% Licence: GNU GPL, no express or implied warranties
% History: 06/2002, Darren.Weber_at_flinders.edu.au
% 10/2002, Darren.Weber_at_flinders.edu.au
% added fiducial point determination
% changed plots from surf to imagesc commands
% added handling of datatype for avw.img
% altered daspect to use avw.hdr.dime.pixdim
% altered color scheme
% 01/2003, Darren.Weber_at_flinders.edu.au
% added parent GUI handling
% 10/2003, Darren.Weber_at_radiology.ucsf.edu
% added right click options, including simple block ROI
% functions, zoom and save image
% 11/2003, Darren.Weber_at_radiology.ucsf.edu
% added arrow key navigation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if gcbf,
AVWVIEW = get(gcbf,'Userdata');
end
if ~exist('command','var'), command = 'init'; end
command = lower(command);
% Check for specific keys and assign command
if strcmp(command, 'keypress'),
cc = get(AVWVIEW.gui,'CurrentCharacter');
cc = double(cc);
if cc,
switch cc,
case 27, command = 'quit'; % ESC
case 28, command = 'left'; % left
case 29, command = 'right'; % right
case 30, command = 'up'; % up
case 31, command = 'down'; % down
otherwise, return; % all other keys
end
end
end
switch command,
case 'init',
if ~exist('avw','var'),
avw = avw_read;
end
if nargin == 0,
AVWVIEW = init(avw);
elseif isempty(inputname(1)),
AVWVIEW = init(avw);
else
AVWVIEW = init(avw,inputname(1));
end
AVWVIEW = set_coordinates(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'coordinates',
AVWVIEW = set_coordinates(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'crosshairs',
AVWVIEW = set_crosshairs(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'axial_image','coronal_image','sagittal_image'},
switch command,
case 'axial_image', AVWVIEW.view = 'axi'; axi_update = 0; cor_update = 1; sag_update = 1;
case 'coronal_image', AVWVIEW.view = 'cor'; axi_update = 1; cor_update = 0; sag_update = 1;
case 'sagittal_image', AVWVIEW.view = 'sag'; axi_update = 1; cor_update = 1; sag_update = 0;
end
AVWVIEW = get_current_position(AVWVIEW);
if axi_update,
axial_update(AVWVIEW);
end
if cor_update,
coronal_update(AVWVIEW);
end;
if sag_update,
sagittal_update(AVWVIEW);
end;
set_display_values(AVWVIEW);
AVWVIEW = set_crosshairs(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'axial_slider','coronal_slider','sagittal_slider'},
switch command,
case 'axial_slider',
AVWVIEW.view = 'axi';
AVWVIEW = get_slider_position(AVWVIEW);
axial_update(AVWVIEW);
case 'coronal_slider',
AVWVIEW.view = 'cor';
AVWVIEW = get_slider_position(AVWVIEW);
coronal_update(AVWVIEW);
case 'sagittal_slider',
AVWVIEW.view = 'sag';
AVWVIEW = get_slider_position(AVWVIEW);
sagittal_update(AVWVIEW);
end
set_display_values(AVWVIEW);
AVWVIEW = set_crosshairs(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'left','right','up','down'},
AVWVIEW = get_slider_position(AVWVIEW);
% what axes are we in?
if isequal(gca, AVWVIEW.handles.axial_axes),
switch command,
case 'left',
% decrease sagittal slice
if AVWVIEW.slices.sag > 1,
AVWVIEW.slices.sag = AVWVIEW.slices.sag - 1;
end
case 'right',
% increase sagittal slice
if AVWVIEW.slices.sag < AVWVIEW.xdim,
AVWVIEW.slices.sag = AVWVIEW.slices.sag + 1;
end
case 'up',
% increase coronal slice
if AVWVIEW.slices.cor < AVWVIEW.ydim,
AVWVIEW.slices.cor = AVWVIEW.slices.cor + 1;
end
case 'down',
% decrease coronal slice
if AVWVIEW.slices.cor > 1,
AVWVIEW.slices.cor = AVWVIEW.slices.cor - 1;
end
end
switch command,
case {'left','right'}
set(AVWVIEW.handles.sagittal_slider,'Value',AVWVIEW.slices.sag);
Ssag = squeeze(AVWVIEW.avw.img(AVWVIEW.slices.sag,:,:));
set(AVWVIEW.handles.sagittal_image,'CData',Ssag');
set(AVWVIEW.handles.sagittal_sliderN,'String',num2str(AVWVIEW.slices.sag));
set(AVWVIEW.handles.sagittal_sliderN,'Value',AVWVIEW.slices.sag);
case {'up','down'},
set(AVWVIEW.handles.coronal_slider,'Value',AVWVIEW.slices.cor);
Scor = squeeze(AVWVIEW.avw.img(:,AVWVIEW.slices.cor,:));
set(AVWVIEW.handles.coronal_image,'CData',Scor');
set(AVWVIEW.handles.coronal_sliderN,'String',num2str(AVWVIEW.slices.cor));
set(AVWVIEW.handles.coronal_sliderN,'Value',AVWVIEW.slices.cor);
end
end
if isequal(gca, AVWVIEW.handles.coronal_axes),
switch command,
case 'left',
% decrease sagittal slice
if AVWVIEW.slices.sag > 1,
AVWVIEW.slices.sag = AVWVIEW.slices.sag - 1;
end
case 'right',
% increase sagittal slice
if AVWVIEW.slices.sag < AVWVIEW.xdim,
AVWVIEW.slices.sag = AVWVIEW.slices.sag + 1;
end
case 'up',
% increase axial slice
if AVWVIEW.slices.axi < AVWVIEW.zdim,
AVWVIEW.slices.axi = AVWVIEW.slices.axi + 1;
end
case 'down',
% decrease axial slice
if AVWVIEW.slices.axi > 1,
AVWVIEW.slices.axi = AVWVIEW.slices.axi - 1;
end
end
switch command,
case {'left','right'}
set(AVWVIEW.handles.sagittal_slider,'Value',AVWVIEW.slices.sag);
Ssag = squeeze(AVWVIEW.avw.img(AVWVIEW.slices.sag,:,:));
set(AVWVIEW.handles.sagittal_image,'CData',Ssag');
set(AVWVIEW.handles.sagittal_sliderN,'String',num2str(AVWVIEW.slices.sag));
set(AVWVIEW.handles.sagittal_sliderN,'Value',AVWVIEW.slices.sag);
case {'up','down'},
set(AVWVIEW.handles.axial_slider,'Value',AVWVIEW.slices.axi);
Saxi = squeeze(AVWVIEW.avw.img(:,:,AVWVIEW.slices.axi));
set(AVWVIEW.handles.axial_image,'CData',Saxi');
set(AVWVIEW.handles.axial_sliderN,'String',num2str(AVWVIEW.slices.axi));
set(AVWVIEW.handles.axial_sliderN,'Value',AVWVIEW.slices.axi);
end
end
if isequal(gca, AVWVIEW.handles.sagittal_axes),
switch command,
case 'left',
% decrease sagittal slice
if AVWVIEW.slices.cor > 1,
AVWVIEW.slices.cor = AVWVIEW.slices.cor - 1;
end
case 'right',
% increase sagittal slice
if AVWVIEW.slices.cor < AVWVIEW.ydim,
AVWVIEW.slices.cor = AVWVIEW.slices.cor + 1;
end
case 'up',
% increase axial slice
if AVWVIEW.slices.axi < AVWVIEW.zdim,
AVWVIEW.slices.axi = AVWVIEW.slices.axi + 1;
end
case 'down',
% decrease axial slice
if AVWVIEW.slices.axi > 1,
AVWVIEW.slices.axi = AVWVIEW.slices.axi - 1;
end
end
switch command,
case {'left','right'}
set(AVWVIEW.handles.coronal_slider,'Value',AVWVIEW.slices.cor);
Scor = squeeze(AVWVIEW.avw.img(:,AVWVIEW.slices.cor,:));
set(AVWVIEW.handles.coronal_image,'CData',Scor');
set(AVWVIEW.handles.coronal_sliderN,'String',num2str(AVWVIEW.slices.cor));
set(AVWVIEW.handles.coronal_sliderN,'Value',AVWVIEW.slices.cor);
case {'up','down'},
set(AVWVIEW.handles.axial_slider,'Value',AVWVIEW.slices.axi);
Saxi = squeeze(AVWVIEW.avw.img(:,:,AVWVIEW.slices.axi));
set(AVWVIEW.handles.axial_image,'CData',Saxi');
set(AVWVIEW.handles.axial_sliderN,'String',num2str(AVWVIEW.slices.axi));
set(AVWVIEW.handles.axial_sliderN,'Value',AVWVIEW.slices.axi);
end
end
AVWVIEW = set_crosshairs(AVWVIEW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'roi_9','roi_7','roi_5','roi_3'},
position = [ AVWVIEW.slices.sag, AVWVIEW.slices.cor, AVWVIEW.slices.axi ];
shape.type = 'block';
if findstr(command,'9'), shape.size = [9,9,9]; end
if findstr(command,'7'), shape.size = [7,7,7]; end
if findstr(command,'5'), shape.size = [5,5,5]; end
if findstr(command,'3'), shape.size = [3,3,3]; end
stats.roi = avw_roi(AVWVIEW.avw,position,shape);
AVWVIEW.avw.stats = avw_stats(stats);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'nasion','rpa','lpa','ac'},
% return voxel coordinates into AVWVIEW.imgXYZ
AVWVIEW = slices2metric(AVWVIEW);
if get(AVWVIEW.handles.coord,'value') == 2,
format = '%7.3f %7.3f %7.3f';
imgXYZ = AVWVIEW.imgXYZ.mm;
string = sprintf('%7.3f %7.3f %7.3f',imgXYZ);
elseif get(AVWVIEW.handles.coord,'value') == 3,
format = '%7.3f %7.3f %7.3f';
imgXYZ = AVWVIEW.imgXYZ.meters;
string = sprintf('%7.3f %7.3f %7.3f',imgXYZ);
else
imgXYZ = AVWVIEW.imgXYZ.voxels;
string = sprintf('%7.0f %7.0f %7.0f',imgXYZ);
end;
switch command,
case 'nasion',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -