Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
aedes/aedes.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
11187 lines (9774 sloc)
325 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aedes(DATA,ROI,inputOverlay) | |
% AEDES - Graphical user interface for analyzing MRI images | |
% | |
% | |
% Synopsis: | |
% aedes(InArg) | |
% | |
% or | |
% | |
% aedes | |
% | |
% Description: | |
% AEDES is a graphic user interface (GUI) based tool for region | |
% of interest (ROI) analysis of (mainly) MRI images. | |
% | |
% The input argument InArg is optional. If the function is called | |
% without input arguments, an empty GUI window is initialized. InArg | |
% can be a DATA structure, containing at least the FTDATA and HDR | |
% fields, and a string or a cell array of strings containing the full | |
% path(s) to supported data file(s). Input argument can also be a 2D, | |
% 3D, or 4D-matrix containing image slices and possibly volumes in the | |
% 4th dimension. | |
% | |
% Examples: | |
% %% Example 1 | |
% aedes % Initialize an empty GUI window | |
% | |
% %% Example 2 | |
% DataMtx = rand(100); % Generate a 100x100 random matrix | |
% aedes(DataMtx) % Open the data in Aedes | |
% | |
% %% Example 3 | |
% DATA=aedes_data_read; % Read various image data to a DATA-structure | |
% aedes(DATA) % Open data in Aedes | |
% | |
% %% Example 4 | |
% % Read data from file with path given as a string | |
% aedes('C:\MyDataDirectory\MyDataFiles\MyData.fid') | |
% | |
% %% Example 5 | |
% % Read data from multiple files given as a cell | |
% % array. Each file has to contain only one slice. | |
% files={'C:\MyData\MyDataFile1.nii','C:\MyData\MyDataFile1.nii'}; | |
% aedes(files) | |
% | |
% See also: | |
% AEDES_DATA_READ, AEDES_READFID, AEDES_RESVIEWER, AEDES_JUIGETFILES | |
% Aedes - A graphical tool for analyzing medical images | |
% | |
% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi> | |
% | |
% Department of Physics, Department of Neurobiology | |
% University of Eastern Finland, Kuopio, FINLAND | |
% | |
% This program may be used under the terms of the GNU General Public | |
% License version 2.0 as published by the Free Software Foundation | |
% and appearing in the file LICENSE.TXT included in the packaging of | |
% this program. | |
% | |
% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
% Define "public" variables. Since Aedes utilizes nested functions, | |
% these variables will be visible to all the subfunctions. | |
H = []; % Handles structure. Contains all handles to figure, | |
% uicontrols, axes, etc... | |
Dat = []; % Internal data structure for exchanging information between | |
% functions | |
switch nargin | |
case 0; | |
DATA = []; % The data structure containing image data and header | |
ROI = []; % The ROI structure | |
inputOverlay = []; | |
case 1 | |
ROI = []; | |
inputOverlay = []; | |
case 2 | |
inputOverlay = []; | |
end | |
% % Auto-check for updates ------------------------------ | |
% try | |
% if getpref('Aedes','AutoCheckUpdates') | |
% Dat=aedes_update('semiprompt'); | |
% if Dat | |
% return | |
% else | |
% Dat = []; | |
% end | |
% end | |
% catch | |
% % pass | |
% end | |
% Detect Matlab version | |
[Dat.MatlabVersion,Dat.isImageProc] = aedes_getmatlabversion; | |
% Show license and warranty notification ---------------- | |
% | |
% NOTE: You can disable this license notification using the following | |
% command: setpref('Aedes','ShowLicenseAtStartUp',false) | |
if ~ispref('Aedes','ShowLicenseAtStartUp') || ... | |
getpref('Aedes','ShowLicenseAtStartUp') | |
l_PrintLicense([],[]); | |
end | |
%% Parse input arguments ------------------------- | |
if nargin>0 | |
if ischar(DATA) %% String input | |
tmp_filename = DATA; | |
DATA = []; | |
% Draw blank GUI | |
H=l_draw_gui(); | |
% Read data and initialize | |
l_OpenFile([],[],'single',tmp_filename) | |
% Initialize GUI | |
%l_Initialize([],[]) | |
elseif iscell(DATA) %% Cell input | |
if ischar(DATA{1}) | |
tmp_filename = DATA; | |
DATA = []; | |
% Draw blank GUI | |
H=l_draw_gui(); | |
% Read data and initialize | |
l_OpenFile([],[],'multi',tmp_filename) | |
% Initialize GUI | |
%l_Initialize([],[]) | |
elseif ~isstruct(DATA{1}) | |
error('Invalid type for input argument!') | |
else | |
% Draw blank GUI | |
H=l_draw_gui(); | |
% Initialize GUI | |
l_Initialize([],[]) | |
end | |
else | |
if isstruct(DATA) %% Structure input | |
DATA = {DATA}; | |
% Check if kspace should be viewed | |
if isfield(DATA{1},'KSPACE') && ... | |
(isempty(DATA{1}.FTDATA) & ~isempty(DATA{1}.KSPACE)) | |
resp=questdlg(['The inputted DATA structure contains only k-space',... | |
' information. Do you want to view real, imaginary, or absolute',... | |
' part of the complex k-space?'],... | |
'Complex data inputted',... | |
'Real','Imaginary','Absolute','Absolute'); | |
if strcmpi(resp,'Real') | |
DATA{1}.FTDATA = real(DATA{1}.KSPACE); | |
elseif strcmpi(resp,'Imaginary') | |
DATA{1}.FTDATA = imag(DATA{1}.KSPACE); | |
elseif strcmpi(resp,'Absolute') | |
DATA{1}.FTDATA = abs(DATA{1}.KSPACE); | |
else | |
% Canceled | |
return | |
end | |
%DATA{1}.FTDATA = abs(DATA{1}.KSPACE); | |
end | |
elseif isnumeric(DATA) || islogical(DATA) | |
if isreal(DATA) | |
DATA_tmp=DATA; | |
else | |
resp=questdlg(['The inputted data is complex. Do you want ' ... | |
'to view real, imaginary, or absolute part of the data?'],... | |
'Complex data inputted',... | |
'Real','Imaginary','Absolute','Absolute'); | |
if strcmpi(resp,'Real') | |
DATA_tmp = real(DATA); | |
elseif strcmpi(resp,'Imaginary') | |
DATA_tmp = imag(DATA); | |
else | |
DATA_tmp = abs(DATA); | |
end | |
end | |
DATA=[]; | |
DATA.FTDATA = DATA_tmp; | |
DATA.HDR.fpath = ''; | |
DATA.HDR.fname = ''; | |
DATA={DATA}; | |
clear DATA_tmp | |
else | |
error('Invalid type for input argument') | |
end | |
% Draw blank GUI | |
H=l_draw_gui(); | |
% Initialize GUI | |
l_Initialize([],[]) | |
end | |
% Load ROI if given as input argument | |
if nargin>1 | |
if ~isempty(ROI) | |
l_RoiLoad([],[],''); | |
end | |
if nargin==3 && ~isempty(inputOverlay) | |
% Load overlay | |
l_LoadImageOverlay([],[],'inputarg') | |
end | |
end | |
else | |
% Open an empty GUI window, if called without input arguments | |
H=l_draw_gui; | |
end | |
% Build plugins menu | |
l_BuildPluginsMenu(); | |
% Wait for quit in standalone | |
if isdeployed | |
waitfor(H.FIG) | |
end | |
% Debug function - paste debug information into workspace... | |
function l_debug(h,evd) | |
assignin('base','DATA',DATA); | |
assignin('base','H',H); | |
assignin('base','ROI',ROI); | |
assignin('base','Dat',Dat); | |
end | |
%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% CHECK FOR UPDATES | |
%%%%%%%%%%%%%%%%%%%%%%%%%% | |
function l_CheckUpdates(h,evd) | |
done = aedes_update('prompt'); | |
end | |
%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% DRAW GUI | |
%%%%%%%%%%%%%%%%%%%%%%%%%% | |
function H=l_draw_gui() | |
%% Toggle debug on/off | |
debug=true; | |
%% Determine paths | |
tmp=which('aedes'); | |
[fp,fn,fe]=fileparts(tmp); | |
Dat.AedesFolder = [fp,filesep]; | |
Dat.PluginsFolder = [Dat.AedesFolder,'plugins',filesep]; | |
Dat.IconsFolder = [Dat.AedesFolder,'icons',filesep]; | |
Dat.TablibFolder = [Dat.AedesFolder,'tablib',filesep]; | |
%% Figure Size Definitions ---------------- | |
taskbar_sz = 70; % The windows taskbar height in pixels | |
fig_w = 1000; % Screen width in pixels | |
fig_h = 661;%768-taskbar_sz; % Screen height in pixels | |
dx = 1/fig_w; % Horizontal space | |
dy = 1/fig_h; % Vertical space | |
dxx = 5*dx; % Horizontal big space | |
dyy = 5*dy; % Vertical big space | |
btn_h = 25/fig_h; % Push button height | |
btn_w = 75/fig_w; % Push button width | |
btns_w = 25/fig_w; | |
popup_h = 25/fig_h; % Popup menu height | |
popup_w = 100/fig_w; % Popup menu width | |
edit_w = 45/fig_w; % Edit box width | |
edit_h = 20/fig_h; % Edit box height | |
%% Load default font and colors | |
if isunix | |
DefaultColor = [239 235 222]/255; | |
else | |
DefaultColor=get(0,'DefaultUicontrolBackgroundcolor'); | |
end | |
GD=aedes_gui_defaults; | |
GD.col.frame = DefaultColor; | |
Dat.HG2graphics = GD.HG2graphics; | |
% Calculate default position for Aedes window | |
try | |
% If multiple monitors are connected, draw Aedes on the monitor where the | |
% mouse cursor is located | |
scrsz = get(0,'MonitorPositions'); | |
ind = aedes_getcurrentmonitor; | |
fig_pos = [scrsz(ind,3)/2-fig_w/2 scrsz(ind,4)/2-fig_h/2-20 fig_w fig_h]; | |
fig_pos(1) = fig_pos(1)+scrsz(ind,1); | |
catch | |
% Get screen size | |
scrsz=get(0,'ScreenSize'); | |
% Calculate gui position on the center of the screen | |
fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2-20 fig_w fig_h]; | |
end | |
%% Check if other Aedes windows exist | |
figs=findall(0,'tag','aedes_main_fig'); | |
if ~isempty(figs) | |
tmp_pos=get(figs(1),'position'); | |
fig_pos(1)=tmp_pos(1)+15; | |
fig_pos(2)=tmp_pos(2)-15; | |
end | |
%% Draw main figure | |
H.FIG=figure('Position',fig_pos, ... | |
'Units','Pixel', ... | |
'Name','Aedes 1.0', ... | |
'Numbertitle','off', ... | |
'Tag','aedes_main_fig', ... | |
'Color',GD.col.mainfig, ... | |
'Toolbar','none', ... | |
'Menubar','none', ... | |
'DockControls','off',... | |
'renderer','OpenGL',... | |
'KeyPressFcn',@l_KeyPressFcn,... | |
'CloseRequestFcn',@l_quit,... | |
'Handlevisibility','off'); | |
if ~Dat.HG2graphics | |
set(H.FIG,'DoubleBuffer','on') | |
end | |
% File Uimenu --------------------------- | |
file_h = uimenu('Label','File','Accelerator','F', ... | |
'Parent',H.FIG); | |
H.FILEMENU_NEW = uimenu(file_h,'Label','New window',... | |
'Callback','aedes'); | |
H.FILEMENU_OPEN_SINGLE = uimenu(file_h,'Label','&Open File',... | |
'Accelerator','O', ... | |
'Callback',{@l_OpenFile,'single'},'Tag', ... | |
'open_single_file',... | |
'separator','on'); | |
H.FILEMENU_OPEN_MULTI = uimenu(file_h,'Label','Open &Multiple Files',... | |
'Callback',{@l_OpenFile,'multi'},'Tag', ... | |
'open_multiple_file'); | |
H.FILEMENU_OPEN_RECENT = uimenu(file_h,'Label','Open Recent',... | |
'Tag','open_recent',... | |
'separator','on'); | |
l_BuildRecentFilesMenu([],[],H.FILEMENU_OPEN_RECENT); | |
H.FILEMENU_SAVE_IMAGE = uimenu(file_h,'Label','Save Image Data as', ... | |
'Callback',@l_SaveImageData, ... | |
'Separator','on','userdata','','enable','off'); | |
H.FILEMENU_SAVERES = uimenu(file_h,'Label','Save results as','Accelerator','S', ... | |
'Callback',{@l_SaveResults,[]}, ... | |
'Separator','off','userdata','','enable','off'); | |
H.FILEMENU_EXPORT = uimenu(file_h,'Label','Export Image Data...', ... | |
'Callback',@l_ExportImages, ... | |
'Separator','on','userdata','','enable','off'); | |
% $$$ H.FILEMENU_PRINT = uimenu(file_h,'Label','Print...', ... | |
% $$$ 'Callback',@l_Print, ... | |
% $$$ 'Separator','on','userdata','','enable','off'); | |
closefile_h = uimenu(file_h,'Label','Close File', ... | |
'Callback',@l_CloseFile, ... | |
'Separator','on','userdata','','enable','off'); | |
H.FILEMENU_QUIT = uimenu(file_h,'Label','Exit Aedes','Accelerator','Q', ... | |
'Callback',@l_quit,'Separator','on'); | |
% Edit Uimenu --------------------------------- | |
edit_h = uimenu('Label','Edit', ... | |
'Parent',H.FIG,... | |
'enable','off'); | |
H.UIEDIT_IMSTACK = uimenu(edit_h,'Label','&Image Stack',... | |
'Callback',@l_EditImageStack,... | |
'separator','off',... | |
'enable','off'); | |
% Unfold data | |
H.UNFOLD_DATA = uimenu(edit_h,'Label','Unfold data',... | |
'Callback',@l_UnfoldData,... | |
'separator','on',... | |
'enable','off'); | |
% Rotate/flip view | |
rotate_h=uimenu(edit_h,'Label','Rotate/Flip Images','separator','on',... | |
'enable','off'); | |
H.UIMENU_ROTATEFLIP = rotate_h; | |
rot_h=uimenu(rotate_h,'Label','Rotate Current Slice'); | |
tmp_str={'90','180','270'}; | |
for ii=1:3 | |
H.ROTATE(ii) = uimenu(rot_h,'Label',[tmp_str{ii},char(176)],... | |
'callback',... | |
{@l_RotateFlip,tmp_str{ii}}); | |
end | |
flip_h=uimenu(rotate_h,'Label','Flip Current Slice'); | |
tmp_str={'FlipLR','FlipUD'}; | |
for ii=1:2 | |
H.FLIP(ii) = uimenu(flip_h,'Label',tmp_str{ii},... | |
'callback',... | |
{@l_RotateFlip,tmp_str{ii}}); | |
end | |
rotcustom_h = uimenu(rotate_h,'Label','Rotate/Flip Custom...',... | |
'callback',... | |
{@l_RotateFlip,'custom'},... | |
'separator','on'); | |
H.UIROTRESET = uimenu(rotate_h,'Label','Reset Rotation/Flip',... | |
'callback',... | |
{@l_RotateFlip,'reset'},... | |
'separator','on'); | |
% Rotate/Flip volumes ---------------------------------------- | |
rotate3d_h=uimenu(edit_h,'Label','Rotate/Flip Volumes','separator','off',... | |
'enable','off'); | |
H.UIMENU_ROTATEFLIP3D = rotate3d_h; | |
rot3d_h=uimenu(rotate3d_h,'Label','Rotate'); | |
flip3d_h=uimenu(rotate3d_h,'Label','Flip'); | |
tmpx_h = uimenu(rot3d_h,'Label','X-dir'); | |
tmpy_h = uimenu(rot3d_h,'Label','Y-dir'); | |
tmpz_h = uimenu(rot3d_h,'Label','Z-dir'); | |
tmp_str={'90','180','270'}; | |
tmp_h = [tmpx_h,tmpy_h,tmpz_h]; | |
tmp_str2 = {'X','Y','Z'}; | |
for kk=1:3 | |
for ii=1:3 | |
H.ROTATE3D(kk,ii) = uimenu(tmp_h(kk),'Label',[tmp_str{ii},char(176)],... | |
'callback',... | |
{@l_RotateFlip,['3d',tmp_str2{kk},'_',tmp_str{ii}]}); | |
end | |
end | |
H.FLIP3D_X = uimenu(flip3d_h,'Label','X-dir',... | |
'callback',{@l_RotateFlip,'flipX'}); | |
H.FLIP3D_Y = uimenu(flip3d_h,'Label','Y-dir',... | |
'callback',{@l_RotateFlip,'flipY'}); | |
H.FLIP3D_Z = uimenu(flip3d_h,'Label','Z-dir',... | |
'callback',{@l_RotateFlip,'flipZ'}); | |
H.FLIP3D_V = uimenu(flip3d_h,'Label','V-dir',... | |
'callback',{@l_RotateFlip,'flipV'},... | |
'enable','off'); | |
% View Uimenu ------------------------------ | |
view_h = uimenu('Label','View', ... | |
'Parent',H.FIG,... | |
'enable','off'); | |
% View XYZ (3D) direction (default) | |
H.UIVIEW_3D = uimenu(view_h,'Label','View 3D',... | |
'callback',{@l_ChangeView,0},... | |
'checked','on'); | |
% View only X direction | |
H.UIVIEW_X = uimenu(view_h,'Label','View X direction',... | |
'callback',{@l_ChangeView,1},... | |
'separator','on'); | |
% View only X direction | |
H.UIVIEW_Y = uimenu(view_h,'Label','View Y direction',... | |
'callback',{@l_ChangeView,2}); | |
% View only X direction | |
H.UIVIEW_Z = uimenu(view_h,'Label','View Z direction',... | |
'callback',{@l_ChangeView,3}); | |
% View axes ticks and grid | |
H.UIVIEW_GRID = uimenu(view_h,'Label','Show Grid',... | |
'callback',{@l_ViewAxesUnits,'pixel'},... | |
'separator','on',... | |
'checked','off'); | |
% View Header in aedes_headerbrowser | |
H.viewheader_h = uimenu(view_h,'Label','File Header',... | |
'callback',@l_LaunchHeaderBrowser,... | |
'enable','on','Accelerator','H',... | |
'separator','on'); | |
% Show Info text background | |
H.UIVIEW_INFOTXTBACKGROUND = uimenu(view_h,'Label','Info/ROI Text Background',... | |
'callback',@l_InfoTextBackground,... | |
'separator','on',... | |
'checked','off'); | |
% View Voxel Time Series | |
H.UIVIEW_TIMESERIES = uimenu(view_h,'Label','Voxel time-series',... | |
'callback',{@l_ShowTimeSeries,'toggle'},... | |
'separator','on',... | |
'checked','off'); | |
% % Volume menu | |
% H.UIVIEW_VOL = uimenu(view_h,'Label','Select volume',... | |
% 'separator','on'); | |
% | |
% $$$ H.UIVIEW_FOV_UNITS = uimenu(view_h,'Label','View FOV units',... | |
% $$$ 'callback',{@l_ViewAxesUnits,'FOV'},... | |
% $$$ 'checked','off'); | |
% $$$ flipcustom_h=uimenu(rotate_h,'Label','Flip Custom',... | |
% $$$ 'callback',... | |
% $$$ {@l_RotateZoom,'flip','custom'},... | |
% $$$ 'separator','off'); | |
% % Zoom view | |
% tmp_str={'normalized',... | |
% '0.5x',... | |
% '1x',... | |
% '2x',... | |
% '3x',... | |
% '4x',... | |
% '5x',... | |
% '6x',... | |
% '7x',... | |
% '8x',... | |
% '9x',... | |
% '10x',... | |
% '11x',... | |
% '12x',... | |
% '13x',... | |
% '14x',... | |
% '15x',... | |
% '16x',... | |
% '17x',... | |
% '18x',... | |
% '19x',... | |
% '20x'}; | |
% tmp_fact = [0 0.5 1 2 3 4 5 6 7 8 9 10 ... | |
% 11 12 13 14 15 16 17 18 19 20]; | |
% zoom_h=uimenu(view_h,'Label','Zoom',... | |
% 'separator','on'); | |
% for ii=1:length(tmp_str) | |
% H.UIZOOM(ii)=uimenu(zoom_h,'Label',tmp_str{ii},... | |
% 'callback',{@l_Zoom,tmp_fact(ii)},... | |
% 'tag',['uizoom_' num2str(tmp_fact(ii))],... | |
% 'userdata',tmp_fact(ii)); | |
% if ii==2 | |
% set(H.UIZOOM(ii),'separator','on') | |
% end | |
% end | |
% set(H.UIZOOM(3),'checked','on') | |
% TOOLS UIMENU ------------------------------------- | |
tools_h = uimenu('Label','Tools', ... | |
'Parent',H.FIG,... | |
'enable','on'); | |
vnmredit_h = uimenu(tools_h,'Label','Edit VNMR defaults', ... | |
'callback','aedes_readfidprefs',... | |
'enable','on'); | |
resview_h = uimenu(tools_h,'Label','Results Viewer', ... | |
'callback','aedes_resviewer',... | |
'enable','on',... | |
'separator','on'); | |
% update_h = uimenu(tools_h,'Label','Check for updates', ... | |
% 'callback',@l_CheckUpdates,... | |
% 'enable','on',... | |
% 'separator','on'); | |
% Overlay menu --------------------------------------- | |
H.UIOVERLAY = uimenu('Label','Overlay', ... | |
'Parent',H.FIG,... | |
'enable','off'); | |
load_overlay_h = uimenu(H.UIOVERLAY,'Label','Load Image Overlay', ... | |
'separator','off',... | |
'enable','on'); | |
uimenu(load_overlay_h,'Label','From File', ... | |
'callback',{@l_LoadImageOverlay,'file'},... | |
'separator','off',... | |
'enable','on'); | |
uimenu(load_overlay_h,'Label','From Variable', ... | |
'callback',{@l_LoadImageOverlay,'var'},... | |
'separator','on',... | |
'enable','on'); | |
H.UIOVERLAY_SAVE = uimenu(H.UIOVERLAY,'Label','Save Overlay to file', ... | |
'callback',{@l_OverlayControls,'save'},... | |
'separator','on',... | |
'enable','off'); | |
H.UIOVERLAY_CONTROLS = uimenu(H.UIOVERLAY,'Label','Show Overlay Controls', ... | |
'callback',{@l_OverlayControls,'show'},... | |
'separator','on',... | |
'enable','off'); | |
H.UIOVERLAY_DELETE = uimenu(H.UIOVERLAY,'Label','Delete Image Overlay', ... | |
'callback',{@l_OverlayControls,'delete'},... | |
'separator','on',... | |
'enable','off'); | |
% ROI Tools ------------------------------------------ | |
roi_tools_h = uimenu('Label','ROI', ... | |
'Parent',H.FIG,... | |
'enable','off'); | |
% $$$ H.UIROITOOLS_AUTOCLOSE = uimenu(roi_tools_h,'Label','Autoclose',... | |
% $$$ 'callback',... | |
% $$$ ['if strcmp(get(gcbo,''checked''),''on''),' ... | |
% $$$ 'set(gcbo,''checked'',''off''),else,' ... | |
% $$$ 'set(gcbo,''checked'',''on''),end'],... | |
% $$$ 'checked','off'); | |
H.UIROITOOLS_LOAD = uimenu(roi_tools_h,'Label','Load ROI(s)',... | |
'callback',{@l_RoiLoad,'interactive'},... | |
'separator','off'); | |
H.UIROITOOLS_SAVE = uimenu(roi_tools_h,'Label','Save ROI(s)',... | |
'callback',@l_RoiSave,... | |
'separator','off',... | |
'enable','off'); | |
H.UIROITOOLS_SAVETEMPLATE = uimenu(roi_tools_h,'Label','Save ROI template',... | |
'callback',{@l_RoiSave,'template'},... | |
'separator','off',... | |
'enable','off'); | |
H.UIROISTATS = uimenu(roi_tools_h,'Label','View/Export ROI Statistics',... | |
'callback',@l_RoiViewStats,... | |
'separator','on',... | |
'enable','off'); | |
H.UIROITOOLS_COPY = uimenu(roi_tools_h,'Label','Copy ROI',... | |
'separator','on',... | |
'enable','off'); | |
H.UIROITOOLS_COPYSLICES = uimenu(H.UIROITOOLS_COPY,'Label','Copy ROI to slices/volumes',... | |
'callback',@l_RoiCopy,... | |
'separator','off',... | |
'enable','on'); | |
H.UIROITOOLS_COPYADD = uimenu(H.UIROITOOLS_COPY,'Label','Copy current ROI to new',... | |
'callback',{@l_RoiAdd,'copy'},... | |
'separator','off',... | |
'enable','on'); | |
H.UIROITOOLS_FLIP = uimenu(roi_tools_h,'Label','Flip current ROI',... | |
'separator','off',... | |
'enable','off'); | |
tmp_str={'FlipLR','FlipUD'}; | |
for ii=1:2 | |
H.ROIFLIP(ii) = uimenu(H.UIROITOOLS_FLIP,'Label',tmp_str{ii},... | |
'callback',... | |
{@l_RoiFlip,tmp_str{ii}}); | |
end | |
H.UIROITOOLS_COMP = uimenu(roi_tools_h,'Label','Boolean operations',... | |
'callback',@l_RoiBooleanOperations,... | |
'separator','off',... | |
'checked','off',... | |
'enable','off'); | |
H.UIROISHOWEDGES = uimenu(roi_tools_h,'Label','Show ROI edges',... | |
'callback',@l_UiRoiEdgesCB,... | |
'separator','off',... | |
'checked','off',... | |
'enable','off'); | |
H.UIROIRENAME = uimenu(roi_tools_h,'Label','Rename current ROI',... | |
'callback',@l_RoiRename,... | |
'separator','off',... | |
'checked','off',... | |
'enable','off'); | |
H.UIROISETCOLOR = uimenu(roi_tools_h,'Label','Set current ROI color',... | |
'callback',@l_RoiSetColor,... | |
'separator','off',... | |
'checked','off',... | |
'enable','off'); | |
H.UIROITOOLS_UNDO = uimenu(roi_tools_h,'Label','Undo draw (0)',... | |
'callback',@l_RoiUndo,... | |
'separator','on',... | |
'enable','off',... | |
'accelerator','z'); | |
%% Plugins menu -------------------------------------------------------- | |
%% DO NOT ADD/REMOVE PLUGINS FROM HERE. | |
% Construct plugins uimenu | |
H.UIPLUGINS = uimenu('Label','Plugins', ... | |
'Parent',H.FIG,... | |
'enable','off'); | |
%% ---------------------------------------------------------------------- | |
%% Help uimenu | |
help_h = uimenu('Label','Help', ... | |
'Parent',H.FIG,... | |
'enable','on'); | |
help_about_h = uimenu(help_h,... | |
'Label','About Aedes', ... | |
'enable','on',... | |
'callback','eval(get(gcbo,''userdata''))'); | |
set(help_about_h,'userdata',... | |
'aedes_helpabout'); | |
if debug | |
debug_h=uimenu('Label','Debug', ... | |
'Parent',H.FIG,... | |
'enable','on',... | |
'callback',@l_debug); | |
end | |
%% Uitoolbar controls -------------------------------- | |
H.UITOOLBAR = uitoolbar('parent',H.FIG); | |
%% load CData for buttons | |
btn_cdata = load('aedes_cdata.mat'); | |
H.btn_cdata = btn_cdata; | |
%tmp=NaN(18,20,3); | |
%tmp(:,3:end,:)=btn_cdata.cdata.open; | |
% Open file | |
H.UIPUSH_OPEN = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.open2,... | |
'ClickedCallback',{@l_OpenFile,'single'},... | |
'TooltipString','Open a new data file'); | |
% Open multiple files | |
H.UIPUSH_OPENMULTI = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.openmulti,... | |
'ClickedCallback',{@l_OpenFile,'multi'},... | |
'TooltipString',... | |
'Open multiple single-slice data files'); | |
% Save file | |
H.UIPUSH_SAVE = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.save2_small,... | |
'ClickedCallback',{@l_SaveResults,[]},... | |
'TooltipString','Save',... | |
'enable','off'); | |
% $$$ H.UIPUSH_PRINT = uipushtool('parent',H.UITOOLBAR,... | |
% $$$ 'CData',btn_cdata.cdata.print2,... | |
% $$$ 'ClickedCallback','',... | |
% $$$ 'TooltipString','Print',... | |
% $$$ 'enable','off'); | |
% Zoom Normalized | |
H.UITOGGLE_ZOOMNORM = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.fitheight,... | |
'separator','on',... | |
'ClickedCallback',{@l_Zoom,'normalize'},... | |
'TooltipString','Fit to Window Height',... | |
'enable','off'); | |
% Zoom in | |
H.UIPUSH_ZOOMIN = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.zoomin,... | |
'separator','off',... | |
'ClickedCallback',{@l_Zoom,'+'},... | |
'TooltipString','Zoom In',... | |
'enable','off'); | |
% Zoom out | |
H.UIPUSH_ZOOMOUT = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.zoomout,... | |
'ClickedCallback',{@l_Zoom,'-'},... | |
'TooltipString','Zoom Out',... | |
'enable','off'); | |
% Show/hide crosshairs | |
H.UITOGGLE_CROSSHAIRS = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.crosshairs_small,... | |
'ClickedCallback',@l_ShowHideCrossbars,... | |
'TooltipString','Show/Hide Crosshairs',... | |
'enable','off',... | |
'state','off',... | |
'separator','on'); | |
% Show Grid | |
H.UITOGGLE_GRID = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.grid,... | |
'ClickedCallback',{@l_ViewAxesUnits,'pixel'},... | |
'TooltipString','Show/Hide Grid',... | |
'enable','off',... | |
'state','off',... | |
'separator','on'); | |
% Show/hide colorbar | |
H.UITOGGLE_COLORBAR = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.colorbar,... | |
'ClickedCallback',@l_ShowColorbar,... | |
'TooltipString','Show/Hide Colorbar',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
% Show Info Text | |
H.UITOGGLE_INFO = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.about,... | |
'ClickedCallback',@l_UpdateInfoText,... | |
'TooltipString','Show/Hide Info Text',... | |
'enable','off',... | |
'state','on',... | |
'separator','off'); | |
% Show image stack | |
H.UIPUSH_IMSTACK = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.editimagestack,... | |
'ClickedCallback',@l_EditImageStack,... | |
'TooltipString','Edit Image Stack',... | |
'enable','off',... | |
'separator','on'); | |
% Show rotate/flip custom menu | |
H.UIPUSH_ROTATE = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.rotateflip,... | |
'ClickedCallback',{@l_RotateFlip,'custom'},... | |
'TooltipString','Rotate/Flip Custom',... | |
'enable','off',... | |
'separator','off'); | |
% View 3D | |
H.UITOGGLE_VIEW3D = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.view3d,... | |
'ClickedCallback',{@l_ChangeView,0},... | |
'TooltipString','View 3D',... | |
'enable','off',... | |
'state','off',... | |
'separator','on'); | |
H.UITOGGLE_VIEWX = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.viewx,... | |
'ClickedCallback',{@l_ChangeView,1},... | |
'TooltipString','View X direction',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_VIEWY = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.viewy,... | |
'ClickedCallback',{@l_ChangeView,2},... | |
'TooltipString','View Y direction',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_VIEWZ = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.viewz,... | |
'ClickedCallback',{@l_ChangeView,3},... | |
'TooltipString','View Z direction',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
% Mouse uitoggletools | |
H.UITOGGLE_ARROW = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.arrow,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Normal',... | |
'enable','off',... | |
'state','on',... | |
'separator','on'); | |
H.UITOGGLE_PAN = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.pan,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Pan image',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
% ROI buttons | |
H.UITOGGLE_DRAWROI = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.freedraw,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Draw ROI',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_ERASEROI = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.eraser,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Erase ROI',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_FILLROI = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.bucketfill,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Fill ROI',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_MOVEROI = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.move,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Move ROI in slice',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
H.UITOGGLE_MOVEROI3D = uitoggletool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.move3d,... | |
'ClickedCallback',... | |
['set(get(gcbo,''userdata''),''state'',''off''),' ... | |
'set(gcbo,''state'',''on'')'],... | |
'TooltipString','Mouse: Move ROI in volume',... | |
'enable','off',... | |
'state','off',... | |
'separator','off'); | |
% Show ROI statistics | |
H.UIPUSH_STATS_ROI = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.statistics,... | |
'ClickedCallback',@l_RoiViewStats,... | |
'TooltipString','View ROI statistics',... | |
'enable','off',... | |
'separator','on'); | |
H.UIPUSH_NEWROI = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.add_small,... | |
'ClickedCallback',@l_RoiAdd,... | |
'TooltipString','New ROI',... | |
'enable','off',... | |
'separator','on'); | |
H.UIPUSH_COPYROI = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.copy_small,... | |
'ClickedCallback',@l_RoiCopy,... | |
'TooltipString','Copy ROI to slices/volumes',... | |
'enable','off',... | |
'separator','off'); | |
% $$$ H.UIPUSH_DELETEROI = uipushtool('parent',H.UITOOLBAR,... | |
% $$$ 'CData',btn_cdata.cdata.delete_small,... | |
% $$$ 'ClickedCallback',{@l_RoiFunctions,'delete'},... | |
% $$$ 'TooltipString','Delete selected ROI(s)',... | |
% $$$ 'enable','off',... | |
% $$$ 'separator','off'); | |
% $$$ | |
% $$$ H.UIPUSH_DELETEALLROI = uipushtool('parent',H.UITOOLBAR,... | |
% $$$ 'CData',btn_cdata.cdata.deleteall_small,... | |
% $$$ 'ClickedCallback',{@l_RoiFunctions,'delete_all'},... | |
% $$$ 'TooltipString','Delete ALL ROI(s)',... | |
% $$$ 'enable','off',... | |
% $$$ 'separator','off'); | |
H.UIPUSH_UNDOROI = uipushtool('parent',H.UITOOLBAR,... | |
'CData',btn_cdata.cdata.undo_small,... | |
'ClickedCallback',@l_RoiUndo,... | |
'TooltipString','Undo last ROI action',... | |
'enable','off',... | |
'separator','off'); | |
set([H.UITOGGLE_ARROW,H.UITOGGLE_PAN,... | |
H.UITOGGLE_DRAWROI,H.UITOGGLE_ERASEROI,H.UITOGGLE_MOVEROI,... | |
H.UITOGGLE_MOVEROI3D,H.UITOGGLE_FILLROI],... | |
'userdata',[H.UITOGGLE_ARROW,H.UITOGGLE_PAN,... | |
H.UITOGGLE_DRAWROI,H.UITOGGLE_ERASEROI,H.UITOGGLE_MOVEROI,... | |
H.UITOGGLE_MOVEROI3D,H.UITOGGLE_FILLROI]) | |
fig_pos = get(H.FIG,'position'); | |
H.ORIG_FIG_POS = fig_pos; | |
%% Draw uicontrol frame behind the uicontrols | |
% to make them draw faster in opengl mode | |
H.SIDEBAR_FRAME=uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[0 0 232 fig_pos(4)+2],... | |
'backgroundcolor',GD.col.frame,... | |
'style','frame',... | |
'visible','on'); | |
%% Draw sidebar ------------------------------- | |
% H.SIDEBAR=uipanel('parent',H.FIG,... | |
% 'units','pixel',... | |
% 'position',[0 0 232 fig_pos(4)+1],... | |
% 'backgroundcolor',GD.col.frame); | |
%% Draw image sliders | |
%tmp=get(H.SIDEBAR,'position'); | |
tmp=get(H.SIDEBAR_FRAME,'position'); | |
% Draw frame to hide the opening in the corner | |
H.IMSLIDER_FRAME = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+1 0 fig_pos(3)-tmp(1)-tmp(3) 17],... | |
'style','frame',... | |
'backgroundcolor',GD.col.mainfig,... | |
'visible','off'); | |
% x-slider | |
H.IMSLIDER(1) = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3) 0 fig_pos(3)-tmp(1)-tmp(3)-17 17],... | |
'style','slider',... | |
'min',0,... | |
'max',1,... | |
'visible','off');%'callback',@l_AxesPositions);%@l_ImSliderCB); | |
% y-slider | |
H.IMSLIDER(2) = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[fig_pos(3)-17 17 17 fig_pos(4)-17+1],... | |
'style','slider',... | |
'min',-1,... | |
'max',0,... | |
'visible','off');%'callback',@l_AxesPositions);%@l_ImSliderCB); | |
% If JavaFigures are enabled, set image sliders to work while moving | |
if ~Dat.HG2graphics | |
if Dat.MatlabVersion>7.03 | |
SliderListener1 = handle.listener(H.IMSLIDER(1),... | |
'ActionEvent',... | |
@l_AxesPositions);%@l_ImSliderCB); | |
SliderListener2 = handle.listener(H.IMSLIDER(2),... | |
'ActionEvent',... | |
@l_AxesPositions);%@l_ImSliderCB); | |
setappdata(H.IMSLIDER_FRAME,'ImSliderListener',... | |
[SliderListener1,... | |
SliderListener2]) | |
else | |
if feature('javafigures') | |
SliderListener1 = handle.listener(H.IMSLIDER(1),... | |
'ActionEvent',... | |
@l_AxesPositions);%@l_ImSliderCB); | |
SliderListener2 = handle.listener(H.IMSLIDER(2),... | |
'ActionEvent',... | |
@l_AxesPositions);%@l_ImSliderCB); | |
setappdata(H.IMSLIDER_FRAME,'ImSliderListener',... | |
[SliderListener1,... | |
SliderListener2]) | |
else | |
set(H.IMSLIDER,'callback',@l_AxesPositions) | |
end | |
end | |
else | |
SliderListener1 = addlistener(H.IMSLIDER(1),... | |
'ContinuousValueChange',@l_AxesPositions); | |
SliderListener2 = addlistener(H.IMSLIDER(2),... | |
'ContinuousValueChange',@l_AxesPositions); | |
setappdata(H.IMSLIDER_FRAME,'ImSliderListener',[SliderListener1,... | |
SliderListener2]) | |
end | |
%% Slice viewing tools uipanel | |
% H.SLICE_TOOLS=uipanel('parent',H.FIG,...H.SIDEBAR,... | |
% 'units','pixel',... | |
% 'position',[round(0.01*232) round(0.79*fig_pos(4)) ... | |
% round(0.98*232)-2 round(0.18*fig_pos(4))],... | |
% 'title','Slice viewing tools',... | |
% 'fontsize',8,... | |
% 'backgroundcolor',GD.col.frame,...%'highlightcolor',[0.5 0.5 0.5],...%'shadowcolor',[0 0 0],... | |
% 'fontweight','bold',... | |
% 'bordertype','etchedin'); | |
fig_pos=get(H.FIG,'position'); | |
H.SLICE_TOOLS=uicontrol('parent',H.FIG,... | |
'style','frame',... | |
'units','pixel',... | |
'position',[5 fig_pos(4)-105-2 ... | |
232-10 105],...%135 | |
'backgroundcolor',GD.col.frame); | |
% Slice Tools text | |
tmp=get(H.SLICE_TOOLS,'position'); | |
H.SLICE_TOOLS_TX = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+tmp(4)-20 150 15],... | |
'style','text',... | |
'horizontalalign','left',... | |
'fontweight','bold',... | |
'backgroundcolor',GD.col.frame,... | |
'string','Image Coordinates'); | |
% Volume popup | |
tmp = get(H.SLICE_TOOLS,'position'); | |
% $$$ H.VOL_POPUP = uicontrol('parent',H.FIG,... | |
% $$$ 'units','pixel',...%'normal',... | |
% $$$ 'position',[85 ... | |
% $$$ 80+tmp(2) ... | |
% $$$ 45 ... | |
% $$$ 34],...%[0.37 0.8 0.2 0.15],... | |
% $$$ 'style','popup',... | |
% $$$ 'backgroundcolor','w',... | |
% $$$ 'string',{'1'},... | |
% $$$ 'callback',''); | |
% $$$ | |
% $$$ % Volume text | |
% $$$ h1 = uicontrol('parent',H.FIG,... | |
% $$$ 'units','pixel',... | |
% $$$ 'position',[tmp(1)+5 tmp(2)+95 72 15],... | |
% $$$ 'style','text',... | |
% $$$ 'horizontalalign','left',... | |
% $$$ 'backgroundcolor',GD.col.frame,... | |
% $$$ 'string','Select volume'); | |
% Slice slider | |
H.SL_SLIDER = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+60 215 20],... | |
'style','slider',... | |
'backgroundcolor',GD.col.slider); | |
% If JavaFigures are enabled, set slider to work while moving | |
if ~Dat.HG2graphics | |
if Dat.MatlabVersion>7.03 | |
SliderListener = handle.listener(H.SL_SLIDER,... | |
'ActionEvent',... | |
{@l_ChangeSlice,'slider'}); | |
setappdata(H.SL_SLIDER,'SliderListener',SliderListener) | |
else | |
if feature('javafigures') | |
SliderListener = handle.listener(H.SL_SLIDER,... | |
'ActionEvent',... | |
{@l_ChangeSlice,'slider'}); | |
setappdata(H.SL_SLIDER,'SliderListener',SliderListener) | |
else | |
set(H.SL_SLIDER,'callback',{@l_ChangeSlice,'slider'}) | |
end | |
end | |
else | |
SliderListener = addlistener(H.SL_SLIDER,... | |
'ContinuousValueChange',@l_ChangeSlice); | |
setappdata(H.SL_SLIDER,'SliderListener',SliderListener) | |
end | |
% X -------------------------- | |
H.X_BTN = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+35 30 22],... | |
'style','togglebutton',... | |
'fontweight','bold',... | |
'string','X:',... | |
'value',1,... | |
'callback',{@l_ChangeSliderOrient,1}); | |
tmp=get(H.X_BTN,'pos'); | |
H.X_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[5+tmp(3)+5 tmp(2) 35 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','1',... | |
'callback',{@l_ChangeSlice,'editbox'}); | |
% Y ----------------------------- | |
tmp_gap = 8; | |
tmp=get(H.X_EDIT,'pos'); | |
H.Y_BTN = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2) 30 tmp(4)],... | |
'style','togglebutton',... | |
'string','Y:',... | |
'fontweight','normal',... | |
'value',0,... | |
'callback',{@l_ChangeSliderOrient,2}); | |
tmp=get(H.Y_BTN,'pos'); | |
H.Y_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3) tmp(2) 35 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','1',... | |
'callback',{@l_ChangeSlice,'editbox'}); | |
% Z ----------------------------- | |
tmp=get(H.Y_EDIT,'pos'); | |
H.Z_BTN = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2) 30 tmp(4)],... | |
'style','togglebutton',... | |
'fontweight','normal',... | |
'string','Z:',... | |
'value',0,... | |
'callback',{@l_ChangeSliderOrient,3}); | |
tmp=get(H.Z_BTN,'pos'); | |
H.Z_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3) tmp(2) 35 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','1',... | |
'callback',{@l_ChangeSlice,'editbox'}); | |
% V ------------------------------ | |
tmp=get(H.Z_BTN,'pos'); | |
H.V_BTN = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-tmp(4)-tmp_gap 30 tmp(4)],... | |
'style','togglebutton',... | |
'fontweight','normal',... | |
'string','V:',... | |
'value',0,... | |
'callback',{@l_ChangeSliderOrient,4},... | |
'enable','off'); | |
tmp=get(H.V_BTN,'pos'); | |
H.V_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3) tmp(2) 35 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','1',... | |
'callback',{@l_ChangeVolume,'editbox'},... | |
'enable','off'); | |
% Crossbars | |
tmp=get(H.SLICE_TOOLS,'pos'); | |
% H.SHOW_CROSSBARS = uicontrol('parent',H.FIG,... | |
% 'units','pixel',... | |
% 'position',[tmp(1)+5 tmp(2)+25 130 20],... | |
% 'style','checkbox',... | |
% 'fontweight','normal',... | |
% 'string','Show Crossbars',... | |
% 'backgroundcolor',GD.col.frame,... | |
% 'value',0,... | |
% 'callback',@l_ShowHideCrossbars); | |
H.VOXEL_VALUE_TX = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+20 130 13],... | |
'style','text',... | |
'fontweight','normal',... | |
'string','Current pixel value:',... | |
'horizontalalign','left',... | |
'backgroundcolor',GD.col.frame); | |
H.VOXEL_VALUE = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+5 130 13],... | |
'style','text',... | |
'fontweight','normal',... | |
'string','-',... | |
'horizontalalign','left',... | |
'backgroundcolor',GD.col.frame); | |
tmp=get(H.SLICE_TOOLS,'position'); | |
fig_pos = get(H.FIG,'position'); | |
%% Window/Level tools frame | |
H.WINDOWLEVEL_TOOLS=uicontrol('parent',H.FIG,... | |
'style','frame',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-5-220 ... | |
tmp(3) 220],... | |
'backgroundcolor',GD.col.frame); | |
% Window/Level text | |
tmp=get(H.WINDOWLEVEL_TOOLS,'position'); | |
H.WINDOWLEVEL_TOOLS_TX = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+tmp(4)-18 150 13],... | |
'style','text',... | |
'horizontalalign','left',... | |
'fontweight','bold',... | |
'backgroundcolor',GD.col.frame,... | |
'string','Window/Level'); | |
% Window slider ------------------------------ | |
tmp=get(H.WINDOWLEVEL_TOOLS,'position'); | |
H.WINDOW_SLIDER = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+5 tmp(2)+165 173 18],... | |
'style','slider',... | |
'min',0,... | |
'max',100,... | |
'value',100,... | |
'sliderstep',[0.01 0.1],... | |
'backgroundcolor',GD.col.slider); | |
tmp=get(H.WINDOW_SLIDER,'position'); | |
% Window Edit box | |
H.WINDOW_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+3 tmp(2) 37 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','',... | |
'callback',@l_SetWindowLevel); | |
% Window text | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)+tmp(4)+2 150 12],... | |
'style','text',... | |
'horizontalalign','left',... | |
'backgroundcolor',GD.col.frame,... | |
'string','Window (0% - 100%)'); | |
% Level slider --------------------------------- | |
tmp=get(H.WINDOW_SLIDER,'position'); | |
tmp_gap=20; | |
H.LEVEL_SLIDER = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-tmp(4)-tmp_gap tmp(3) tmp(4)],... | |
'style','slider',... | |
'min',0,... | |
'max',100,... | |
'value',50,... | |
'sliderstep',[0.01 0.1],... | |
'backgroundcolor',GD.col.slider); | |
tmp=get(H.LEVEL_SLIDER,'position'); | |
% Level Edit box | |
H.LEVEL_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+3 tmp(2) 37 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','',... | |
'callback',@l_SetWindowLevel); | |
% Level text | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)+tmp(4)+2 170 12],... | |
'style','text',... | |
'horizontalalign','left',... | |
'backgroundcolor',GD.col.frame,... | |
'string','Level (0% - 100%)'); | |
if ~Dat.HG2graphics | |
if Dat.MatlabVersion>7.03 | |
WindowSliderListener = handle.listener(H.WINDOW_SLIDER,... | |
'ActionEvent',@l_SetWindowLevel); | |
LevelSliderListener = handle.listener(H.LEVEL_SLIDER,... | |
'ActionEvent',@l_SetWindowLevel); | |
setappdata(H.WINDOW_SLIDER,'HandleListeners',... | |
[WindowSliderListener,LevelSliderListener]) | |
else | |
if feature('javafigures') | |
WindowSliderListener = handle.listener(H.WINDOW_SLIDER,... | |
'ActionEvent',@l_SetWindowLevel); | |
LevelSliderListener = handle.listener(H.LEVEL_SLIDER,... | |
'ActionEvent',@l_SetWindowLevel); | |
setappdata(H.WINDOW_SLIDER,'HandleListeners',... | |
[WindowSliderListener,LevelSliderListener]) | |
else | |
set(H.WINDOW_SLIDER,'callback',@l_SetWindowLevel) | |
set(H.LEVEL_SLIDER,'callback',@l_SetWindowLevel) | |
end | |
end | |
else | |
WindowSliderListener = addlistener(H.WINDOW_SLIDER,... | |
'ContinuousValueChange',@l_SetWindowLevel); | |
LevelSliderListener = addlistener(H.LEVEL_SLIDER,... | |
'ContinuousValueChange',@l_SetWindowLevel); | |
setappdata(H.WINDOW_SLIDER,'HandleListeners',... | |
[WindowSliderListener,LevelSliderListener]) | |
end | |
tmp=get(H.LEVEL_SLIDER,'position'); | |
% Clim Min text | |
H.CLIMRANGETEXT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[10 tmp(2)-25 50 15],... | |
'string','Range:',... | |
'horizontalalign','left',... | |
'style','text',... | |
'backgroundcolor',GD.col.frame); | |
tmp=get(H.CLIMRANGETEXT,'position'); | |
H.CLIMMINEDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[tmp(1)+tmp(3)+5 tmp(2) 60 18],... | |
'string','',... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'callback',@l_ChangeClim); | |
tmp=get(H.CLIMMINEDIT,'position'); | |
% % Clim Max text | |
H.CLIMMAXTEXT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[tmp(1)+tmp(3)+5 tmp(2) 25 15],... | |
'string','-',... | |
'horizontalalign','center',... | |
'style','text',... | |
'backgroundcolor',GD.col.frame); | |
% tmp=get(H.CLIMMAXTEXT,'position'); | |
% Max (Clim(2)) | |
H.CLIMMAXEDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[tmp(1)+tmp(3)+35 tmp(2) 60 18],... | |
'string','',... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'callback',@l_ChangeClim); | |
tmp=get(H.CLIMMINEDIT,'position'); | |
% Clim range behavior text | |
H.CLIMRANGEBEHTEXT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[10 tmp(2)-25 200 15],... | |
'string','Range in image stack:',... | |
'horizontalalign','left',... | |
'style','text',... | |
'backgroundcolor',GD.col.frame); | |
tmp=get(H.CLIMMINEDIT,'position'); | |
% Clim range popup | |
H.CLIMRANGE_POPUP = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[10 tmp(2)-45 210 20],... | |
'string',{'Range fixed (all images)',... | |
'Range fixed (image)','Range image min-max','Range auto-balanced W/L'},... | |
'horizontalalign','left',... | |
'style','popup',... | |
'enable','on',... | |
'value',1,... | |
'callback',@l_ChangeClimRange,... | |
'backgroundcolor','w'); | |
% Window/level autobalance | |
tmp=get(H.CLIMRANGE_POPUP,'position'); | |
H.WINDOWLEVEL_AUTO = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[tmp(1) tmp(2)-tmp(4)-30 35 35],... | |
'string','',... | |
'CData',btn_cdata.cdata.contrast,... | |
'tooltip','Window/level auto-balance',... | |
'style','pushbutton',... | |
'callback',@l_SetAutoWindowLevel); | |
tmp=get(H.WINDOWLEVEL_AUTO,'position'); | |
H.CONTRAST_INVERT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',... | |
[tmp(1)+tmp(3)+5 tmp(2) 35 35],... | |
'string','',... | |
'CData',btn_cdata.cdata.invertcontrast,... | |
'style','togglebutton',... | |
'tooltip','Invert contrast',... | |
'callback',@l_ColormapInvert); | |
tmp=get(H.CONTRAST_INVERT,'position'); | |
% Colormap popup | |
H.COLMAP_POPUP = uicontrol('parent',H.FIG,... | |
'style','popup',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+5 tmp(2) 130 25],... | |
'string',{'Gray','Jet','HSV','Cool','Hot','Spring',... | |
'Summer','Autumn','Winter','Bone','Copper','Pink','Custom'},... | |
'enable','on',... | |
'value',1,... | |
'backgroundcolor','w',... | |
'callback',{@l_ChangeColormap,[]}); | |
tmp=get(H.COLMAP_POPUP,'position'); | |
h1=uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)+tmp(4)+2 80 12],... | |
'style','text',... | |
'horizontalalign','left',... | |
'backgroundcolor',GD.col.frame,... | |
'string','Colormap'); | |
%% Analyze tools ------------------------ | |
tmp = get(H.WINDOWLEVEL_TOOLS,'position'); | |
H.ANALYZE_TOOLS = uicontrol('parent',H.FIG,...H.SIDEBAR,... | |
'style','frame',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-318-5 tmp(3) 318],...%[tmp(1) tmp(2)-348-5+40 tmp(3) 308],... | |
'backgroundcolor',GD.col.frame); | |
% Tab-group for uitabs | |
% $$$ H.ANALYZE_TABGROUP = uitabgroup('parent',H.ANALYZE_TOOLS,... | |
% $$$ 'units','normalized',... | |
% $$$ 'position',[0 0 1 1],... | |
% $$$ 'backgroundcolor',GD.col.frame); | |
% H.ANALYZE_TABGROUP = uipanel('parent',H.ANALYZE_TOOLS,... | |
% 'units','normalized',... | |
% 'position',[0 0 1 1],... | |
% 'backgroundcolor',GD.col.frame); | |
% Create uitabs | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% $$$ H.ROI_UITAB = uitab('parent',H.ANALYZE_TABGROUP,... | |
% $$$ 'title','ROI tools'); | |
% H.ROI_ANALYSIS = uicontrol('parent',H.FIG,...H.ROI_UITAB,... | |
% 'units','normal',... | |
% 'position',[0 0 1 1],... | |
% 'backgroundcolor',GD.col.frame,... | |
% 'bordertype','etchedin'); | |
tmp = get(H.ANALYZE_TOOLS,'position'); | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[10 tmp(2)+tmp(4)-20 200 14],...%[10 332-40 200 14],... | |
'style','text',... | |
'string','ROI Analysis',... | |
'horizontalalign','left',... | |
'fontweight','bold',... | |
'backgroundcolor',GD.col.frame); | |
% Radiobutton group for ROI buttons | |
tmp=get(h1,'position'); | |
H.ROITOOLS_FRAME=uicontrol('parent',H.FIG,... | |
'style','frame',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-55 212 50]);%[10 259-40 212 70]); | |
tmp=get(H.ROITOOLS_FRAME,'position'); | |
% ROI buttons | |
tmp=get(H.ROITOOLS_FRAME,'position'); | |
H.ROIBTN_NEW = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[14 tmp(2)+5 40 40],... | |
'string','',... | |
'CData',btn_cdata.cdata.add,... | |
'callback',@l_RoiAdd,... | |
'tooltip','Create a new ROI'); | |
tmp=get(H.ROIBTN_NEW,'position'); | |
tmp_gap=1; | |
H.ROIBTN_COPY = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2:4)],... | |
'string','',... | |
'CData',btn_cdata.cdata.copy,... | |
'callback',@l_RoiCopy,... | |
'enable','off',... | |
'tooltip','Copy ROI to slices/volumes'); | |
tmp=get(H.ROIBTN_COPY,'position'); | |
H.ROIBTN_DEL = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2:4)],... | |
'string','',... | |
'enable','off',... | |
'CData',btn_cdata.cdata.delete,... | |
'callback',{@l_RoiDelete,'selected'},... | |
'tooltip','Delete selected ROI(s)'); | |
tmp=get(H.ROIBTN_DEL,'position'); | |
H.ROIBTN_DELALL = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2:4)],... | |
'string','',... | |
'enable','off',... | |
'CData',btn_cdata.cdata.deleteall,... | |
'callback',{@l_RoiDelete,'all'},... | |
'tooltip','Delete ALL ROIs'); | |
tmp=get(H.ROIBTN_DELALL,'position'); | |
H.ROIBTN_UNDO = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+tmp_gap tmp(2:4)],... | |
'string','',... | |
'fontweight','bold',... | |
'enable','off',... | |
'CData',btn_cdata.cdata.undo,... | |
'tooltip','Undo last draw action',... | |
'callback',@l_RoiUndo); | |
tmp=get(H.ROITOOLS_FRAME,'position'); | |
H.ROIBTN_LOAD = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-70 40 40],... | |
'string','',... | |
'fontweight','bold',... | |
'enable','on',... | |
'CData',btn_cdata.cdata.load,... | |
'tooltip','Load ROI(s)',... | |
'callback',{@l_RoiLoad,'interactive'}); | |
tmp=get(H.ROIBTN_LOAD,'position'); | |
H.ROIBTN_SAVE = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-tmp(4)-5 tmp(3:4)],... | |
'string','',... | |
'fontweight','bold',... | |
'enable','off',... | |
'CData',btn_cdata.cdata.save2,... | |
'tooltip','Save ROI(s)',... | |
'callback',@l_RoiSave); | |
tmp=get(H.ROIBTN_SAVE,'position'); | |
H.ROIBTN_STATS = uicontrol('parent',H.FIG,... | |
'style','pushbutton',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-tmp(4)-5 tmp(3:4)],... | |
'string','',... | |
'fontweight','bold',... | |
'enable','off',... | |
'CData',btn_cdata.cdata.statistics_large,... | |
'tooltip','View ROI statistics',... | |
'callback',@l_RoiViewStats); | |
tmp=get(H.ROIBTN_LOAD,'position'); | |
% ROI selection listbox | |
%uicm=uicontextmenu; | |
%uimenu(uicm,'Label','Add') | |
%uimenu(uicm,'Label','testi2') | |
H.ROIVIEW_LBOX = uicontrol('parent',H.FIG,... | |
'style','listbox',... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+5 tmp(2)-85+40 165 85],... | |
'string','',... | |
'min',0,... | |
'max',2,... | |
'value',[],... | |
'backgroundcolor','w',... | |
'fontweight','bold',... | |
'string','',... | |
'callback',@l_RoiView); | |
tmp=get(H.ROIVIEW_LBOX,'position'); | |
h1=uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)+tmp(4)+2 86 14],... | |
'style','text',... | |
'string','View ROI(s)',... | |
'horizontalalign','left',... | |
'fontweight','normal',... | |
'backgroundcolor',GD.col.frame); | |
h1=uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-21 150 14],... | |
'style','text',... | |
'string','Edit/Current ROI',... | |
'horizontalalign','left',... | |
'fontweight','normal',... | |
'backgroundcolor',GD.col.frame); | |
tmp=get(h1,'position'); | |
H.ROI_EDIT = uicontrol('parent',H.FIG,... | |
'style','popup',... | |
'units','pixel',... | |
'position',[tmp(1) tmp(2)-24 165 24],... | |
'string',{''},... | |
'enable','off',... | |
'backgroundcolor','w',... | |
'callback',@l_UpdateRoiInfoText); | |
tmp=get(H.ROI_EDIT,'position'); | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[10 tmp(2)-35 133 14],... | |
'style','text',... | |
'string','ROI Transparency',... | |
'horizontalalign','left',... | |
'fontweight','normal',... | |
'backgroundcolor',GD.col.frame); | |
tmp=get(h1,'position'); | |
H.ROI_TRANSP_SLIDER = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[10 tmp(2)-18 170 18],... | |
'style','slider',... | |
'min',0,... | |
'max',1,... | |
'value',0.5,... | |
'sliderstep',[0.1 0.3],... | |
'backgroundcolor',GD.col.slider); | |
if ~Dat.HG2graphics | |
RoiTransparencyListener = handle.listener(H.ROI_TRANSP_SLIDER,... | |
'ActionEvent',... | |
{@l_SetRoiTransparency, ... | |
'slider'}); | |
set(H.ROI_TRANSP_SLIDER,'userdata',RoiTransparencyListener) | |
else | |
RoiTransparencyListener=addlistener(H.ROI_TRANSP_SLIDER,... | |
'ContinuousValueChange',@l_SetRoiTransparency); | |
set(H.ROI_TRANSP_SLIDER,'userdata',RoiTransparencyListener) | |
end | |
tmp=get(H.ROI_TRANSP_SLIDER,'position'); | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[10 tmp(2)-14 88 14],... | |
'style','text',... | |
'string','Transparent',... | |
'horizontalalign','left',... | |
'fontweight','normal',... | |
'fontsize',8,... | |
'backgroundcolor',GD.col.frame); | |
h1 = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)-88 tmp(2)-14 88 14],... | |
'style','text',... | |
'string','Opaque',... | |
'horizontalalign','right',... | |
'fontweight','normal',... | |
'fontsize',8,... | |
'backgroundcolor',GD.col.frame); | |
H.ROI_TRANSP_EDIT = uicontrol('parent',H.FIG,... | |
'units','pixel',... | |
'position',[tmp(1)+tmp(3)+3 tmp(2) 38 tmp(4)],... | |
'style','edit',... | |
'backgroundcolor','w',... | |
'string','0.5',... | |
'callback',{@l_SetRoiTransparency,'edit'},... | |
'userdata',0.5); | |
%% Draw invisible uipanel for axes | |
%tmp=get(H.SIDEBAR,'position'); | |
tmp=get(H.SIDEBAR_FRAME,'position'); | |
% $$$ H.AXES_UIPANEL = uipanel('parent',H.FIG,... | |
% $$$ 'units','pixel',... | |
% $$$ 'position',[tmp(1)+tmp(3) ... | |
% $$$ 0 fig_pos(3)-(tmp(1)+tmp(3)) fig_pos(4)],... | |
% $$$ 'backgroundcolor',GD.col.mainfig,... | |
% $$$ 'bordertype','none',... | |
% $$$ 'tag','ax_uipanel'); | |
%% Draw image axes | |
gap=10*dxx; | |
%pos=get(H.SIDEBAR,'position'); | |
pos=get(H.SIDEBAR_FRAME,'position'); | |
% Calculate axis positions | |
%ax_pos=l_AxesPositions([],[],0,[256,256;256,256;256,256]); | |
ax_pos = ones(3,4); | |
H.IMAX1=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(1,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',...%'Yticklabel',{},... 'Xticklabel',{},... | |
'Box','on', ... | |
'xgrid','on',... | |
'ygrid','on',... | |
'Fontsize',GD.ax_fs,... | |
'visible','off'); | |
H.IMOVERLAYAX(1)=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(1,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',... | |
'Box','on', ... | |
'xgrid','off',... | |
'ygrid','off',... | |
'Fontsize',GD.ax_fs,... | |
'visible','off',... | |
'hittest','off'); | |
H.IMAX2=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(2,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',...%'Yticklabel',{},... 'Xticklabel',{},... | |
'Box','on', ... | |
'Fontsize',GD.ax_fs,... | |
'visible','off'); | |
H.IMOVERLAYAX(2)=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(2,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',... | |
'Box','on', ... | |
'xgrid','off',... | |
'ygrid','off',... | |
'Fontsize',GD.ax_fs,... | |
'visible','off',... | |
'hittest','off'); | |
H.IMAX3=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(3,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',...%'Yticklabel',{},... 'Xticklabel',{},... | |
'Box','on', ... | |
'Fontsize',GD.ax_fs,... | |
'visible','off'); | |
H.IMOVERLAYAX(3)=axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
ax_pos(3,:),'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'ydir','reverse',... | |
'Box','on', ... | |
'xgrid','off',... | |
'ygrid','off',... | |
'Fontsize',GD.ax_fs,... | |
'visible','off',... | |
'hittest','off'); | |
H.COLORBAR_AX = axes('Parent',H.FIG,... | |
'units','pixel',... | |
'Position', ... | |
[1 1 1 1],'Ylim',[0 1], ... | |
'xlim',[0 1],... | |
'yaxislocation','right',... | |
'ydir','reverse',...%'Yticklabel',{},... 'Xticklabel',{},... | |
'Box','on', ...%'fontunits','normal',...'Fontsize',0.023,... | |
'fontsize',8,... | |
'visible','on'); | |
H.COLORBAR_IM = []; | |
H.IMROI=[]; | |
H.ROIAX=[]; | |
H.IMOVERLAY=[]; | |
% Info text | |
H.INFOTEXT = text('parent',H.IMAX1,... | |
'units','normalized',... | |
'position',[0.01 0.99],... | |
'verticalalign','top',... | |
'horizontalalign','left',... | |
'string',{'File: ','Slice: ','Image size: ','Zoom: '},... | |
'visible','off',... | |
'color','w',... | |
'interpreter','none',... | |
'fontsize',9,... | |
'fontname','fixedwidth',... | |
'backgroundcolor','none'); | |
if ~Dat.HG2graphics | |
set(H.INFOTEXT,'erasemode','normal') | |
end | |
if isunix | |
set(H.INFOTEXT,'fontname','bitstream vera sans mono') | |
end | |
H.ROIINFOTEXT = text('parent',H.IMAX1,... | |
'units','normalized',... | |
'position',[0.01 0.01],... | |
'verticalalign','bottom',... | |
'horizontalalign','left',... | |
'color','w',... | |
'string',... | |
{'Current ROI:',... | |
'Mean:',... | |
'STD:',... | |
'Sum:',... | |
'Min:',... | |
'Max:',... | |
'Pixel Count:'},... | |
'visible','off',... | |
'interpreter','none',... | |
'fontsize',9,... | |
'fontname','fixedwidth',... | |
'backgroundcolor','none'); | |
if ~Dat.HG2graphics | |
set(H.ROIINFOTEXT,'erasemode','normal') | |
end | |
if isunix | |
set(H.ROIINFOTEXT,'fontname','bitstream vera sans mono') | |
end | |
% Set axes to the bottom of the uistack | |
fig_childs = get(H.FIG,'children'); | |
ind=ismember(double(fig_childs),double([H.IMAX1,H.IMAX2,H.IMAX3])'); | |
fig_childs(end+1:end+3)=fig_childs(ind); | |
fig_childs(ind)=[]; | |
set(H.FIG,'children',fig_childs) | |
% Set KeyPressFcn for uicontrol objects | |
h=findobj(H.FIG,'type','uicontrol'); | |
set(h,'KeyPressFcn',@l_KeyPressFcn); | |
set(h(strcmpi(get(h,'style'),'edit')),'KeyPressFcn','') | |
%% Draw frame | |
H.BLANK_FRAME = uicontrol('Parent',H.FIG,'Units','normalized', ... | |
'Backgroundcol',[0.5 0.5 0.5], ... | |
'Tag','BLANK_FRAME', ... | |
'Position',[0 0 1 1],'Style','frame',... | |
'visible','on'); | |
% Get uicontrol original positions for ResizeFcn ------------- | |
uich=findobj(H.FIG,'type','uicontrol'); | |
uich(find(uich==H.IMSLIDER_FRAME))=[]; | |
uich(find(uich==H.SIDEBAR_FRAME))=[]; | |
uich(find(uich==H.IMSLIDER(1)))=[]; | |
uich(find(uich==H.IMSLIDER(2)))=[]; | |
uich(find(uich==H.BLANK_FRAME))=[]; | |
tmp=get(uich,'position'); | |
H.UICH_ORIG_POS = reshape([tmp{:}],4,length(tmp))'; | |
% Get handles to uicontrols that need to be enabled after initialising | |
H.UICH_ENABLED=uich(strcmp(get(uich,'enable'),'on')); | |
H.UICH_ENABLED(end+1)=view_h; | |
H.UICH_ENABLED(end+1)=edit_h; | |
H.UICH_ENABLED(end+1)=roi_tools_h; | |
H.UICH_ENABLED(end+1)=closefile_h; | |
%H.UICH_ENABLED(end+1)=H.viewprocpar_h; | |
H.UICH_ENABLED(end+1)=H.UIOVERLAY; | |
H.UICH_ENABLED(end+1)=H.UIPUSH_SAVE; | |
%H.UICH_ENABLED(end+1)=H.UIPUSH_PRINT; | |
H.UICH_ENABLED(end+1)=H.FILEMENU_SAVE_IMAGE; | |
H.UICH_ENABLED(end+1)=H.FILEMENU_SAVERES; | |
H.UICH_ENABLED(end+1)=H.UIPUSH_IMSTACK; | |
H.UICH_ENABLED(end+1)=H.UIPUSH_ROTATE; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_VIEW3D; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_VIEWX; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_VIEWY; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_VIEWZ; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_GRID; | |
H.UICH_ENABLED(end+1)=H.UIPLUGINS; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_INFO; | |
H.UICH_ENABLED(end+1)=H.UIPUSH_NEWROI; | |
H.UICH_ENABLED(end+1)=H.ROIBTN_LOAD; | |
H.UICH_ENABLED(end+1)=H.FILEMENU_EXPORT; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_COLORBAR; | |
H.UICH_ENABLED(end+1)=H.UITOGGLE_CROSSHAIRS; | |
H.UICH_ENABLED(end+1)=H.UNFOLD_DATA; | |
% Get handles to the uicontrols that need to enabled when ROIs are | |
% defined | |
H.UICH_ROIENABLED = [H.UIROITOOLS_SAVE,... | |
H.UIROITOOLS_SAVETEMPLATE,... | |
H.UIROITOOLS_COPY,... | |
H.UIROITOOLS_COMP,... | |
H.UIROITOOLS_FLIP,... | |
H.UIROISTATS,... | |
H.UITOGGLE_DRAWROI,... | |
H.UITOGGLE_ERASEROI,... | |
H.UITOGGLE_FILLROI,... | |
H.UITOGGLE_MOVEROI,... | |
H.UITOGGLE_MOVEROI3D,... | |
H.UIPUSH_COPYROI,... | |
H.ROIBTN_COPY,... | |
H.ROIBTN_DEL,... | |
H.ROIBTN_DELALL,... | |
H.ROIBTN_SAVE,... | |
H.ROIBTN_STATS,... | |
H.ROI_EDIT,... | |
H.UIROISHOWEDGES,... | |
H.UIROIRENAME,... | |
H.UIROISETCOLOR,... | |
H.UIPUSH_STATS_ROI]; | |
% Set enable off for all the uicontrols, when there is no data | |
set(uich,'enable','off') | |
end % function H=l_draw_gui() | |
%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% Open file(s) | |
%% | |
%%%%%%%%%%%%%%%%%%%%%% | |
function l_OpenFile(h,evd,opt,FileName) | |
try | |
% Ask if ROI(s) should be saved | |
cancel=l_CheckRoiSaved; | |
if cancel | |
return | |
end | |
if exist('FileName','var') | |
PromptFiles = false; | |
else | |
PromptFiles = true; | |
end | |
%Dat.LoadRoiAtStartUp = false; | |
if PromptFiles | |
% Default filepath | |
try | |
filepath=getpref('Aedes','GetDataFileDir'); | |
catch | |
filepath=''; | |
end | |
[filefilt,dataformats] = aedes_getfilefilter; | |
% Ask for a file | |
if strcmpi(opt,'single') | |
[f_name, f_path, f_index] = uigetfile( ... | |
filefilt, ... | |
'Select data file',filepath); | |
if ( all(f_name==0) | all(f_path==0) ) % Cancel is pressed | |
return | |
end | |
% There is a bug in uigetfile in OSX version of Matlab and the | |
% fid-directory may be returned instead of the fid-file. | |
if ismac | |
if length(f_name)>3 && strcmpi(f_name(end-3:end),'.fid') | |
f_path = [fullfile(f_path,f_name),filesep]; | |
f_name = 'fid'; | |
end | |
end | |
else | |
[f_name, f_path, f_index] = aedes_juigetfiles( ... | |
filefilt, ... | |
'Select data file(s)',filepath); | |
if ~iscell(f_name) && ~iscell(f_path) | |
if ( all(f_name==0) | all(f_path==0) ) % Cancel is pressed | |
return | |
end | |
end | |
end | |
% Put strings in a cell array so we don't have to check it all the | |
% time... | |
if ~iscell(f_name) | |
f_path = {f_path}; | |
f_name = {f_name}; | |
end | |
% Set current directory to preferences | |
setpref('Aedes','GetDataFileDir',f_path{1}) | |
else | |
if strcmpi(opt,'single') | |
[f_path,f_name,f_ext]=fileparts(FileName); | |
if isempty(f_path) | |
f_path = {[pwd,filesep]}; | |
else | |
if ispc && length(f_path)<3 | |
f_path = {[pwd,filesep,f_path,filesep]}; | |
elseif isunix && f_path(1)~=filesep | |
f_path = {[pwd,filesep,f_path,filesep]}; | |
else | |
f_path = {[f_path,filesep]}; | |
end | |
end | |
f_name = {[f_name,f_ext]}; | |
% f_index = 0; | |
% dataformat = ''; | |
% Check that the file exists... | |
if exist([f_path{1},f_name{1}],'file')~=2 | |
showError = true; | |
% If the file cannot be found, it might be a VNMR file with only | |
% folder reference... | |
if strcmpi(f_ext,'.fid') | |
if exist([f_path{1},f_name{1},filesep,'fid'],'file')~=2 | |
showError = true; | |
else | |
showError = false; | |
f_path = {[f_path{1},f_name{1},filesep]}; | |
f_name = {'fid'}; | |
end | |
end | |
if showError | |
h=errordlg({'Could not find file',... | |
['"',f_path{1},f_name{1},'"'],... | |
'','Check that the file has not been removed and can be accessed.'},... | |
'Cannot not find file', ... | |
'modal'); | |
uiwait(h); | |
return | |
end | |
end | |
else | |
f_name = {}; | |
f_path = {}; | |
%f_index = 0; | |
%% Extract file and path names to separate cell arrays | |
for ii=1:length(FileName) | |
[fp,fn,fe]=fileparts(FileName{ii}); | |
f_path{ii} = [fp,filesep]; | |
f_name{ii} = [fn,fe]; | |
end | |
%dataformat = ''; | |
end | |
end | |
% Close file if necessary | |
if ~isempty(DATA) | |
l_CloseFile([],[]); | |
end | |
%% Read the data from other data files | |
if strcmpi(opt,'single') || length(f_name)==1 | |
try | |
DATA=aedes_data_read([f_path{1},f_name{1}]); | |
catch | |
h=errordlg({['Could not read file "',[f_path{1},f_name{1}],'"'],'',lasterr},... | |
'Error reading file', ... | |
'modal'); | |
uiwait(h); | |
return | |
end | |
% Set to Recent Files menu | |
l_BuildRecentFilesMenu([],[],[],[f_path{1},f_name{1}]); | |
else | |
DATA={}; | |
count=0; | |
SkippedFiles={}; | |
SkippedInd = []; | |
[h,txh]=aedes_calc_wait({['Reading file 1/',... | |
num2str(length(f_name))],'""'}); | |
for ii=1:length(f_name) | |
set(txh,'String',... | |
sprintf('%s\n%s',['Reading file ' num2str(ii) '/' num2str(length(f_name))],... | |
['"',f_path{ii},f_name{ii},'"'])) | |
drawnow | |
try | |
tmp=aedes_data_read([f_path{ii},f_name{ii}],'wbar','off'); | |
% Determine from the first file if we are reading one slice data into | |
% "mixed" cell arrayed format or 3D volumes into a 4D file | |
if ii==1 | |
if ndims(tmp.FTDATA)==3 | |
% Read 3D data into 4D array | |
Read2Mixed = false; | |
% Reserve space for data | |
DATA = tmp; | |
DATA.FTDATA = zeros(size(tmp.FTDATA,1),... | |
size(tmp.FTDATA,2),size(tmp.FTDATA,3),... | |
length(f_name),class(tmp.FTDATA)); | |
DATA.FTDATA(:,:,:,1)=tmp.FTDATA; | |
elseif ndims(tmp.FTDATA)==2 | |
% Read 2D slices into mixed cell array... | |
Read2Mixed = true; | |
DATA = {tmp}; | |
else | |
% Throw error... | |
Read2Mixed = false; | |
error('Reading of multiple 4D files is not supported.') | |
end | |
end | |
if ~Read2Mixed | |
if isequal(size(DATA.FTDATA(:,:,:,1)),size(tmp.FTDATA)) | |
DATA.FTDATA(:,:,:,ii) = tmp.FTDATA; | |
else | |
count=count+1; | |
SkippedFiles{count} = [f_path{ii},f_name{ii}]; | |
disp(['Aedes: Warning: Data size in file "',f_path{ii},... | |
f_name{ii},'" does not match with the first data file! Skipping file...']) | |
end | |
elseif Read2Mixed | |
DATA{ii}=tmp; | |
if length(size(tmp.FTDATA))>2 | |
count=count+1; | |
SkippedInd(end+1) = ii; | |
SkippedFiles{count} = [f_path{ii},f_name{ii}]; | |
DATA{ii}=[]; | |
disp(['Aedes: Warning: File "',f_path{ii},... | |
f_name{ii},'" contains multiple slices! Skipping file...']) | |
end | |
end | |
catch | |
if ii==1 | |
h=errordlg({'Could not read file',... | |
['"',f_path{ii},f_name{ii},'"'],... | |
'','Returned error:',lasterr},... | |
'Could not read file','modal'); | |
DATA = []; | |
break | |
elseif Read2Mixed | |
count=count+1; | |
SkippedFiles{count} = [f_path{ii},f_name{ii}]; | |
DATA{ii}=[]; | |
disp(['Aedes: Warning: Could not read file "',... | |
f_path{ii},f_name{ii},'". Skipping file...']) | |
else | |
% Throw the actual error and break | |
h=errordlg({'Could not read file',... | |
['"',f_path{ii},f_name{ii},'"'],... | |
'','Returned error:',lasterr},... | |
'Could not read file','modal'); | |
DATA = []; | |
break | |
end | |
end | |
end | |
delete(h) | |
% Ensure that there are no empty values in DATA | |
if iscell(DATA) | |
empty_val=cellfun('isempty',DATA); | |
if all(empty_val) | |
DATA=[]; | |
else | |
DATA(empty_val)=[]; | |
end | |
end | |
% If the data consists of multiple 2D files that are all of the same | |
% size, ask if the user wants to view them as 3D data. | |
if Read2Mixed | |
nFiles = length(DATA); | |
X = zeros(1,nFiles); | |
Y = zeros(1,nFiles); | |
for ii = 1:nFiles | |
X(ii)=size(DATA{ii}.FTDATA,1); | |
Y(ii)=size(DATA{ii}.FTDATA,2); | |
end | |
if all(X==X(1)) && all(Y==Y(1)) | |
resp = questdlg('Do you want to view data as a 3D data set or a 2D image stack?',... | |
'View data 3D or 2D?','View as 3D data','View as 2D image stack','View as 2D image stack'); | |
if isempty(resp) | |
viewAs3D = false; | |
elseif strcmpi(resp,'View as 3D data') | |
viewAs3D = true; | |
else | |
viewAs3D = false; | |
end | |
if viewAs3D | |
tmp = DATA{1}; | |
tmp.FTDATA = zeros(X(1),Y(1),nFiles,class(DATA{1}.FTDATA)); | |
for ii = 1:nFiles | |
tmp.FTDATA(:,:,ii) = DATA{ii}.FTDATA; | |
DATA{ii}.FTDATA=[]; | |
end | |
DATA=[]; | |
DATA=tmp; | |
end | |
end | |
end | |
% Remove skipped volumes | |
if ~Read2Mixed && ~isempty(SkippedInd) | |
DATA.FTDATA(:,:,:,SkippedInd) = []; | |
end | |
% Warn about skipped files | |
if count~=0 | |
if isempty(DATA) | |
h=errordlg(['All files were skipped either due to errors ',... | |
'or because they contained multiple slices.'],... | |
'Could not read files','modal'); | |
return | |
else | |
h=warndlg({['The following file(s) were ',... | |
'skipped either due to errors or ',... | |
'because they contained multiple slices:'],'',SkippedFiles{:}},... | |
'Some Files Were Skipped','modal'); | |
uiwait(h) | |
end | |
end | |
end | |
if isempty(DATA) | |
% Canceled | |
return | |
end | |
if isstruct(DATA) | |
DATA = {DATA}; | |
end | |
%% Load ROI also if they can be found in the DATA structure | |
if isfield(DATA{1},'ROI') | |
ROI = DATA{1}.ROI; | |
DATA{1}=rmfield(DATA{1},'ROI'); | |
end | |
%% If the DATA was loaded from MAT-File, it might also contain rotation | |
%% and flipping and clim information | |
if isfield(DATA{1},'DataRotation') && isfield(DATA{1},'DataFlip') | |
Dat.DataRotation = DATA{1}.DataRotation; | |
Dat.DataFlip = DATA{1}.DataFlip; | |
DATA{1}=rmfield(DATA{1},'DataRotation'); | |
DATA{1}=rmfield(DATA{1},'DataFlip'); | |
end | |
if isfield(DATA{1},'RotateFlip3d') | |
Dat.RotateFlip3d = DATA{1}.RotateFlip3d; | |
DATA{1}=rmfield(DATA{1},'RotateFlip3d'); | |
end | |
% Check if data file contain only kspace information | |
if length(DATA)==1 && isfield(DATA{1},'KSPACE') && ... | |
(isempty(DATA{1}.FTDATA) & ~isempty(DATA{1}.KSPACE) ) | |
drawnow; | |
resp=questdlg(['The inputted DATA structure contains only k-space',... | |
' information. Do you want to view real, imaginary, or absolute',... | |
' part of the complex k-space?'],... | |
'Complex data inputted',... | |
'Real','Imaginary','Absolute','Absolute'); | |
if strcmpi(resp,'Real') | |
DATA{1}.FTDATA = real(DATA{1}.KSPACE); | |
elseif strcmpi(resp,'Imaginary') | |
DATA{1}.FTDATA = imag(DATA{1}.KSPACE); | |
elseif strcmpi(resp,'Absolute') | |
DATA{1}.FTDATA = abs(DATA{1}.KSPACE); | |
else | |
DATA=[]; | |
return | |
end | |
end | |
% Initialize GUI | |
l_Initialize([],[]); | |
if isfield(DATA{1},'SliceClim') | |
Dat.SliceClim = DATA{1}.SliceClim; | |
DATA{1}=rmfield(DATA{1},'SliceClim'); | |
set(H.CLIMRANGE_POPUP,'value',2) | |
l_ChangeClimRange([],[]) | |
end | |
%% If the ROI-structure has been given in file load time, refresh ROIs | |
if ~isempty(ROI) | |
l_RoiLoad([],[],'') | |
end | |
catch | |
aedes_errordump(lasterror); | |
end | |
end % function l_OpenFile(h, | |
%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% Save Image Data | |
%% | |
%%%%%%%%%%%%%%%%%%%%%%%%% | |
function l_SaveImageData(h,evd) | |
try | |
%% Get default save path | |
try | |
filepath=getpref('Aedes','PutDataFileDir'); | |
catch | |
filepath=''; | |
end | |
%% Save 3D data | |
if length(DATA)==1 | |
%% Get default save file name | |
try | |
if isfield(DATA{Dat.DataInd},'DataFormat') && ... | |
strcmpi(DATA{Dat.DataInd}.DataFormat,'vnmr') | |
[fp,fn,fe]=fileparts([DATA{Dat.DataInd}.HDR.fpath,DATA{Dat.DataInd}.HDR.fname]); | |
[fp,fn,fe]=fileparts(fp); | |
else | |
[fp,fn,fe]=fileparts([DATA{Dat.DataInd}.HDR.fpath,DATA{Dat.DataInd}.HDR.fname]); | |
end | |
catch | |
fp=[pwd,filesep]; | |
fn=''; | |
fe=''; | |
end | |
%% Get saved file name and type | |
[fname, fpath, findex] = uiputfile( ... | |
{'*.nii;*.NII','NIfTI-files (*.nii)'; ... | |
'*.hdr;*.HDR','Analyze 7.5 files (*.hdr)';... | |
'*.mat:*.MAT','Matlab MAT-File (*.mat)';... | |
'*.mri;*.MRI','MRI-files (*.mri)'}, ... | |
'Save Image Data as', [filepath,fn]); | |
if ( all(fname==0) | all(fpath==0) ) % Cancel is pressed | |
return | |
end | |
%% Set fpath to preferences | |
setpref('Aedes','PutDataFileDir',fpath); | |
% Write NIfTI-files ------------------------- | |
if findex==1 | |
%% Prompt save type | |
resp=questdlg('Save slices in separate NIfTI-files or in a single file?',... | |
'Separate files or single file?',... | |
'Separate files','Single file','Cancel',... | |
'Separate files'); | |
if isempty(resp) || strcmpi(resp,'Cancel') | |
return | |
elseif strcmpi(resp,'Separate files') | |
singleFile = false; | |
else | |
singleFile = true; | |
end | |
fext = '.nii'; | |
fileType = 'NIfTI'; | |
elseif findex==2 % Write Analyze 7.5 file(s) ---------------- | |
%% Prompt save type | |
resp=questdlg('Save slices in separate Analyze75-files or in a single file?',... | |
'Separate files or single file?',... | |
'Separate files','Single file','Cancel',... | |
'Separate files'); | |
if isempty(resp) || strcmpi(resp,'Cancel') | |
return | |
elseif strcmpi(resp,'Separate files') | |
singleFile = false; | |
else | |
singleFile = true; | |
end | |
fext = '.hdr'; | |
fileType = 'Analyze 7.5'; | |
elseif findex==3 % Save data in MATLAB MAT-File ------------------ | |
[fp,fn,fe]=fileparts([fpath,fname]); | |
try | |
SliceClim = Dat.SliceClim; | |
if strcmpi(fe,'.mat') | |
save([fpath,fname],'DATA','SliceClim','-mat') | |
else | |
save([fp,filesep,fn,'.mat'],'DATA','SliceClim','-mat') | |
end | |
catch | |
errordlg({'Could not save MAT-file. The following error was returned:',... | |
'',lasterr},'Error saving MAT-file!','modal') | |
end | |
return | |
else % Save data in MRI-files ------------------- | |
singleFile = false; | |
%% Warn about MRI-files | |
resp=questdlg({['WARNING! Exporting data to MRI-format is not advisable. ' ... | |
'The data will be scaled and rounded to 12-bit before ' ... | |
'writing into the MRI-file, and scaling errors of ' ... | |
'various severities will occur!'],'',... | |
'Are you sure you want to continue?'},'WARNING!',... | |
'Yes','No','No'); | |
if isempty(resp) || strcmpi(resp,'No') | |
return | |
end | |
fileType = 'MRI'; | |
fext = '.mri'; | |
end | |
% Determine file prefix | |
[fp,fn,fe]=fileparts([fpath,fname]); | |
if strcmpi(fe,fext) | |
fprefix = fn; | |
else | |
fprefix = [fn,fe]; | |
end | |
done=false; | |
%% Write separate files | |
if ~singleFile | |
% Create file names | |
filenames={}; | |
for ii=1:Dat.ImageDim(3) | |
filenames{ii}=sprintf('%s%03d%s',[fprefix,'_'],ii,fext); | |
end | |
nFiles = length(filenames); | |
% Check if files exist | |
ind=aedes_check_file_exist(filenames,fpath); | |
if any(ind) | |
% Warn if some files are about to be overwritten | |
overwrited_files = {filenames{ind}}; | |
% Limit the file list to 20 files | |
if length(overwrited_files)>20 | |
overwrited_files = {overwrited_files{1:20}}; | |
overwrited_files{end+1}='...'; | |
end | |
resp=questdlg({['The following files already exist in the output directory' ... | |
' "',fpath,'"'],'','(NOTE: max. 20 files shown here)','',... | |
overwrited_files{:},'',... | |
'Do you want to overwrite these files?'},... | |
'Overwrite Existing Files?','Overwrite','Abort','Abort'); | |
if isempty(resp) || strcmpi(resp,'Abort') | |
return | |
end | |
end | |
if strcmpi(fileType,'MRI') | |
done=true; | |
h=aedes_wbar(0,sprintf('Saving slice 1/%d in MRI format...',nFiles)); | |
for ii=1:nFiles | |
aedes_wbar(ii/nFiles,h,sprintf('Saving slice %d/%d in MRI format...',ii, ... | |
nFiles)) | |
try | |
aedes_smiswrite(DATA{Dat.DataInd}.FTDATA(:,:,ii),... | |
[fpath,filenames{ii}]) | |
catch | |
done=false; | |
break | |
end | |
end | |
elseif strcmpi(fileType,'NIfTI') | |
h=aedes_wbar(0,sprintf('Saving slice 1/%d in NIfTI format...',nFiles)); | |
for ii=1:nFiles | |
aedes_wbar(ii/nFiles,h,sprintf('Saving slice %d/%d in NIfTI format...',ii, ... | |
nFiles)) | |
[done,msg]=aedes_write_nifti(DATA{Dat.DataInd}.FTDATA(:,:,ii),... | |
[fpath,filenames{ii}],'DataType','single',... | |
'FileType',2,'Clim',Dat.SliceClim(Dat.DataInd,:)); | |
end | |
elseif strcmpi(fileType,'Analyze 7.5') | |
h=aedes_wbar(0,sprintf('Saving slice 1/%d in Analyze 7.5 format...',nFiles)); | |
for ii=1:nFiles | |
aedes_wbar(ii/nFiles,h,sprintf('Saving slice %d/%d in Analyze 7.5 format...',ii, ... | |
nFiles)) | |
[done,msg]=aedes_write_nifti(DATA{Dat.DataInd}.FTDATA(:,:,ii),... | |
[fpath,filenames{ii}],'DataType','single',... | |
'FileType',0,'Clim',Dat.SliceClim(Dat.DataInd,:)); | |
end | |
end | |
else | |
if strcmpi(fileType,'NIfTI') | |
[h,txh]=aedes_calc_wait('Saving image data in NIfTI format...'); | |
[done,msg]=aedes_write_nifti(DATA{Dat.DataInd}.FTDATA,... | |
[fpath,fname],'filetype',2,... | |
'Clim',Dat.SliceClim(Dat.DataInd,:)); | |
elseif strcmpi(fileType,'Analyze 7.5') | |
[h,txh]=aedes_calc_wait('Saving image data in Analyze 7.5 format...'); | |
[done,msg]=aedes_write_nifti(DATA{Dat.DataInd}.FTDATA,... | |
[fpath,fname],'filetype',0,... | |
'Clim',Dat.SliceClim(Dat.DataInd,:)); | |
end | |
end | |
delete(h) | |
%% Show warning if something went wrong | |
if ~done | |
h=errordlg(msg,'Error while saving image data','modal') | |
uiwait(h); | |
return | |
end | |
%% Save Slice Data | |
else | |
%% Get default save file name | |
if strcmpi(DATA{Dat.DataInd}.DataFormat,'vnmr') | |
[fp,fn,fe]=fileparts([DATA{Dat.DataInd}.HDR.fpath,DATA{Dat.DataInd}.HDR.fname]); | |
[fp,fn,fe]=fileparts(fp); | |
else | |
[fp,fn,fe]=fileparts([DATA{Dat.DataInd}.HDR.fpath,DATA{Dat.DataInd}.HDR.fname]); | |
end | |
%% Get saved file name and type | |
[fname, fpath, findex] = uiputfile( ... | |
{'*.mat:*.MAT','Matlab MAT-File (*.mat)';... | |
'*.nii;*.NII','NIfTI-files (*.nii)'; ... | |
'*.hdr;*.HDR','Analyze 7.5 files (*.hdr)'}, ... | |
'Save Image Data as', [filepath,fn]); | |
if ( all(fname==0) | all(fpath==0) ) % Cancel is pressed | |
return | |
end | |
%% Set fpath to preferences | |
setpref('Aedes','PutDataFileDir',fpath); | |
if findex==1 %% Save data in MAT-file | |
% Determine file prefix | |
[fp,fn,fe]=fileparts([fpath,fname]); | |
if strcmpi(fe,'.mat') | |
fprefix = fn; | |
else | |
fprefix = [fn,fe]; | |
end | |
%% Save data in Matlab MAT-file | |
try | |
DataRotation = Dat.DataRotation; | |
DataFlip = Dat.DataFlip; | |
SliceClim = Dat.SliceClim; | |
save([fpath,fprefix,'.mat'],'DATA','DataRotation','DataFlip',... | |
'SliceClim','-mat') | |
catch | |
hh=errodlg({'Error occurred while saving DATA to file',... | |
[fpath,fprefix,'.mat']},'Error.','modal'); | |
return | |
end | |
elseif any(findex==[2 3]) | |
if findex==2 | |
fext = '.nii'; | |
fileType = 2; | |
else | |
fext = '.hdr'; | |
fileType = 0; | |
end | |
if findex==2 && Dat.DataL>1 | |
%% Ask if NIfTI files are saved in separate files or the whole | |
%% volume into a single file | |
resp=questdlg('Save slices in separate NIfTI-files or in a single file?',... | |
'Separate files or single file?',... | |
'Separate files','Single file','Cancel',... | |
'Separate files'); | |
if isempty(resp) || strcmpi(resp,'Cancel') | |
return | |
elseif strcmpi(resp,'Separate files') | |
singleFile = false; | |
else | |
singleFile = true; | |
end | |
else | |
% Try to write Analyze75 files allways into a single volume file | |
singleFile = true; | |
end | |
% Determine file prefix | |
[fp,fn,fe]=fileparts([fpath,fname]); | |
if strcmpi(fe,fext) | |
fprefix = fn; | |
else | |
fprefix = [fn,fe]; | |
end | |
if singleFile | |
%% Check if all slices are the same size. Otherwise it is not | |
%% possible to save all the slices in one file | |
if all(Dat.ImageDim(:,1)/Dat.ImageDim(1,1)) && ... | |
all(Dat.ImageDim(:,2)/Dat.ImageDim(1,2)) | |
[calc_h,txh]=aedes_calc_wait({'Writing image data to file', | |
[fpath,fprefix,fext]}); | |
% Generate a new data matrix. This can in extreme cases inflict | |
% "out of memory" error. | |
data_mtx = zeros(Dat.ImageDim(1,1),Dat.ImageDim(1,2),Dat.DataL,... | |
'single'); | |
for ii=1:Dat.DataL | |
data_mtx(:,:,ii)=DATA{ii}.FTDATA; | |
end | |
% Write data to NIfTI/Analyze75-file | |
[done,msg]=aedes_write_nifti(data_mtx,[fpath,fprefix,fext],... | |
'FileType',fileType,'DataType', ... | |
'single'); | |
clear('data_mtx') | |
if ~done | |
delete(calc_h) | |
hh=errordlg({'An error occurred while writing file',... | |
[fpath,fprefix,fext]},'Error Writing File',... | |
'modal'); | |
return | |
end | |
delete(calc_h) | |
else | |
hh=errordlg(['Cannot write slices into a single file, because all ' ... | |
'the slices are not of the same size.'],... | |
'Cannot Write Single File','modal'); | |
return | |
end | |
else | |
%% Write all slices into separate NIfTI-files | |
% Create file names | |
filenames={}; | |
for ii=1:Dat.DataL | |
filenames{ii}=sprintf('%s%03d%s',[fprefix,'_'],ii,fext); | |
end | |
nFiles = length(filenames); | |
% Check if files exist | |
ind=aedes_check_file_exist(filenames,fpath); | |
if any(ind) | |
% Warn if some files are about to be overwritten | |
overwrited_files = {filenames{ind}}; | |
% Limit the file list to 20 files | |
if length(overwrited_files)>20 | |
overwrited_files = {overwrited_files{1:20}}; | |
overwrited_files{end+1}='...'; | |
end | |
resp=questdlg({['The following files already exist in the output directory' ... | |
' "',fpath,'"'],'','(NOTE: max. 20 files shown here)','',... | |
overwrited_files{:},'',... | |
'Do you want to overwrite these files?'},... | |
'Overwrite Existing Files?','Overwrite','Abort','Abort'); | |
if isempty(resp) || strcmpi(resp,'Abort') | |
return | |
end | |
end | |
h=aedes_wbar(0,sprintf('Saving slice 1/%d in NIfTI format...',nFiles)); | |
for ii=1:nFiles | |
aedes_wbar(ii/nFiles,h,sprintf('Saving slice %d/%d in NIfTI format...',ii, ... | |
nFiles)) | |
[done,msg]=aedes_write_nifti(DATA{ii}.FTDATA,... | |
[fpath,filenames{ii}],'DataType','single',... | |
'FileType',2,... | |
'Clim',Dat.SliceClim(ii,:)); | |
if ~done | |
delete(h) | |
hh=errordlg({'An error occurred while writing file',... | |
[fpath,filenames{ii}]},'Error Writing File', ... | |
'modal'); | |
return | |
end | |
end | |
delete(h) | |
end | |
end | |
end | |
catch | |
aedes_errordump(lasterror); | |
end | |
end % function l_SaveImageData(h, | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% | |
% Check if ROI(s) are saved | |
% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
function cancel=l_CheckRoiSaved() | |
% Warn if ROIs are not saved | |
if ~isempty(ROI) && ~Dat.RoiSaved | |
resp=questdlg({'Modified ROI(s) exist.',... | |
'Do you want save ROI(s) before closing file?'},... | |
'Save ROI(s) before closing file?','Yes','No','Cancel','Yes'); | |
if strcmpi(resp,'Yes') | |
l_RoiSave([],[]) | |
cancel = false; | |
return | |
elseif isempty(resp) || strcmpi(resp,'Cancel') | |
cancel = true; | |
return | |
else | |
cancel = false; | |
end | |
else | |
cancel = false; | |
end | |
figure(H.FIG) | |
end % function cancel=l_CheckRoiSaved() | |
%%%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% Close File(s) | |
%% | |
%%%%%%%%%%%%%%%%%%%%%%%% | |
function l_CloseFile(h,evd,opt) | |
try | |
if nargin>2 && strcmpi(opt,'PreserveData') | |
PreserveData = true; | |
else | |
PreserveData = false; | |
end | |
% Warn if ROIs are not saved | |
if ~isempty(h) && ishandle(h) && ~PreserveData | |
cancel=l_CheckRoiSaved; | |
if cancel | |
return | |
end | |
end | |
% Reset uicontrol focus | |
%uicontrol(H.SL_SLIDER); | |
% Remember HG2 status | |
hg2_status = Dat.HG2graphics; | |
% Delete Voxel Time Series Figure if open | |
try | |
close(H.TSFIG) | |
end | |
set(H.UIVIEW_TIMESERIES,'checked','off') | |
%% Remove callback for Mouse scroll wheel | |
if Dat.MatlabVersion>=7.05 | |
set(H.FIG,'WindowScrollWheelFcn','') | |
end | |
% Delete all ROIs and related images and axes | |
if ~PreserveData | |
clear ROI DATA Dat | |
ROI = []; | |
else | |
clear Dat | |
end | |
try | |
delete(H.IMROI) | |
end | |
try | |
delete(H.ROIAX) | |
end | |
H.ROIAX=[]; | |
H.IMROI=[]; | |
if isfield(H,'IM') | |
set(H.IM,'CData',[]) | |
end | |
% Set mouse for changing window/level | |
set(get(H.UITOGGLE_ARROW,'userdata'),'state','off') | |
set(H.UITOGGLE_ARROW,'state','on') | |
% Clear ROI undo buffer and disable ROI uicontrols | |
l_RoiUndoBuffer('clear') | |
set(H.ROIVIEW_LBOX,'value',[],'string','') | |
set([H.ROIBTN_DEL,H.ROIBTN_DELALL,... | |
H.ROIBTN_UNDO,H.UIPUSH_UNDOROI,H.ROIBTN_COPY],'enable','off') | |
set(H.ROI_EDIT,'value',1,'string',{''},'enable','off') | |
% Delete crossbars | |
try | |
delete(H.CROSSBAR_LN) | |
end | |
H.CROSSBAR_LN=[]; | |
%set(H.SHOW_CROSSBARS,'value',0) | |
% Reset image sliders | |
set(H.IMSLIDER,'visible','off','value',0) | |
set(H.IMSLIDER_FRAME,'visible','off') | |
% Reset uitoolbar buttons | |
set([H.UIPUSH_ZOOMIN,H.UIPUSH_ZOOMOUT,H.UITOGGLE_ZOOMNORM],'enable','off') | |
set([H.UITOGGLE_VIEW3D,H.UITOGGLE_VIEWY,H.UITOGGLE_VIEWZ,H.UITOGGLE_CROSSHAIRS],'state','off') | |
set([H.UITOGGLE_ARROW,H.UITOGGLE_PAN,... | |
H.UITOGGLE_DRAWROI,H.UITOGGLE_ERASEROI,H.UITOGGLE_MOVEROI,... | |
H.UITOGGLE_MOVEROI3D,H.UITOGGLE_GRID,H.UITOGGLE_CROSSHAIRS],... | |
'enable','off') | |
set([H.UIPUSH_NEWROI,H.UIPUSH_UNDOROI],... | |
'enable','off') | |
set(H.UICH_ROIENABLED,'enable','off') | |
set(H.UIMENU_ROTATEFLIP,'enable','off') | |
set(H.UIEDIT_IMSTACK,'enable','off') | |
% Delete overlay control window | |
if isfield(H,'OVERLAY_CONTROL_FIG') && ~isempty(H.OVERLAY_CONTROL_FIG) ... | |
&& ishandle(H.OVERLAY_CONTROL_FIG) | |
delete(H.OVERLAY_CONTROL_FIG) | |
H.OVERLAY_CONTROL_FIG = []; | |
end | |
% Disable overlay uimenus | |
set([H.UIOVERLAY_CONTROLS,... | |
H.UIOVERLAY_SAVE,... | |
H.UIOVERLAY_DELETE],'enable','off') | |
% Reset volume button and editbox | |
set([H.V_BTN,H.V_EDIT],'enable','off') | |
set(H.V_EDIT,'string','1') | |
% Delete overlays if loaded | |
if isfield(H,'IMOVERLAY') && ~isempty(H.IMOVERLAY) | |
try | |
delete(H.IMOVERLAY) | |
catch | |
end | |
H.IMOVERLAY=[]; | |
end | |
% Delete colorbar image and intensity line | |
try | |
delete(H.COLORBAR_IM) | |
end | |
try | |
delete(H.COLORBAR_LN) | |
end | |
try | |
delete(H.COLORBAR_TX) | |
end | |
H.COLORBAR_IM=[]; | |
H.COLORBAR_LN=[]; | |
H.COLORBAR_TX=[]; | |
% Delete data images | |
try | |
delete(H.IM) | |
end | |
% Clear data from memory | |
if ~PreserveData | |
DATA = []; | |
end | |
% disable uicontrols | |
set(H.UICH_ENABLED,'enable','off') | |
% Reset figure window title | |
set(H.FIG,'Name','Aedes 1.0') | |
% Update Voxel Value text | |
set(H.VOXEL_VALUE,'string','-') | |
%% Place blank frame in front of gui | |
set(H.BLANK_FRAME,'visible','on') | |
%drawnow | |
% Clear internal variables | |
Dat = []; | |
Dat.HG2graphics = hg2_status; | |
catch | |
aedes_errordump(lasterror); | |
end | |
end % function l_CloseFile(h, | |
%%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% Initialize GUI | |
%% | |
%%%%%%%%%%%%%%%%%%%%%%% | |
function l_Initialize(h,evd) | |
try | |
%% Initialize "Mixed" type (i.e. slice per file) data ------------------- | |
if length(DATA)>1 || ( length(DATA)==1 & any(ndims(DATA{1}.FTDATA)==[1 2])) | |
Dat.isDataMixed = true; | |
Dat.DataL = length(DATA); | |
Dat.RealAxSize = cell(1,Dat.DataL); | |
for ii=1:Dat.DataL | |
Dat.ImageDim(ii,:) = [size(DATA{ii}.FTDATA) 1 1]; | |
Dat.RealAxSize{ii} = [Dat.ImageDim(ii,2),Dat.ImageDim(ii,1);... | |
Dat.ImageDim(ii,3),Dat.ImageDim(ii,1);... | |
Dat.ImageDim(ii,3),Dat.ImageDim(ii,2)]; | |
end | |
Dat.DataInd = 1; | |
if ~isfield(Dat,'DataRotation') || ~isfield(Dat,'DataFlip') | |
Dat.DataRotation = zeros(1,Dat.DataL); | |
Dat.DataFlip = zeros(1,Dat.DataL); | |
end | |
Dat.RotateFlip3d = {}; | |
else %% Initialize normal 3D- or 4D data -------------- | |
Dat.isDataMixed = false; | |
Dat.ImageDim = size(DATA{1}.FTDATA); | |
if length(Dat.ImageDim)<4 | |
le=length(Dat.ImageDim); | |
Dat.ImageDim = [Dat.ImageDim ones(1,4-le)]; | |
end | |
Dat.DataL = 1; | |
Dat.DataInd = 1; | |
if ~isfield(Dat,'DataRotation') || ~isfield(Dat,'DataFlip') | |
Dat.DataRotation = []; | |
Dat.DataFlip = []; | |
end | |
if ~isfield(Dat,'RotateFlip3d') | |
Dat.RotateFlip3d = {}; | |
end | |
Dat.RealAxSize{Dat.DataInd} = [Dat.ImageDim(Dat.DataInd,2),Dat.ImageDim(Dat.DataInd,1);... | |
Dat.ImageDim(Dat.DataInd,3),Dat.ImageDim(Dat.DataInd,1);... | |
Dat.ImageDim(Dat.DataInd,3),Dat.ImageDim(Dat.DataInd,2)]; | |
end | |
% % Detect if HG2 graphics are used | |
% if isa(H.FIG,'matlab.ui.Figure') | |
% Dat.HG2graphics = true; | |
% else | |
% Dat.HG2graphics = false; | |
% set(H.FIG,'DoubleBuffer','on') | |
% end | |
% Save data file headers ------------------------------- | |
for ii=1:Dat.DataL | |
Dat.HDR{ii} = DATA{ii}.HDR; | |
end | |
% Initialize volumes and slices ------------------------ | |
Dat.Vols = Dat.ImageDim(Dat.DataInd,4); | |
Dat.Rcvrs = size(DATA{1}.FTDATA,5); | |
Dat.CurrentVol = 1; | |
Dat.Slices = [1 1 1]; | |
% Initialize Clim -------------------------------------- | |
Dat.ScaleMin=[]; | |
Dat.ScaleMax=[]; | |
Dat.OrigClim=[]; | |
for ii=1:Dat.DataL | |
Dat.ScaleMin(ii) = double(min(min(min(DATA{ii}.FTDATA(:,:,:,Dat.CurrentVol))))); | |
Dat.ScaleMax(ii) = double(max(max(max(DATA{ii}.FTDATA(:,:,:,Dat.CurrentVol))))); | |
Dat.OrigClim(ii,:) = [Dat.ScaleMin(ii) Dat.ScaleMax(ii)]; | |
if diff(Dat.OrigClim(ii,:))==0 | |
Dat.OrigClim(ii,:) = [0 1]; | |
end | |
end | |
% Detect Matlab version | |
[Dat.MatlabVersion,Dat.isImageProc] = aedes_getmatlabversion; | |
% If any of the currently opened files is Analyze or NIfTI type, the | |
% cal_max and cal_min fields are checked and adjusted accordingly | |
Dat.Clim = Dat.OrigClim(1,:); | |
if ~isfield(Dat,'SliceClim') | |
Dat.SliceClim = Dat.OrigClim; | |
for ii=1:Dat.DataL | |
if isfield(DATA{ii},'DataFormat') && ... | |
any(strcmpi(DATA{ii}.DataFormat,{'analyze75','nifti(1)', ... | |
'nifti(2)'})) | |
try | |
cal_min=DATA{ii}.HDR.FileHeader.dime.cal_min; | |
cal_max=DATA{ii}.HDR.FileHeader.dime.cal_max; | |
if cal_min~=0 | |
Dat.SliceClim(ii,1)=cal_min; | |
end | |
if cal_max~=0 | |
Dat.SliceClim(ii,2)=cal_max; | |
end | |
catch | |
continue | |
end | |
end | |
end | |
end | |
% Get default Clim behavior from preferences ------------- | |
% try | |
% Dat.LockClim = getpref('Aedes','LockClim'); | |
% if Dat.LockClim==0 | |
% val=3; | |
% elseif Dat.LockClim==1 | |
% val=1; | |
% elseif Dat.LockClim==2 | |
% val=2; | |
% else | |
% val=4; | |
% end | |
% catch | |
Dat.LockClim = 0; % 0 = clim unlocked | |
% 1 = clim locked global | |
% 2 = clim locked slice | |
% 3 = clim unlocked and auto-balanced | |
val = 3; | |
% end | |
% Set Clim values ---------------------------------- | |
set(H.CLIMMAXEDIT,'string',num2str(Dat.Clim(2)),... | |
'userdata',Dat.Clim(2)) | |
set(H.CLIMMINEDIT,'string',num2str(Dat.Clim(1)),... | |
'userdata',Dat.Clim(1)) | |
set(H.CLIMRANGE_POPUP,'value',val) | |
% Default gap between axes -------------------- | |
Dat.AxGap=4; | |
% Default view direction -------------------- | |
Dat.AxView=0; | |
% Initialize colorbar ----------------------- | |
Dat.ColMap = []; | |
Dat.ColMapInverted=false; | |
try | |
Dat.ShowColorbar = getpref('Aedes','ShowColorbar'); | |
if Dat.ShowColorbar | |
set(H.UITOGGLE_COLORBAR,'state','on') | |
end | |
catch | |
Dat.ShowColorbar = false; | |
set(H.UITOGGLE_COLORBAR,'state','off') | |
end | |
% Try to determine field of view (FOV) ---------------------------- | |
if isfield(DATA{Dat.DataInd},'PROCPAR') && isfield(DATA{Dat.DataInd}.PROCPAR,'lro') && ... | |
isfield(DATA{Dat.DataInd}.PROCPAR,'lpe') | |
Dat.FOV = [DATA{Dat.DataInd}.PROCPAR.lpe DATA{Dat.DataInd}.PROCPAR.lro]; | |
else | |
Dat.FOV = []; | |
end | |
% Get default Zoom levels from preferences ----------------------------- | |
Dat.OldZoom = []; | |
Dat.ZoomStep = 0.2; | |
try | |
Dat.ZoomLevel = getpref('Aedes','ZoomLevel'); | |
if Dat.ZoomLevel==0 | |
Dat.AxSize = 0; | |
set(H.UITOGGLE_ZOOMNORM,'enable','on',... | |
'state','on') | |
else | |
%Dat.AxSize = Dat.RealAxSize*zoom_level; | |
end | |
catch | |
% Default axes sizes | |
Dat.ZoomLevel=1; | |
setpref('Aedes','ZoomLevel',1) | |
end | |
% Initialize axes --------------------------------------------- | |
tmp=get(H.SIDEBAR_FRAME,'position'); | |
l_AxesPositions([],[],Dat.AxView,Dat.ZoomLevel); | |
set(H.IMAX1,'xlim',[0.5 Dat.ImageDim(Dat.DataInd,2)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,1)+0.49],... | |
'visible','off',... | |
'clim',Dat.Clim) | |
set(H.IMOVERLAYAX(1),'xlim',[0.5 Dat.ImageDim(Dat.DataInd,2)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,1)+0.49]); | |
set(H.IMAX2,'xlim',[0.5 Dat.ImageDim(Dat.DataInd,3)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,1)+0.49],... | |
'visible','off',... | |
'clim',Dat.Clim) | |
set(H.IMOVERLAYAX(2),'xlim',[0.5 Dat.ImageDim(Dat.DataInd,3)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,1)+0.49]); | |
set(H.IMAX3,'xlim',[0.5 Dat.ImageDim(Dat.DataInd,3)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,2)+0.49],... | |
'visible','off',... | |
'clim',Dat.Clim) | |
set(H.IMOVERLAYAX(3),'xlim',[0.5 Dat.ImageDim(Dat.DataInd,3)+0.5],... | |
'ylim',[0.5 Dat.ImageDim(Dat.DataInd,2)+0.49]) | |
% Get default View direction from preferences ------------------------------ | |
try | |
Dat.AxView = getpref('Aedes','AxView'); | |
if Dat.AxView==0 | |
set(H.UITOGGLE_VIEW3D,'state','on') | |
elseif Dat.AxView==1 | |
set(H.UITOGGLE_VIEWX,'state','on') | |
elseif Dat.AxView==2 | |
set(H.UITOGGLE_VIEWY,'state','on') | |
else | |
set(H.UITOGGLE_VIEWZ,'state','on') | |
end | |
catch | |
Dat.AxView = 0; | |
setpref('Aedes','AxView',Dat.AxView) | |
set(H.UITOGGLE_VIEW3D,'state','on') | |
end | |
if Dat.ImageDim(Dat.DataInd,3)==1 | |
Dat.AxView=3; | |
set(H.UITOGGLE_VIEWZ,'state','on') | |
end | |
% Get grid info from preferences --------------------------- | |
try | |
Dat.ShowGrid = getpref('Aedes','ShowGrid'); | |
catch | |
Dat.ShowGrid = false; | |
end | |
if Dat.ShowGrid | |
set(H.UIVIEW_GRID,'checked','off') | |
set(H.UITOGGLE_GRID,'state','off',... | |
'enable','on') | |
l_ViewAxesUnits([],[],'pixel') | |
else | |
set(H.UIVIEW_GRID,'checked','on') | |
set(H.UITOGGLE_GRID,'state','on',... | |
'enable','on') | |
l_ViewAxesUnits([],[],'pixel') | |
end | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% Initialize toolbar buttons | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% Initialize Zoom buttons ---------------------------- | |
if Dat.ZoomLevel==0.5 | |
set(H.UIPUSH_ZOOMIN,'enable','on') | |
elseif Dat.ZoomLevel==10 | |
set(H.UIPUSH_ZOOMOUT,'enable','on') | |
else | |
set([H.UIPUSH_ZOOMIN,H.UIPUSH_ZOOMOUT],'enable','on') | |
end | |
set(H.UITOGGLE_ZOOMNORM,'enable','on') | |
%Dat.ZoomLevel = zoom_level; | |
% Initialize mouse function buttons -------------------------- | |
set([H.UITOGGLE_ARROW,H.UITOGGLE_PAN],'enable','on') | |
% Initialize ROI toolbar button ----------------------------- | |
set(H.UIPUSH_NEWROI,'enable','on') | |
% Set colormap --------------------------------------- | |
try | |
ColMap_str=getpref('Aedes','ColorMap'); | |
catch | |
ColMap_str='gray'; | |
Dat.ColMap=gray(256); | |
setpref('Aedes','ColorMap',ColMap_str); | |
end | |
if strcmpi(ColMap_str,'Custom') | |
try | |
Dat.ColMap = getpref('Aedes','CustomColorMap'); | |
if ~isequal(size(Dat.ColMap),[256 3]) || ... | |
~isnumeric(Dat.ColMap) | |
ColMap_str='gray'; | |
Dat.ColMap=gray(256); | |
setpref('Aedes','ColorMap',ColMap_str); | |
h=errordlg(['Error initializing custom colormap!',... | |
' Reverting to GRAY.'],... | |
'Error!','modal'); | |
end | |
catch | |
ColMap_str='gray'; | |
Dat.ColMap=gray(256); | |
setpref('Aedes','ColorMap',ColMap_str); | |
h=errordlg(['Error initializing custom colormap!',... | |
' Reverting to GRAY.'],... | |
'Error!','modal'); | |
end | |
end | |
% Set colorbar image ----------------------------- | |
if Dat.ShowColorbar | |
vis = 'on'; | |
else | |
vis = 'off'; | |
end | |
H.COLORBAR_IM = image('parent',H.COLORBAR_AX,... | |
'cdatamapping','scaled',... | |
'cdata',gray(256),... | |
'visible',vis); | |
set(H.COLORBAR_AX,'xlim',[0.5 3.5],... | |
'ylim',[0.5 256+0.5],... | |
'ydir','normal',... | |
'layer','top',... | |
'xtick',[]) | |
l_ChangeColorbarLimits([],[]) | |
% Set default Window, Level, and Gamma. | |
% Store current valid value in the userdata... | |
Dat.Window = 100; | |
Dat.Level = 50; | |
set(H.WINDOW_EDIT,'string',num2str(Dat.Window),... | |
'userdata',Dat.Window) | |
set(H.LEVEL_EDIT,'string',num2str(Dat.Level),... | |
'userdata',Dat.Level) | |
% Set initial slices --------------------------------- | |
if ~Dat.isDataMixed && isfield(DATA{1},'DataFormat') && ... | |
strncmpi(DATA{1}.DataFormat,'NIfTI',5) | |
if DATA{1}.HDR.FileHeader.hist.qform_code>0 | |
q_b = DATA{1}.HDR.FileHeader.hist.quatern_b; | |
q_c = DATA{1}.HDR.FileHeader.hist.quatern_c; | |
q_d = DATA{1}.HDR.FileHeader.hist.quatern_d; | |
q_a = sqrt(1.0-(q_b*q_b+q_c*q_c+q_d*q_d)); | |
R = [q_a*q_a+q_b*q_b-q_c*q_c-q_d*q_d,2*q_b*q_c-2*q_a*q_d,2*q_b*q_d+2*q_a*q_c;... | |
2*q_b*q_c+2*q_a*q_d,q_a*q_a+q_c*q_c-q_b*q_b-q_d*q_d,2*q_c*q_d-2*q_a*q_b; ... | |
2*q_b*q_d-2*q_a*q_c,2*q_c*q_d+2*q_a*q_b,q_a*q_a+q_d*q_d-q_c*q_c-q_b*q_b]; | |
qfac = DATA{1}.HDR.FileHeader.dime.pixdim(1); | |
qoffset = [DATA{1}.HDR.FileHeader.hist.qoffset_x;... | |
DATA{1}.HDR.FileHeader.hist.qoffset_y;... | |
DATA{1}.HDR.FileHeader.hist.qoffset_z]; | |
end | |
else | |
set(H.X_EDIT,'string',num2str(Dat.Slices(1))) | |
set(H.Y_EDIT,'string',num2str(Dat.Slices(2))) | |
set(H.Z_EDIT,'string',num2str(Dat.Slices(3))) | |
end | |
% Initialize volumes | |
if Dat.Vols>1 | |
set([H.V_BTN,H.V_EDIT],'enable','on') | |
set(H.V_EDIT,'string','1'); | |
set(H.FLIP3D_V,'enable','on'); | |
else | |
set([H.V_BTN,H.V_EDIT],'enable','off') | |
set(H.V_EDIT,'string','1'); | |
set(H.V_BTN,'fontweig','normal'); | |
set(H.FLIP3D_V,'enable','off'); | |
end | |
% Set defaults for ROIs | |
Dat.RoiColors = [255 0 0;... | |
0 255 0;... | |
0 0 255;... | |
255 255 0;... | |
255 0 255;... | |
0 255 255;... | |
255 128 0;... | |
128 255 0;... | |
0 128 255;... | |
128 0 255;... | |
255 0 128;... | |
0 255 128;... | |
64 128 255;... | |
128 64 255;... | |
255 64 128;... | |
255 128 64;... | |
128 255 64;... | |
64 255 128;... | |
255 128 128;... | |
128 255 128;... | |
128 128 255;... | |
255 255 128;... | |
255 128 255;... | |
128 255 255;... | |
255 64 64;... | |
64 255 64;... | |
64 64 255;... | |
255 255 64;... | |
255 64 255;... | |
64 255 255;... | |
255 64 0;... | |
64 255 0;... | |
64 0 255;... | |
0 64 255;... | |
0 255 64;... | |
255 0 64]; | |
Dat.RoiView = []; | |
Dat.RoiUndo=[]; | |
Dat.RoiSaved=1; | |
Dat.ShowRoiEdges = false; | |
Dat.CopiedROI = []; | |
% Set ROI transparency -------------------------- | |
try | |
Dat.RoiTransp=getpref('Aedes','RoiTransp'); | |
catch | |
Dat.RoiTransp=0.5; | |
end | |
set(H.ROI_TRANSP_SLIDER,'value',Dat.RoiTransp) | |
set(H.ROI_TRANSP_EDIT,'string',Dat.RoiTransp,... | |
'userdata',Dat.RoiTransp) | |
% Initialize Info Texts | |
try | |
ShowInfoTexts = getpref('Aedes','ShowInfoTexts'); | |
catch | |
ShowInfoTexts = true; | |
end | |
if ShowInfoTexts | |
set(H.UITOGGLE_INFO,'state','on') | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'visible','on') | |
else | |
set(H.UITOGGLE_INFO,'state','off') | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'visible','off') | |
end | |
% Initialize Time Series view | |
Dat.ShowTimeSeries = false; | |
% Initialize Info Text Background | |
try | |
ShowInfoBackGround = getpref('Aedes','ShowInfoTextBackGround'); | |
catch | |
ShowInfoBackGround = false; | |
end | |
if ShowInfoBackGround | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'backgroundcolor','w') | |
if ~Dat.HG2graphics | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'erasemode','normal') | |
end | |
set(H.UIVIEW_INFOTXTBACKGROUND,'checked','on') | |
else | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'backgroundcolor','none') | |
if ~Dat.HG2graphics | |
set([H.INFOTEXT,H.ROIINFOTEXT],... | |
'erasemode','normal') | |
end | |
set(H.UIVIEW_INFOTXTBACKGROUND,'checked','off') | |
end | |
% Initialize variables for imagemask | |
Dat.ImageOverlay = []; | |
Dat.ImageOverlayOrig = []; | |
Dat.isImageOverlayLoaded = false; | |
% Set figure resize function | |
set(H.FIG,'resizefcn',@l_ResizeFcn) | |
% Display data and initialize | |
l_DisplayData([],[],[1 2 3],1) | |
% Draw crassbars | |
l_ShowHideCrossbars; | |
% Set default zoom level | |
l_Zoom([],[],Dat.ZoomLevel) | |
% Set default colormap | |
l_ChangeColormap([],[],ColMap_str) | |
% Set default view direction | |
l_ChangeView([],[],Dat.AxView) | |
% Refresh Clim values | |
l_RefreshClim([],[]); | |
% Enable uicontrols | |
set(H.UICH_ENABLED,'enable','on') | |
% Disable "View VNMR Procpar" for non-VNMR data | |
%if ~isfield(DATA{1},'PROCPAR') || isempty(DATA{1}.PROCPAR) | |
% set(H.viewprocpar_h,'enable','off') | |
%end | |