📄 plotmri.m
字号:
function plotMRI( MRI_struct )
% Create labels for MRIs to be used in popup menus:
MRI_list = MRI_struct.MRI_list;
for i=1:length(MRI_list)
MRI_label{i} = ['MRI ' num2str(i) ': ' num2str(MRI_list(i)) ' year'];
end
% Create labels for frames to be used in popup menus:
length_units = MRI_struct.length_units;
frame_loc = MRI_struct.frame_coords(:,2);
n_f = length(frame_loc);
for i = 1:n_f
frame_label{i} = ['Frame ' num2str(i) ': y = ' num2str(frame_loc(i)) ' ' length_units];
end
% Create labels for responses to be used in popup menus:
resp_names = MRI_struct.resp_names;
resp_units = MRI_struct.resp_units;
n_r = length(resp_names);
for i = 1:n_r
resp_label{i} = ['Response ' num2str(i) ': ' resp_names{i} ' (' resp_units{i} ')'];
end
% Create labels for orientations to be used in popup menus:
orientations = MRI_struct.orientations;
n_o = length(orientations);
for i=1:n_o
orientations_label{i} = [num2str(orientations(i)) ' degrees'];
end
m = 1; % index for MRI to plot
f = 1; % index for frame to plot
r = 1; % index for response to plot
o = 1; % index for orientation to plot
scrsz = get(0,'ScreenSize');
oX = scrsz(3)*.05;
oY = scrsz(4)*.2;
dX = scrsz(3)*.9;
dY = scrsz(4)*.6;
clr = get(0,'DefaultUicontrolBackgroundColor');
side_w = 70; % width of MRI, frame, response selection panel on right side
btm_h = 5; % height of menu panel at bottom
% ************************* Create figure for plotting resampled DIFs:
DIF_fig = figure('Color',clr,'Position',[oX oY dX dY],'Name','Plotting of Resampled DIFs','NumberTitle','off');
set( DIF_fig, 'Units', 'character');
Size = get( DIF_fig, 'Position');
X0 = Size(3);
Y0 = Size(4);
plot_h = Y0 - btm_h;
plot_w = X0 - side_w;
toggle_w = X0/3-2; % width of toggle buttons on menu panel
toggle_h = btm_h-1;
DIF_plot_panel = uipanel('Parent',DIF_fig,'BackgroundColor',clr,'Units','character','Position',[0 btm_h plot_w plot_h]);
DIF_axes = axes('Parent',DIF_plot_panel);
DIF_select_panel = uipanel('Parent',DIF_fig,'BackgroundColor',clr,'Units','character','Position',[plot_w btm_h side_w plot_h]);
%
%
uicontrol(DIF_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Building Orientation:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-2.5 side_w-4 1.5]);
orientation_popup = uicontrol(DIF_select_panel, 'Style', 'popupmenu', 'String',orientations_label,'Value',o,...
'Units','characters','Position',[2 plot_h-4 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@OrientationCallback);
uicontrol(DIF_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Frame:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-6.5 side_w-4 1.5]);
DIF_frame_popup = uicontrol(DIF_select_panel, 'Style', 'popupmenu', 'String',frame_label,'Value',f,...
'Units','characters','Position',[2 plot_h-8 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@DIFFrameSelectCallback);
uicontrol(DIF_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Response:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-10.5 side_w-4 1.5]);
DIF_resp_popup = uicontrol(DIF_select_panel, 'Style', 'popupmenu', 'String',resp_label,'Value',f,...
'Units','characters','Position',[2 plot_h-12 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@DIFRespSelectCallback);
uicontrol(DIF_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Type of peak (select one or both):',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-14.5 side_w-4 1.5]);
DIF_max_radio = uicontrol(DIF_select_panel, 'Style', 'radiobutton', 'String','Maximum values','Value',1,...
'Units','characters','Position',[4 plot_h-15.75 side_w-4 1.5],...
'Callback',@DIFMaxCallback);
DIF_min_radio = uicontrol(DIF_select_panel, 'Style', 'radiobutton', 'String','Minimum values','Value',1,...
'Units','characters','Position',[4 plot_h-17.25 side_w-4 1.5],...
'Callback',@DIFMinCallback);
uicontrol(DIF_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Peak evaluation method (select one):',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-19.5 side_w-4 1.5]);
DIF_obs_radio = uicontrol(DIF_select_panel, 'Style', 'radiobutton', 'String','Observed peaks (sample max / min)','Value',1,...
'Enable','inactive','Units','characters','Position',[4 plot_h-20.75 side_w-4 1.5],...
'Callback',@DIFObsPksCallback);
DIF_est_radio = uicontrol(DIF_select_panel, 'Style', 'radiobutton', 'String','Estimated peaks (from probability distribution)','Value',0,...
'Units','characters','Position',[4 plot_h-22.25 side_w-4 1.5],...
'Callback',@DIFEstPksCallback);
DIF_menu_panel = uipanel('Parent',DIF_fig,'BackgroundColor',clr,'Units','character','Position',[0 0 X0 btm_h]);
DIF_DIF_toggle = uicontrol(DIF_menu_panel, 'Style','togglebutton','String','Resampled DIFs','Value',1,'Enable','inactive',...
'BackgroundColor',.87*[1 1 1],'Units','characters','Position',[X0/6-toggle_w/2 0.5 toggle_w toggle_h]);
DIF_MRI_toggle = uicontrol(DIF_menu_panel, 'Style','togglebutton','String','Mean Recurrence Intervals','Value',0,...
'Units','characters','Position',[X0/2-toggle_w/2 0.5 toggle_w toggle_h],...
'Callback',@MRIToggleCallback);
DIF_exit_button = uicontrol(DIF_menu_panel, 'Style','pushbutton','String','Close',...
'Units','characters','Position',[X0*5/6-toggle_w/2 0.5 toggle_w toggle_h],...
'Callback',@ExitCallback);
% ************************* Create figure for peaks with specified MRI:
MRI_fig = figure('Color',clr,'Position',[oX oY dX dY],'Name','Plotting of Peaks with Specified MRIs','NumberTitle','off');
set( MRI_fig, 'Units', 'character');
Size = get( MRI_fig, 'Position');
MRI_plot_panel = uipanel('Parent',MRI_fig,'BackgroundColor',clr,'Units','character','Position',[0 btm_h plot_w plot_h]);
MRI_axes = axes('Parent',MRI_plot_panel);
MRI_select_panel = uipanel('Parent',MRI_fig,'BackgroundColor',clr,'Units','character','Position',[plot_w btm_h side_w plot_h]);
uicontrol(MRI_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Mean Recurrence Interval:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-2.5 side_w-4 1.5]);
MRI_popup = uicontrol(MRI_select_panel, 'Style', 'popupmenu', 'String',MRI_label,'Value',m,...
'Units','characters','Position',[2 plot_h-4 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@MRISelectCallback);
uicontrol(MRI_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Frame:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-6.5 side_w-4 1.5]);
MRI_frame_popup = uicontrol(MRI_select_panel, 'Style', 'popupmenu', 'String',frame_label,'Value',f,...
'Units','characters','Position',[2 plot_h-8 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@MRIFrameSelectCallback);
uicontrol(MRI_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Select Response:',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-10.5 side_w-4 1.5]);
MRI_resp_popup = uicontrol(MRI_select_panel, 'Style', 'popupmenu', 'String',resp_label,'Value',f,...
'Units','characters','Position',[2 plot_h-12 side_w-4 1.5],'BackgroundColor','w',...
'Callback',@MRIRespSelectCallback);
uicontrol(MRI_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Type of peak (select one or both):',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-14.5 side_w-4 1.5]);
MRI_max_radio = uicontrol(MRI_select_panel, 'Style', 'radiobutton', 'String','Maximum values','Value',1,...
'Units','characters','Position',[4 plot_h-15.75 side_w-4 1.5],...
'Callback',@MRIMaxCallback);
MRI_min_radio = uicontrol(MRI_select_panel, 'Style', 'radiobutton', 'String','Minimum values','Value',1,...
'Units','characters','Position',[4 plot_h-17.25 side_w-4 1.5],...
'Callback',@MRIMinCallback);
uicontrol(MRI_select_panel,'BackgroundColor',clr, 'Style', 'text', 'String','Peak evaluation method (select one or both):',...
'HorizontalAlignment','left','Units','characters','Position',[2 plot_h-19.5 side_w-4 1.5]);
MRI_obs_radio = uicontrol(MRI_select_panel, 'Style', 'radiobutton', 'String','Observed peaks (sample max / min)','Value',1,...
'Enable','inactive','Units','characters','Position',[4 plot_h-20.75 side_w-4 1.5],...
'Callback',@MRIObsPksCallback);
MRI_est_radio = uicontrol(MRI_select_panel, 'Style', 'radiobutton', 'String','Estimated peaks (from probability distribution)','Value',0,...
'Units','characters','Position',[4 plot_h-22.25 side_w-4 1.5],...
'Callback',@MRIEstPksCallback);
MRI_menu_panel = uipanel('Parent',MRI_fig,'BackgroundColor',clr,'Units','character','Position',[0 0 X0 btm_h]);
MRI_DIF_toggle = uicontrol(MRI_menu_panel, 'Style','togglebutton','String','Resampled DIFs','Value',0,...
'Units','characters','Position',[X0/6-toggle_w/2 0.5 toggle_w toggle_h],...
'Callback',@DIFToggleCallback);
MRI_MRI_toggle = uicontrol(MRI_menu_panel, 'Style','togglebutton','String','Mean Recurrence Intervals','Value',1,'Enable','inactive',...
'BackgroundColor',.87*[1 1 1],'Units','characters','Position',[X0/2-toggle_w/2 0.5 toggle_w toggle_h]);
MRI_exit_button = uicontrol(MRI_menu_panel, 'Style','pushbutton','String','Close',...
'Units','characters','Position',[X0*5/6-toggle_w/2 0.5 toggle_w toggle_h],...
'Callback',@ExitCallback);
max_obs = MRI_struct.max_obs;
min_obs = MRI_struct.min_obs;
max_est = MRI_struct.max_est;
min_est = MRI_struct.min_est;
if ~((max_obs & min_obs) | (max_est & min_est))
err = errordlg('No MRI results available for plotting.','Error plotting MRI results');
uiwait(err); return;
end
if max_obs & min_obs
MRI_max_obs = MRI_struct.MRI_max_obs;
MRI_min_obs = MRI_struct.MRI_min_obs;
MRI_UKO_max_obs = MRI_struct.MRI_UKO_max_obs;
MRI_UKO_min_obs = MRI_struct.MRI_UKO_min_obs;
else
set(DIF_obs_radio, 'Value', 0, 'Enable', 'off');
set(DIF_est_radio, 'Value',1,'Enable', 'inactive');
set(MRI_obs_radio, 'Value', 0, 'Enable', 'off');
set(MRI_est_radio, 'Value',1,'Enable', 'inactive');
end
if max_est & min_est
MRI_max_est = MRI_struct.MRI_max_est;
MRI_min_est = MRI_struct.MRI_min_est;
MRI_UKO_max_est = MRI_struct.MRI_UKO_max_est;
MRI_UKO_min_est = MRI_struct.MRI_UKO_min_est;
else
set(DIF_est_radio, 'Value',0, 'Enable', 'off');
set(MRI_est_radio, 'Value',0, 'Enable', 'off');
end
DIF_struct = MRI_struct.DIF_struct;
DIF_hat = MRI_struct.DIF_hat;
%size([orientations orientations])
%size([squeeze(MRI_max_obs(m,f,:,r)) squeeze(MRI_max_obs(m,f,:,r))])
UpdateDIFplot
UpdateMRIplot;
set(DIF_fig,'Visible','off');
uiwait(MRI_fig);
% -------------------------------------------- Callback functions
function OrientationCallback( src, event )
o = get( orientation_popup, 'Value');
UpdateDIFplot;
end
function DIFFrameSelectCallback( src, event )
f = get( DIF_frame_popup, 'Value');
set(MRI_frame_popup, 'Value',f);
UpdateDIFplot;
end
function DIFRespSelectCallback( src, event )
r = get( DIF_resp_popup, 'Value');
set(MRI_resp_popup, 'Value',r);
UpdateDIFplot;
end
function DIFMaxCallback( src, event )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -