📄 bfm_input_run_ui.m
字号:
'Callback','bfm_input_run_ui(''EDIT_LENGTH'');', ...
'Tag','BlockLengthEdit');
x = left_margin;
y = .14;
w = .65;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Replicate Label
'Style','check', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'fontunit','normal', ...
'FontSize',fnt, ...
'FontWeight','normal', ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','Replicate trial Information across run', ...
'value',1, ...
'Callback','bfm_input_run_ui(''EDIT_REPLICATE'');', ...
'Tag','ReplicateLabel');
x = 1 - left_margin - .15;
y = .12;
w = .1;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Run Edit Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'fontunit','normal',...
'FontSize',fnt, ...
'HorizontalAlignment','center', ...
'Position',pos, ...
'String','Run', ...
'Tag','RunEditLabel');
x = 1 - left_margin - .2;
y = y-.05;
w = .05;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Previous
'Units','normal', ...
'fontunit','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','<<', ...
'Enable','off', ...
'Callback','bfm_input_run_ui(''PREVIOUS_BUTTON_PRESSED'');', ...
'Tag','PREVIOUSButton');
x = 1 - left_margin - .15;
w = .1;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Number Run Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'fontunit','normal', ...
'FontSize',fnt, ...
'HorizontalAlignment','center', ...
'Position',pos, ...
'String','1',...
'Callback','bfm_input_run_ui(''RUN_EDIT'');', ...
'Tag','NumRunEdit');
x = 1 - left_margin - .05;
w = .05;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Next
'Units','normal', ...
'fontunit','normal',...
'FontSize',fnt, ...
'Position',pos, ...
'String','>>', ...
'Enable','off', ...
'Callback','bfm_input_run_ui(''NEXT_BUTTON_PRESSED'');', ...
'Tag','NEXTButton');
x = left_margin;
w = .15;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % DONE
'Units','normal', ...
'fontunit','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','DONE', ...
'Callback','bfm_input_run_ui(''DONE_BUTTON_PRESSED'');', ...
'Tag','DONEButton');
x = left_margin+.2;
w = .15;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % CANCEL
'Units','normal', ...
'fontunit','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','CANCEL', ...
'Callback','bfm_input_run_ui(''CANCEL_BUTTON_PRESSED'');', ...
'Tag','CANCELButton');
x = .01;
y = 0;
w = 1;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % MessageLine
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'ForegroundColor',[0.8 0.0 0.0], ...
'fontunit','normal', ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'Tag','MessageLine');
h_file = uimenu('Parent',h0, ...
'Label', 'Edit', ...
'Tag', 'EditMenu');
m1 = uimenu(h_file, ...
'Label', 'Load Onsets from a text file for this run', ...
'Callback','bfm_input_run_ui(''LOAD_TXT'');', ...
'Tag', 'LoadTxtMenu');
m1 = uimenu(h_file, ...
'Label', 'Save Onsets to a text file for this run', ...
'Callback','bfm_input_run_ui(''SAVE_TXT'');', ...
'Tag', 'SaveTxtMenu');
m1 = uimenu(h_file, ...
'Label', 'Clear', ...
'separator', 'on', ...
'Callback','bfm_input_run_ui(''CLEAR_RUN'');', ...
'Tag', 'ClearRunsMenu');
m1 = uimenu(h_file, ...
'Label', 'Delete', ...
'Enable', 'on', ...
'Callback','bfm_input_run_ui(''DELETE_RUN'');', ...
'Tag', 'DeleteRunsMenu');
h_file = uimenu('Parent',h0, ...
'Label', 'Plot', ...
'Tag', 'PlotMenu');
m1 = uimenu(h_file, ...
'Label', 'HRF Plots in time points', ...
'Callback','bfm_input_run_ui(''PLOT_HRF'');', ...
'Tag', 'PlotHRFMenu');
m1 = uimenu(h_file, ...
'Label', 'Onset Timing Plot in seconds', ...
'Callback','bfm_input_run_ui(''PLOT_ONSET'');', ...
'Tag', 'PlotOnsetMenu');
% set up the data directory
%
curr = pwd;
if isempty(curr)
curr = filesep;
end
setappdata(gcf,'DataDirectory',curr);
onset_template = copyobj([t1 t2 t3 t4 t5],h0);
set(onset_template(1),'Tag','ConditionNameLabelTemplate','Visible','off');
set(onset_template(2),'Tag','BlockOnsetEditTemplate','Visible','off');
set(onset_template(3),'Tag','BlockLengthEditTemplate','Visible','off');
set(onset_template(2),'Tag','BlockOnsetLabelTemplate','Visible','off');
set(onset_template(3),'Tag','BlockLengthLabelTemplate','Visible','off');
setappdata(gcf,'OnsetRowHeight',.18);
setappdata(gcf,'Onset_hlist',[t1 t2 t3 t4 t5]);
setappdata(gcf,'OnsetTemplate',onset_template);
setappdata(gcf,'TopOnsetIdx',1);
LoadSessionInfo(run_info,num_runs,conditions);
SetupBlockOnsetRows;
DisplayBlockOnsets;
SetupSlider;
return; % init
% --------------------------------------------------------------------
function SetupBlockOnsetRows()
onset_hdls = getappdata(gcf,'Onset_hlist');
onset_template = getappdata(gcf,'OnsetTemplate');
row_height = getappdata(gcf,'OnsetRowHeight');
frame_pos = get(findobj(gcf,'Tag','BlockOnsetFrame'),'Position');
clabel_pos = get(findobj(gcf,'Tag','ConditionNameLabel'),'Position');
top_frame_pos = frame_pos(2) + frame_pos(4);
margin = top_frame_pos - (clabel_pos(2) + clabel_pos(4));
rows = floor((frame_pos(4) - margin*2) / row_height);
v_pos = (top_frame_pos - margin) - [1:rows]*row_height;
nr = size(onset_hdls,1);
if (rows < nr) % too many rows
for i=rows+1:nr,
delete(onset_hdls(i,:));
end;
onset_hdls = onset_hdls(1:rows,:);
else % add more rows
for i=nr+1:rows,
new_s_hdls = copyobj(onset_template,gcf);
onset_hdls = [onset_hdls; new_s_hdls'];
end;
end;
first_onset_pos = get(onset_hdls(1,3),'Position');
width = first_onset_pos(3);
v = 'on';
for i=1:rows,
% Condition Label
new_s_hdls = onset_hdls(i,:);
pos = get(new_s_hdls(1),'Position'); pos(2) = v_pos(i)+0.11;
set(new_s_hdls(1),'String','','Position',pos,'Visible',v,'UserData',i);
% Onset Label
pos = get(new_s_hdls(4),'Position');
pos(2) = v_pos(i)+0.06;
set(new_s_hdls(4),'Position',pos,'Visible',v,'UserData',i);
% Onsets
pos = get(new_s_hdls(2),'Position');
pos(2) = v_pos(i)+0.06; pos(3) = width;
set(new_s_hdls(2),'String','','Position',pos,'Visible',v,'UserData',i);
% Length Label
pos = get(new_s_hdls(5),'Position');
pos(2) = v_pos(i);
set(new_s_hdls(5),'Position',pos,'Visible',v,'UserData',i);
% Length
pos = get(new_s_hdls(3),'Position');
pos(2) = v_pos(i); pos(3) = width;
set(new_s_hdls(3),'String','','Position',pos,'Visible',v,'UserData',i);
end;
setappdata(gcf,'Onset_hlist',onset_hdls);
setappdata(gcf,'NumOnsetRows',rows);
return; % SetupBlockOnsetRows
% --------------------------------------------------------------------
function DisplayBlockOnsets()
cond = getappdata(gcf,'SessionConditions');
curr_onsets = getappdata(gcf,'CurrOnsets');
curr_length = getappdata(gcf,'CurrLength');
top_onset_idx = getappdata(gcf,'TopOnsetIdx');
onset_hdls = getappdata(gcf,'Onset_hlist');
rows = getappdata(gcf,'NumOnsetRows');
num_onsets = length(cond);
onset_idx = top_onset_idx;
for i=1:rows,
o_hdls = onset_hdls(i,:);
if (onset_idx <= num_onsets),
set(o_hdls(1),'String',cond{onset_idx},'Visible','on');
set(o_hdls(4),'String','Onsets:','Visible','on');
output_onset = Number2String(curr_onsets{onset_idx}); % edit
set(o_hdls(2),'String',output_onset,'Visible','on');
set(o_hdls(5),'String','Length:','Visible','on');
output_onset = Number2String(curr_length{onset_idx}); % length
set(o_hdls(3),'String',output_onset,'Visible','on');
onset_idx = onset_idx + 1;
else
set(o_hdls(1),'String','','Visible','off');
set(o_hdls(2),'String','','Visible','off');
set(o_hdls(3),'String','','Visible','off');
set(o_hdls(4),'String','','Visible','off');
set(o_hdls(5),'String','','Visible','off');
end
end;
if (top_onset_idx ~= 1) | (num_onsets > rows)
set(findobj(gcf,'Tag','BlockOnsetSlider'),'Visible','on');
else
set(findobj(gcf,'Tag','BlockOnsetSlider'),'Visible','off');
end;
return; % DisplayBlockOnsets
% --------------------------------------------------------------------
function LoadSessionInfo(run_info,total_runs,conditions)
setappdata(gcf,'SessionRunInfo',run_info);
if is_same_across_run
set(findobj('tag','ReplicateLabel'),'value',1);
if (length(run_info) < total_runs)
for i=(length(run_info)+1):total_runs
run_info(i).num_scans = '';
run_info(i).data_path = [];
run_info(i).data_files = [];
run_info(i).file_pattern = [];
if isfield(run_info(1), 'blk_onsets') & isfield(run_info(1), 'blk_length') ...
& ( ~isempty(run_info(1).blk_onsets) | ~isempty(run_info(1).blk_length) )
run_info(i).blk_onsets = run_info(1).blk_onsets;
run_info(i).blk_length = run_info(1).blk_length;
else
for j=1:length(conditions)
run_info(i).blk_onsets{j} = [];
run_info(i).blk_length{j} = [];
end
end;
end
end;
else
set(findobj('tag','ReplicateLabel'),'value',0);
if (length(run_info) < total_runs)
for i=(length(run_info)+1):total_runs
run_info(i).num_scans = '';
run_info(i).data_path = [];
run_info(i).data_files = [];
run_info(i).file_pattern = [];
for j=1:length(conditions)
run_info(i).blk_onsets{j} = [];
run_info(i).blk_length{j} = [];
end
end
end
end;
setappdata(gcf,'SessionConditions',conditions);
setappdata(gcf,'SessionRunInfo',run_info);
setappdata(gcf,'TotalRuns',total_runs);
LoadRunInfo(1);
return; % LoadSessionInfo
% --------------------------------------------------------------------
function LoadRunInfo(run_idx)
run_info = getappdata(gcf,'SessionRunInfo');
total_runs = getappdata(gcf,'TotalRuns');
if (run_idx == total_runs)
set(findobj(gcf,'Tag','NEXTButton'),'Enable','off');
else
set(findobj(gcf,'Tag','NEXTButton'),'Enable','on');
end;
set(findobj(gcf,'Tag','RunIndex'),'String',sprintf('Run #%d',run_idx));
if (run_idx == 1);
set(findobj(gcf,'Tag','PREVIOUSButton'),'Enable','off');
else
set(findobj(gcf,'Tag','PREVIOUSButton'),'Enable','on');
end;
curr_num_scans = run_info(run_idx).num_scans;
curr_data_path = run_info(run_idx).data_path;
curr_data_files = run_info(run_idx).data_files;
curr_file_pattern = run_info(run_idx).file_pattern;
curr_onsets = run_info(run_idx).blk_onsets;
if isfield(run_info(run_idx),'blk_length') & ...
~isempty(run_info(run_idx).blk_length)
curr_length = run_info(run_idx).blk_length;
else
for i=1:length(curr_onsets)
curr_length{i} = ones(length(curr_onsets{i}),1);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -