📄 mia_gui.m
字号:
function varargout = mia_gui(varargin)
% mia_GUI M-file for mia_gui.fig
% mia_GUI, by itself, creates a new mia_GUI or raises the existing
% singleton*.
%
% H = mia_GUI returns the handle to a new mia_GUI or the handle to
% the existing singleton*.
%
% mia_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in mia_GUI.M with the given input arguments.
%
% mia_GUI('Property','Value',...) creates a new mia_GUI or raises the
% existing singleton*. Starting from the left, property value pairs
% are
% applied to the GUI before mia_gui_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mia_gui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help mia_gui
% Last Modified by GUIDE v2.5 29-Jun-2004 01:24:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mia_gui_OpeningFcn, ...
'gui_OutputFcn', @mia_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before mia_gui is made visible.
function mia_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to mia_gui (see VARARGIN)
%zoom and opengl does not work well with some video card
openglinfo = opengl('data');
handles.openglinfo.Renderer = openglinfo.Renderer;
handles.openglinfo.UseGenericOpenGL = 0;
handles.openglinfo.miafigure_useOpenGL = 0;
if strcmp(openglinfo.Renderer,'GeForce4 Ti 4200 with AGP8X/AGP/SSE2') | ...
strcmp(openglinfo.Renderer,'Savage4')
handles.openglinfo.UseGenericOpenGL = 1;
feature('UseGenericOpenGL',1); % turn off the hardwer version of opengl
else
handles.openglinfo.UseGenericOpenGL = 0;
end
% Choose default command line output for mia_gui
handles.output = hObject;
handles.ColorRes = 128; % used color resolution in color maps
handles.ROINumOfColor = 8; % number of color used for ROI coloring
handles.ROIColorStrings = ['y','m','c','r','g','b','w','k']; % color codes for ROI colors
handles.ROIColorStringsLong = cellstr(['yellow ';'magenta';'cyan ';'red '; ...
'green ';'blue ';'white ';'black ']); % long names for ROI colors
% initiate variables for image handlers of resliced maps
handles.haxial = []; handles.hcoronal= []; handles.hsagital= [];
handles.haxial2 = []; handles.hcoronal2= []; handles.hsagital2= [];
% initiate variables for image handlers of sliceomatic_mia and improfile tools
handles.sliceomatic_haxmain = [];
handles.hf_improfile = 0;
% set some deafult settings for GUI
set(handles.MeasureTogglebutton,'value',1);
set(handles.RoiColor4ToggleButton,'value',1);% red ROI color on
handles.CurrentROIColor = 4;
set(handles.RenderingLevelEdit,'String',[]);
set(handles.RenderingLevel2Edit,'String',[]);
set(handles.CurrentFrameEdit,'String',[]);
set(handles.CurrentSliceEdit,'String',[]);
set(handles.ImaAxes,'Yticklabel',{});
set(handles.ImaAxes,'Xticklabel',{});
set(handles.CurrentFrameLengthEdit,'visible','off');
set(handles.CurrentFrameLengthText,'visible','off');
set(handles.CurrentFrameTimeEdit,'visible','off');
set(handles.CurrentFrameTimeText,'visible','off');
set(handles.FrameSlider,'visible','off');
miaControlSetup(2,handles);
axes(handles.ImaAxes);
image(zeros(256,256,3));
axis off;
handles.DICOMDIRmenu_1Selected = 0;
handles.DICOMDIRmenu_2Selected = 0;
%defining the global variable for mia_pixval function
global gVOIpixval;
gVOIpixval.pixunit = 'mm';
gVOIpixval.xypixsize = [];
gVOIpixval.CurrentImage = [];
gVOIpixval.CurrentAxes = handles.ImaAxes;
gVOIpixval.xLim = [];
gVOIpixval.yLim = [];
% set some menu items
set(handles.MouseSelected,'enable','off');
set(handles.MouseSelected2,'enable','off');
set(handles.DynFrameMovie,'enable','off');
set(handles.SaveDynFramesAsAvi,'enable','off');
set(handles.SumFrames,'enable','off');
set(handles.OpenDICOMDIRfromCurrent,'enable','off');
set(handles.Open2DICOMDIRfromCurrent,'enable','off');
if ~ispc % no excel output
set(handles.SaveTACMenuItem,'label','Save VOI TAC (as txt file) ');
set(handles.SaveROIStatMenuItem,'label','Save ROI statistics (as txt file)');
end
if nargin == 4
handles.inputpath = char(varargin{1});
% Update handles structure
guidata(hObject, handles);
else
%handles.scaninfo = varargin{2};
% Update handles structure
guidata(hObject, handles);
end
if str2double(license) == (206212) & ispc
tmp = userinfo;
end
% UIWAIT makes mia_gui wait for user response (see UIRESUME)
% uiwait(handles.mia_figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mia_gui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function OpenImage()
OpenImageFilemenuItem_Callback(handles.OpenImageFilemenuItem, [], handles);
% --------------------------------------------------------------------
function OpenImageFilemenuItem_Callback(hObject, eventdata, handles)
% hObject handle to OpenImageFilemenuItem (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~handles.DICOMDIRmenu_1Selected
dicomdirYES = 0;
% if previous imaVOL is currently being opened delete and set
% the appropriate objects
if isfield(handles,'FileNames')
handles = ClearImages(handles,2);
drawnow;
set(handles.mia_figure1,'keyPressFcn','mia_gui(''mia_figure1_KeyPressFcn'',gcbo,[],guidata(gcbo))');
end
% if inputpath was supplied as varargin set this as startup_dir to uigetfiles.m
if isfield(handles,'inputpath')
if ispc
[FilesSelected, dir_path] = uigetfiles(...
'*.img;*.mnc;*.dcm;*.v;*.V;*.ima;*.cub;*.mat','Select image file',handles.inputpath);
else
[FilesSelected, dir_path] = uigetfiles2('Start', '*.*', handles.inputpath);
end
else
% if this is not the first file opening, use the handles.dirname as startup_dir to uigetfiles.m
if isfield(handles,'dirname')
if ispc
[FilesSelected, dir_path] = uigetfiles(...
'*.img;*.mnc;*.dcm;*.v;*.V;*.ima;*.cub;*.mat','Select image file',handles.dirname);
else
[FilesSelected, dir_path] = uigetfiles2('Start', '*.*', handles.dirname);
end
else
if ispc
[FilesSelected, dir_path] = uigetfiles(...
'*.img;*.mnc;*.dcm;*.v;*.V;*.ima;*.cub;*.mat','Select image file');
else
[FilesSelected, dir_path] = uigetfiles2('Start', '*.*');
end
end
end
else % if the open DICOMDIR menu item was selected
FilesSelected = handles.dcmdir.dcmSeries.Images';
dir_path = handles.dcmdir.dcmSeries.Path;
dicomdirYES = 1;
handles.DICOMDIRmenu_1Selected = 0;
end
if isempty(FilesSelected);return;end
handles.FileNames = sortrows(FilesSelected');
handles.dirname = dir_path;
%if isfield(handles,'inputpath')
% cd(matlabroot);
%end
%
% identify the file type :img, mnc or ima, and
% load the appropriate imaVOL
%
[fpath,fname,fextension,fversion] = fileparts(char(handles.FileNames(1)));
handles.fextension = char(fextension);
handles.fname = char(fname);
if strcmp(char(fextension),'.ima')
num_of_files = size(handles.FileNames,1);
for i=1:num_of_files
filelist(i).name = char(handles.FileNames(i));
end
filelist = filelist';
filename=[];jobinfo=1;
[handles.imaVOL, handles.scaninfo, handles.fileheader] = loadvaxima(filename,jobinfo,filelist,handles.dirname);
elseif strcmp(char(fextension),'.mnc')
[handles.imaVOL, handles.scaninfo] = loadminc([handles.dirname,char(handles.FileNames(1))]);
elseif strcmp(char(fextension),'.dcm') | strcmp(char(fextension),'') | dicomdirYES
[handles.imaVOL, handles.scaninfo] = loaddcm(handles.FileNames,handles.dirname);
elseif strcmp(lower(char(fextension)),'.v') | strcmp(lower(char(fextension)),'.V')
[handles.imaVOL, handles.scaninfo] = loadecat([handles.dirname,char(handles.FileNames(1))]);
elseif strcmp(char(fextension),'.img')
[handles.imaVOL, handles.scaninfo] = loadanalyze([handles.dirname,char(handles.FileNames(1))]);
elseif strcmp(char(fextension),'.cub')
[handles.imaVOL, handles.scaninfo] = loadcube([handles.dirname,char(handles.FileNames(1))]);
elseif strcmp(char(fextension),'.mat')
[handles.imaVOL, handles.scaninfo] = loadmat([handles.dirname,char(handles.FileNames(1))]);
else
hm = msgbox(['No image file was selected. The supported files are: ',...
'*.img;*.mnc;*.dcm;*.v;*.ima;*.cub;*.mat'],'mia Info' );
return;
end
if isempty(handles.imaVOL)% error during file opening
hm = msgbox('Error during file opening. For details See the Matlab Command Window','mia Info' );
return;
end
% set the default colormap to spectral
set(handles.ImaListbox,'String',handles.FileNames,...
'Value',1);
% inititate the ImaAxes figure
axes(handles.ImaAxes);
CurrentSlice = round(handles.scaninfo.num_of_slice/2);
CurrentImgIdx = handles.scaninfo.num_of_slice*(handles.scaninfo.Frames-1)+CurrentSlice;
CurrentImage = handles.imaVOL(:,:,handles.scaninfo.num_of_slice*(handles.scaninfo.Frames-1)+CurrentSlice);
CurrentImageMinMax = [min(CurrentImage(:)) max(CurrentImage(:)) ];
if CurrentImageMinMax(2) == 0
CurrentImageMinMax(2) = max(handles.imaVOL(:));
end
handles.VolMax = double(max(handles.imaVOL(:)));
handles.VolMin = double(min(handles.imaVOL(:)));
if handles.scaninfo.float % imaVOL type is float
handles.decimal_prec = 2;
else
handles.decimal_prec = 0;
end
%Create the RGB image
if strcmp(char(fextension),'.dcm') | strcmp(char(fextension),'') ...
| strcmp(char(fextension),'.cub') | strcmp(char(fextension),'.mat')
% in case of dcm, cube and mat file the default colormap is gray
Initial_cmap = gray(handles.ColorRes);
set(handles.ColorMapPopupmenu,'Value',3);
else
%otherwise the colormap spectral
set(handles.ColorMapPopupmenu,'Value',1);
Initial_cmap = spectral(handles.ColorRes);
end
CurrentImage_RGB = ...
CreateRGBImage(CurrentImage,CurrentImageMinMax,handles.ColorRes,Initial_cmap);
ImaHandler = image(CurrentImage_RGB);
set(handles.ImaAxes,'PlotBoxAspectRatioMode','manual');
PlotBAspectRatio = [ size(handles.imaVOL,2)*handles.scaninfo.pixsize(2) ...
size(handles.imaVOL,1)*handles.scaninfo.pixsize(1) 1];
set(handles.ImaAxes,'PlotBoxAspectRatio',PlotBAspectRatio);
set(handles.ImaAxes,'Tag','ImaAxes');
handles.ImaHandler = ImaHandler;
set(handles.ImaHandler,'Tag','MainImage');
axis off;
%Create the initial colorbar
col=Initial_cmap;
r=col(:,1);g=col(:,2);b=col(:,3);
CMapImgRes=[1:handles.ColorRes];
CMapImg=cat(3,r(CMapImgRes),g(CMapImgRes),b(CMapImgRes));
axes(handles.CmapAxes);
set(handles.CmapAxes,'visible','on');
hcb = image(CMapImg);
handles.hcb = hcb;
set(handles.hcb,'tag','ColorbarImage');
set(handles.hcb,'buttonDownFcn','mia_gui(''SetImageContrast'',gcbo,[],guidata(gcbo))');
set(handles.CmapAxes,'Xticklabel',{});
set(handles.CmapAxes,'Ydir','normal');
set(handles.CmapAxes,'YaxisLocation','right');
Yticks = linspace(0,handles.ColorRes,5);
set(handles.CmapAxes,'Ytick',Yticks);
set(handles.CmapAxes,'Yticklabel',num2cell(Yticks));
handles.NumOfYtickOfColorbar = length(get(handles.CmapAxes,'Yticklabel'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -