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

📄 avw_view_old.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.
%

% $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
%                    The Analyze format is copyright 
%                    (c) Copyright, 1986-1995
%                    Biomedical Imaging Resource, Mayo Foundation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if ~exist('avw','var'),
    msg = sprintf('AVW_VIEW: No input avw - see help avw_view\n');
    error(msg);
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


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
G.Ha = 0;
G.Hc = 0;
G.Hs = 0;

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

% Axial Slice
if xdim > 1 & ydim > 1,
	
	[x,y] = meshgrid(1:xdim,1:ydim);
	Xaxial = x'; clear x;
	Yaxial = y'; clear y;
	Zaxial = zeros(xdim,ydim);
	
	G.Aa = subplot('position',[0.05 0.56 0.4 0.4]);
	colormap('gray');
	Saxial = uint8(squeeze(avw.img(:,:,AxiSlice)));
	%G.Ha = surf(Xaxial,Yaxial,Zaxial,Saxial,'EdgeColor','none');
	
    G.Ha = imagesc([0, xdim],[0, ydim],Saxial);
    
    
    axis square, daspect([1,1,1]);
	xlabel('(Left <<) X (>> Right)')
	ylabel('Y')
	zlabel('Z')
	title('Axial')
	view([0,90]);
	
	% 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 = 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); drawnow;',...
        '   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); drawnow;',...
        '   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); drawnow;',...
            'set(AVWVIEW.handles.Taxi,''String'',num2str(AxiSlice));',...
            'CorSlice = round(get(AVWVIEW.handles.Scor,''Value''));',...
            'SagSlice = round(get(AVWVIEW.handles.Ssag,''Value''));',...
            'imgvalue = 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,
	
	[x,z] = meshgrid(1:xdim,1:zdim);
	Xcor = x'; clear x;
	Zcor = z'; clear z;
	Ycor = zeros(xdim,zdim);
	
	subplot('position',[0.55 0.56 0.4 0.4])
	colormap('gray');
	Scor = squeeze(avw.img(:,CorSlice,:));
	
	G.Hc = surf(Xcor,Ycor,Zcor,Scor,'EdgeColor','none');
	axis square, daspect([1,1,1]);
    xlabel('(Left <<) X (>> Right)')
	ylabel('Y')
	zlabel('Z')
	title('Coronal')
	view([0,0]);
	
	% 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,3)); ',...
        'CorSlice = round(str2num(get(AVWVIEW.handles.Tcor,''String''))); ',...
        'imgvalue = 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); drawnow;',...
        '   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); drawnow;',...
        '   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',...
            'BusyAction','queue',...
            'Min',1,'Max',ydim,'SliderStep',slider_step,'Value',CorSlice,...
            'Callback',strcat('AVWVIEW = get(gcbf,''Userdata''); ',...
            'CorSlice = round(get(AVWVIEW.handles.Scor,''Value''));',...
            'set(AVWVIEW.handles.Scor,''Value'',CorSlice);',...
            'Scor = squeeze(AVWVIEW.avw.img(:,CorSlice,:));',...
            'set(AVWVIEW.handles.Hc,''CData'',Scor); drawnow;',...
            'set(AVWVIEW.handles.Tcor,''String'',num2str(CorSlice));',...
            'AxiSlice = round(get(AVWVIEW.handles.Saxi,''Value''));',...
            'SagSlice = round(get(AVWVIEW.handles.Ssag,''Value''));',...
            'imgvalue = AVWVIEW.avw.img(SagSlice,CorSlice,AxiSlice); ',...
            'set(AVWVIEW.handles.imval,''String'',sprintf(''%8.2f'',imgvalue));',...
            'set(AVWVIEW.gui,''UserData'',AVWVIEW);',...
            'clear imgvalue Scor AxiSlice CorSlice SagSlice AVWVIEW;'));

⌨️ 快捷键说明

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