📄 erp_create_datamat.m
字号:
% datamat=[datamat;temp];
% datamat(:,:,:,i) = temp;
datamat(:,:,:,i) = reshape(temp,[r c n]);
rri_progress_ui(progress_hdl, '', ((i-1)*n+j)*factor);
end
if ~isempty(merged_conds)
new_num_conditions = length(merged_conds);
new_condition = {merged_conds.name};
behavdata = session_info.behavdata;
[d1 d2 d3 d4] = size(datamat);
[b_dr b_dc] = size(behavdata);
for i = 1:k
datamat_cond{i} = datamat(:,:,:,i);
datamat_cond{i} = datamat_cond{i}(:)';
if ~isempty(behavdata)
behav_cond{i} = behavdata((i-1)*n+1:i*n,:);
behav_cond{i} = behav_cond{i}(:)';
end
end
clear datamat;
for i = 1:new_num_conditions
new_datamat_cond{i} = ...
mean(cat(1, datamat_cond{merged_conds(i).cond_idx}), 1);
new_datamat_cond{i} = reshape(new_datamat_cond{i}, [d1 d2 d3]);
if ~isempty(behavdata)
new_behav_cond{i} = ...
mean(cat(1, behav_cond{merged_conds(i).cond_idx}), 1);
new_behav_cond{i} = reshape(new_behav_cond{i}, [n b_dc]);
end
end
clear datamat_cond behav_cond;
datamat = cat(4, new_datamat_cond{:});
if ~isempty(behavdata)
behavdata = cat(1, new_behav_cond{:});
session_info.behavdata = behavdata;
session_info.num_behavior = size(behavdata,1);
end
clear new_datamat_cond new_behav_cond;
session_info.num_conditions = new_num_conditions;
session_info.condition = new_condition;
end
message = 'Saving to the disk ...';
rri_progress_ui(progress_hdl,'Save',message);
% save to disk
%
% datamatfile = [pls_data_path, filesep, filename];
% datafile = [pls_data_path, filesep, dataname];
datamatfile = fullfile(curr, filename);
datafile = fullfile(curr, dataname);
% check if exist datamat file
%
if(exist(datamatfile,'file')==2) % datamat file with same filename exist
dlg_title = 'Confirm File Overwrite';
msg = ['File ',filename,' exist. Are you sure you want to overwrite it?'];
response = questdlg(msg,dlg_title,'Yes','No','Yes');
if(strcmp(response,'No'))
% cd(pls_data_path);
savfig = [];
if strcmpi(get(gcf,'windowstyle'),'modal')
savfig = gcf;
set(gcf,'windowstyle','normal');
end
done1=0;
while ~done1
putfile_filter = [datamat_prefix,'_ERPdatamat.mat'];
[filename, pathname] = uiputfile(putfile_filter,'Save As');
if isequal(filename,0)
close(progress_hdl);
msg1 = ['WARNING: No file is saved.'];
%uiwait(msgbox(msg1,'Uncomplete','modal'));
set(findobj(gcf,'Tag','MessageLine'),'String',msg1);
done1=1;
return;
else
if rri_chkfname(filename,'ERP','datamat')
datamatfile = fullfile(pathname, filename);
done1=1;
else
msg = ['File name must be ended with _ERPdatamat.mat'];
uiwait(msgbox(msg,'Wrong filename','modal'));
end
end
end
if ~isempty(savfig)
set(savfig,'windowstyle','modal');
end
end
end
% check if exist data file
%
if(exist(datafile,'file')==2) % data file with same filename exist
dlg_title = 'Confirm File Overwrite';
msg = ['File ',dataname,' exist. Are you sure you want to overwrite it?'];
response = questdlg(msg,dlg_title,'Yes','No','Yes');
if(strcmp(response,'No'))
% cd(pls_data_path);
savfig = [];
if strcmpi(get(gcf,'windowstyle'),'modal')
savfig = gcf;
set(gcf,'windowstyle','normal');
end
done1=0;
while ~done1
putfile_filter = [datamat_prefix,'_ERPdata.mat'];
[filename, pathname] = uiputfile(putfile_filter,'Save As');
if isequal(filename,0)
close(progress_hdl);
msg1 = ['WARNING: No file is saved.'];
%uiwait(msgbox(msg1,'Uncomplete','modal'));
set(findobj(gcf,'Tag','MessageLine'),'String',msg1);
done1=1;
return;
else
if rri_chkfname(filename, 'ERP', 'data')
datafile = fullfile(pathname, filename);
done1=1;
else
msg = ['File name must be ended with _ERPdata.mat'];
uiwait(msgbox(msg,'Wrong filename','modal'));
end
end
end
if ~isempty(savfig)
set(savfig,'windowstyle','modal');
end
end
end
selected_channels = zeros(1, num_channels);
selected_channels(chan_value) = 1;
selected_subjects = zeros(1, num_subjects);
selected_subjects(subj_value) = 1;
selected_conditions = zeros(1, session_info.num_conditions);
selected_conditions(cond_value) = 1;
selected_behav = zeros(1, num_behav);
selected_behav(behav_value) = 1;
setting1 = [];
create_ver = plsgui_vernum;
savfig = [];
if strcmpi(get(gcf,'windowstyle'),'modal')
savfig = gcf;
set(gcf,'windowstyle','normal');
end
% save data file
%
done = 0;
while ~done
try
save(datafile, 'datamat', 'create_ver');
done = 1;
catch
done1=0;
while ~done1
putfile_filter = [datamat_prefix,'_ERPdata.mat'];
[filename, pathname] = uiputfile(putfile_filter, ...
'Can not save data file, please try again');
if isequal(filename,0)
datafile = [];
close(progress_hdl);
msg1 = ['WARNING: Data file is not saved.'];
%uiwait(msgbox(msg1,'Uncomplete','modal'));
set(findobj(gcf,'Tag','MessageLine'),'String',msg1);
done1=1;
return;
else
if rri_chkfname(filename, 'ERP', 'data')
datafile = fullfile(pathname, filename);
done1=1;
else
msg = ['File name must be ended with _ERPdata.mat'];
uiwait(msgbox(msg,'Wrong filename','modal'));
end
end
end
end
end
% save datamat file
%
done = 0;
while ~done
try
save(datamatfile, 'datafile', 'create_ver', ...
'session_file', 'session_info', 'selected_behav', ...
'selected_conditions', 'selected_subjects', ...
'selected_channels', 'time_info', 'setting1');
done = 1;
catch
done1=0;
while ~done1
putfile_filter = [datamat_prefix,'_ERPdatamat.mat'];
[filename, pathname] = uiputfile(putfile_filter, ...
'Can not save datamat file, please try again');
if isequal(filename,0)
datamatfile = [];
close(progress_hdl);
msg1 = ['WARNING: Datamat file is not saved.'];
%uiwait(msgbox(msg1,'Uncomplete','modal'));
set(findobj(gcf,'Tag','MessageLine'),'String',msg1);
done1=1;
return;
else
if rri_chkfname(filename, 'ERP', 'datamat')
datamatfile = fullfile(pathname, filename);
done1=1;
else
msg = ['File name must be ended with _ERPdatamat.mat'];
uiwait(msgbox(msg,'Wrong filename','modal'));
end
end
end
end
end
if ~isempty(savfig)
set(savfig,'windowstyle','modal');
end
cd(savepwd);
close(progress_hdl);
h_createdatamat = gcf;
erp_plot_ui({datamatfile, 1});
close(h_createdatamat);
% msg1 = ['WARNING: Do not change file name manually in command window.'];
% uiwait(msgbox(msg1,'File has been saved'));
return; % CreateDatamat
%----------------------------------------------------------------------------
function MergeConditions()
session_info = getappdata(gcf, 'session_info');
condition = session_info.condition;
merged_conds = fmri_merge_condition_ui(condition);
setappdata(gcf, 'merged_conds', merged_conds);
if ~isempty(merged_conds)
cond_lst_hdl = getappdata(gcf,'cond_lst_hdl');
set(cond_lst_hdl, 'string', {merged_conds.name}, 'list', 1, ...
'value', [1:length(merged_conds)]);
end
return; % MergeConditions
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -