⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avw_view_test.m

📁 mri_toolbox是一个工具用来MRI. 来自于SourceForge, 我上传这个软件,希望能结识对医疗软件感兴趣的兄弟.
💻 M
📖 第 1 页 / 共 2 页
字号:
function avw_view(avw),

% AVW_VIEW: Create and navigate ortho views of Analyze file
%
% avw_view(avw)
%
% avw    -  a struct, created by avw_img_read
%
% The navigation is by sliders and mouse clicks on the
% images in any of the ortho views.
% Fiducial points can be selected, which are returned
% into mriFID or p.mriFID in the base workspace.  These
% points are given in meters, with an origin translated 
% from the center of the MRI volume to (0,0,0).  +X is
% right, +Y is anterior, +Z is superior, the default RAS
% orientation of Analyze MRI files.
%
% See also, AVW_IMG_READ
% 

% $Revision: 1.1 $ $Date: 2003/07/09 05:27:37 $

% Licence:  GNU GPL, no express or implied warranties
% History:  06/2002, Darren.Weber@flinders.edu.au
%           10/2002, Darren.Weber@flinders.edu.au
%                    added fiducial point determination
%                    changed plots from surf to imagesc commands
%                    added initial handling of datatype for avw.img
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if ~exist('avw','var'),
    msg = sprintf('...no input avw - see help avw_view\n');
    error(msg);
end


% use the correct datatype of avw.img
switch double(avw.hdr.dime.bitpix),
case 1,
    fprintf('...converting avw.img to uint8\n');
    avw.img = uint8(avw.img);
case 8,
    fprintf('...converting avw.img to uint8\n');
    avw.img = uint8(avw.img);
case 16,
    fprintf('...converting avw.img to uint16\n');
    avw.img = uint16(avw.img);
case {32,64},
    fprintf('...ensuring avw.img is double\n');
    % make sure it is double
    avw.img = double(avw.img);
otherwise,
    % do nothing, leave it as is
end



% GUI General Parameters
GUIwidth  = 150;
GUIheight = 50;
if isfield(avw,'fileprefix'),
    if isempty(avw.fileprefix),
        name = 'AVW View';
    else
        format = strcat('%+',sprintf('%d',length(avw.fileprefix)+1),'s');
        name = strcat('AVW View - ',sprintf(format,avw.fileprefix));
    end
else
    name = 'AVW View';
end

GUI = figure('Name',name,'Tag','AVWVIEW','units','characters',...
             'NumberTitle','off',...
             'MenuBar','figure','Position',[1 1 GUIwidth GUIheight]);
movegui(GUI,'center');

AVWVIEW.gui = GUI;


Font.FontName   = 'Helvetica';
Font.FontUnits  = 'Pixels';
Font.FontSize   = 12;
Font.FontWeight = 'normal';
Font.FontAngle  = 'normal';


shading flat


% Determine image size and origin (center)

xdim = size(avw.img,1);
ydim = size(avw.img,2);
zdim = size(avw.img,3);

SagSlice = 1;
CorSlice = 1;
AxiSlice = 1;
if xdim > 1, SagSlice = floor(xdim/2); end
if ydim > 1, CorSlice = floor(ydim/2); end
if zdim > 1, AxiSlice = floor(zdim/2); end

AVWVIEW.origin = [SagSlice,CorSlice,AxiSlice];             % vol origin
AVWVIEW.scale  = double(avw.hdr.dime.pixdim(2:4)) ./ 1000; % vol scale in meters


% Initialise some window handles, useful if the input image is only 2D
G.Ha = 0;
G.Hc = 0;
G.Hs = 0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Axial Slice
if xdim > 1 & ydim > 1,
	
	G.Aa = subplot('position',[0.05 0.56 0.4 0.4]);
	colormap('gray');
    
	Saxial = squeeze(avw.img(:,:,AxiSlice));
    G.Ha = imagesc([0,xdim],[0,ydim],Saxial');
    set(gca,'YDir','normal')
    
    axis square, daspect([1,1,1]);
	xlabel('(Left <<) X (>> Right)')
	ylabel('Y')
	title('Axial')
	
	% This callback navigates with left click
	set(G.Ha,'ButtonDownFcn',...
        strcat('AVWVIEW = get(gcbf,''Userdata''); ',...
        'currentpoint = get(get(AVWVIEW.handles.Ha,''Parent''),''CurrentPoint''); ',...
        'SagSlice = round(currentpoint(2,1)); ',...
        'CorSlice = round(currentpoint(2,2)); ',...
        'AxiSlice = round(str2num(get(AVWVIEW.handles.Taxi,''String''))); ',...
        'imgvalue = double(AVWVIEW.avw.img(SagSlice,CorSlice,AxiSlice)); ',...
        'set(AVWVIEW.handles.imval,''String'',sprintf(''%8.2f'',imgvalue));',...
        'set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'if ishandle(AVWVIEW.handles.Hs) & AVWVIEW.handles.Hs, ',...
        '   Ssag = squeeze(AVWVIEW.avw.img(SagSlice,:,:));',...
        '   set(AVWVIEW.handles.Hs,''CData'',Ssag''); ',...
        '   set(AVWVIEW.handles.Tsag,''String'',num2str(SagSlice));',...
        '   set(AVWVIEW.handles.Ssag,''Value'',SagSlice);',...
        '   clear Ssag; ',...
        '   set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'end; ',...
        'if ishandle(AVWVIEW.handles.Hc) & AVWVIEW.handles.Hc, ',...
        '   Scor = squeeze(AVWVIEW.avw.img(:,CorSlice,:));',...
        '   set(AVWVIEW.handles.Hc,''CData'',Scor''); ',...
        '   set(AVWVIEW.handles.Tcor,''String'',num2str(CorSlice));',...
        '   set(AVWVIEW.handles.Scor,''Value'',CorSlice);',...
        '   clear Scor; ',...
        '   set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'end; ',...
        'clear currentpoint imgvalue AxiSlice CorSlice SagSlice AVWVIEW;'));
    
    if zdim > 1,
		slider_step(1) = 1/(zdim);
		slider_step(2) = 1/(zdim);
		G.Saxi = uicontrol('Parent',GUI,'Style','slider','Units','Normalized', Font, ...
            'Position',[.45 .56 .03 .40], 'HorizontalAlignment', 'center',...
            'BusyAction','queue',...
            'Min',1,'Max',zdim,'SliderStep',slider_step,'Value',AxiSlice,...
            'Callback',strcat('AVWVIEW = get(gcbf,''Userdata''); ',...
            'AxiSlice = round(get(AVWVIEW.handles.Saxi,''Value''));',...
            'set(AVWVIEW.handles.Saxi,''Value'',AxiSlice);',...
            'Saxi = squeeze(AVWVIEW.avw.img(:,:,AxiSlice));',...
            'set(AVWVIEW.handles.Ha,''CData'',Saxi''); ',...
            'set(AVWVIEW.handles.Taxi,''String'',num2str(AxiSlice));',...
            'CorSlice = round(get(AVWVIEW.handles.Scor,''Value''));',...
            'SagSlice = round(get(AVWVIEW.handles.Ssag,''Value''));',...
            'imgvalue = double(AVWVIEW.avw.img(SagSlice,CorSlice,AxiSlice)); ',...
            'set(AVWVIEW.handles.imval,''String'',sprintf(''%8.2f'',imgvalue));',...
            'set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
            'clear imgvalue Saxi AxiSlice CorSlice SagSlice AVWVIEW;'));
    end
	G.Taxi = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
        'Position',[.45 .51 .03 .05], 'HorizontalAlignment', 'center',...
        'BusyAction','queue',...
        'String',num2str(AxiSlice));
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Coronal Slice
if xdim > 1 & zdim > 1,
	
	subplot('position',[0.55 0.56 0.4 0.4])
	colormap('gray');
    
	Scor = squeeze(avw.img(:,CorSlice,:));
    G.Hc = imagesc([0,ydim],[0,zdim],Scor');
    set(gca,'YDir','normal')
    
	axis square, daspect([1,1,1]);
    xlabel('(Left <<) X (>> Right)')
	ylabel('Z')
	title('Coronal')
	
	% This callback navigates with left click
	set(G.Hc,'ButtonDownFcn',...
        strcat('AVWVIEW = get(gcbf,''Userdata''); ',...
        'currentpoint = get(get(AVWVIEW.handles.Hc,''Parent''),''CurrentPoint''); ',...
        'SagSlice = round(currentpoint(2,1)); ',...
        'AxiSlice = round(currentpoint(2,2)); ',...
        'CorSlice = round(str2num(get(AVWVIEW.handles.Tcor,''String''))); ',...
        'imgvalue = double(AVWVIEW.avw.img(SagSlice,CorSlice,AxiSlice)); ',...
        'set(AVWVIEW.handles.imval,''String'',sprintf(''%8.2f'',imgvalue));',...
        'set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'if ishandle(AVWVIEW.handles.Hs) & AVWVIEW.handles.Hs, ',...
        '   Ssag = squeeze(AVWVIEW.avw.img(SagSlice,:,:));',...
        '   set(AVWVIEW.handles.Hs,''CData'',Ssag''); ',...
        '   set(AVWVIEW.handles.Tsag,''String'',num2str(SagSlice));',...
        '   set(AVWVIEW.handles.Ssag,''Value'',SagSlice);',...
        '   clear Ssag; ',...
        '   set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'end; ',...
        'if ishandle(AVWVIEW.handles.Ha) & AVWVIEW.handles.Ha, ',...
        '   Saxi = squeeze(AVWVIEW.avw.img(:,:,AxiSlice));',...
        '   set(AVWVIEW.handles.Ha,''CData'',Saxi''); ',...
        '   set(AVWVIEW.handles.Taxi,''String'',num2str(AxiSlice));',...
        '   set(AVWVIEW.handles.Saxi,''Value'',AxiSlice);',...
        '   clear Saxi; ',...
        '   set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
        'end; ',...
        'clear currentpoint imgvalue AxiSlice CorSlice SagSlice AVWVIEW;'));
    
    if ydim > 1,
        slider_step(1) = 1/(ydim);
		slider_step(2) = 1/(ydim);
		G.Scor = uicontrol('Parent',GUI,'Style','slider','Units','Normalized', Font, ...
            'Position',[.95 .56 .03 .40], 'HorizontalAlignment', 'center',...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -