📄 rri_input_condition_ui.m
字号:
%RRI_INPUT_CONDITION_UI Form to input conditions
%
% Usage: [new_condition, subj_files, reselect_subj] = ...
% rri_input_condition_ui(condition, old_subj_files);
%
% See also PLS_INPUT_CONDITION_UI
%
% I (condition) - old conditions cell array, or action word call recursively
% I (old_subj_files) - saved subj_files
% O (new_condition) - new conditions cell array
% O (subj_files) - A row vector containing the images file name.
%
% Modified on 26-SEP-2002 by Jimmy Shen
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [new_condition, subj_files, reselect_subj] = ...
rri_input_condition_ui(varargin)
if nargin == 0
old_conditions = [];
end;
if nargin == 0 | ~ischar(varargin{1})
old_conditions = varargin{1};
old_subj_files = varargin{2};
init(old_conditions, old_subj_files);
uiwait; % wait for user finish
new_condition = getappdata(gcf,'CurrConditions');
subj_files = getappdata(gcf,'subj_files');
reselect_subj = getappdata(gcf,'reselect_subj');
close(gcf);
return;
end;
% clear the message line,
%
h = findobj(gcf,'Tag','MessageLine');
set(h,'String','');
action = upper(varargin{1});
if strcmp(action,'UPDATE_CONDITION'),
UpdateCondition;
elseif strcmp(action,'DELETE_CONDITION'),
DeleteCondition;
elseif strcmp(action,'ADD_CONDITION'),
AddCondition;
elseif strcmp(action,'MOVE_SLIDER'),
MoveSlider;
elseif strcmp(action,'DELETE_FIG')
delete_fig;
elseif strcmp(action,'CANCEL_BUTTON_PRESSED'),
old_conditions = getappdata(gcf,'OldConditions');
old_subj_files = getappdata(gcf,'old_subj_files');
setappdata(gcf,'CurrConditions',old_conditions);
setappdata(gcf,'subj_files',old_subj_files);
setappdata(gcf,'reselect_subj',0);
uiresume;
elseif strcmp(action,'DONE_BUTTON_PRESSED'),
DoneButtonPressed;
end;
return;
%----------------------------------------------------------------------------
function init(old_conditions, old_subj_files)
save_setting_status = 'on';
input_condition_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(input_condition_pos) & strcmp(save_setting_status,'on')
pos = input_condition_pos;
else
w = 0.6;
h = 0.7;
x = (1-w)/2;
y = (1-h)/2;
pos = [x y w h];
end
h0 = figure('Color',[0.8 0.8 0.8], ...
'Units','normal', ...
'Name','Edit Condition', ...
'MenuBar','none', ...
'NumberTitle','off', ...
'deletefcn','rri_input_condition_ui(''DELETE_FIG'');', ...
'Position',pos, ...
'WindowStyle', 'modal', ...
'Tag','InputCondition', ...
'ToolBar','none');
% 'DoubleBuffer', 'on', ...
% 'Renderer', 'OpenGL', ...
x = 0.06;
y = 0.9;
w = 1;
h = 0.06;
pos = [x y w h];
c = uicontrol('Parent',h0, ...
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.6, ...
'FontName', 'FixedWidth', ...
'FontAngle','italic', ...
'FontWeight','bold', ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',pos, ...
'String','Conditions: ', ...
'Tag','ConditionTitleLabel');
x = 0.03;
y = 0.83;
w = 0.07;
pos = [x y w h];
c_h1 = uicontrol('Parent',h0, ... % condition idx
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',pos, ...
'String','1.', ...
'Tag','ConditionIdxLabel');
x = x+w+0.01;
w = 0.63;
pos = [x y w h];
c_h2 = uicontrol('Parent',h0, ... % condition name
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',pos, ...
'String','', ...
'tooltip','Click Add button when finish', ...
'Tag','ConditionNameEdit');
x = x+w+0.01;
w = 0.12;
pos = [x y w h];
c_h3 = uicontrol('Parent',h0, ... % condition button
'Units','normal', ...
'Position',pos, ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'ListboxTop',0, ...
'String','Add', ...
'Tag','ADD/DELButton');
x = x+w+0.02;
w = 0.04;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ... % scroll bar
'Style', 'slider', ...
'Units','normal', ...
'Min',1, ...
'Max',20, ...
'Value',20, ...
'Position',pos, ...
'Callback','rri_input_condition_ui(''MOVE_SLIDER'');', ...
'Tag','CondSlider');
x = 0.11;
y = 0.08;
w = 0.2;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ... % DONE
'Units','normal', ...
'Callback','', ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'ListboxTop',0, ...
'Position',pos, ...
'String','DONE', ...
'Callback','rri_input_condition_ui(''DONE_BUTTON_PRESSED'');', ...
'Tag','DONEButton');
x = 0.67;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ... % CANCEL
'Units','normal', ...
'Callback','', ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'ListboxTop',0, ...
'Position',pos, ...
'String','CANCEL', ...
'Callback','rri_input_condition_ui(''CANCEL_BUTTON_PRESSED'');', ...
'Tag','CANCELButton');
x = 0.01;
y = 0;
w = 1;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ... % Message Line
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'ForegroundColor',[0.8 0.0 0.0], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'Tag','MessageLine');
cond1_hdls = [c_h1,c_h2,c_h3]; % save handles for condition#1
setappdata(h0,'Cond_hlist',cond1_hdls);
cond_template = copyobj(cond1_hdls,h0);
set(cond_template,'visible','off');
setappdata(h0,'OldConditions',old_conditions);
setappdata(h0,'CurrConditions',old_conditions);
setappdata(h0,'ConditionTemplate',cond_template);
cond_h = 0.06;
setappdata(h0,'ConditionHeight', cond_h);
lower_h = 0.01; % vert. space for Number of rows etc.
setappdata(h0,'lower_h',lower_h);
setappdata(h0,'TopConditionIdx',1);
setappdata(h0,'ConditionMap',[1:length(old_conditions)]);
setappdata(h0,'old_subj_files', old_subj_files);
setappdata(h0,'subj_files', old_subj_files);
setappdata(h0,'reselect_subj',0);
SetupConditionRows;
SetupSlider;
CreateAddRow;
DisplayConditions;
UpdateSlider;
return; % init
%----------------------------------------------------------------------------
function DoneButtonPressed()
curr_cond = getappdata(gcf,'CurrConditions');
num_cond = length(curr_cond);
empty_condition = 0;
for i=1:num_cond,
if isempty(curr_cond{i}),
empty_condition = 1;
break;
end;
end;
if (empty_condition)
msg = 'ERROR: All conditions must have name specified.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'reselect_subj',0);
return;
else
for i=1:num_cond
for j=i+1:num_cond
if(strcmp(curr_cond{i}, curr_cond{j}))
msg = 'ERROR: No conditions should be duplicated.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'reselect_subj',0);
return;
end
end;
end
AddCondition;
uiresume;
end
return; % DoneButtonPressed
%----------------------------------------------------------------------------
function SetupConditionRows()
cond_hdls = getappdata(gcf,'Cond_hlist');
cond_h = getappdata(gcf,'ConditionHeight');
lower_h = getappdata(gcf,'lower_h');
bottom_pos = get(findobj(gcf,'Tag','DONEButton'),'Position');
top_pos = get(cond_hdls(1,2),'Position');
rows = floor(( top_pos(2) - bottom_pos(2) - lower_h ) / cond_h);
% A row of vertical positions, at which the 13 4-controls will be located.
v_pos = top_pos(2) - [0:rows-1]*cond_h;
cond_template = getappdata(gcf,'ConditionTemplate');
edit_cbf = 'rri_input_condition_ui(''UPDATE_CONDITION'');';
delete_cbf = 'rri_input_condition_ui(''DELETE_CONDITION'');';
nr = size(cond_hdls,1); % nr = 1 for the initial
if (rows < nr) % too many rows
for i=rows+1:nr,
delete(cond_hdls(i,:));
end;
cond_hdls = cond_hdls(1:rows,:);
else % add new rows to 'rows' amount
for i=nr+1:rows,
new_c_hdls = copyobj(cond_template,gcf);
cond_hdls = [cond_hdls; new_c_hdls'];
end;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -