📄 volumization.m
字号:
function varargout = volumization(varargin)
% GUI for visualizing 3D data
%
% To run type:
% >>volumization (data,'n')
% where data are of format [n x m x p] and 'n' - which slice to display:
% '1'- all, '2' - every second, '3' - every third, etc.
%
% For users with PLS_Toolbox 3.5 can type
% >> volumization
% and then load data interactively using lddlgpls routine.
%
% Includes different types of visualization:
% 1. Orthogonal slices - each slice individually, as well as three orthogonal slices on one plot
% 2. Rendered volume through showing series of z-slices. Enter the number of slices to display:
% ('1' - all, '2' - every second, etc.)
% 3. Isosurfaces:
% - one for a single value
% - multiple for multiple values of interest on one figure (each with different color)
%
% Options to change for orthogonal slices (1) and volumes (2):
% - transparency;
% - color scheme.
%
% Options to changes for all three types of visualization (1-3):
% - top/bottom, left/right
% - aspect ratio.
%
% To display isosurface on top of rendered volume or orthogonal slices, use controls to
% display desired view and then use Multiple isosurface slider to display the isosurface
% of value of interest. (Single isosurface slider clears the figure on execution).
%
% Use Clear figure button to start over.
%
% created by K.Artyushkova
% November 2004
%
% Kateryna Artyushkova
% Postdoctoral Scientist
% Department of Chemical and Nuclear Engineering
% The University of New Mexico
% (505) 277-0750
% kartyush@unm.edu
%
% Last Modified by GUIDE v2.5 08-Dec-2004 10:21:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @volumization_OpeningFcn, ...
'gui_OutputFcn', @volumization_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before volumization is made visible.
function volumization_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to volumization (see VARARGIN)
% Choose default command line output for volumization
handles.output = hObject;
% Update handles structure
if (nargin <4)
H.Position=[181 477 332 275];
figure(H)
msgbox('Please load the data through the File Load menu')
else
data= varargin{1};
display=varargin{2};
[m,n,p]=size(data);
set(handles.xmin,'string',1);
set(handles.xmax,'string',n);
set(handles.xi,'string',1);
set(handles.ymin,'string',1);
set(handles.ymax,'string',m);
set(handles.yi,'string',1);
set(handles.zmin,'string',1);
set(handles.zmax,'string',p);
set(handles.zi,'string',1);
s=data;
handles.s=s;
H.Position=[181 477 332 275];
figure(H)
step=str2double(display);
hz=slice(s,[],[],[1:step:p]);
alpha('color')
axis tight
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
alphamap('rampdown')
daspect([1 1 0.5])
handles.aspect=[1 1 0.5];
handles.count=0;
colormap(jet)
end
handles.v={'0'};
guidata(hObject, handles);
% UIWAIT makes volumization wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = volumization_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function load_data_Callback(hObject, eventdata, handles)
% hObject handle to load_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data =lddlgpls;
[m,n,p]=size(data);
set(handles.xmin,'string',1);
set(handles.xmax,'string',n);
set(handles.xi,'string',1);
set(handles.ymin,'string',1);
set(handles.ymax,'string',m);
set(handles.yi,'string',1);
set(handles.zmin,'string',1);
set(handles.zmax,'string',p);
set(handles.zi,'string',1);
s=data;
handles.s=data;
figure(1)
hz=slice(s,[],[],[1:3:p]);
alpha('color')
axis tight
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
alphamap('rampdown')
daspect([1 1 0.5])
handles.aspect=[1 1 0.5];
handles.count=0;
colormap(jet)
guidata(hObject, handles);
% --- Executes on button press in alphaincrease.
function alphaincrease_Callback(hObject, eventdata, handles)
% hObject handle to alphaincrease (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure(1)
alphamap('increase',.1)
% --- Executes on button press in alphadecrease.
function alphadecrease_Callback(hObject, eventdata, handles)
% hObject handle to alphadecrease (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure(1)
alphamap('decrease',.1)
% --- Executes during object creation, after setting all properties.
function colormap_CreateFcn(hObject, eventdata, handles)
% hObject handle to colormap (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in colormap.
function colormap_Callback(hObject, eventdata, handles)
% hObject handle to colormap (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns colormap contents as cell array
% contents{get(hObject,'Value')} returns selected item from colormap
val = get(hObject,'Value');
figure(1)
switch val
case 1
colormap(jet)
case 2
colormap(hsv)
case 3
colormap(hot)
case 4
colormap(gray)
case 5
colormap(bone)
case 6
colormap(copper)
case 7
colormap(pink)
case 8
colormap(white)
case 9
colormap(colorcube)
case 10
colormap(vga)
case 11
colormap(jet)
case 12
colormap(prism)
case 13
colormap(cool)
case 14
colormap(autumn)
case 15
colormap(spring)
case 16
colormap(winter)
case 17
colormap(summer)
end
% --- Executes on button press in aspect_ratio.
function aspect_ratio_Callback(hObject, eventdata, handles)
% hObject handle to aspect_ratio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt={'X:','Y:','Z:'};
def={'1','1','0.5'};
dlgTitle='Input for Aspect ratio';
lineNo=1;
answer=inputdlg(prompt,dlgTitle,lineNo,def);
M=str2double(answer);
figure(1)
daspect([M(1) M(2) M(3)])
handles.aspect=[M(1) M(2) M(3)];
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function reverse_axes_CreateFcn(hObject, eventdata, handles)
% hObject handle to reverse_axes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in reverse_axes.
function reverse_axes_Callback(hObject, eventdata, handles)
% hObject handle to reverse_axes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns reverse_axes contents as cell array
% contents{get(hObject,'Value')} returns selected item from reverse_axes
val = get(hObject,'Value');
switch val
case 1
figure(1)
set(gca,'Xdir','reverse')
case 2
figure(1)
set(gca,'Ydir','reverse')
case 3
figure(1)
set(gca,'Zdir','reverse')
end
% --- Executes during object creation, after setting all properties.
function display_CreateFcn(hObject, eventdata, handles)
% hObject handle to display (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function display_Callback(hObject, eventdata, handles)
% hObject handle to display (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of display as text
% returns contents of display as a double
step=str2double(get(hObject,'String'));
s=handles.s;
figure(1)
[m,n,p]=size(s);
hz=slice(s,[],[],[1:step:p]);
alpha('color')
axis tight
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
alphamap('rampdown')
aspect=handles.aspect;
daspect(aspect)
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function sliderx_CreateFcn(hObject, eventdata, handles)
% hObject handle to sliderx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function sliderx_Callback(hObject, eventdata, handles)
% hObject handle to sliderx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s=handles.s;
[m,n,p]=size(s);
step=1/n;
slider_step(1)=step;
slider_step(2)=step;
set(handles.sliderx, 'SliderStep', slider_step, 'Max', n, 'Min',0)
ix=get(hObject,'Value');
ix=round(ix);
set(handles.xi,'string',ix);
set(handles.ix,'string',ix);
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hx=slice(x,y,z, s,ix,[],[]);
alpha('color')
set(hx,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
handles.IX=ix;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slidery_CreateFcn(hObject, eventdata, handles)
% hObject handle to slidery (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slidery_Callback(hObject, eventdata, handles)
% hObject handle to slidery (see GCBO)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -