📄 bfm_create_datamat_ui.m
字号:
set(findobj(gcbf,'Tag','PredefineRegionFileLabel'),'Foreground',[0 0 0]);
set(findobj(gcbf,'Tag','PredefineRegionFileEdit'),'Enable','on');
set(findobj(gcbf,'Tag','PredefineRegionFileButton'),'Enable','on');
end
return; % SelectPredefineBrainRegion
%----------------------------------------------------------------------------
function EditBrainRegionFile()
fname = get(gcbo,'String');
if isempty(fname)
setappdata(gcf,'BrainRegionFile',[]);
return;
end;
if (exist(fname,'file') ~= 2)
msg = 'ERROR: Invalid file specified.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'BrainRegionFile',[]);
return;
end;
% make sure the IMG file can be accessed.
%
try
dummy = rri_imginfo(fname);
catch
msg = 'ERROR: Cannot open the file. Make sure it is an IMG file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
if (fname(1) == filesep) % full path
setappdata(gcf,'BrainRegionFile',fname);
return;
end;
% construct the path
%
[fpath, fname, fext] = fileparts(fname);
curr = pwd;
if isempty(curr)
curr = filesep;
end
if isempty(fpath) % just filename no path
fpath = curr;
else % relative path
curr_path = curr;
cd (fpath);
fpath = curr;
cd (curr_path);
end;
if isempty(fpath), % in the root directory
fpath = filesep;
end;
fname = fullfile(fpath,[fname, fext]);
set(gcbo,'String',fname);
setappdata(gcf,'BrainRegionFile',fname);
return; % EditBrainRegionFile
%----------------------------------------------------------------------------
function SelectBrainRegionFile()
[fname, fpath] = uigetfile('*.img','Brain Region Mask');
if isequal(fname,0), % no file has been selected
return;
end;
if ~isequal(fpath,filesep) & ~isequal(fpath,0)
fname = fullfile(fpath,fname);
end;
% make sure the IMG file can be accessed.
%
try
dummy = rri_imginfo(fname);
catch
msg = 'ERROR: Cannot open the file. Make sure it is an IMG file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
set(findobj(gcbf,'Tag','PredefineRegionFileEdit'),'String',fname);
setappdata(gcf,'BrainRegionFile',fname);
return; % SelectBrainRegionFile
%----------------------------------------------------------------------------
function SelectAutoBrainRegion()
if get(findobj(gcf,'Tag','AutoRegionChkButton'),'Value') == 0 % click itself
set(findobj(gcf,'Tag','AutoRegionChkButton'),'Value',1);
else
set(findobj(gcbf,'Tag','PredefineRegionChkButton'),'Value',0);
set(findobj(gcbf,'Tag','PredefineRegionFileLabel'), ...
'Foreground',[0.5 0.5 0.5]);
set(findobj(gcbf,'Tag','PredefineRegionFileEdit'),'Enable','off');
set(findobj(gcbf,'Tag','PredefineRegionFileButton'),'Enable','off');
set(findobj(gcbf,'Tag','AutoRegionThresholdLabel'),'Foreground',[0 0 0]);
set(findobj(gcbf,'Tag','AutoRegionThresholdEdit'),'Enable','on');
set(findobj(gcbf,'Tag','ConsiderAllVoxels'),'Enable','on');
end
return; % SelectAutoBrainRegion
%----------------------------------------------------------------------------
function SelectConsiderAllVoxels
if get(findobj(gcbf,'Tag','ConsiderAllVoxels'),'Value') == 0
set(findobj(gcbf,'Tag','AutoRegionThresholdEdit'),'Enable','on');
set(findobj(gcbf,'Tag','AutoRegionThresholdEdit'),'String','0.15');
setappdata(gcbf,'Threshold',0.25);
else
set(findobj(gcbf,'Tag','AutoRegionThresholdEdit'),'Enable','off');
set(findobj(gcbf,'Tag','AutoRegionThresholdEdit'),'String','0');
setappdata(gcbf,'Threshold',0);
end
return; % SelectConsiderAllVoxels
%----------------------------------------------------------------------------
function SetThreshold()
try
threshold = str2num(get(gcbo,'String'));
if (threshold < 0) | (threshold > 1)
msg = 'ERROR: Threshold must be between 0 and 1.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'Threshold',[]);
return;
end;
setappdata(gcf,'Threshold',threshold);
catch
msg = 'ERROR: Invalid threshold value.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'Threshold',[]);
return;
end;
return; % SetThreshold
%----------------------------------------------------------------------------
function SetMaxStdDeviation()
try
max_std_dev = str2num(get(gcbo,'String'));
if (max_std_dev <= 0)
msg = 'ERROR: Max. standard deviation must be larger than 0';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'MaxStdDev',[]);
return;
end;
setappdata(gcf,'MaxStdDev',max_std_dev);
catch
msg = 'ERROR: Invalid value for the max. standard deviation.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'MaxStdDev',[]);
return;
end;
return; % SetMaxStdDeviation
%----------------------------------------------------------------------------
function SelectMergeDataWithinRun()
if get(findobj(gcf,'Tag','MergeDataWithinRunButton'),'Value') == 0 % click itself
set(findobj(gcf,'Tag','MergeDataWithinRunButton'),'Value',1);
else
set(findobj(gcbf,'Tag','MergeDataAcrossRunsButton'),'Value',0);
if get(findobj(gcf,'Tag','SingleSubjectChkButton'),'Value')
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','On');
else
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
end
set_num_behav;
end
return; % SelectMergeDataWithinRun
%----------------------------------------------------------------------------
function SelectMergeDataAcrossRuns()
if get(findobj(gcf,'Tag','MergeDataAcrossRunsButton'),'Value') == 0 % click itself
set(findobj(gcf,'Tag','MergeDataAcrossRunsButton'),'Value',1);
else
set(findobj(gcbf,'Tag','MergeDataWithinRunButton'),'Value',0);
if get(findobj(gcf,'Tag','SingleSubjectChkButton'),'Value')
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
else
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
end
set_num_behav;
end
return; % SelectMergeDataAcrossRuns
%----------------------------------------------------------------------------
function check_singlesubject
if 0
if get(findobj(gcf,'Tag','MergeDataAcrossRunsButton'),'Value')
if get(findobj(gcf,'Tag','SingleSubjectChkButton'),'Value')
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
else
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
end
else
if get(findobj(gcf,'Tag','SingleSubjectChkButton'),'Value')
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','On');
else
set(findobj(gcbf,'Tag','BehavDataEdit_all'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each'),'Visible','On');
set(findobj(gcbf,'Tag','BehavDataEdit_all_single'),'Visible','Off');
set(findobj(gcbf,'Tag','BehavDataEdit_each_single'),'Visible','Off');
end
end
set_num_behav;
end
return;
%----------------------------------------------------------------------------
function SetScanSkipped()
num_scans_skipped = str2num(get(gcbo,'String'));
if isempty(num_scans_skipped) | (num_scans_skipped < 0)
msg = 'ERROR: Invalid value for the number of skipped scans.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'NumScansSkipped',[]);
return;
end;
setappdata(gcf,'NumScansSkipped',num_scans_skipped);
return; % SetScanSkipped
%----------------------------------------------------------------------------
function SetRunIncluded()
run_idx = str2num(get(gcbo,'String'));
if isempty(run_idx)
msg = 'ERROR: Invalid value for the run indices.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'RunsIncluded',[]);
return;
end;
num_runs = getappdata(gcf,'NumRuns');
if ~isempty(find(run_idx <= 0 | run_idx > num_runs))
msg = sprintf('ERROR: Slice number must be between 1 to %d',num_runs);
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'RunsIncluded',[]);
return;
end;
setappdata(gcf,'RunsIncluded',run_idx);
return; % SetRunIncluded
%----------------------------------------------------------------------------
function SetIgnoreSlices()
ignore_slices = str2num(get(gcbo,'String'));
if isempty(ignore_slices)
msg = 'ERROR: Invalid value for the slice number.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'SliceIgnored',-1);
return;
end;
num_slices = getappdata(gcf,'NumSlices');
if ~isempty(find(ignore_slices <= 0 | ignore_slices > num_slices))
msg = sprintf('ERROR: Slice number must be between 1 to %d',num_slices);
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'SliceIgnored',-1);
return;
end;
setappdata(gcf,'SliceIgnored',ignore_slices);
return; % SetIgnoreSlices
%----------------------------------------------------------------------------
function SetTemporalWindowSize()
try
window_size = str2num(get(gcbo,'String'));
if (window_size <= 0)
msg = 'ERROR: The temporal window size must be larger than 0';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'TemporalWindowSize',[]);
return;
end;
catch
msg = 'ERROR: Invalid value for the max. standard deviation.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'TemporalWindowSize',[]);
return;
end;
setappdata(gcf,'TemporalWindowSize',window_size);
return; % SetTemporalWindowSize
%----------------------------------------------------------------------------
function status = SaveDatamatOptions()
status = 0; % set status to fail first
STOptions.session_win_hdl = getappdata(gcf,'session_win_hdl');
% For brain region
%
if (get(findobj(gcbf,'Tag','PredefineRegionChkButton'),'Value') == 1)
STOptions.UseBrainRegionFile = 1;
STOptions.BrainRegionFile = getappdata(gcf,'BrainRegionFile');
if isempty(STOptions.BrainRegionFile),
msg = 'ERROR: Invalid file for the brain region mask.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
STOptions.Threshold = [];
STOptions.ConsiderAllVoxels = 0;
else
STOptions.UseBrainRegionFile = 0;
STOptions.BrainRegionFile = [];
STOptions.Threshold = getappdata(gcf,'Threshold');
if isempty(STOptions.Threshold)
msg = 'ERROR: Invalid threshold value.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
STOptions.ConsiderAllVoxels = ...
get(findobj(gcbf,'Tag','ConsiderAllVoxels'),'value');
end;
STOptions.MaxStdDev = getappdata(gcf,'MaxStdDev');
if isempty(STOptions.MaxStdDev)
msg = 'ERROR: Invalid max. standard deviation value.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
% for Datamat
%
STOptions.NumScansSkipped = getappdata(gcf,'NumScansSkipped');
if isempty(STOptions.NumScansSkipped)
msg = 'ERROR: Invalid value for the number of skipped scans.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
STOptions.RunsIncluded = getappdata(gcf,'RunsIncluded');
if isempty(STOptions.RunsIncluded)
msg = 'ERROR: Invalid run indices.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
STOptions.SliceIgnored = getappdata(gcf,'SliceIgnored');
if ~isempty(STOptions.SliceIgnored) & (STOptions.SliceIgnored == -1)
msg = 'ERROR: Invalid slice number to be ignored.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
STOptions.TemporalWindowSize = getappdata(gcf,'TemporalWindowSize');
if isempty(STOptions.TemporalWindowSize)
msg = 'ERROR: Invalid temporal window size.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
h = findobj(gcbf,'Tag','MeanRatioChkButton');
STOptions.NormalizeVolumeMean = get(h,'Value');
h = findobj(gcbf,'Tag','MeanSignalChkButton');
STOptions.NormalizeSignalMean = get(h,'Value');
h = findobj(gcbf,'Tag','SingleSubjectChkButton');
STOptions.SingleSubject = get(h,'Value');
h = findobj(gcbf,'Tag','MergeDataAcrossRunsButton');
STOptions.MergeDataAcrossRuns = get(h,'Value');
STOptions.MergeDataAcrossRuns = getappdata(STOptions.session_win_hdl,'SessionAcrossRun');
STOptions.BehavData = []; % getappdata(gcf,'BehavData');
STOptions.BehavName = {}; % getappdata(gcf,'BehavName');
STOptions.NumBehavior = 0; % getappdata(gcf,'NumBehavior');
if ~isempty(STOptions.BehavData)
session_file = getappdata(gcbf,'SessionFile');
load(session_file);
num_cond = session_info.num_conditions;
num_run = length(STOptions.RunsIncluded);
if STOptions.MergeDataAcrossRuns & ~STOptions.SingleSubject
if STOptions.NumBehavior == num_cond
num_behav_not_match = 0;
else
num_behav_not_match = num_cond;
end
elseif ~STOptions.MergeDataAcrossRuns & ~STOptions.SingleSubject
if STOptions.NumBehavior == num_cond * num_run
num_behav_not_match = 0;
else
num_behav_not_match = num_cond * num_run;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -