📄 roi_session_ui.m
字号:
'Tag','select_roi');
x = 0.15;
y = (num_inputline-7) * factor_inputline;
w = 0.15;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % max value label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','Max. Value:', ...
'enable', 'on', ...
'Tag','max_value_label');
x = x+w;
y = y+0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % max value edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','0', ...
'enable', 'on', ...
'callback','roi_session_ui(''max_value_edit'');', ...
'Tag','max_value_edit');
x = x+w+0.11;
y = y-0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % min value label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','Min. Value:', ...
'enable', 'on', ...
'Tag','min_value_label');
x = x+w;
y = y+0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % min value edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','0', ...
'enable', 'on', ...
'callback','roi_session_ui(''min_value_edit'');', ...
'Tag','min_value_edit');
x = 0.15;
y = (num_inputline-8) * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % LV index label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','LV Index:', ...
'enable', 'on', ...
'Tag','lv_index_label');
x = x+w;
y = y+0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % LV index edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','0', ...
'enable', 'on', ...
'callback','roi_session_ui(''lv_index_edit'');', ...
'Tag','lv_index_edit');
x = x+w+0.11;
y = y-0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % threshold label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','Threshold:', ...
'enable', 'on', ...
'Tag','threshold_label');
x = x+w;
y = y+0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % threshold edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'enable', 'on', ...
'callback','roi_session_ui(''threshold_edit'');', ...
'Tag','threshold_edit');
x = 0.15;
y = (num_inputline-9) * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % title label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','Title:', ...
'enable', 'on', ...
'Tag','title_label');
x = x+w;
y = y+0.01;
w = 0.25;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % title edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'enable', 'on', ...
'Tag','title_edit');
x = x+w+0.06;
w = 0.12;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % plot
'Units','normal', ...
'string', 'Plot', ...
'FontSize',fnt, ...
'Position',pos, ...
'callback','roi_session_ui(''roi_plot'');', ...
'enable', 'off', ...
'Tag','roi_plot');
x = x+w+0.01;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % close
'Units','normal', ...
'string', 'Close', ...
'FontSize',fnt, ...
'Position',pos, ...
'callback','roi_session_ui(''close'');', ...
'enable', 'on', ...
'Tag','close');
x = 0.01;
y = 0;
w = 1;
h = 0.6 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Message Line
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'ForegroundColor',[0.8 0.0 0.0], ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'Tag','MessageLine');
% menu bar
%
h_file = uimenu('Parent',h0, ...
'Label', 'File', ...
'Tag', 'FileMenu');
m1 = uimenu(h_file, ...
'Label', 'Load information figure', ...
'Callback','roi_session_ui(''open_fig'');');
m1 = uimenu(h_file, ...
'Label', 'Save information figure', ...
'Callback','roi_session_ui(''saveas_fig'');');
m1 = uimenu(h_file, ...
'Label', 'Close', ...
'separator', 'on', ...
'callback','roi_session_ui(''close'');');
roi_session_ui('reset1');
return; % init
%-------------------------------------------------------------------------------
function flooded_file_radio
if get(findobj(gcf,'Tag','flooded_file_radio'),'Value') == 0 % click itself
set(findobj(gcf,'Tag','flooded_file_radio'),'Value',1);
else
set(findobj(gcf,'Tag','template_image_radio'),'Value',0);
set(findobj(gcf,'Tag','template_image_label'),'enable','off');
set(findobj(gcf,'Tag','template_image_edit'),'enable','off','string','');
set(findobj(gcf,'Tag','template_image_browse'),'enable','off');
set(findobj(gcf,'Tag','create_roi_flooded_file'),'enable','off');
set(findobj(gcf,'Tag','flooded_file_label'),'enable','on');
set(findobj(gcf,'Tag','flooded_file_edit'),'enable','inactive','string','');
set(findobj(gcf,'Tag','flooded_file_browse'),'enable','on');
set(findobj(gcf,'Tag','template_image_edit'),'user','');
set(findobj(gcf,'Tag','flooded_file_edit'),'user','');
end
roi_session_ui('reset1');
return; % flooded_file_radio
%-------------------------------------------------------------------------------
function template_image_radio
if get(findobj(gcf,'Tag','template_image_radio'),'Value') == 0 % click itself
set(findobj(gcf,'Tag','template_image_radio'),'Value',1);
else
set(findobj(gcf,'Tag','flooded_file_radio'),'Value',0);
set(findobj(gcf,'Tag','flooded_file_label'),'enable','off');
set(findobj(gcf,'Tag','flooded_file_edit'),'enable','off','string','');
set(findobj(gcf,'Tag','flooded_file_browse'),'enable','off');
set(findobj(gcf,'Tag','create_roi_flooded_file'),'enable','off');
set(findobj(gcf,'Tag','template_image_label'),'enable','on');
set(findobj(gcf,'Tag','template_image_edit'),'enable','inactive','string','');
set(findobj(gcf,'Tag','template_image_browse'),'enable','on');
set(findobj(gcf,'Tag','template_image_edit'),'user','');
set(findobj(gcf,'Tag','flooded_file_edit'),'user','');
end
roi_session_ui('reset1');
return; % template_image_radio
%-------------------------------------------------------------------------------
function flooded_file_browse
[fn, pn] = uigetfile('*.tif', 'Select a Flooded Image File');
if isequal(fn, 0) | isequal(pn, 0)
return;
end;
flooded_file = fullfile(pn, fn);
set(findobj(gcf,'Tag','flooded_file_edit'),'string',fn);
set(findobj(gcf,'Tag','flooded_file_edit'),'user',flooded_file);
old_pointer = get(gcf,'Pointer');
set(gcf,'Pointer','watch');
flooded_image = imread(flooded_file);
num_roi = flooded_image(find(flooded_image<150));
num_roi = max(double(num_roi(:)))+1;
for i=1:num_roi
coord{i} = find(flooded_image==(i-1));
end
setappdata(gcf,'coord',coord);
setappdata(gcf,'num_roi',num_roi);
set(gcf,'Pointer',old_pointer);
roi_session_ui('reset1');
if ~isempty(get(findobj(gcf,'Tag','template_location_edit'),'user'))
temp_loc_file = get(findobj(gcf,'Tag','template_location_edit'),'user');
roi_name = read_ixy(temp_loc_file,1);
if(size(roi_name,1) == num_roi)
set(findobj(gcf,'Tag','edit_compare'),'enable','on');
else
set(findobj(gcf,'Tag','template_location_edit'),'user','','string','');
msg = 'Wrong ROI seed location file';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
end
end
return; % flooded_file_browse
%-------------------------------------------------------------------------------
function template_location_browse
[fn, pn] = uigetfile('*.txt', 'Select an ROI Seed Location File');
if isequal(fn, 0) | isequal(pn, 0)
return;
end;
temp_loc_file = fullfile(pn, fn);
set(findobj(gcf,'Tag','template_location_edit'),'string',fn);
set(findobj(gcf,'Tag','template_location_edit'),'user',temp_loc_file);
num_roi = getappdata(gcf,'num_roi');
roi_name = read_ixy(temp_loc_file,1);
if ~isempty(num_roi) & size(roi_name,1) ~= num_roi
set(findobj(gcf,'Tag','template_location_edit'),'user','','string','');
msg = 'Wrong ROI seed location file';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
roi_session_ui('reset1');
if ~isempty(get(findobj(gcf,'Tag','flooded_file_edit'),'user'))
set(findobj(gcf,'Tag','edit_compare'),'enable','on');
end
if ~isempty(get(findobj(gcf,'Tag','template_image_edit'),'user'))
set(findobj(gcf,'Tag','create_roi_flooded_file'),'enable','on');
end
return; % template_location_browse
%-------------------------------------------------------------------------------
function template_image_browse
[fn, pn] = uigetfile('*.tif', 'Select a Template Image File');
if isequal(fn, 0) | isequal(pn, 0)
return;
end;
temp_image_file = fullfile(pn, fn);
set(findobj(gcf,'Tag','template_image_edit'),'string',fn);
set(findobj(gcf,'Tag','template_image_edit'),'user',temp_image_file);
if ~isempty(get(findobj(gcf,'Tag','template_location_edit'),'user'))
set(findobj(gcf,'Tag','create_roi_flooded_file'),'enable','on');
end
return; % template_image_browse
%-------------------------------------------------------------------------------
function create_roi_flooded_file
[fn, pn] = uiputfile('*.tif','Please input a flooded image file name to save');
if isequal(fn, 0) | isequal(pn, 0)
return;
end;
[tmp fn] = fileparts(fn);
fn = [fn '.tif'];
flooded_file = fullfile(pn, fn);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -