diff --git a/GUIs/artifactinterpGUI.fig b/GUIs/artifactinterpGUI.fig
index 1ab20824..c42bb3dd 100755
Binary files a/GUIs/artifactinterpGUI.fig and b/GUIs/artifactinterpGUI.fig differ
diff --git a/GUIs/artifactmenuGUI.fig b/GUIs/artifactmenuGUI.fig
index 29659ee5..aadad049 100755
Binary files a/GUIs/artifactmenuGUI.fig and b/GUIs/artifactmenuGUI.fig differ
diff --git a/GUIs/binselectorGUI.mlapp b/GUIs/binselectorGUI.mlapp
new file mode 100644
index 00000000..a095e4ff
Binary files /dev/null and b/GUIs/binselectorGUI.mlapp differ
diff --git a/GUIs/combinebestbinsGUI.mlapp b/GUIs/combinebestbinsGUI.mlapp
new file mode 100644
index 00000000..03f11ffc
Binary files /dev/null and b/GUIs/combinebestbinsGUI.mlapp differ
diff --git a/GUIs/decodingGUI.mlapp b/GUIs/decodingGUI.mlapp
new file mode 100644
index 00000000..ebda97f8
Binary files /dev/null and b/GUIs/decodingGUI.mlapp differ
diff --git a/GUIs/export2textGUI.fig b/GUIs/export2textGUI.fig
index b29c43ec..2dcf9d13 100755
Binary files a/GUIs/export2textGUI.fig and b/GUIs/export2textGUI.fig differ
diff --git a/GUIs/geterpvaluesGUI2.fig b/GUIs/geterpvaluesGUI2.fig
index 68c4ff37..a7d814c8 100755
Binary files a/GUIs/geterpvaluesGUI2.fig and b/GUIs/geterpvaluesGUI2.fig differ
diff --git a/GUIs/grandaveragerGUI.fig b/GUIs/grandaveragerGUI.fig
index fafc94c7..11f6ca1a 100755
Binary files a/GUIs/grandaveragerGUI.fig and b/GUIs/grandaveragerGUI.fig differ
diff --git a/GUIs/meaviewerGUI.fig b/GUIs/meaviewerGUI.fig
index 5b5e6917..771e6637 100755
Binary files a/GUIs/meaviewerGUI.fig and b/GUIs/meaviewerGUI.fig differ
diff --git a/GUIs/meaviewerGUI.m b/GUIs/meaviewerGUI.m
index 784a99af..c7c3899e 100755
--- a/GUIs/meaviewerGUI.m
+++ b/GUIs/meaviewerGUI.m
@@ -1561,7 +1561,7 @@ function mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
checknan(handles, val)
end
hold off
-drawnow
+%drawnow
nbinput = length(binput);
nchinput = length(chinput);
diff --git a/GUIs/mvpa_save_multi_file.fig b/GUIs/mvpa_save_multi_file.fig
new file mode 100644
index 00000000..d968893b
Binary files /dev/null and b/GUIs/mvpa_save_multi_file.fig differ
diff --git a/GUIs/mvpa_save_multi_file.m b/GUIs/mvpa_save_multi_file.m
new file mode 100644
index 00000000..155b46b8
--- /dev/null
+++ b/GUIs/mvpa_save_multi_file.m
@@ -0,0 +1,406 @@
+function varargout = mvpa_save_multi_file(varargin)
+% MVPA_SAVE_MULTI_FILE MATLAB code for mvpa_save_multi_file.fig
+% MVPA_SAVE_MULTI_FILE, by itself, creates a new MVPA_SAVE_MULTI_FILE or raises the existing
+% singleton*.
+%
+% H = MVPA_SAVE_MULTI_FILE returns the handle to a new MVPA_SAVE_MULTI_FILE or the handle to
+% the existing singleton*.
+%
+% MVPA_SAVE_MULTI_FILE('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in MVPA_SAVE_MULTI_FILE.M with the given input arguments.
+%
+% MVPA_SAVE_MULTI_FILE('Property','Value',...) creates a new MVPA_SAVE_MULTI_FILE or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before mvpa_save_multi_file_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to mvpa_save_multi_file_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help mvpa_save_multi_file
+
+% Last Modified by GUIDE v2.5 17-Mar-2023 16:20:49
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpa_save_multi_file_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpa_save_multi_file_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before mvpa_save_multi_file is made visible.
+function mvpa_save_multi_file_OpeningFcn(hObject, eventdata, handles, varargin)
+% Choose default command line output for mvpa_save_multi_file
+
+try
+ ALLERP = varargin{1};
+ Selected_ERP_label = varargin{2};
+ suffix = varargin{3};
+catch
+ suffix = '';
+ ERPLAB = [];
+ ERPLAB.erpname = 'No erpset was selected';
+ ERPLAB.filename ='No erpset was selected';
+ ERPLAB.event = [];
+ ERPLAB.chanlocs = [];
+ ERPLAB.nbchan = 0;
+ ALLERP(1) = ERPLAB;
+ Selected_ERP_label = 1;
+end
+
+% handles.erpnameor = erpname;
+handles.output = [];
+handles.suffix = suffix;
+
+handles.ALLERP = ALLERP;
+handles.Selected_ERP_label =Selected_ERP_label;
+
+%erplab_studio_default_values;
+erplab_default_values;
+version = erplabver;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save multiple MVPAsets GUI'])
+
+
+% set(handles.checkbox1_suffix,'Value',1);
+set(handles.edit_suffix_name,'String',suffix);
+set(handles.checkbox2_save_label,'Value',0);
+
+ColumnName_table = {'MVPA name','File name'};
+
+set(handles.uitable1_erpset_table,'ColumnName',cellstr(ColumnName_table));
+set(handles.uitable1_erpset_table,'RowName',cellstr(num2str(Selected_ERP_label')));
+
+
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ DataString{Numofselectederp,1} = strcat(ALLERP(Selected_ERP_label(Numofselectederp)).bestname,suffix);
+ DataString{Numofselectederp,2} = '';
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248});
+set(handles.uitable1_erpset_table,'Enable','on');
+set(handles.checkbox3_filename_erpname,'Enable','off');
+
+%
+% % Color GUI
+% %
+handles = painterplab(handles);
+%
+% %
+% % Set font size
+% %
+handles = setfonterplab(handles);
+
+% Update handles structure
+guidata(hObject, handles);
+
+set(handles.checkbox2_save_label,'Value',1);
+checkbox2_save_label_Callback(hObject, [], handles)
+
+
+% UIWAIT makes savemyerpGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpa_save_multi_file_OutputFcn(hObject, eventdata, handles)
+
+% Get default command line output from handles structure
+try
+ varargout{1} = handles.output;
+catch
+ varargout{1} = [];
+end
+
+delete(handles.gui_chassis);
+pause(0.1)
+
+
+
+% --- Executes on button press in checkbox1_suffix.
+function checkbox1_suffix_Callback(hObject, eventdata, handles)
+ALLERP = handles.ALLERP;
+Selected_ERP_label = handles.Selected_ERP_label;
+suffix_edit = handles.edit_suffix_name.String;
+
+if isempty(suffix_edit)
+ msgboxText = 'You must enter a suffix at least!';
+ title = 'EStudio: f_ERP_save_multi_file() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+DataString_before = handles.uitable1_erpset_table.Data;
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ %DataString{Numofselectederp,1} = strcat(ALLERP(Selected_ERP_label(Numofselectederp)).bestname,suffix_edit);
+ DataString{Numofselectederp,1} = strcat(DataString_before{Numofselectederp,1},suffix_edit);
+ DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248});
+% if handles.checkbox2_save_label.Value
+% set(handles.uitable1_erpset_table,'Enable','off');
+% else
+% set(handles.uitable1_erpset_table,'Enable','on');
+% end
+
+
+
+
+function edit_suffix_name_Callback(hObject, eventdata, handles)
+
+% Suffix_string = handles.edit_suffix_name.String;
+% if isempty(Suffix_string)
+% msgboxText = 'You must enter a suffix at least!';
+% title = 'EStudio: mvpa_save_multi_file() error';
+% errorfound(msgboxText, title);
+% return
+% end
+%
+% if handles.checkbox1_suffix.Value
+%
+% DataString_before = handles.uitable1_erpset_table.Data;
+% for Numofselectederp = 1:size(DataString_before,1)
+% DataString{Numofselectederp,1} = char(strcat(DataString_before{Numofselectederp,1},'-',char(Suffix_string)));
+% DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+% end
+%
+% set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+% set(handles.uitable1_erpset_table,'ColumnWidth',{248 248});
+% set(handles.uitable1_erpset_table,'Enable','off');
+% handles.suffix=Suffix_string;
+% end
+
+% --- Executes during object creation, after setting all properties.
+function edit_suffix_name_CreateFcn(hObject, eventdata, handles)
+
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+
+
+
+% --- Executes on button press in checkbox2_save_label.
+function checkbox2_save_label_Callback(hObject, eventdata, handles)
+
+Values = handles.checkbox2_save_label.Value;
+
+if Values
+ set(handles.checkbox3_filename_erpname,'Enable','on');
+ ALLERP = handles.ALLERP;
+ Selected_ERP_label = handles.Selected_ERP_label;
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
+ fileName= char(ALLERP(Selected_ERP_label(Numofselectederp)).filename);
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpa'];
+ else
+ file_name = [file_name,'.mvpa'];
+ end
+ DataString{Numofselectederp,2} = file_name;
+
+ end
+
+ set(handles.uitable1_erpset_table,'Data',DataString);
+else
+ set(handles.checkbox3_filename_erpname,'Enable','off');
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ DataString_before{Numofselectederp,2} = '';
+ end
+ set(handles.uitable1_erpset_table,'Data',DataString_before);
+ set(handles.uitable1_erpset_table,'Enable','on');
+end
+% if handles.checkbox2_save_label.Value
+% set(handles.uitable1_erpset_table,'Enable','off');
+% else
+% set(handles.uitable1_erpset_table,'Enable','on');
+% end
+
+
+
+% --- Executes on button press in checkbox3_filename_erpname.
+function checkbox3_filename_erpname_Callback(hObject, eventdata, handles)
+Value_filename_erpname = handles.checkbox3_filename_erpname.Value;
+%
+% set(handles.uitable1_erpset_table,'Enable','off');
+DataString_before = handles.uitable1_erpset_table.Data;
+
+for Numofselectederp = 1:size(DataString_before,1)
+
+ DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
+ fileName = char(DataString_before{Numofselectederp,1});
+ if isempty(fileName)
+ fileName = strcat(num2str(Numofselectederp),'mvpa');
+ end
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpa'];
+ else
+ file_name = [file_name,'.mvpa'];
+ end
+ DataString{Numofselectederp,2} = file_name;
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248});
+
+
+
+
+
+% --- Executes when entered data in editable cell(s) in uitable1_erpset_table.
+function uitable1_erpset_table_CellEditCallback(hObject, eventdata, handles)
+
+DataString = handles.uitable1_erpset_table.Data;
+Selected_ERP_label = handles.Selected_ERP_label;
+if size(DataString,1) < numel(Selected_ERP_label)
+ msgboxText = 'Erpname and filename for one of erpsets are empty at least! Please give name to erpname and filename';
+ title = 'EStudio: f_ERP_save_multi_file empty erpname';
+ errorfound(msgboxText, title);
+ return
+end
+
+for Numofselected = 1:numel(Selected_ERP_label)
+ if isempty(DataString{Numofselected,1})
+ msgboxText = 'Erpname for one of erpsets is empty at least! Please give name to that erpset';
+ title = 'EStudio: f_ERP_save_multi_file empty erpname';
+ errorfound(msgboxText, title);
+ return
+ end
+
+end
+
+
+
+% --- Executes on button press in pushbutton_Cancel.
+function pushbutton_Cancel_Callback(hObject, eventdata, handles)
+handles.output = [];
+% beep;
+disp('User selected Cancel.');
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+
+
+
+% --- Executes on button press in pushbutton4_okay.
+function pushbutton4_okay_Callback(hObject, eventdata, handles)
+% suffix = strtrim(get(handles.edit_suffix_name, 'String'));
+% if handles.checkbox1_suffix.Value
+% if isempty(suffix)
+% msgboxText = 'You must enter suffix at least!';
+% title = 'EStudio: mvpa_save_multi_file empty erpname';
+% errorfound(msgboxText, title);
+% return
+% end
+% end
+
+Data_String =handles.uitable1_erpset_table.Data;
+ALLERP = handles.ALLERP;
+Selected_ERP_label = handles.Selected_ERP_label;
+
+if size(Data_String,1)< numel(Selected_ERP_label)%
+ msgboxText = 'MVPAname for one of MVPAsets is empty at least! Please give a name';
+ title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+if size(Data_String,1)> numel(Selected_ERP_label)%
+ msgboxText = 'More MVPAname is given. Please delete it!!!';
+ title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+for Numofselected = 1:numel(Selected_ERP_label)
+ if isempty(Data_String{Numofselected,1})
+ msgboxText = 'MVPAname for one of MVPAsets is empty at least! Please give a name';
+ title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
+ errorfound(msgboxText, title);
+ return
+ end
+
+end
+
+
+
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ ALLERP(Selected_ERP_label(Numofselectederp)).bestname = Data_String{Numofselectederp,1};
+ fileName = char(Data_String{Numofselectederp,2});
+ if isempty(fileName)
+ fileName = Data_String{Numofselectederp,1};
+ end
+
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_mvpa.mvpa'];
+ else
+ file_name = [file_name,'.mvpa'];
+ end
+
+ ALLERP(Selected_ERP_label(Numofselectederp)).filename = file_name;
+ if handles.checkbox2_save_label.Value
+ ALLERP(Selected_ERP_label(Numofselectederp)).filepath = cd;
+ end
+
+ if handles.checkbox2_save_label.Value
+ ALLERP(Selected_ERP_label(Numofselectederp)).saved = 'yes';
+ else
+ ALLERP(Selected_ERP_label(Numofselectederp)).saved = 'no';
+ end
+
+end
+
+FilePath = handles.checkbox2_save_label.Value;
+
+handles.output = {ALLERP, FilePath};
+% Update handles structure
+guidata(hObject, handles);
+
+uiresume(handles.gui_chassis);
+
+
+
+% -----------------------------------------------------------------------
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = '';
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
diff --git a/GUIs/mvpaviewerGUI.fig b/GUIs/mvpaviewerGUI.fig
new file mode 100644
index 00000000..424a3797
Binary files /dev/null and b/GUIs/mvpaviewerGUI.fig differ
diff --git a/GUIs/mvpaviewerGUI.m b/GUIs/mvpaviewerGUI.m
new file mode 100644
index 00000000..ba7cf390
--- /dev/null
+++ b/GUIs/mvpaviewerGUI.m
@@ -0,0 +1,2195 @@
+%
+% Author: Javier Lopez-Calderon
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2012
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function varargout = mvpaviewerGUI(varargin)
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpaviewerGUI_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpaviewerGUI_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+% --- Executes just before mvpaviewerGUI is made visible.
+function mvpaviewerGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+
+
+% Choose default command line output for mvpaviewerGUI
+handles.output = [];
+%defx = erpworkingmemory('pop_geterpvalues');
+% try
+% cerpi = evalin('base', 'CURRENTERP'); % current erp index
+% catch
+% cerpi = 1;
+% end
+% handles.cerpi = cerpi;
+try
+ ALLMVPA = varargin{1};
+ setArray = 1:length(ALLMVPA);
+catch
+ ALLMVPA = buildERPstruct;
+ ALLMVPA.times = -200:800;
+ ALLMVPA.xmin = -0.2;
+ ALLMVPA.xmax = 0.8;
+ ALLMVPA.nchan = 1;
+ ALLMVPA.pnts = length(ALLMVPA.times);
+ ALLMVPA.nbin = 1;
+ ALLMVPA.bindata = zeros(1, ALLMVPA.pnts, 1);
+ ALLMVPA.srate = 1000;
+ ALLMVPA.bindescr = {'empty'};
+ ALLMVPA.chanlocs.labels = 'empty';
+end
+% if strcmpi(datatype, 'ERP')
+% meaword = 'latenc';
+% else
+% meaword = 'frequenc';
+% end
+% if isempty(defx)
+% if isempty(ALLMVPA)
+% inp1 = 1; %from hard drive
+% erpset = [];
+% else
+% inp1 = 0; %from erpset menu
+% erpset = 1:length(ALLMVPA);
+% end
+% defx = {inp1 erpset '' 0 1 1 'instabl' 1 3 'pre' 0 1 5 0 0.5 0 0 0 '' 0 1};
+% end
+% try
+% def = varargin{2};
+% AMP = def{1};
+% Lat = def{2};
+% binArray = def{3};
+% chanArray = def{4};
+% setArray = def{5};
+% latency = def{6};
+% moreoptions = def{7};
+%
+% blc = moreoptions{1};
+% moption = moreoptions{2};
+% tittle = moreoptions{3};
+% dig = moreoptions{4};
+% coi = moreoptions{5};
+% polpeak = moreoptions{6};
+% sampeak = moreoptions{7};
+% locpeakrep = moreoptions{8};
+% frac = moreoptions{9};
+% fracmearep = moreoptions{10};
+% intfactor = moreoptions{11};
+% catch
+% latency = defx{4};
+% moption = defx{7};
+%
+% AMP = [];
+% Lat = {{[-200 800]}};
+% binArray = 1:ALLMVPA(1).nbin;
+% chanArray = 1:ALLMVPA(1).nchan;
+% setArray = 1:length(ALLMVPA);
+% %latency = 0;
+% blc = 'pre';
+% %moption = 'instabl';
+% tittle = 'nada';
+% dig = 3;
+% coi = [];
+% polpeak = [];
+% sampeak = [];
+% locpeakrep = [];
+% frac = [];
+% fracmearep = [];
+% intfactor = 1;
+% end
+%datatype2 = '';
+if isfield(ALLMVPA(1).header, 'DecodingMethod')
+ datatype = ALLMVPA(1).header.DecodingMethod;
+
+ if strcmpi(datatype,'SVM')
+ % here, treat SEM data like ERP data
+ datatype = 'SVM';
+ % datatype2 = 'SEM';
+ end
+
+else
+ datatype = 'SVM';
+end
+
+set(handles.checkbox_dmouse, 'String', 'Adjust measurement window with the mouse by click, hold, drag and release')
+
+if strcmpi(datatype, 'ERP')
+ measurearray = {'Average Decoding Accuracy'};
+else
+ %blc = 'none';
+ measurearray = {'Average Decoding Accuracy'};
+end
+
+handles.measurearray = measurearray;
+
+meacodes = {'avgdecodingacc' };
+
+handles.meacodes = meacodes;
+
+%set(handles.text_measurementv, 'String', measurearray);
+
+%[tfm, indxmeaX] = ismember_bc2({moption}, meacodes);
+
+meamenu = 1; % 'Average Decoding Accuracy',...
+set(handles.text_measurementv, 'String', measurearray{meamenu});
+% set(handles.text_measurementv, 'Value', meamenu);
+% set(handles.text_measurementv, 'Enable', 'inactive');
+
+cwm = erpworkingmemory('WMColor'); % window color for measurement
+cvl = erpworkingmemory('VLColor'); % line color for measurement
+mwm = erpworkingmemory('WMmouse'); % select window measurement by mouse option
+
+if isempty(cwm)
+ cwm = [0.8490 1.0000 0.1510];
+end
+if isempty(cvl)
+ cvl = [1 0 0];
+end
+if isempty(mwm)
+ mwm = 0;
+end
+
+%handles.defx = defx;
+handles.cwm = cwm;
+handles.cvl = cvl;
+handles.ALLMVPA = ALLMVPA;
+%handles.binArray = binArray;
+%handles.chanArray = chanArray;
+handles.setArray = setArray;
+%handles.ich = 1;
+%handles.ibin = 1;
+handles.iset = 1;
+%handles.orilatency = latency;
+%handles.blc = blc;
+%handles.moption = moption;
+handles.tittle = tittle;
+handles.dig = 3;
+handles.coi = [];
+handles.polpeak = [];
+handles.sampeak = [];
+handles.locpeakrep = [];
+handles.frac = [];
+handles.fracmearep = [];
+handles.intfactor = 1;
+handles.x1 = -1.75;
+handles.x2 = 1.75;
+
+%
+% create random x-values for scatter plot
+%
+% xscatt = rand(1,numel(AMP))*2.5-1.25;
+% handles.xscatt = xscatt;
+indxsetstr = {''};
+% end
+handles.indxsetstr = indxsetstr;
+
+% handles.membin = [];
+% handles.memch = [];
+% handles.memset = [];
+
+binvalue = erpworkingmemory('BinHisto'); % value(s) for bin in histogram
+normhisto = erpworkingmemory('NormHisto'); % normalize histogram
+chisto = erpworkingmemory('HistoColor'); % histogram color
+cfitnorm = erpworkingmemory('FnormColor'); % line color for fitted normal distribution
+fitnormd = erpworkingmemory('FitNormd'); % fit nomal distribution
+
+if isempty(binvalue)
+ binvalue = 'auto';
+end
+if isempty(normhisto)
+ normhisto = 0;
+end
+if isempty(chisto)
+ chisto = [1 0.5 0.2];
+end
+if isempty(cfitnorm)
+ cfitnorm = [1 0 0];
+end
+if isempty(fitnormd)
+ fitnormd = 0;
+end
+
+handles.binvalue = binvalue;
+handles.normhisto = normhisto;
+handles.chisto = chisto;
+handles.cfitnorm = cfitnorm;
+handles.fitnormd = fitnormd;
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - VIEWER FOR MVPA GUI']); %, 'toolbar','figure')
+
+ibin = 1;
+ich = 1;
+iset = 1;
+times = ALLMVPA(1).times;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ ylim = [-20 20];
+ enablepolabutt = 'on';
+else
+ xlim = [0 30];
+ ylim = [0 15];
+ enablepolabutt = 'off';
+end
+% if strcmpi(datatype2, 'SEM')
+% ylim = [-1 20];
+% end
+
+set(handles.edit_ylim, 'String', num2str(ylim))
+set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)))
+%set(handles.edit_bin, 'String', num2str(ibin))
+%set(handles.edit_channel, 'String', num2str(ich))
+set(handles.edit_file, 'String', num2str(iset))
+frdm = erpworkingmemory('freedom');
+if isempty(frdm);frdm=0;end
+if frdm==0 %JLC
+ %set(handles.edit_bin, 'Enable', 'inactive')
+ % set(handles.edit_channel, 'Enable', 'inactive')
+ % set(handles.edit_file, 'Enable', 'inactive')
+end
+handles.frdm = frdm;
+word = 'positive';
+set(handles.togglebutton_y_axis_polarity, 'String', sprintf('
%s is up', word));
+set(handles.togglebutton_y_axis_polarity, 'Enable', enablepolabutt);
+handles.ydir = 'normal';
+%set(handles.checkbox_butterflybin,'Value', 0)
+%set(handles.checkbox_butterflychan,'Value', 0)
+set(handles.checkbox_butterflyset,'Value', 0)
+% if length(binArray)==1
+% set(handles.checkbox_butterflybin, 'Enable', 'off')
+% if frdm; set(handles.edit_bin, 'Enable', 'off');end
+% set(handles.pushbutton_right_bin, 'Enable', 'off')
+% set(handles.pushbutton_left_bin, 'Enable', 'off')
+% end
+% if length(chanArray)==1
+% set(handles.checkbox_butterflychan, 'Enable', 'off')
+% if frdm; set(handles.edit_channel, 'Enable', 'off');end
+% set(handles.pushbutton_right_channel, 'Enable', 'off')
+% set(handles.pushbutton_left_channel, 'Enable', 'off')
+% end
+if length(setArray)==1
+ set(handles.checkbox_butterflyset, 'Enable', 'off')
+ if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+end
+handles.datatype = datatype;
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+
+% help
+% helpbutton
+
+%
+% Drag
+%
+% set(handles.checkbox_dmouse,'Value', 0)
+% set(handles.radiobutton_histo,'Value', 0)
+% set(handles.radiobutton_histo,'Enable', 'off')
+% set(handles.pushbutton_histosetting,'Enable', 'off')
+% set(handles.radiobutton_scatter,'Value', 0)
+% set(handles.radiobutton_scatter,'Enable', 'off')
+% set(handles.checkbox_fileindx,'Value', 0)
+% set(handles.checkbox_fileindx,'Enable', 'off')
+% set(handles.checkbox_scatterlabels, 'Value',0)
+% set(handles.checkbox_scatterlabels, 'Enable', 'off')
+% set(handles.pushbutton_narrow, 'Enable', 'off')
+% set(handles.pushbutton_wide, 'Enable', 'off')
+% set(handles.checkbox_3sigma, 'Value',0)
+% set(handles.checkbox_3sigma, 'Enable', 'off')
+% % set(handles.togglebutton_y_axis_polarity, 'Enable', 'on');
+% set(handles.gui_chassis,'DoubleBuffer','on')
+
+% if isempty(AMP)
+% [ AMP, Lat, latency ] = getnewvals(hObject, handles, latency);
+% handles.AMP = AMP;
+% handles.Lat = Lat;
+% handles.latency = latency;
+% else
+% handles.AMP = AMP;
+% handles.Lat = Lat;
+% handles.latency = latency;
+%
+% end
+% Update handles structure
+guidata(hObject, handles);
+
+%
+% Plot figure
+%
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% UIWAIT makes mvpaviewerGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpaviewerGUI_OutputFcn(hObject, eventdata, handles)
+
+% Get default command line output from handles structure
+varargout{1} = handles.output;
+
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+% -------------------------------------------------------------------------
+function pushbutton_left_bin_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ibin = ibin-1;
+
+if ibin<1
+ return; %ibin = 1;
+end
+handles.ibin = ibin;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+
+% -------------------------------------------------------------------------
+function pushbutton_right_bin_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+binArray = handles.binArray;
+ich = handles.ich;
+ibin = handles.ibin; % pointer of bin
+iset = handles.iset;
+ibin = ibin+1;
+
+if ibin>length(binArray)
+ return; %ibin = length(binArray);
+end
+handles.ibin = ibin;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+
+% -------------------------------------------------------------------------
+function pushbutton_left_channel_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ich = ich-1;
+
+if ich<1
+ return; %ich = 1;
+end
+handles.ich = ich;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+% -------------------------------------------------------------------------
+function pushbutton_right_channel_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+chanArray = handles.chanArray;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ich = ich+1;
+
+if ich>length(chanArray)
+ return; %ich = length(chanArray);
+end
+handles.ich = ich;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+% -------------------------------------------------------------------------
+function pushbutton_left_file_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+iset = iset-1;
+
+if iset<1
+ return; %iset = 1;
+end
+handles.iset = iset;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+% -------------------------------------------------------------------------
+function pushbutton_right_file_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+setArray = handles.setArray;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+iset = iset+1;
+
+if iset>length(setArray)
+ return; %iset = length(setArray);
+end
+handles.iset = iset;
+
+% Update handles structure
+guidata(hObject, handles);
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+% -------------------------------------------------------------------------
+function checknan(handles, val)
+if any(isnan(val))
+ cvl = handles.cvl;
+ ylim = str2num(get(handles.edit_ylim, 'String' ));
+ xlim = str2num(get(handles.edit_xlim, 'String' ));
+ set(handles.edit_report, 'BackgroundColor', 'r')
+ line([xlim(1) xlim(2)], [ylim(2) ylim(1)], 'Color', cvl) % JLC. Feb 13, 2013
+ line([xlim(1) xlim(2)], [ylim(1) ylim(2)], 'Color', cvl) % JLC. Feb 13, 2013
+else
+ set(handles.edit_report, 'BackgroundColor', 'w')
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_gotomea_Callback(hObject, eventdata, handles)
+if get(handles.checkbox_dmouse, 'Value')
+ latency = handles.latency;
+ handles.output = {1 latency};
+
+ defx = handles.defx;
+ defx{4} = latency;
+
+ erpworkingmemory('pop_geterpvalues', defx);
+
+else
+ handles.output = {1 []};
+end
+
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function pushbutton6_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_xlim_Callback(hObject, eventdata, handles)
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if length(xlim)~=2 || length(ylim)~=2 || any(isnan(xlim)) || any(isnan(ylim)) || any(isinf(xlim)) || any(isinf(ylim)) || xlim(1)>=xlim(2) || ylim(1)>=ylim(2)
+ msgboxText = 'Invalid scale!\n You must enter 2 numeric values on each range.\tThe first one must be lower than the second one.';
+ title = 'ERPLAB: meaviewerGUI, invalid baseline input';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function edit_xlim_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_ylim_Callback(hObject, eventdata, handles)
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if length(xlim)~=2 || length(ylim)~=2 || any(isnan(xlim)) || any(isnan(ylim)) || any(isinf(xlim)) || any(isinf(ylim)) || xlim(1)>=xlim(2) || ylim(1)>=ylim(2)
+ msgboxText = 'Invalid scale!\n You must enter 2 numeric values on each range.\tThe first one must be lower than the second one.';
+ title = 'ERPLAB: meaviewerGUI, invalid baseline input';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function edit_ylim_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_update_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if length(xlim)~=2 || length(ylim)~=2 || any(isnan(xlim)) || any(isnan(ylim)) || any(isinf(xlim)) || any(isinf(ylim)) || xlim(1)>=xlim(2) || ylim(1)>=ylim(2)
+ msgboxText = 'Invalid scale!\n You must enter 2 numeric values on each range.\tThe first one must be lower than the second one.';
+ title = 'ERPLAB: meaviewerGUI, invalid baseline input';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function checkbox_butterflychan_Callback(hObject, eventdata, handles)
+chanArray = handles.chanArray;
+if get(hObject, 'Value')
+ set(handles.edit_channel, 'String', vect2colon(chanArray, 'Delimiter', 'off'))
+ if handles.frdm; set(handles.edit_channel, 'Enable', 'off');end
+ set(handles.pushbutton_right_channel, 'Enable', 'off')
+ set(handles.pushbutton_left_channel, 'Enable', 'off')
+ set(handles.radiobutton_histo,'Enable', 'on')
+ set(handles.radiobutton_scatter,'Enable', 'on')
+else
+ if handles.frdm; set(handles.edit_channel, 'Enable', 'on');end
+ %chanArray = handles.chanArray;
+ chinput = str2num(get(handles.edit_channel, 'String'));
+
+ if length(chinput)>1 && ~handles.frdm
+ chinput = chinput(1);
+ [xxx, ich] = closest(chanArray, chinput);
+ handles.ich=ich;
+ set(handles.edit_channel, 'String', num2str(chinput))
+ end
+ if length(chinput)<=1
+ set(handles.pushbutton_right_channel, 'Enable', 'on')
+ set(handles.pushbutton_left_channel, 'Enable', 'on')
+ else
+ set(handles.pushbutton_right_channel, 'Enable', 'off')
+ set(handles.pushbutton_left_channel, 'Enable', 'off')
+ end
+ if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') % none checked
+ set(handles.radiobutton_histo,'Value', 0)
+ set(handles.radiobutton_histo,'Enable', 'off')
+ set(handles.pushbutton_histosetting,'Enable', 'off')
+ set(handles.radiobutton_scatter,'Value', 0)
+ set(handles.radiobutton_scatter,'Enable', 'off')
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'off')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'off')
+ set(handles.checkbox_dmouse,'Enable', 'on')
+ end
+end
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function checkbox_butterflybin_Callback(hObject, eventdata, handles)
+binArray = handles.binArray;
+if get(hObject, 'Value')
+ set(handles.edit_bin, 'String', vect2colon(binArray, 'Delimiter', 'off'))
+ if handles.frdm; set(handles.edit_bin, 'Enable', 'off');end
+ set(handles.pushbutton_right_bin, 'Enable', 'off')
+ set(handles.pushbutton_left_bin, 'Enable', 'off')
+ set(handles.radiobutton_histo,'Enable', 'on')
+ %set(handles.pushbutton_histosetting,'Enable', 'on')
+ set(handles.radiobutton_scatter,'Enable', 'on')
+else
+ if handles.frdm; set(handles.edit_bin, 'Enable', 'on');end
+ bininput = str2num(get(handles.edit_bin, 'String'));
+ if length(bininput)>1 && ~handles.frdm
+ bininput = bininput(1);
+ [xxx, ibin] = closest(binArray, bininput);
+ handles.ibin=ibin;
+ set(handles.edit_bin, 'String', num2str(bininput))
+ % Update handles structure
+ guidata(hObject, handles);
+ end
+ if length(bininput)<=1
+ set(handles.pushbutton_right_bin, 'Enable', 'on')
+ set(handles.pushbutton_left_bin, 'Enable', 'on')
+ else
+ set(handles.pushbutton_right_bin, 'Enable', 'off')
+ set(handles.pushbutton_left_bin, 'Enable', 'off')
+ end
+ if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') % none checked
+ set(handles.radiobutton_histo,'Value', 0)
+ set(handles.radiobutton_histo,'Enable', 'off')
+ set(handles.pushbutton_histosetting,'Enable', 'off')
+ set(handles.radiobutton_scatter,'Value', 0)
+ set(handles.radiobutton_scatter,'Enable', 'off')
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'off')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'off')
+ set(handles.checkbox_dmouse,'Enable', 'on')
+ end
+end
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function checkbox_butterflyset_Callback(hObject, eventdata, handles)
+setArray = handles.setArray;
+if get(hObject, 'Value')
+ set(handles.edit_file, 'String', vect2colon(setArray, 'Delimiter', 'off'))
+ if handles.frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ set(handles.radiobutton_histo,'Enable', 'on')
+ set(handles.radiobutton_scatter,'Enable', 'on')
+
+ if get(handles.radiobutton_scatter, 'Value')
+ set(handles.checkbox_fileindx,'Enable', 'on')
+ set(handles.checkbox_scatterlabels, 'Enable', 'on')
+ set(handles.pushbutton_narrow, 'Enable', 'on')
+ set(handles.pushbutton_wide, 'Enable', 'on')
+ set(handles.checkbox_3sigma, 'Enable', 'on')
+ else
+ set(handles.checkbox_fileindx,'Enable', 'off')
+ set(handles.pushbutton_narrow, 'Enable', 'off')
+ set(handles.pushbutton_wide, 'Enable', 'off')
+ end
+else
+ if handles.frdm; set(handles.edit_file, 'Enable', 'on');end
+ setinput = str2num(get(handles.edit_file, 'String'));
+ if length(setinput)>1 && ~handles.frdm
+ setinput = setinput(1);
+ [xxx, iset] = closest(setArray, setinput);
+ handles.iset=iset;
+ set(handles.edit_file, 'String', num2str(setinput))
+ end
+ if length(setinput)<=1
+ set(handles.pushbutton_right_file, 'Enable', 'on')
+ set(handles.pushbutton_left_file, 'Enable', 'on')
+ else
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ end
+ if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') % none checked
+ set(handles.radiobutton_histo,'Value', 0)
+ set(handles.radiobutton_histo,'Enable', 'off')
+ set(handles.pushbutton_histosetting,'Enable', 'off')
+ set(handles.radiobutton_scatter,'Value', 0)
+ set(handles.radiobutton_scatter,'Enable', 'off')
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'off')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'off')
+ set(handles.checkbox_dmouse,'Enable', 'on')
+ set(handles.pushbutton_narrow, 'Enable', 'off')
+ set(handles.pushbutton_wide, 'Enable', 'off')
+ end
+ set(handles.checkbox_fileindx,'Value', 0)
+ set(handles.checkbox_fileindx,'Enable', 'off')
+end
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function semibutterflychan(hObject, eventdata, handles)
+
+chanArray = handles.chanArray;
+chinput = str2num(get(handles.edit_channel, 'String'));
+
+if length(chinput)<=1
+ return
+end
+chinput = chinput(ismember_bc2(chinput, chanArray));
+
+
+% [c, ich] = closest(chanArray, chinput);
+% handles.ich = ich;
+%
+% % Update handles structure
+% guidata(hObject, handles);
+
+set(handles.edit_channel, 'String', vect2colon(chinput, 'Delimiter', 'off'))
+% set(handles.edit_channel, 'Enable', 'off')
+set(handles.pushbutton_right_channel, 'Enable', 'off')
+set(handles.pushbutton_left_channel, 'Enable', 'off')
+set(handles.radiobutton_histo,'Enable', 'on')
+set(handles.radiobutton_scatter,'Enable', 'on')
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function semibutterflybin(hObject, eventdata, handles)
+
+binArray = handles.binArray;
+bininput = str2num(get(handles.edit_bin, 'String'));
+
+if length(bininput)<=1
+ return
+end
+bininput = bininput(ismember_bc2(bininput, binArray));
+
+
+% [c, ich] = closest(chanArray, chinput);
+% handles.ich = ich;
+%
+% % Update handles structure
+% guidata(hObject, handles);
+
+set(handles.edit_bin, 'String', vect2colon(bininput, 'Delimiter', 'off'))
+% set(handles.edit_channel, 'Enable', 'off')
+set(handles.pushbutton_right_bin, 'Enable', 'off')
+set(handles.pushbutton_left_bin, 'Enable', 'off')
+set(handles.radiobutton_histo,'Enable', 'on')
+set(handles.radiobutton_scatter,'Enable', 'on')
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function semibutterflyfile(hObject, eventdata, handles)
+
+setArray = handles.setArray;
+setinput = str2num(get(handles.edit_file, 'String'));
+
+if length(setinput)<=1
+ return
+end
+setinput = setinput(ismember_bc2(setinput, setArray));
+
+
+% [c, ich] = closest(chanArray, chinput);
+% handles.ich = ich;
+%
+% % Update handles structure
+% guidata(hObject, handles);
+
+set(handles.edit_file, 'String', vect2colon(setinput, 'Delimiter', 'off'))
+% set(handles.edit_channel, 'Enable', 'off')
+set(handles.pushbutton_right_file, 'Enable', 'off')
+set(handles.pushbutton_left_file, 'Enable', 'off')
+set(handles.radiobutton_histo,'Enable', 'on')
+set(handles.radiobutton_scatter,'Enable', 'on')
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function edit_bin_Callback(hObject, eventdata, handles)
+bin = str2num(get(handles.edit_bin, 'String'));
+if length(bin)>1
+ semibutterflybin(hObject, eventdata, handles)
+ return
+else
+ set(handles.pushbutton_right_bin, 'Enable', 'on')
+ set(handles.pushbutton_left_bin, 'Enable', 'on')
+ %set(handles.radiobutton_histo,'Enable', 'off')
+ %set(handles.radiobutton_scatter,'Enable', 'off')
+end
+
+binArray = handles.binArray;
+[c, ibin] = closest(binArray, bin);
+handles.ibin = ibin;
+
+% Update handles structure
+guidata(hObject, handles);
+
+set(handles.edit_bin, 'String', num2str(ibin))
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+iset = handles.iset;
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+% -------------------------------------------------------------------------
+function edit_bin_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_channel_Callback(hObject, eventdata, handles)
+chan = str2num(get(handles.edit_channel, 'String'));
+if length(chan)>1
+ semibutterflychan(hObject, eventdata, handles)
+ return
+else
+ set(handles.pushbutton_right_channel, 'Enable', 'on')
+ set(handles.pushbutton_left_channel, 'Enable', 'on')
+ %set(handles.radiobutton_histo,'Enable', 'off')
+ %set(handles.radiobutton_scatter,'Enable', 'off')
+end
+
+chanArray = handles.chanArray;
+[c, ich] = closest(chanArray, chan);
+handles.ich = ich;
+
+% Update handles structure
+guidata(hObject, handles);
+
+set(handles.edit_channel, 'String', num2str(ich))
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+% -------------------------------------------------------------------------
+function edit_channel_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_file_Callback(hObject, eventdata, handles)
+setx = str2num(get(handles.edit_file, 'String'));
+if length(setx)>1
+ semibutterflyfile(hObject, eventdata, handles)
+ return
+else
+ set(handles.pushbutton_right_file, 'Enable', 'on')
+ set(handles.pushbutton_left_file, 'Enable', 'on')
+ %set(handles.radiobutton_histo,'Enable', 'off')
+ %set(handles.radiobutton_scatter,'Enable', 'off')
+end
+if isempty(setx)
+ if strcmpi(get(handles.edit_file, 'String'), 'all')
+ set(handles.checkbox_butterflyset, 'Value', 1)
+ if handles.frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ iset = handles.iset;
+ else
+ setArray = handles.setArray;
+ iset = handles.iset;
+ msgboxText = 'Invalid input';
+ title = 'ERPLAB: meaviewerGUI';
+ errorfound(sprintf(msgboxText), title);
+ set(handles.edit_file, 'String', num2str(setArray(iset)))
+ set(handles.checkbox_butterflyset, 'Value', 0)
+ return
+ end
+else
+ setArray = handles.setArray;
+ [c, iset] = closest(setArray, setx);
+ handles.iset = iset;
+
+ % Update handles structure
+ guidata(hObject, handles);
+ set(handles.edit_file, 'String', num2str(iset))
+end
+
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+% -------------------------------------------------------------------------
+function edit_file_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_report_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_report_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+%--------------------------------------------------------------------------
+function Untitled_1_Callback(hObject, eventdata, handles)
+
+%--------------------------------------------------------------------------
+function pushbutton_color_window_Callback(hObject, eventdata, handles)
+cwm = handles.cwm;
+cwm = uisetcolor(cwm,'Window color') ;
+erpworkingmemory('WMColor', cwm);
+handles.cwm = cwm;
+% Update handles structure
+guidata(hObject, handles);
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+if isempty(xlim) || isempty(ylim)
+ return
+end
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function pushbutton_color_val_Callback(hObject, eventdata, handles)
+cvl = handles.cvl;
+cvl = uisetcolor( cvl,'Value line color') ;
+erpworkingmemory('VLColor', cvl);
+handles.cvl = cvl;
+% Update handles structure
+guidata(hObject, handles);
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+mplotdata(hObject, handles, iset, xlim, ylim, tittle)
+
+% PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+% PPPPPPPPPPPPPPPPPPPPPPPPPPP PLOT PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+% PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+function mplotdata(hObject, handles, iset, xlim, ylim, tittle)
+% nhisto = 10; % temporary
+ydir = handles.ydir;
+%binArray = handles.binArray;
+%chanArray = handles.chanArray;
+setArray = handles.setArray;
+
+%binput = [];
+%chinput = [];
+setinput = [];
+
+% if get(handles.checkbox_butterflybin, 'Value')
+% jbin = binArray;
+% else
+% binput = str2num(get(handles.edit_bin, 'String'));
+%
+% if length(binput)>1
+% jbin = binput;
+% else
+% jbin = binArray(ibin) ;
+% end
+% end
+% if get(handles.checkbox_butterflychan, 'Value')
+% jchannel = chanArray;
+% else
+% chinput = str2num(get(handles.edit_channel, 'String'));
+%
+% if length(chinput)>1
+% jchannel = chinput;
+% else
+% jchannel = chanArray(ich);
+% end
+% end
+if get(handles.checkbox_butterflyset, 'Value')
+ jseta = setArray;
+else
+ setinput = str2num(get(handles.edit_file, 'String'));
+
+ if length(setinput)>1
+ jseta = setinput;
+ else
+ jseta = setArray(iset);
+ end
+end
+
+% nvalue = length(jbin)*length(jchannel)*length(jseta);
+%
+% if nvalue>1
+% set(handles.uipanel_distplots, 'Title', sprintf('Distribution Plots (N=%g)', nvalue));
+% else
+% set(handles.uipanel_distplots, 'Title', 'Distribution Plots');
+% end
+
+ALLERP = handles.ALLERP;
+AMP = handles.AMP;
+Lat = handles.Lat;
+latency = handles.latency;
+truelat = latency;
+blc = handles.blc;
+meacodes = handles.meacodes;
+moption = handles.moption;
+mearea = { 'areat', 'areap', 'arean','areazt','areazp','areazn', 'ninteg','nintegz'};
+dig = handles.dig;
+times = ALLERP(setArray(1)).times;
+intfactor = handles.intfactor;
+pnts = ALLERP(setArray(1)).pnts;
+timeor = ALLERP(setArray(1)).times; % original time vector
+p1 = timeor(1);
+p2 = timeor(end);
+
+if intfactor~=1
+ timex = linspace(p1,p2,round(pnts*intfactor));
+else
+ timex = timeor;
+end
+
+%
+% Colors
+%
+cwm = handles.cwm;
+cvl = handles.cvl;
+% fctr = length(jseta)*length(jchannel)*length(jbin);
+iptch = 1;
+lt = 1;
+latmin = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+latmax = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+axes(handles.axes1);
+fntsz = get(handles.edit_report, 'FontSize');
+set(handles.edit_report, 'FontSize', fntsz*1.5 )
+set(handles.edit_report, 'String', sprintf('\nWorking...\n'))
+drawnow
+% tic
+for seta = jseta
+ kset = find(setArray==seta,1);
+ for channel = jchannel
+ kch = find(chanArray==channel,1);
+ for bin = jbin
+ kbin = find(binArray==bin,1);
+ lat4mea = Lat{1, 1, kset}; % kset is ok
+ lat4mea = lat4mea{kbin, kch};
+ val(iptch)= AMP(kbin, kch, kset); % kbin, kch, kset are ok
+ indxsetstr{iptch} = num2str(seta); % stores set index
+
+ %
+ % get data
+ %
+ data = ALLERP(seta).bindata(channel, :, bin);
+
+ if intfactor~=1
+ data = spline(timeor, data, timex); % re-sampled data
+ end
+
+ %
+ % Baseline
+ %
+ blv = blvalue2(data, timex, blc);
+ data = data - blv;
+
+ if ~get(handles.radiobutton_histo, 'Value') && ~get(handles.radiobutton_scatter, 'Value')
+
+ %
+ % Plot
+ %
+ plot(timex, data, 'LineWidth', 1, 'Color', [0 0.1 0.5]);
+
+ if iptch==1
+ axis([xlim ylim])
+ set(handles.axes1,'ydir', ydir);
+ hold on
+ end
+
+ %
+ % Line for value
+ %
+ latetype = 0; % when lat is from measurement window
+ switch moption
+ case 'instabl'
+ line(xlim, [val(iptch) val(iptch) ], 'Color', cvl, 'LineStyle',':')
+ line([latency(1)-(xlim(2)-xlim(1))*0.025 latency(1)+(xlim(2)-xlim(1))*0.025], [val(iptch) val(iptch) ], 'Color', cvl)
+ case {'meanbl', 'areat', 'areap', 'arean', 'ninteg'}
+ line(xlim, [val(iptch) val(iptch) ], 'Color', cvl, 'LineStyle',':')
+ line([latency(1) latency(2)], [val(iptch) val(iptch) ], 'Color', cvl)
+ case {'areazt','areazp','areazn', 'nintegz'}
+ line(xlim, [val(iptch) val(iptch) ], 'Color', cvl, 'LineStyle',':')
+ line([lat4mea(1) lat4mea(2)], [val(iptch) val(iptch) ], 'Color', cvl)
+ latetype = 1; % use true lat istead
+ truelat = lat4mea;
+ case 'peakampbl'
+ line(xlim, [val(iptch) val(iptch) ], 'Color', cvl, 'LineStyle',':')
+ line([lat4mea(1)-(xlim(2)-xlim(1))*0.025 lat4mea(1)+(xlim(2)-xlim(1))*0.025], [val(iptch) val(iptch) ], 'Color', cvl)
+ truelat = lat4mea;
+ otherwise
+ end
+
+ %
+ % Paint area
+ %
+ if ismember_bc2(moption, mearea) || ismember_bc2(moption, {'fareatlat', 'fareaplat','fninteglat','fareanlat'})
+ if latetype ==0
+ latx = latency;
+ else
+ latx = lat4mea;
+ end
+
+ [xxx, latsamp] = closest(timex, latx);
+ datax = data(latsamp(1):latsamp(2));
+
+ if ismember_bc2(moption, {'areap', 'areazp', 'fareaplat'}) % positive area
+ datax(datax<0) = 0;
+ area(timex(latsamp(1):latsamp(2)), datax, 'FaceColor', 'b')
+ elseif ismember_bc2(moption, {'arean', 'areazn', 'fareanlat'}) % negative area
+ datax(datax>0) = 0;
+ area(timex(latsamp(1):latsamp(2)), datax, 'FaceColor', 'r')
+ elseif ismember_bc2(moption, {'ninteg','nintegz', 'fninteglat'}) % integration
+ datatemp = datax;
+ datatemp(datatemp<0) = 0;
+ area(timex(latsamp(1):latsamp(2)), datatemp, 'FaceColor', 'b')
+ datatemp = datax;
+ datatemp(datatemp>0) = 0;
+ area(timex(latsamp(1):latsamp(2)), datatemp, 'FaceColor', 'r')
+ else
+ area(timex(latsamp(1):latsamp(2)), datax, 'FaceColor', [0.2000 0.1 0])
+ end
+ end
+
+ %
+ % Line(s) for latency(ies) and window for measurement
+ %
+ if length(latency)==1
+ if ismember_bc2(moption, {'areazt','areazp','areazn', 'nintegz'})
+ line([latency latency], ylim, 'Color', cvl)
+ latmin(lt) = lat4mea(1);
+ latmax(lt) = lat4mea(2);
+
+ if (iptch==1 && length([jbin jchannel jseta])==3) || (iptch==length(jbin)*length(jchannel)*length(jseta) && length([jbin jchannel jseta])>3)
+ pp = patch([min(latmin) max(latmax) max(latmax) min(latmin)],[ylim(1) ylim(1) ylim(2) ylim(2)], cwm);
+ set(pp,'FaceAlpha',0.4, 'EdgeAlpha', 0.4, 'EdgeColor', cwm);
+ end
+
+ %
+ % workaround (redraw axis)
+ %
+ line([0 0], ylim, 'Color', 'k')
+ line(xlim, [0 0], 'Color', 'k')
+ lt = lt + 1;
+ else
+ line([latency latency], ylim, 'Color', cvl)
+ end
+ elseif length(latency)==2
+ if iptch==1
+ pp = patch([latency(1) latency(2) latency(2) latency(1)],[ylim(1) ylim(1) ylim(2) ylim(2)], cwm);
+ set(pp,'FaceAlpha',0.4, 'EdgeAlpha', 0.4, 'EdgeColor', cwm);
+ end
+ if ismember_bc2(moption, {'peakampbl'})
+ if length(lat4mea)~=1
+ % line([xlim(1) xlim(2)], [ylim(2) ylim(1)], 'Color', cvl) % JLC. Feb 13, 2013
+ % line([xlim(1) xlim(2)], [ylim(1) ylim(2)], 'Color', cvl) % JLC. Feb 13, 2013
+ else
+
+ %lat4mea
+
+
+ line([lat4mea lat4mea], ylim, 'Color', cvl)
+ end
+ elseif ismember_bc2(moption, {'peaklatbl', 'fareatlat', 'fareaplat','fninteglat','fareanlat'})
+
+ %val(iptch)
+
+
+ line([val(iptch) val(iptch) ], ylim, 'Color', cvl)
+
+
+
+ elseif ismember_bc2(moption, {'fpeaklat'}) % fractional peak latency
+ line([val(iptch) val(iptch) ], ylim, 'Color', cvl) % fractional peak lat
+ line([lat4mea lat4mea], ylim, 'Color', cvl,'LineStyle',':') % peak lat
+ end
+ end
+ end
+ iptch = iptch+1;
+ end
+ end
+end
+
+set(handles.edit_report, 'String', '')
+set(handles.edit_report, 'FontSize', fntsz)
+
+if any(isnan(val))
+ iststrnan = indxsetstr(isnan(val));
+ nanindxfile = unique_bc2(str2num(char(iststrnan))');
+else
+ nanindxfile = [];
+ iststrnan = {[]};
+end
+if get(handles.radiobutton_histo, 'Value')
+ if any(isnan(val))
+ indxok = find(~isnan(val));
+
+ if isempty(indxok)
+ msgboxText = 'Unfortunately, you only got NaN values...';
+ title = 'ERPLAB: Error, only NaN values were found';
+ errorfound(msgboxText, title);
+ return
+ end
+ val = val(indxok);
+ end
+
+ nhisto = handles.binvalue;
+ if ischar(nhisto) && strcmpi(nhisto,'auto')
+ nhisto = round(sqrt(length(val)));
+ elseif ischar(nhisto) && ~strcmpi(nhisto,'auto')
+ msgboxText = [nhisto ' is not a valid input.\n\n'...
+ 'Enter a single value, a monotonically non-decreasing vector, or ''auto''.\n'...
+ 'Or just click the "suggest" button.'];
+ title = 'ERPLAB: meaviewerGUI, wrong inputs';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ normhisto = handles.normhisto;
+ chisto = handles.chisto;
+ fitnormd = handles.fitnormd;
+ cfitnorm = handles.cfitnorm;
+ [valhist, binhist] = hist(val, nhisto);
+ areahisto = sum(valhist)*mean(diff(binhist));
+
+ if normhisto
+ val2plot = valhist/areahisto;
+ areahisto = 1; % for fitting a normalized pdf
+ else
+ val2plot = valhist;
+ end
+ if length(val2plot)==1 && (isnan(val2plot) || isinf(val2plot)) && normhisto
+ msgboxText = 'Oops! There are not enough measurement points to make a normalized histogram...';
+ title = 'ERPLAB: meaviewerGUI, few inputs';
+ errorfound(msgboxText, title);
+ return
+ elseif length(val2plot)==1 && (isnan(val2plot) || isinf(val2plot)) && ~normhisto
+ msgboxText = 'Oops! There are not enough measurement points to make a histogram...';
+ title = 'ERPLAB: meaviewerGUI, few inputs';
+ errorfound(msgboxText, title);
+ return
+ elseif length(val2plot)==1 && ~isnan(val2plot) && ~isinf(val2plot)
+ hview = bar(binhist, val2plot);
+ axis([binhist-2 binhist+2 -0.15*min(val2plot) 1.15*max(val2plot)])
+ else
+ hview = bar(binhist, val2plot, 'hist');
+ xh = [min(binhist) max(binhist)];
+ cxh = abs(diff(xh))/2;
+ axis([xh(1)-cxh xh(2)+cxh -0.15*min(val2plot) 1.15*max(val2plot)])
+ end
+
+ set(hview,'FaceColor', chisto); %[1 0.5 0.2]
+
+ if fitnormd %&& normhisto
+ hold on
+ mu = mean(val);
+ sg = std(val);
+ npnd = length(binhist)*10; % 10 time the number of histo's bins
+ xnd = linspace(mu-4*sg,mu+4*sg,npnd);
+ pdfxnd = areahisto*(1/sqrt(2*pi)/sg*exp(-(xnd-mu).^2/(2*sg^2)));
+ pfnorm = plot(xnd,pdfxnd);
+ set(pfnorm,'Color',cfitnorm,'LineWidth',1)
+ hold off
+ end
+elseif get(handles.radiobutton_scatter, 'Value') % JLC scatter plot
+ chisto = handles.chisto;
+ xscatt = handles.xscatt; % x-ccord for scatter plot
+ if any(isnan(val))
+ indxok = find(~isnan(val));
+ if isempty(indxok)
+ msgboxText = 'Unfortunately, you only got NaN values...'
+ title = 'ERPLAB: Error, only NaN values were found';
+ errorfound(msgboxText, title);
+ return
+ end
+ val = val(indxok);
+ xsct = xscatt(indxok);
+ iststr = indxsetstr(indxok);
+ else
+ nv = length(val); % number of current values to plot
+ xsct = xscatt(1:nv); % set indices for scatter plot current values
+ iststr = indxsetstr(1:nv);
+ end
+
+ mu = mean(val);
+ me = median(val);
+
+ x1 = handles.x1;
+ x2 = handles.x2;
+ y1 = mean(val) - std(val);
+ y2 = mean(val) + std(val);
+ y3 = mean(val) - 2*std(val);
+ y4 = mean(val) + 2*std(val);
+ y6 = mean(val) - 3*std(val);
+ y7 = mean(val) + 3*std(val);
+ cla
+ try
+ rectangle('Position',[x1,y1,x2-x1,abs(y2-y1)], 'EdgeColor', [0.5 0.5 0.5])
+ rectangle('Position',[x1,y3,x2-x1,abs(y1-y3)], 'EdgeColor', [0.5 0.5 0.5])
+ rectangle('Position',[x1,y2,x2-x1,abs(y4-y2)], 'EdgeColor', [0.5 0.5 0.5])
+ if get(handles.checkbox_3sigma, 'Value')
+ rectangle('Position',[x1,y6,x2-x1,abs(y4-y6)], 'EdgeColor', [0.5 0.5 0.5])
+ rectangle('Position',[x1,y4,x2-x1,abs(y7-y4)], 'EdgeColor', [0.5 0.5 0.5])
+ end
+ catch
+ set(handles.radiobutton_histo, 'Value', 0)
+ return
+ end
+ if get(handles.checkbox_scatterlabels, 'Value')
+ labfont = 10;
+ text(x2+0.15,mu,'\mu','FontSize',labfont)
+ text(x1-2,me,'median','FontSize',labfont)
+ text(x2+0.15,y2,'\mu+\sigma','FontSize',labfont)
+ text(x2+0.15,y4,'\mu+2\sigma','FontSize',labfont)
+ text(x2+0.15,y1,'\mu-\sigma','FontSize',labfont)
+ text(x2+0.15,y3,'\mu-2\sigma','FontSize',labfont)
+
+ if get(handles.checkbox_3sigma, 'Value')
+ text(x2+0.15,y7,'\mu+3\sigma','FontSize',labfont)
+ text(x2+0.15,y6,'\mu-3\sigma','FontSize',labfont)
+ end
+ end
+
+ line([x1 x2], [mu mu]) % mean in blue
+ line([x1 x2], [me me], 'Color',[1 0 0], 'LineStyle', '--') % median in red
+ hold on
+
+ if get(handles.checkbox_3sigma, 'Value')
+ ysc = [min([min(val) y6])-abs(0.15*max(val)) 1.15*max([max(val) y7])];
+ else
+ ysc = [min([min(val) y3])-abs(0.15*max(val)) 1.15*max([max(val) y4])];
+ end
+ if get(handles.checkbox_fileindx, 'Value') % identify file index
+ isetfont = 10;
+ plot(xsct, val, 'r.')
+ text(xsct,val,iststr,'FontSize',isetfont)
+ else
+ plot(xsct, val, 'ro','MarkerEdgeColor','k', 'MarkerFaceColor',chisto,'MarkerSize',8);
+ end
+
+ axis([-10 10 ysc])
+ set(gca,'XTick',[])
+ hold off
+else
+ %
+ % workaround (redraw axis)
+ %
+ line([0 0], ylim, 'Color', 'k')
+ line(xlim, [0 0], 'Color', 'k')
+ checknan(handles, val)
+end
+hold off
+drawnow
+
+nbinput = length(binput);
+nchinput = length(chinput);
+nsetinput = length(setinput);
+
+if ~get(handles.checkbox_butterflybin, 'Value') && nbinput<=1
+ set(handles.edit_bin, 'String', num2str(jbin))
+ handles.ibin = ibin;
+ % Update handles structure
+ guidata(hObject, handles);
+end
+if ~get(handles.checkbox_butterflychan, 'Value') && nchinput<=1
+ set(handles.edit_channel, 'String', num2str(jchannel))
+ handles.ich = ich;
+ % Update handles structure
+ guidata(hObject, handles);
+end
+if ~get(handles.checkbox_butterflyset, 'Value') && nsetinput<=1
+ set(handles.edit_file, 'String', num2str(jseta))
+ handles.iset = iset;
+ % Update handles structure
+ guidata(hObject, handles);
+end
+%
+% Files
+%
+setlabelx = '';
+if get(handles.checkbox_butterflyset, 'Value')
+ if length(setArray)>10
+ var1 = vect2colon(setArray, 'Delimiter', 'off');
+ else
+ var1 = num2str(setArray);
+ end
+elseif nsetinput>0
+ if nsetinput>10
+ var1 = vect2colon(jseta, 'Delimiter', 'off');
+ else
+ var1 = num2str(jseta);
+ if nsetinput==1
+ setlabelx = sprintf('(%s)', ALLERP(seta).erpname);
+ end
+ end
+else
+ var1 = ALLERP(seta).erpname;
+end
+%
+% Bins
+%
+binlabelx = '';
+if get(handles.checkbox_butterflybin, 'Value')
+ if length(binArray)>10
+ var2 = vect2colon(binArray, 'Delimiter', 'off');
+ else
+ var2 = num2str(binArray);
+ end
+elseif nbinput>0
+ if nbinput>10
+ var2 = vect2colon(jbin, 'Delimiter', 'off');
+ else
+ var2 = num2str(jbin);
+ if nbinput==1
+ binlabelx = sprintf('(%s)', ALLERP(seta).bindescr{bin});
+ end
+ end
+else
+ var2 = ALLERP(seta).bindescr{bin};
+end
+
+%
+% Channels
+%
+chanlabelx = '';
+if get(handles.checkbox_butterflychan, 'Value')
+ if length(chanArray)>10
+ var3 = vect2colon(chanArray, 'Delimiter', 'off');
+ else
+ var3 = num2str(chanArray);
+ end
+elseif nchinput>0
+ if nchinput>10
+ var3 = vect2colon(jchannel, 'Delimiter', 'off');
+ else
+ var3 = num2str(jchannel);
+ if nchinput==1
+ chanlabelx = sprintf('(%s)', ALLERP(seta).chanlocs(channel).labels);
+ end
+ end
+else
+ var3 = ALLERP(seta).chanlocs(channel).labels;
+end
+if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') &&...
+ nsetinput<=1 && nbinput<=1 && nchinput<=1
+ % none checked
+ strfrmt = ['File : %s %s\nBin : %s %s\nChannel: %s %s\nMeasu : %s\nWindow : %s\nLate : %s\nValue : %.' num2str(dig) 'f\n'];
+ values2print = {var1, setlabelx, var2, binlabelx, var3, chanlabelx, tittle, sprintf('%.2f\t', latency), sprintf('%.2f\t', truelat), val};
+else
+ strfrmt = ['File : %s %s\nBin : %s %s\nChannel: %s %s\nMeasu : %s\nWindow : %s\nLate : %s\nMean Value : %.' num2str(dig) 'f +/- %.' num2str(dig) 'f\n'];
+ values2print = {var1, setlabelx, var2, binlabelx, var3, chanlabelx, tittle, sprintf('%.2f\t', latency), sprintf('%.2f\t', truelat), mean(val), std(val)};
+end
+
+repo = sprintf(strfrmt, values2print{:});
+if ~isempty(nanindxfile) && length(jseta)>1
+ repo = sprintf('%sNaN values found at files: %s', repo, num2str(nanindxfile));
+end
+set(handles.edit_report, 'String', repo)
+
+%--------------------------------------------------------------------------
+function togglebutton_y_axis_polarity_Callback(hObject, eventdata, handles)
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ set(hObject, 'string', sprintf('%s is up', 'positive'));
+ set(hObject, 'Value', 1)
+ return
+end
+if get(hObject, 'Value')
+ word = 'negative';
+ %set(handles.axes1,'ydir','reverse');
+ handles.ydir = 'reverse';
+else
+ word = 'positive';
+ %set(handles.axes1,'ydir','normal');
+ handles.ydir = 'normal';
+end
+set(hObject, 'string', sprintf('%s is up', word));
+
+%Update handles structure
+guidata(hObject, handles);
+
+if get(handles.checkbox_dmouse, 'Value') % trick
+ set(handles.gui_chassis,'WindowButtonDownFcn', {@mbuttondwn, hObject, eventdata, handles});
+end
+
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function checkbox_dmouse_Callback(hObject, eventdata, handles)
+if get(hObject, 'Value')
+ erpworkingmemory('WMmouse', 1);
+ %
+ % Drag
+ %
+ % set(handles.gui_chassis,'WindowButtonUpFcn', {@mbuttonup, handles, hObject});
+ set(handles.gui_chassis,'WindowButtonDownFcn', {@mbuttondwn, hObject, eventdata, handles});
+else
+ set(handles.gui_chassis,'WindowButtonDownFcn', []);
+ erpworkingmemory('WMmouse', 0);
+ latency = handles.orilatency;
+ handles.latency = latency;
+
+ % Update handles structure
+ guidata(hObject, handles);
+ pause(0.1)
+
+ tittle = handles.tittle;
+ ich = handles.ich;
+ ibin = handles.ibin;
+ iset = handles.iset;
+
+ mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+end
+
+%--------------------------------------------------------------------------
+function mbuttondwn(h, xxx, hObject, eventdata, handles)
+if get(handles.checkbox_dmouse,'Value')
+ latency = handles.latency;
+
+ C = get(gca, 'CurrentPoint');
+ x = C(1,1);
+
+ props.WindowButtonUpFcn = get(h,'WindowButtonUpFcn');
+ setappdata(h,'meaviewerGUICallbacks',props);
+
+ if length(latency)>1
+ latency = [x latency(2)];
+ else
+ latency = x;
+ end
+ handles.latency = latency;
+
+ % Update handles structure
+ guidata(hObject, handles);
+
+ set(h,'WindowButtonUpFcn',{@mbuttonup, hObject, eventdata, handles})
+end
+
+%--------------------------------------------------------------------------
+function mbuttonup(h, xxx, hObject, eventdata, handles)
+if get(handles.checkbox_dmouse,'Value')
+ latency = handles.latency;
+ C = get(gca, 'CurrentPoint');
+ x = C(1,1);
+
+ props = getappdata(h,'meaviewerGUICallbacks');
+ set(h,props);
+ if length(latency)>1
+ latency = sort([latency(1) x]);
+ else
+ latency = x;
+ end
+
+ [ AMP, Lat, latency ] = getnewvals(hObject, handles, latency);
+
+ handles.AMP = AMP;
+ handles.Lat = Lat;
+ handles.latency = latency;
+
+ % Update handles structure
+ guidata(hObject, handles);
+ pause(0.1)
+
+ tittle = handles.tittle;
+ % ich = handles.ich;
+ % ibin = handles.ibin;
+ % iset = handles.iset;
+
+ %
+ % info
+ %
+ binArray = handles.binArray;
+ chanArray = handles.chanArray;
+ setArray = handles.setArray;
+ xbin = str2num(get(handles.edit_bin, 'String'));
+ xch = str2num(get(handles.edit_channel, 'String'));
+ xset = str2num(get(handles.edit_file, 'String'));
+ ibin = find(ismember_bc2(binArray,xbin)); %find(binArray==xbin,1);
+ ich = find(ismember_bc2(chanArray,xch)); %find(chanArray==xch,1);
+ iset = find(ismember_bc2(setArray,xset)); %find(setArray==xset,1);
+
+ mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+end
+
+%--------------------------------------------------------------------------
+function radiobutton_histo_Callback(hObject, eventdata, handles)
+if get(hObject, 'Value')
+ set(handles.pushbutton_color_val, 'Enable', 'off');
+ set(handles.pushbutton_color_window, 'Enable', 'off');
+ set(handles.togglebutton_y_axis_polarity, 'Enable', 'off');
+ %set(handles.pushbutton_update, 'Enable', 'off');
+ set(handles.edit_ylim, 'Enable', 'off');
+ set(handles.edit_xlim, 'Enable', 'off');
+ set(handles.checkbox_dmouse, 'Value', 0);
+ set(handles.checkbox_dmouse, 'Enable', 'off');
+ set(handles.radiobutton_scatter, 'Value', 0);
+ set(handles.checkbox_fileindx,'Value', 0)
+ set(handles.checkbox_fileindx,'Enable', 'off')
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'off')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'off')
+ set(handles.pushbutton_narrow, 'Enable', 'off')
+ set(handles.pushbutton_wide, 'Enable', 'off')
+ set(handles.pushbutton_histosetting,'Enable','on')
+else
+ datatype = handles.datatype;
+ set(handles.pushbutton_color_val, 'Enable', 'on');
+ set(handles.pushbutton_color_window, 'Enable', 'on');
+ if strcmpi(datatype, 'ERP')
+ set(handles.togglebutton_y_axis_polarity, 'Enable', 'on');
+ end
+ %set(handles.pushbutton_update, 'Enable', 'on');
+ set(handles.edit_ylim, 'Enable', 'on');
+ set(handles.edit_xlim, 'Enable', 'on');
+ set(handles.checkbox_dmouse, 'Enable', 'on');
+ mwm = erpworkingmemory('WMmouse');
+ if mwm
+ set(handles.checkbox_dmouse, 'Value', 1);
+ end
+ set(handles.pushbutton_histosetting,'Enable','off')
+end
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function radiobutton_scatter_Callback(hObject, eventdata, handles)
+if get(hObject, 'Value')
+ set(handles.pushbutton_color_val, 'Enable', 'off');
+ set(handles.pushbutton_color_window, 'Enable', 'off');
+ set(handles.togglebutton_y_axis_polarity, 'Enable', 'off');
+ %set(handles.pushbutton_update, 'Enable', 'off');
+ set(handles.edit_ylim, 'Enable', 'off');
+ set(handles.edit_xlim, 'Enable', 'off');
+ set(handles.checkbox_dmouse, 'Value', 0);
+ set(handles.checkbox_dmouse, 'Enable', 'off');
+ set(handles.radiobutton_histo, 'Value', 0);
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'on')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'on')
+ set(handles.pushbutton_narrow, 'Enable', 'on')
+ set(handles.pushbutton_wide, 'Enable', 'on')
+ if get(handles.checkbox_butterflyset, 'Value')
+ set(handles.checkbox_fileindx,'Value', 0)
+ set(handles.checkbox_fileindx,'Enable', 'on')
+ end
+ set(handles.pushbutton_histosetting,'Enable','off')
+else
+ datatype = handles.datatype;
+ set(handles.pushbutton_color_val, 'Enable', 'on');
+ set(handles.pushbutton_color_window, 'Enable', 'on');
+ if strcmpi(datatype, 'ERP')
+ set(handles.togglebutton_y_axis_polarity, 'Enable', 'on');
+ end
+ %set(handles.pushbutton_update, 'Enable', 'on');
+ set(handles.edit_ylim, 'Enable', 'on');
+ set(handles.edit_xlim, 'Enable', 'on');
+ set(handles.checkbox_dmouse, 'Enable', 'on');
+ mwm = erpworkingmemory('WMmouse');
+ if mwm
+ set(handles.checkbox_dmouse, 'Value', 1);
+ end
+ set(handles.checkbox_fileindx,'Value', 0)
+ set(handles.checkbox_fileindx,'Enable', 'off')
+ set(handles.checkbox_scatterlabels, 'Value',0)
+ set(handles.checkbox_scatterlabels, 'Enable', 'off')
+ set(handles.checkbox_3sigma, 'Value',0)
+ set(handles.checkbox_3sigma, 'Enable', 'off')
+ set(handles.pushbutton_narrow, 'Enable', 'off')
+ set(handles.pushbutton_wide, 'Enable', 'off')
+end
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function pushbutton_narrow_Callback(hObject, eventdata, handles)
+x1 = handles.x1;
+x2 = handles.x2;
+x1 = x1+1;
+x2 = x2-1;
+if x1>-1.75
+ return
+end
+if x2<1.75
+ return
+end
+handles.x1 = x1;
+handles.x2 = x2;
+
+handles.xscatt = handles.xscatt*0.75;
+
+%Update handles structure
+guidata(hObject, handles);
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function pushbutton_wide_Callback(hObject, eventdata, handles)
+
+x1 = handles.x1;
+x2 = handles.x2;
+x1 = x1-1;
+x2 = x2+1;
+if x1<-8
+ return
+end
+if x2>8
+ return
+end
+handles.x1 = x1;
+handles.x2 = x2;
+handles.xscatt = handles.xscatt*1.33;
+
+%Update handles structure
+guidata(hObject, handles);
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function checkbox_scatterlabels_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function checkbox_3sigma_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function checkbox_fileindx_Callback(hObject, eventdata, handles)
+tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if isempty(xlim) || isempty(ylim)
+ return
+end
+
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+%--------------------------------------------------------------------------
+function pushbutton_histosetting_Callback(hObject, eventdata, handles)
+
+binvalue = handles.binvalue;
+normhisto = handles.normhisto;
+chisto = handles.chisto;
+fitnormd = handles.fitnormd;
+cfitnorm = handles.cfitnorm;
+xbin = str2num(get(handles.edit_bin, 'String'));
+xch = str2num(get(handles.edit_channel, 'String'));
+xset = str2num(get(handles.edit_file, 'String'));
+nvalue = length(xbin)*length(xch)*length(xset);
+
+%
+% Call GUI
+%
+answer = histosettingGUI({binvalue, normhisto, chisto, fitnormd, cfitnorm, nvalue});
+
+if isempty(answer)
+ disp('User selected Cancel')
+ return
+end
+
+handles.binvalue = answer{1};
+handles.normhisto = answer{2};
+handles.chisto = answer{3};
+handles.fitnormd = answer{4};
+handles.cfitnorm = answer{5};
+
+%Update handles structure
+guidata(hObject, handles);
+
+tittle = handles.tittle;
+ich = handles.ich;
+ibin = handles.ibin;
+iset = handles.iset;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles, ibin, ich, iset, xlim, ylim, tittle)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+%--------------------------------------------------------------------------
+function [ Amp, Lat, latency] = getnewvals(hObject, handles, latency)
+
+fntsz = get(handles.edit_report, 'FontSize');
+set(handles.edit_report, 'FontSize', fntsz)
+set(handles.edit_report, 'String', sprintf('\nRemeasuring values...\nThis process might take a while. Please wait...\n'))
+drawnow
+
+ALLERP = handles.ALLERP;
+binArray = handles.binArray;
+chanArray = handles.chanArray;
+setArray = handles.setArray;
+nfile = length(setArray);
+moption = handles.moption;
+blc = handles.blc;
+coi = handles.coi;
+polpeak = handles.polpeak;
+sampeak = handles.sampeak;
+locpeakrep = handles.locpeakrep;
+frac = handles.frac;
+fracmearep = handles.fracmearep;
+intfactor = handles.intfactor;
+datatype = handles.datatype;
+
+[xxx, latsamp] = closest(ALLERP(setArray(end)).times, latency);
+
+if strcmpi(datatype, 'ERP')
+ fs = ALLERP(setArray(end)).srate;
+ latency = (((latsamp-1)*1000)/fs) + ALLERP(setArray(end)).xmin*1000;
+else
+ bx = unique(diff(ALLERP(setArray(end)).times));
+ latency = (latsamp-1)*bx(1);
+end
+
+Amp = zeros(length(binArray), length(chanArray), length(setArray));
+Lat = {[]};
+
+for k=1:nfile
+ ERP = ALLERP(setArray(k));
+ [A, lat4mea] = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor);
+
+ %
+ % Store values
+ %
+ Amp(:,:,k) = A; % bin x channel x erpset
+ Lat{:,:,k} = lat4mea; % bin x channel x erpset
+end
+
+set(handles.edit_report, 'FontSize', fntsz )
+pause(0.1)
+
+%
+% create random x-values for scatter plot
+%
+xscatt = rand(1,numel(Amp))*2.5-1.25;
+handles.xscatt = xscatt;
+% chan indices
+indxsetstr = cellstr(num2str(setArray'))';
+handles.indxsetstr = indxsetstr;
+
+%Update handles structure
+guidata(hObject, handles);
+
+% -----------------------------------------------------------------------
+function pushbutton_cancel_Callback(hObject, eventdata, handles)
+handles.output = [];
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+%--------------------------------------------------------------------------
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = [];
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
+
+%--------------------------------------------------------------------------
+function popupmenu_measurementv_Callback(hObject, eventdata, handles)
+
+% meamenu = get(handles.text_measurementv, 'String');
+% currmea = get(handles.text_measurementv, 'Value');
+% moption = meamenu{currmea};
+
+%--------------------------------------------------------------------------
+function text_measurementv_CreateFcn(hObject, eventdata, handles)
+
+% Hint: popupmenu controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+%--------------------------------------------------------------------------
+function pushbutton_createplot_Callback(hObject, eventdata, handles)
+% h1=handles.axes1;
+% %
+% % Create figure
+% %
+% hbig = figure('Name','ERP VIEWER',...
+% 'NumberTitle','on', 'Tag', 'Viewer_figure');erplab_figtoolbar(hbig);
+% % objects=allchild(h1);
+% copyobj(h1,hbig);
+% opengl software
+OFF_STD = 0.25; % std dev of figure offset
+MIN_OFF = 0.15; % minimum offset for new figure
+BORDER = 0.04; % screen edge tolerance
+
+fig=handles.gui_chassis;
+sel=handles.axes1;
+%
+% Get position for new figure
+%
+set(sel,'Units','normalized');
+place = get(sel,'Position');
+cmap = colormap;
+% newxy = (OFF_STD*randn(1,2))+place(1,1:2);
+% newx = newxy(1);newy=newxy(2);
+%
+% if abs(newx-place(1,1))1-BORDER, newx=1-BORDER-place(3); end
+% if newy+place(4)>1-BORDER, newy=1-BORDER-place(4); end
+
+% newfig = figure('Units','Normalized','Position',[newx,newy,place(1,3:4)]);
+newfig = figure('Units','Normalized','Position', place, 'Name','ERP VIEWER', 'NumberTitle','on', 'Tag', 'Viewer_figure');
+
+%
+% Copy object to new figure
+%
+set(newfig,'Color',[1 1 1]);
+copyobj(sel,newfig);
+set(gca,'Position',[0.130 0.110 0.775 0.815]);
+set(gca,'Box', 'off')
+colormap(cmap);
+erplab_figtoolbar(newfig)
+
+% %
+% % Increase font size
+% %
+% set(findobj('parent',newfig,'type','axes'),'FontSize',14);
+% set(get(gca,'XLabel'),'FontSize',16)
+% set(get(gca,'YLabel'),'FontSize',16)
+% set(get(gca,'Title'),'Fontsize',16);
+%
+% Add xtick and ytick labels if missing
+%
+% if strcmp(get(gca,'Box'),'on')
+% set(gca,'xticklabelmode','auto')
+% set(gca,'xtickmode','auto')
+% set(gca,'yticklabelmode','auto')
+% set(gca,'ytickmode','auto')
+% end
+%
+% Turn on zoom in the new figure
+%
+% zoom on;
+pause(0.2)
+
+latency = handles.latency;
+handles.output = NaN;
+
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
diff --git a/GUIs/mvpaviewerGUI2.fig b/GUIs/mvpaviewerGUI2.fig
new file mode 100644
index 00000000..7b19ee91
Binary files /dev/null and b/GUIs/mvpaviewerGUI2.fig differ
diff --git a/GUIs/mvpaviewerGUI2.m b/GUIs/mvpaviewerGUI2.m
new file mode 100644
index 00000000..1b9dec8d
--- /dev/null
+++ b/GUIs/mvpaviewerGUI2.m
@@ -0,0 +1,668 @@
+function varargout = mvpaviewerGUI2(varargin)
+% MVPAVIEWERGUI2 MATLAB code for mvpaviewerGUI2.fig
+% MVPAVIEWERGUI2, by itself, creates a new MVPAVIEWERGUI2 or raises the existing
+% singleton*.
+%
+% H = MVPAVIEWERGUI2 returns the handle to a new MVPAVIEWERGUI2 or the handle to
+% the existing singleton*.
+%
+% MVPAVIEWERGUI2('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in MVPAVIEWERGUI2.M with the given input arguments.
+%
+% MVPAVIEWERGUI2('Property','Value',...) creates a new MVPAVIEWERGUI2 or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before mvpaviewerGUI2_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to mvpaviewerGUI2_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help mvpaviewerGUI2
+
+% Last Modified by GUIDE v2.5 27-Mar-2023 16:58:03
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpaviewerGUI2_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpaviewerGUI2_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before mvpaviewerGUI2 is made visible.
+function mvpaviewerGUI2_OpeningFcn(hObject, eventdata, handles, varargin)
+% This function has no output args, see OutputFcn.
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% varargin command line arguments to mvpaviewerGUI2 (see VARARGIN)
+
+% Choose default command line output for mvpaviewerGUI2
+handles.output = [];
+
+%defx = erpworkingmemory('pop_geterpvalues');
+% try
+% cerpi = evalin('base', 'CURRENTERP'); % current erp index
+% catch
+% cerpi = 1;
+% end
+% handles.cerpi = cerpi;
+try
+ ALLMVPA = varargin{1};
+ setArray = 1:length(ALLMVPA);
+catch
+ ALLMVPA = buildERPstruct;
+ ALLMVPA.times = -200:800;
+ ALLMVPA.xmin = -0.2;
+ ALLMVPA.xmax = 0.8;
+ ALLMVPA.nchan = 1;
+ ALLMVPA.pnts = length(ALLMVPA.times);
+ ALLMVPA.nbin = 1;
+ ALLMVPA.bindata = zeros(1, ALLMVPA.pnts, 1);
+ ALLMVPA.srate = 1000;
+ ALLMVPA.bindescr = {'empty'};
+ ALLMVPA.chanlocs.labels = 'empty';
+end
+% if strcmpi(datatype, 'ERP')
+% meaword = 'latenc';
+% else
+% meaword = 'frequenc';
+% end
+% if isempty(defx)
+% if isempty(ALLMVPA)
+% inp1 = 1; %from hard drive
+% erpset = [];
+% else
+% inp1 = 0; %from erpset menu
+% erpset = 1:length(ALLMVPA);
+% end
+% defx = {inp1 erpset '' 0 1 1 'instabl' 1 3 'pre' 0 1 5 0 0.5 0 0 0 '' 0 1};
+% end
+% try
+% def = varargin{2};
+% AMP = def{1};
+% Lat = def{2};
+% binArray = def{3};
+% chanArray = def{4};
+% setArray = def{5};
+% latency = def{6};
+% moreoptions = def{7};
+%
+% blc = moreoptions{1};
+% moption = moreoptions{2};
+% tittle = moreoptions{3};
+% dig = moreoptions{4};
+% coi = moreoptions{5};
+% polpeak = moreoptions{6};
+% sampeak = moreoptions{7};
+% locpeakrep = moreoptions{8};
+% frac = moreoptions{9};
+% fracmearep = moreoptions{10};
+% intfactor = moreoptions{11};
+% catch
+% latency = defx{4};
+% moption = defx{7};
+%
+% AMP = [];
+% Lat = {{[-200 800]}};
+% binArray = 1:ALLMVPA(1).nbin;
+% chanArray = 1:ALLMVPA(1).nchan;
+% setArray = 1:length(ALLMVPA);
+% %latency = 0;
+% blc = 'pre';
+% %moption = 'instabl';
+% tittle = 'nada';
+% dig = 3;
+% coi = [];
+% polpeak = [];
+% sampeak = [];
+% locpeakrep = [];
+% frac = [];
+% fracmearep = [];
+% intfactor = 1;
+% end
+%datatype2 = '';
+if isfield(ALLMVPA(1).header, 'DecodingMethod')
+ datatype = ALLMVPA(1).header.DecodingMethod;
+
+ if strcmpi(datatype,'SVM')
+ % here, treat SEM data like ERP data
+ datatype = 'SVM';
+ % datatype2 = 'SEM';
+ end
+
+else
+ datatype = 'SVM';
+end
+
+if strcmpi(datatype, 'SVM')
+ measurearray = {'Average Decoding Accuracy'};
+else
+ %blc = 'none';
+ measurearray = {'Average Decoding Accuracy'};
+end
+
+handles.measurearray = measurearray;
+
+meacodes = {'avgdecodingacc' };
+
+handles.meacodes = meacodes;
+
+handles.chance = 0;
+
+
+%set(handles.text_measurementv, 'String', measurearray);
+
+%[tfm, indxmeaX] = ismember_bc2({moption}, meacodes);
+
+meamenu = 1; % 'Average Decoding Accuracy',...
+set(handles.text_measurementv, 'String', measurearray{meamenu});
+% set(handles.text_measurementv, 'Value', meamenu);
+% set(handles.text_measurementv, 'Enable', 'inactive');
+
+cwm = erpworkingmemory('WMColor'); % window color for measurement
+cvl = erpworkingmemory('VLColor'); % line color for measurement
+mwm = erpworkingmemory('WMmouse'); % select window measurement by mouse option
+
+if isempty(cwm)
+ cwm = [0.8490 1.0000 0.1510];
+end
+if isempty(cvl)
+ cvl = [1 0 0];
+end
+if isempty(mwm)
+ mwm = 0;
+end
+
+%handles.defx = defx;
+handles.cwm = cwm;
+handles.cvl = cvl;
+handles.ALLMVPA = ALLMVPA;
+%handles.binArray = binArray;
+%handles.chanArray = chanArray;
+handles.setArray = setArray;
+%handles.ich = 1;
+%handles.ibin = 1;
+handles.iset = 1;
+%handles.orilatency = latency;
+%handles.blc = blc;
+%handles.moption = moption;
+%handles.tittle = tittle;
+handles.dig = 3;
+handles.x1 = -1.75;
+handles.x2 = 1.75;
+
+%
+% create random x-values for scatter plot
+%
+% xscatt = rand(1,numel(AMP))*2.5-1.25;
+% handles.xscatt = xscatt;
+indxsetstr = {''};
+% end
+handles.indxsetstr = indxsetstr;
+
+% handles.membin = [];
+% handles.memch = [];
+% handles.memset = [];
+%
+% binvalue = erpworkingmemory('BinHisto'); % value(s) for bin in histogram
+% normhisto = erpworkingmemory('NormHisto'); % normalize histogram
+% chisto = erpworkingmemory('HistoColor'); % histogram color
+% cfitnorm = erpworkingmemory('FnormColor'); % line color for fitted normal distribution
+% fitnormd = erpworkingmemory('FitNormd'); % fit nomal distribution
+%
+% if isempty(binvalue)
+% binvalue = 'auto';
+% end
+% if isempty(normhisto)
+% normhisto = 0;
+% end
+% if isempty(chisto)
+% chisto = [1 0.5 0.2];
+% end
+% if isempty(cfitnorm)
+% cfitnorm = [1 0 0];
+% end
+% if isempty(fitnormd)
+% fitnormd = 0;
+% end
+
+% handles.binvalue = binvalue;
+% handles.normhisto = normhisto;
+% handles.chisto = chisto;
+% handles.cfitnorm = cfitnorm;
+% handles.fitnormd = fitnormd;
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - VIEWER FOR MVPA GUI']); %, 'toolbar','figure')
+
+% ibin = 1;
+% ich = 1;
+iset = 1;
+times = ALLMVPA(1).times;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ ylim = [-2 100];
+
+else
+ xlim = [0 30];
+ ylim = [0 15];
+
+end
+
+
+% set(handles.edit_ylim, 'String', num2str(ylim))
+% set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)))
+
+set(handles.edit_file, 'String', num2str(iset))
+
+set(handles.checkbox_butterflyset,'Value', 0)
+
+if length(setArray)==1
+ set(handles.checkbox_butterflyset, 'Enable', 'off')
+% if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+end
+handles.datatype = datatype;
+
+%
+% Color GUI
+% %
+% handles = painterplab(handles);
+%
+% %
+% % Set font size
+% %
+% handles = setfonterplab(handles);
+
+
+% help
+% helpbutton
+
+%
+% Drag
+%
+% set(handles.checkbox_dmouse,'Value', 0)
+% set(handles.radiobutton_histo,'Value', 0)
+% set(handles.radiobutton_histo,'Enable', 'off')
+% set(handles.pushbutton_histosetting,'Enable', 'off')
+% set(handles.radiobutton_scatter,'Value', 0)
+% set(handles.radiobutton_scatter,'Enable', 'off')
+% set(handles.checkbox_fileindx,'Value', 0)
+% set(handles.checkbox_fileindx,'Enable', 'off')
+% set(handles.checkbox_scatterlabels, 'Value',0)
+% set(handles.checkbox_scatterlabels, 'Enable', 'off')
+% set(handles.pushbutton_narrow, 'Enable', 'off')
+% set(handles.pushbutton_wide, 'Enable', 'off')
+% set(handles.checkbox_3sigma, 'Value',0)
+% set(handles.checkbox_3sigma, 'Enable', 'off')
+% % set(handles.togglebutton_y_axis_polarity, 'Enable', 'on');
+% set(handles.gui_chassis,'DoubleBuffer','on')
+
+% if isempty(AMP)
+% [ AMP, Lat, latency ] = getnewvals(hObject, handles, latency);
+% handles.AMP = AMP;
+% handles.Lat = Lat;
+% handles.latency = latency;
+% else
+% handles.AMP = AMP;
+% handles.Lat = Lat;
+% handles.latency = latency;
+%
+% end
+
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+
+% Update handles structure
+guidata(hObject, handles);
+
+%
+% Plot figure
+%
+mplotdata(hObject, handles, iset, xlim, ylim)
+
+
+
+% UIWAIT makes mvpaviewerGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+function mplotdata(hObject,handles,iset,xlim,ylim)
+
+setArray = handles.setArray;
+
+setinput = [];
+if get(handles.checkbox_butterflyset, 'Value')
+ jseta = setArray;
+else
+ setinput = str2num(get(handles.edit_file, 'String'));
+
+ if length(setinput)>1
+ jseta = setinput;
+ else
+ jseta = setArray(iset);
+ end
+end
+fntsz = get(handles.edit_report, 'FontSize');
+set(handles.edit_report, 'FontSize', fntsz*1.5)
+set(handles.edit_report, 'String', sprintf('\nWorking...\n'))
+
+ALLMVPA = handles.ALLMVPA;
+times = ALLMVPA(iset).times;
+p1 = times(1);
+p2 = times(end);
+intfactor = 0;
+% if intfactor~=1
+% timex = linspace(p1,p2,round(pnts*intfactor));
+% else
+% timex = timeor;
+% end
+timex = times;
+%
+% Colors
+%
+cwm = handles.cwm;
+cvl = handles.cvl;
+%
+% latmin = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+% latmax = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+axes(handles.axes1);
+% fntsz = get(handles.edit_report, 'FontSize');
+% set(handles.edit_report, 'FontSize', fntsz*1.5 )
+% set(handles.edit_report, 'String', sprintf('\nWorking...\n'))
+%drawnow
+% tic
+for seta = jseta
+
+ AverageAccuracy = ALLMVPA(seta).average_accuracy_1vAll;
+
+ %plot
+ plot(timex,AverageAccuracy, 'LineWidth',1,'Color',[0 0.1 0.5]);
+ hold on
+
+ if handles.chance == 1
+ chancelvl = ALLMVPA(seta).header.nChance;
+ line([timex(1),timex(end)],[chancelvl,chancelvl]); %chance line
+ end
+
+
+
+end
+
+
+
+hold off
+
+set(handles.edit_report, 'String', '');
+set(handles.edit_report, 'FontSize', fntsz);
+
+nsetinput = length(setinput);
+if ~get(handles.checkbox_butterflyset, 'Value') && nsetinput<=1
+ set(handles.edit_file, 'String', num2str(jseta))
+ handles.iset = iset;
+ % Update handles structure
+ guidata(hObject, handles);
+end
+
+setlabelx = '';
+if get(handles.checkbox_butterflyset, 'Value')
+ if length(setArray)>10
+ var1 = vect2colon(setArray, 'Delimiter', 'off');
+ else
+ var1 = num2str(setArray);
+ end
+elseif nsetinput>0
+ if nsetinput>10
+ var1 = vect2colon(jseta, 'Delimiter', 'off');
+ else
+ var1 = num2str(jseta);
+ if nsetinput==1
+ setlabelx = sprintf('(%s)', ALLMVPA(jseta).header.subjectID);
+ chancelabelx = ALLMVPA(jseta).header.nChance;
+ foldlabelx = ALLMVPA(jseta).header.nCrossfolds;
+ methodlabelx = ALLMVPA(jseta).header.DecodingMethod;
+ end
+
+ end
+else
+ var1 = ALLERP(seta).mvpaname;
+end
+
+
+
+
+
+% if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') &&...
+% nsetinput<=1 && nbinput<=1 && nchinput<=1
+% % none checked
+% strfrmt = ['File : %s %s\nBin : %s %s\nChannel: %s %s\nMeasu : %s\nWindow : %s\nLate : %s\nValue : %.' num2str(dig) 'f\n'];
+% values2print = {var1, setlabelx, var2, binlabelx, var3, chanlabelx, tittle, sprintf('%.2f\t', latency), sprintf('%.2f\t', truelat), val};
+% else
+
+if ~get(handles.checkbox_butterflyset,'Value')
+ strfrmt = ['File : %s %s\nChance level: %.4f \nCrossfold Validation: %i \nDecoding Method: %s '];
+ values2print = {var1, setlabelx, chancelabelx, foldlabelx, methodlabelx};
+else
+ strfrmt = ['File : %s %s'];
+ values2print = {var1, setlabelx};
+end
+
+repo = sprintf(strfrmt, values2print{:});
+% if ~isempty(nanindxfile) && length(jseta)>1
+% repo = sprintf('%sNaN values found at files: %s', repo, num2str(nanindxfile));
+% end
+set(handles.edit_report, 'String', repo)
+
+%axis([xlim ylim]);
+
+
+% hold off
+drawnow
+
+nsetinput = length(setinput);
+
+
+
+
+
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpaviewerGUI2_OutputFcn(hObject, eventdata, handles)
+% varargout cell array for returning output args (see VARARGOUT);
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Get default command line output from handles structure
+varargout{1} = handles.output;
+
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+
+
+function edit_file_Callback(hObject, eventdata, handles)
+% hObject handle to edit_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_file as text
+% str2double(get(hObject,'String')) returns contents of edit_file as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_file_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in pushbutton_left_file.
+function pushbutton_left_file_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_left_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% tittle = handles.tittle;
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+iset = iset-1;
+
+if iset<1
+ return; %iset = 1;
+end
+handles.iset = iset;
+
+% Update handles structure
+guidata(hObject, handles);
+
+%ylim = str2num(get(handles.edit_ylim, 'String' ));
+%xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset, xlim, ylim)
+
+
+% --- Executes on button press in pushbutton_right_file.
+function pushbutton_right_file_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_right_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+%tittle = handles.tittle;
+setArray = handles.setArray;
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+iset = iset+1;
+
+if iset>length(setArray)
+ return; %iset = length(setArray);
+end
+handles.iset = iset;
+
+% Update handles structure
+guidata(hObject, handles);
+
+% ylim = str2num(get(handles.edit_ylim, 'String' ));
+% xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset,xlim,ylim)
+
+
+% --- Executes on button press in checkbox_butterflyset.
+function checkbox_butterflyset_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_butterflyset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+setArray = handles.setArray;
+if get(hObject, 'Value')
+ set(handles.edit_file, 'String', vect2colon(setArray, 'Delimiter', 'off'))
+ set(handles.edit_file, 'Enable', 'off');
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+
+else
+ set(handles.edit_file, 'Enable', 'on');
+ setinput = str2num(get(handles.edit_file, 'String'));
+ if length(setinput)>1
+ setinput = setinput(1);
+ [xxx, iset] = closest(setArray, setinput);
+ handles.iset=iset;
+ set(handles.edit_file, 'String', num2str(setinput))
+ end
+ if length(setinput)<=1
+ set(handles.pushbutton_right_file, 'Enable', 'on')
+ set(handles.pushbutton_left_file, 'Enable', 'on')
+ else
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ end
+end
+
+% tittle = handles.tittle;
+% ylim = str2num(get(handles.edit_ylim, 'String' ));
+% xlim = str2num(get(handles.edit_xlim, 'String' ));
+%
+% if isempty(xlim) || isempty(ylim)
+% return
+% end
+
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles,iset)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_butterflyset
+
+
+
+function edit_report_Callback(hObject, eventdata, handles)
+% hObject handle to edit_report (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_report as text
+% str2double(get(hObject,'String')) returns contents of edit_report as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_report_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_report (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in checkbox_chance.
+function checkbox_chance_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_chance (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+iset = handles.iset;
+if get(hObject,'Value')
+ handles.chance = 1;
+else
+ handles.chance = 0;
+end
+mplotdata(hObject, handles,iset)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_chance
diff --git a/GUIs/mvpc2textGUI.mlapp b/GUIs/mvpc2textGUI.mlapp
new file mode 100644
index 00000000..3f650869
Binary files /dev/null and b/GUIs/mvpc2textGUI.mlapp differ
diff --git a/GUIs/mvpc_save_multi_file.fig b/GUIs/mvpc_save_multi_file.fig
new file mode 100644
index 00000000..65fcb1fb
Binary files /dev/null and b/GUIs/mvpc_save_multi_file.fig differ
diff --git a/GUIs/mvpc_save_multi_file.m b/GUIs/mvpc_save_multi_file.m
new file mode 100644
index 00000000..bdcde91b
--- /dev/null
+++ b/GUIs/mvpc_save_multi_file.m
@@ -0,0 +1,583 @@
+function varargout = mvpc_save_multi_file(varargin)
+% MVPC_SAVE_MULTI_FILE MATLAB code for mvpc_save_multi_file.fig
+% MVPC_SAVE_MULTI_FILE, by itself, creates a new MVPC_SAVE_MULTI_FILE or raises the existing
+% singleton*.
+%
+% H = MVPC_SAVE_MULTI_FILE returns the handle to a new MVPC_SAVE_MULTI_FILE or the handle to
+% the existing singleton*.
+%
+% MVPC_SAVE_MULTI_FILE('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in MVPC_SAVE_MULTI_FILE.M with the given input arguments.
+%
+% MVPC_SAVE_MULTI_FILE('Property','Value',...) creates a new MVPC_SAVE_MULTI_FILE or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before mvpc_save_multi_file_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to mvpc_save_multi_file_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help mvpc_save_multi_file
+
+% Last Modified by GUIDE v2.5 26-Apr-2023 19:05:41
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpc_save_multi_file_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpc_save_multi_file_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before mvpc_save_multi_file is made visible.
+function mvpc_save_multi_file_OpeningFcn(hObject, eventdata, handles, varargin)
+% Choose default command line output for mvpc_save_multi_file
+
+try
+ ALLERP = varargin{1};
+ Selected_ERP_label = varargin{2};
+ suffix = varargin{3};
+catch
+ suffix = '';
+ ERPLAB = [];
+ ERPLAB.erpname = 'No erpset was selected';
+ ERPLAB.filename ='No erpset was selected';
+ ERPLAB.event = [];
+ ERPLAB.chanlocs = [];
+ ERPLAB.nbchan = 0;
+ ALLERP(1) = ERPLAB;
+ Selected_ERP_label = 1;
+end
+
+% handles.erpnameor = erpname;
+handles.output = [];
+handles.suffix = suffix;
+
+%reset the filepath for saving to CD
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ %reset the filepath for saving to CD
+ ALLERP(Selected_ERP_label(Numofselectederp)).filepath = cd;
+end
+
+
+handles.ALLERP = ALLERP;
+handles.Selected_ERP_label =Selected_ERP_label;
+
+%erplab_studio_default_values;
+erplab_default_values;
+version = erplabver;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save multiple MVPCsets GUI'])
+
+
+% set(handles.checkbox1_suffix,'Value',1);
+%set(handles.edit_suffix_name,'String',suffix);
+set(handles.checkbox2_save_label,'Value',0); %never assume they want to save
+
+ColumnName_table = {'BEST name', 'MVPC name','File name'};
+
+set(handles.uitable1_erpset_table,'ColumnName',cellstr(ColumnName_table));
+set(handles.uitable1_erpset_table,'RowName',cellstr(num2str(Selected_ERP_label')));
+
+
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ DataString{Numofselectederp,1} = strcat(ALLERP(Selected_ERP_label(Numofselectederp)).bestname,suffix);
+ DataString{Numofselectederp,2} = strcat(ALLERP(Selected_ERP_label(Numofselectederp)).bestname,suffix);
+ DataString{Numofselectederp,3} = '';
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248 248});
+set(handles.uitable1_erpset_table,'Enable','on');
+%set(handles.checkbox3_filename_erpname,'Enable','off');
+set(handles.button_fnameMVPC,'Enable','on');
+set(handles.button_clearfname,'Enable','on');
+
+
+
+
+%
+% % Color GUI
+% %
+handles = painterplab(handles);
+%
+% %
+% % Set font size
+% %
+handles = setfonterplab(handles);
+
+% Update handles structure
+guidata(hObject, handles);
+
+%set(handles.checkbox2_save_label,'Value',1);
+checkbox2_save_label_Callback(hObject, [], handles)
+
+
+% UIWAIT makes savemyerpGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpc_save_multi_file_OutputFcn(hObject, eventdata, handles)
+
+% Get default command line output from handles structure
+try
+ varargout{1} = handles.output;
+catch
+ varargout{1} = [];
+end
+
+%delete(handles.gui_chassis);
+pause(0.1)
+
+
+
+% --- Executes on button press in checkbox1_suffix.
+function checkbox1_suffix_Callback(hObject, eventdata, handles)
+ALLERP = handles.ALLERP;
+Selected_ERP_label = handles.Selected_ERP_label;
+suffix_edit = handles.edit_suffix_name.String;
+
+if isempty(suffix_edit)
+ msgboxText = 'You must enter a suffix at least!';
+ title = 'EStudio: f_ERP_save_multi_file() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+DataString_before = handles.uitable1_erpset_table.Data;
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ %DataString{Numofselectederp,1} = strcat(ALLERP(Selected_ERP_label(Numofselectederp)).bestname,suffix_edit);
+ DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
+ DataString{Numofselectederp,2} = strcat(DataString_before{Numofselectederp,2},suffix_edit);
+ DataString{Numofselectederp,3} = DataString_before{Numofselectederp,3};
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248 248});
+% if handles.checkbox2_save_label.Value
+% set(handles.uitable1_erpset_table,'Enable','off');
+% else
+% set(handles.uitable1_erpset_table,'Enable','on');
+% end
+
+
+
+
+function edit_suffix_name_Callback(hObject, eventdata, handles)
+
+% Suffix_string = handles.edit_suffix_name.String;
+% if isempty(Suffix_string)
+% msgboxText = 'You must enter a suffix at least!';
+% title = 'EStudio: mvpc_save_multi_file() error';
+% errorfound(msgboxText, title);
+% return
+% end
+%
+% if handles.checkbox1_suffix.Value
+%
+% DataString_before = handles.uitable1_erpset_table.Data;
+% for Numofselectederp = 1:size(DataString_before,1)
+% DataString{Numofselectederp,1} = char(strcat(DataString_before{Numofselectederp,1},'-',char(Suffix_string)));
+% DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+% end
+%
+% set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+% set(handles.uitable1_erpset_table,'ColumnWidth',{248 248});
+% set(handles.uitable1_erpset_table,'Enable','off');
+% handles.suffix=Suffix_string;
+% end
+
+% --- Executes during object creation, after setting all properties.
+function edit_suffix_name_CreateFcn(hObject, eventdata, handles)
+
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+
+
+
+% --- Executes on button press in checkbox2_save_label.
+function checkbox2_save_label_Callback(hObject, eventdata, handles)
+
+Values = handles.checkbox2_save_label.Value;
+
+if Values
+ %set(handles.checkbox3_filename_erpname,'Enable','on');
+ set(handles.button_fnameMVPC,'Enable','on');
+ set(handles.button_clearfname,'Enable','on');
+ set(handles.browse_button,'Enable','on');
+ ALLERP = handles.ALLERP;
+ Selected_ERP_label = handles.Selected_ERP_label;
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
+ DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+ fileName= char(ALLERP(Selected_ERP_label(Numofselectederp)).filename);
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpc'];
+ else
+ file_name = [file_name,'.mvpc'];
+ end
+ DataString{Numofselectederp,3} = file_name;
+
+ end
+ set(handles.uitable1_erpset_table,'ColumnEditable',[false true true]);
+ set(handles.uitable1_erpset_table,'Data',DataString);
+
+ % set directory text to pwd
+ set(handles.browsedir,'Enable','on');
+ %set(handles.browsedir,'BackgroundColor',[0,0,0]);
+ set(handles.browsedir,'String',cd);
+else
+ set(handles.button_fnameMVPC,'Enable','off');
+ set(handles.button_clearfname,'Enable','off');
+ set(handles.browse_button,'Enable','off');
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ DataString_before{Numofselectederp,3} = '';
+ end
+ set(handles.uitable1_erpset_table,'Data',DataString_before);
+ set(handles.uitable1_erpset_table,'Enable','on');
+ set(handles.uitable1_erpset_table,'ColumnEditable',[false true false]);
+
+ % set directory text to pwd
+ set(handles.browsedir,'Enable','off');
+ % set(handles.browsedir,'BackgroundColor',[0,0,0]);
+ set(handles.browsedir,'String','');
+
+end
+% if handles.checkbox2_save_label.Value
+% set(handles.uitable1_erpset_table,'Enable','off');
+% else
+% set(handles.uitable1_erpset_table,'Enable','on');
+% end
+
+
+
+% --- Executes on button press in checkbox3_filename_erpname.
+function checkbox3_filename_erpname_Callback(hObject, eventdata, handles)
+Value_filename_erpname = handles.checkbox3_filename_erpname.Value;
+%
+% set(handles.uitable1_erpset_table,'Enable','off');
+DataString_before = handles.uitable1_erpset_table.Data;
+
+for Numofselectederp = 1:size(DataString_before,1)
+ DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
+ DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+ fileName = char(DataString_before{Numofselectederp,2});
+ if isempty(fileName)
+ fileName = strcat(num2str(Numofselectederp),'mvpc');
+ end
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpc'];
+ else
+ file_name = [file_name,'.mvpc'];
+ end
+ DataString{Numofselectederp,3} = file_name;
+end
+
+set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+set(handles.uitable1_erpset_table,'ColumnWidth',{248 248 248});
+
+
+
+
+
+% --- Executes when entered data in editable cell(s) in uitable1_erpset_table.
+function uitable1_erpset_table_CellEditCallback(hObject, eventdata, handles)
+
+DataString = handles.uitable1_erpset_table.Data;
+Selected_ERP_label = handles.Selected_ERP_label;
+if size(DataString,1) < numel(Selected_ERP_label)
+ msgboxText = 'BESTname and filename for one of erpsets are empty at least! Please give name to BESTname and filename';
+ title = 'ERPLAB: f_ERP_save_multi_file empty erpname';
+ errorfound(msgboxText, title);
+ return
+end
+
+% for Numofselected = 1:numel(Selected_ERP_label)
+% if isempty(DataString{Numofselected,2})
+% msgboxText = 'Erpname for one of erpsets is empty at least! Please give name to that erpset';
+% title = 'ERPLAB: f_ERP_save_multi_file empty erpname';
+% errorfound(msgboxText, title);
+% return
+% end
+%
+% end
+
+
+
+% --- Executes on button press in pushbutton_Cancel.
+function pushbutton_Cancel_Callback(hObject, eventdata, handles)
+handles.output = [];
+% beep;
+disp('User selected Cancel.');
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+
+
+
+% --- Executes on button press in pushbutton4_okay.
+function pushbutton4_okay_Callback(hObject, eventdata, handles)
+% suffix = strtrim(get(handles.edit_suffix_name, 'String'));
+% if handles.checkbox1_suffix.Value
+% if isempty(suffix)
+% msgboxText = 'You must enter suffix at least!';
+% title = 'EStudio: mvpc_save_multi_file empty erpname';
+% errorfound(msgboxText, title);
+% return
+% end
+% end
+
+Data_String =handles.uitable1_erpset_table.Data;
+ALLERP = handles.ALLERP;
+Selected_ERP_label = handles.Selected_ERP_label;
+
+if size(Data_String,1)< numel(Selected_ERP_label)%
+ msgboxText = 'MVPCname for one of MVPCsets is empty at least! Please give a name';
+ title = 'ERPLAB: mvpc_save_multi_file empty MVPCname';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+if size(Data_String,1)> numel(Selected_ERP_label)%
+ msgboxText = 'More MVPCname is given. Please delete it!!!';
+ title = 'ERPLAB: mvpc_save_multi_file empty MVPCname';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+for Numofselected = 1:numel(Selected_ERP_label)
+ if isempty(Data_String{Numofselected,2})
+ msgboxText = 'MVPCname for one of MVPCsets is empty at least! Please give a name';
+ title = 'ERPLAB: mvpc_save_multi_file empty MVPCname';
+ errorfound(msgboxText, title);
+ return
+ end
+
+end
+
+
+
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ ALLERP(Selected_ERP_label(Numofselectederp)).mvpcname = Data_String{Numofselectederp,2};
+ fileName = char(Data_String{Numofselectederp,3});
+ if isempty(fileName)
+ %fileName = Data_String{Numofselectederp,2};
+ fileName = '';
+ end
+
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ % file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_mvpc.mvpc'];
+ file_name = '';
+ else
+ file_name = [file_name,'.mvpc'];
+ end
+
+ ALLERP(Selected_ERP_label(Numofselectederp)).filename = file_name;
+ if handles.checkbox2_save_label.Value == 0
+ ALLERP(Selected_ERP_label(Numofselectederp)).filepath = '';
+ end
+
+ if handles.checkbox2_save_label.Value
+ ALLERP(Selected_ERP_label(Numofselectederp)).saved = 'yes';
+ else
+ ALLERP(Selected_ERP_label(Numofselectederp)).saved = 'no';
+ end
+
+end
+
+%Remove bestname
+%ALLERP = rmfield(ALLERP,'bestname');
+
+
+FilePath = handles.checkbox2_save_label.Value;
+
+handles.output = {ALLERP, FilePath};
+% Update handles structure
+guidata(hObject, handles);
+
+uiresume(handles.gui_chassis);
+
+
+
+% -----------------------------------------------------------------------
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = '';
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
+
+
+% --- Executes on button press in browse_button.
+function browse_button_Callback(hObject, eventdata, handles)
+% hObject handle to browse_button (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% Save OUTPUT file
+%
+fndefault = cd;
+dname = uigetdir(fndefault, 'Select path for MVPC files');
+
+
+%set(handles.edit_saveas,'String', fullfile(pathname, fname));
+disp(['To save MVPCset(s), user selected path: ',dname]);
+
+set(handles.browsedir,'String',dname);
+
+Selected_ERP_label = handles.Selected_ERP_label;
+for Numofselectederp = 1:numel(Selected_ERP_label)
+ %reset the filepath for saving to CD
+ handles.ALLERP(Selected_ERP_label(Numofselectederp)).filepath = dname;
+end
+
+guidata(hObject, handles);
+
+% DataString_before = handles.uitable1_erpset_table.Data;
+%
+% for Numofselectederp = 1:size(DataString_before,1)
+% DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1}; %bestname
+% DataString{Numofselectederp,2} = DataString_before{Numofselectederp,2};
+% fileName = char(DataString_before{Numofselectederp,2});
+% if isempty(fileName)
+% fileName = strcat(num2str(Numofselectederp),'mvpc');
+% end
+% [pathstr, file_name, ext] = fileparts(fileName);
+% if ~isempty(dname)
+% file_name = [dname '/' file_name '.mvpc'];
+% end
+% DataString{Numofselectederp,3} = file_name;
+% end
+%
+% set(handles.uitable1_erpset_table,'Data',cellstr(DataString));
+% set(handles.uitable1_erpset_table,'ColumnWidth',{248 248 248});
+
+
+
+function browsedir_Callback(hObject, eventdata, handles)
+% hObject handle to browsedir (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of browsedir as text
+% str2double(get(hObject,'String')) returns contents of browsedir as
+% a double]
+
+desired_dir = get(hObject,'String');
+
+if ~isfolder(desired_dir)
+ msgboxText = sprintf('The folder/directory %s does not exist!',desired_dir);
+ title = 'ERPLAB: save directory does not exist';
+ errorfound(msgboxText, title);
+
+ %chagne back to pwd
+ set(handles.browsedir,'String',pwd);
+
+
+end
+guidata(hObject, handles);
+
+
+% --- Executes during object creation, after setting all properties.
+function browsedir_CreateFcn(hObject, eventdata, handles)
+% hObject handle to browsedir (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in button_fnameMVPC.
+function button_fnameMVPC_Callback(hObject, eventdata, handles)
+% hObject handle to button_fnameMVPC (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ fileName = DataString_before{Numofselectederp,2};
+ %fileName= char(ALLERP(Selected_ERP_label(Numofselectederp)).filename);
+ [pathstr, file_name, ext] = fileparts(fileName);
+ if isempty(file_name)
+ file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERPspatial.mvpc'];
+ else
+ file_name = [file_name,'.mvpc'];
+ end
+ DataString_before{Numofselectederp,3} = file_name;
+ end
+
+ set(handles.uitable1_erpset_table,'ColumnEditable',[false true true]);
+ set(handles.uitable1_erpset_table,'Data',DataString_before);
+ guidata(hObject, handles);
+
+
+
+% --- Executes on button press in button_clearMVPCname.
+function button_clearMVPCname_Callback(hObject, eventdata, handles)
+% hObject handle to button_clearMVPCname (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+
+ DataString_before = handles.uitable1_erpset_table.Data;
+ for Numofselectederp = 1:size(DataString_before,1)
+ DataString_before{Numofselectederp,2} = '';
+ end
+
+ set(handles.uitable1_erpset_table,'ColumnEditable',[false true true]);
+ set(handles.uitable1_erpset_table,'Data',DataString_before);
+ guidata(hObject, handles);
+
+
+% --- Executes on button press in button_clearfname.
+function button_clearfname_Callback(hObject, eventdata, handles)
+% hObject handle to button_clearfname (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+DataString_before = handles.uitable1_erpset_table.Data;
+for Numofselectederp = 1:size(DataString_before,1)
+ DataString_before{Numofselectederp,3} = '';
+end
+
+set(handles.uitable1_erpset_table,'ColumnEditable',[false true true]);
+set(handles.uitable1_erpset_table,'Data',DataString_before);
+guidata(hObject, handles);
diff --git a/GUIs/mvpcaveragerGUI.fig b/GUIs/mvpcaveragerGUI.fig
new file mode 100644
index 00000000..1bd83d87
Binary files /dev/null and b/GUIs/mvpcaveragerGUI.fig differ
diff --git a/GUIs/mvpcaveragerGUI.m b/GUIs/mvpcaveragerGUI.m
new file mode 100644
index 00000000..6ffc5e3b
--- /dev/null
+++ b/GUIs/mvpcaveragerGUI.m
@@ -0,0 +1,767 @@
+%
+% Author: Aaron Matthew Simmons & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2009
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function varargout = mvpcaveragerGUI(varargin)
+% MVPCAVERAGERGUI MATLAB code for mvpcaveragerGUI.fig
+% MVPCAVERAGERGUI, by itself, creates a new MVPCAVERAGERGUI or raises the existing
+% singleton*.
+%
+% H = MVPCAVERAGERGUI returns the handle to a new MVPCAVERAGERGUI or the handle to
+% the existing singleton*.
+%
+% MVPCAVERAGERGUI('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in MVPCAVERAGERGUI.M with the given input arguments.
+%
+% MVPCAVERAGERGUI('Property','Value',...) creates a new MVPCAVERAGERGUI or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before mvpcaveragerGUI_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to mvpcaveragerGUI_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help mvpcaveragerGUI
+
+% Last Modified by GUIDE v2.5 15-May-2023 15:05:37
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpcaveragerGUI_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpcaveragerGUI_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before mvpcaveragerGUI is made visible.
+function mvpcaveragerGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+% This function has no output args, see OutputFcn.
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% varargin command line arguments to mvpcaveragerGUI (see VARARGIN)
+
+% Choose default command line output for mvpcaveragerGUI
+handles.output = [];
+handles.indxline = 1; %for addmvpc set
+
+try
+ % optioni = answer{2}; %1 means from a filelist, 0 means from mvpcsets menu
+ % mvpcset = answer{3};
+ % stderror = answer{4}; % 0;1
+
+ def = varargin{1};
+ actualnset = def{1}; % number of loaded mvpcsets at mvpcset menu
+ optioni = def{2}; % datasets to average, %1 means from a filelist, 0 means from mvpcsets menu
+ mvpcset = def{3}; % %indexs of ALLMVPC to average
+ stderror = def{4};
+catch
+ actualnset = 0;
+ optioni = 1;
+ mvpcset = '';
+% artcrite = 100;
+% wavg = 0;
+% excnullbin = 1;
+ stderror = 1;
+end
+if ~isempty(mvpcset)
+ if ischar(mvpcset)
+ listname = mvpcset;
+ else
+ listname = [];
+ end
+else
+ listname = [];
+end
+
+%helpbutton; %not yet created
+handles.actualnset = actualnset;
+handles.listname = listname;
+handles.mvpcset = mvpcset;
+
+if optioni==0 && actualnset>0 && isnumeric(mvpcset)
+ mvpcs = mvpcset(mvpcset<=actualnset);
+ if isempty(mvpcs)
+ mvpcs = 1:actualnset;
+ end
+ set(handles.radiobutton_mvpcset, 'Value', 1);
+ set(handles.radiobutton_mvpcset, 'Enable', 'on');
+ set(handles.edit_mvpcset, 'String', vect2colon(mvpcs, 'Delimiter', 'off', 'Repeat', 'off'));
+ set(handles.radiobutton_folders, 'Value', 0);
+ set(handles.listbox_mvpcnames, 'Enable', 'off');
+ set(handles.pushbutton_addmvpcset, 'Enable', 'off');
+ set(handles.pushbutton_delmvpcset, 'Enable', 'off');
+ set(handles.button_loadlist, 'Enable', 'off');
+ set(handles.button_savelist, 'Enable', 'off');
+ set(handles.button_savelistas, 'Enable', 'off');
+ set(handles.button_clearfile, 'Enable', 'off');
+elseif optioni==0 && actualnset>0 && ~isnumeric(mvpcset)
+ set(handles.radiobutton_mvpcset, 'Value', 1);
+ set(handles.radiobutton_mvpcset, 'Enable', 'on');
+ set(handles.edit_mvpcset, 'String', vect2colon(1:actualnset, 'Delimiter', 'off'));
+ set(handles.radiobutton_folders, 'Value', 0);
+ set(handles.listbox_mvpcnames, 'Enable', 'off');
+ set(handles.pushbutton_addmvpcset, 'Enable', 'off');
+ set(handles.pushbutton_delmvpcset, 'Enable', 'off');
+ set(handles.button_loadlist, 'Enable', 'off');
+ set(handles.button_savelist, 'Enable', 'off');
+ set(handles.button_savelistas, 'Enable', 'off');
+ set(handles.button_clearfile, 'Enable', 'off');
+elseif optioni>=0 && actualnset==0 && isnumeric(mvpcset)
+ set(handles.edit_mvpcset, 'String', 'no mvpcset found');
+ set(handles.edit_mvpcset, 'Enable', 'off');
+ set(handles.radiobutton_mvpcset, 'Value', 0);
+ set(handles.radiobutton_mvpcset, 'Enable', 'off');
+ set(handles.radiobutton_folders, 'Value', 1);
+ set(handles.listbox_mvpcnames, 'String', {'new mvpcset'});
+elseif optioni==0 && actualnset==0 && ~isnumeric(mvpcset)
+ set(handles.edit_mvpcset, 'String', 'no mvpcset found');
+ set(handles.edit_mvpcset, 'Enable', 'off');
+ set(handles.radiobutton_mvpcset, 'Value', 0);
+ set(handles.radiobutton_mvpcset, 'Enable', 'off');
+ set(handles.radiobutton_folders, 'Value', 1);
+ set(handles.listbox_mvpcnames, 'String', {'new mvpcset'});
+elseif optioni==1 && actualnset>=0 && ~isnumeric(mvpcset)
+ set(handles.edit_mvpcset, 'String', 'no mvpcset found');
+ set(handles.edit_mvpcset, 'Enable', 'off');
+ set(handles.radiobutton_mvpcset, 'Value', 0);
+ set(handles.radiobutton_mvpcset, 'Enable', 'on');
+ set(handles.edit_mvpcset, 'String', vect2colon(1:actualnset, 'Delimiter', 'off'));
+
+ set(handles.radiobutton_folders, 'Value', 1);
+ if ~isempty(mvpcset)
+ button_loadlist_Callback(hObject, eventdata, handles, 1)
+ %listname = mvpcset;
+ else
+ set(handles.listbox_mvpcnames, 'String', {'new mvpcset'});
+ end
+else
+ error('no entiendo esta combinacion :(')
+end
+
+set(handles.checkbox_SEM, 'Value', stderror); %
+
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - MVPC AVERAGER GUI'])
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+% Update handles structure
+guidata(hObject, handles);
+
+% help
+%helpbutton
+
+% UIWAIT makes grandaveragerGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+
+% UIWAIT makes mvpcaveragerGUI wait for user response (see UIRESUME)
+% uiwait(handles.gui_chassis);
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpcaveragerGUI_OutputFcn(hObject, eventdata, handles)
+% varargout cell array for returning output args (see VARARGOUT);
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Get default command line output from handles structure
+varargout{1} = handles.output;
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+% --- Executes on button press in radiobutton_folders.
+function radiobutton_folders_Callback(hObject, eventdata, handles)
+% hObject handle to radiobutton_folders (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+if get(hObject, 'Value')
+ set(handles.radiobutton_folders, 'Value', 1);
+ set(handles.radiobutton_folders, 'Enable', 'on');
+ set(handles.listbox_mvpcnames, 'Enable', 'on');
+ set(handles.pushbutton_addmvpcset, 'Enable', 'on');
+ set(handles.pushbutton_delmvpcset, 'Enable', 'on');
+% set(handles.button_loadlist, 'Enable', 'on');
+% set(handles.button_savelist, 'Enable', 'on');
+% set(handles.button_savelistas, 'Enable', 'on');
+% set(handles.button_clearfile, 'Enable', 'on');
+ set(handles.radiobutton_mvpcset, 'Value', 0);
+
+ if handles.actualnset==0
+ set(handles.radiobutton_mvpcset, 'Enable', 'off');
+ else
+ set(handles.radiobutton_mvpcset, 'Enable', 'on');
+ end
+ if isempty(get(handles.listbox_mvpcnames,'String'))
+ set(handles.listbox_mvpcnames,'String',{'new mvpcset'});
+ end
+
+ set(handles.edit_mvpcset, 'Enable', 'off');
+ set(handles.edit_mvpcset, 'String', '');
+else
+ set(handles.radiobutton_folders, 'Value', 1);
+end
+
+% Hint: get(hObject,'Value') returns toggle state of radiobutton_folders
+
+
+% --- Executes on selection change in listbox_mvpcnames.
+function listbox_mvpcnames_Callback(hObject, eventdata, handles)
+% hObject handle to listbox_mvpcnames (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: contents = cellstr(get(hObject,'String')) returns listbox_mvpcnames contents as cell array
+% contents{get(hObject,'Value')} returns selected item from listbox_mvpcnames
+fulltext = get(handles.listbox_mvpcnames, 'String');
+indxline = length(fulltext);
+currlineindx = get(handles.listbox_mvpcnames, 'Value');
+
+
+% --- Executes during object creation, after setting all properties.
+function listbox_mvpcnames_CreateFcn(hObject, eventdata, handles)
+% hObject handle to listbox_mvpcnames (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: listbox controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in radiobutton_mvpcset.
+function radiobutton_mvpcset_Callback(hObject, eventdata, handles)
+% hObject handle to radiobutton_mvpcset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hint: get(hObject,'Value') returns toggle state of radiobutton_mvpcset
+if get(hObject, 'Value')
+ actualnset = handles.actualnset;
+ set(handles.radiobutton_mvpcset, 'Value', 1);
+ set(handles.radiobutton_mvpcset, 'Enable', 'on');
+ set(handles.edit_mvpcset, 'Enable', 'on');
+ set(handles.edit_mvpcset, 'String', vect2colon(1:actualnset, 'Delimiter', 'off'));
+ set(handles.radiobutton_folders, 'Value', 0);
+ set(handles.listbox_mvpcnames, 'Enable', 'off');
+ set(handles.pushbutton_addmvpcset, 'Enable', 'off');
+ set(handles.pushbutton_delmvpcset, 'Enable', 'off');
+% set(handles.button_loadlist, 'Enable', 'off');
+% set(handles.button_savelist, 'Enable', 'off');
+% set(handles.button_savelistas, 'Enable', 'off');
+% set(handles.button_clearfile, 'Enable', 'off');
+else
+ set(handles.radiobutton_mvpcset, 'Value', 1);
+end
+
+
+function edit_mvpcset_Callback(hObject, eventdata, handles)
+% hObject handle to edit_mvpcset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_mvpcset as text
+% str2double(get(hObject,'String')) returns contents of edit_mvpcset as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_mvpcset_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_mvpcset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in pushbutton_cancel.
+function pushbutton_cancel_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_cancel (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+handles.figure1 = [];
+handles.output = [];
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+
+% --- Executes on button press in pushbutton_GO.
+function pushbutton_GO_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_GO (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+stderror = get(handles.checkbox_SEM,'Value'); % for standard error 1=>yes
+warnon = get(handles.checkbox_warning,'Value');
+
+%
+% mvpcsets
+%
+if get(handles.radiobutton_mvpcset, 'Value')
+ mvpcset = str2num(char(get(handles.edit_mvpcset, 'String')));
+
+ if length(mvpcset)<2
+ msgboxText = 'You have to specify 2 mvpcsets, at least!';
+ title = 'ERPLAB: mvpcaveragerGUI() -> missing input';
+ errorfound(msgboxText, title);
+ return
+ end
+ if min(mvpcset)<1 || max(mvpcset)>handles.actualnset
+ msgboxText = 'Nonexistent mvpcset index(es)';
+ title = 'ERPLAB: mvpcaveragerGUI() -> wrong input';
+ errorfound(msgboxText, title);
+ return
+ else
+ handles.output = {0, mvpcset, stderror, warnon};
+ end
+else
+ mvpcset = cellstr(get(handles.listbox_mvpcnames, 'String'));
+ nline = length(mvpcset);
+
+ if nline<3 % 'new_mvpcset' line is being included
+ msgboxText = 'You have to specify 2 mvpcsets, at least!';
+ title = 'ERPLAB: mvpcaveragerGUI() -> missing input';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ listname = handles.listname;
+
+ if isempty(listname) && nline>1
+ BackERPLABcolor = [1 0.9 0.3]; % yellow
+ question = ['You have not saved your list.\n'...
+ 'What would you like to do?'];
+ title = 'Save List of mvpcsets';
+ oldcolor = get(0,'DefaultUicontrolBackgroundColor');
+ set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
+ button = questdlg(sprintf(question), title,'Save and Continue','Save As', 'Cancel','Save and Continue');
+ set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+
+ if strcmpi(button,'Save As')
+ fullname = savelist(hObject, eventdata, handles);
+ handles.listname = fullname;
+ % Update handles structure
+ guidata(hObject, handles);
+ return
+ elseif strcmpi(button,'Save and Continue')
+ fulltext = char(get(handles.listbox_mvpcnames,'String'));
+ %listname = char(strtrim(get(handles.edit_filelist,'String')));
+ listname = '';
+ if isempty(listname)
+ fullname = savelist(hObject, eventdata, handles);
+ listname = fullname;
+ if isempty(listname)
+ return
+ end
+ else
+ fid_list = fopen( listname , 'w');
+ for i=1:size(fulltext,1)-1
+ fprintf(fid_list,'%s\n', fulltext(i,:));
+ end
+ fclose(fid_list);
+ end
+ elseif strcmpi(button,'Cancel') || strcmpi(button,'')
+ handles.output = [];
+ handles.listname = [];
+ % Update handles structure
+ guidata(hObject, handles);
+ return
+ end
+ end
+
+
+ handles.output = {1, listname, stderror, warnon};
+end
+
+
+
+
+
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+
+
+% --- Executes on button press in checkbox_SEM.
+function checkbox_SEM_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_SEM (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_SEM
+
+
+% --- Executes on button press in pushbutton_addmvpcset.
+function pushbutton_addmvpcset_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_addmvpcset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+[mvpcfname, mvpcpathname] = uigetfile({ '*.mvpc','Multivariate Pattern Classification files (*.mvpc)'; ...
+ '*.mat','Matlab (*.mat)'; ...
+ '*.*', 'All Files (*.*)'}, ...
+ 'Select an edited file', ...
+ 'MultiSelect', 'on');
+
+if isequal(mvpcfname,0)
+ disp('User selected Cancel')
+ return
+else
+ if ~iscell(mvpcfname)
+ mvpcfname = {mvpcfname};
+ end
+
+ nmvpcn = length(mvpcfname);
+
+ for i=1:nmvpcn
+ newline = fullfile(mvpcpathname, mvpcfname{i});
+ currline = get(handles.listbox_mvpcnames, 'Value');
+ fulltext = get(handles.listbox_mvpcnames, 'String');
+ indxline = length(fulltext);
+
+ if currline==indxline
+ % extra line forward
+ fulltext = cat(1, fulltext, {'new mvpcset'});
+ set(handles.listbox_mvpcnames, 'Value', currline+1)
+ else
+ set(handles.listbox_mvpcnames, 'Value', currline)
+ resto = fulltext(currline:indxline);
+ fulltext = cat(1, fulltext, {'new mvpcset'});
+ set(handles.listbox_mvpcnames, 'Value', currline+1)
+ [fulltext{currline+1:indxline+1}] = resto{:};
+ end
+
+ fulltext{currline} = newline;
+ set(handles.listbox_mvpcnames, 'String', fulltext)
+ end
+
+ indxline = length(fulltext);
+ handles.indxline = indxline;
+ handles.fulltext = fulltext;
+ handles.listname = [];
+ % set(handles.edit_filelist,'String','');
+ % Update handles structure
+ guidata(hObject, handles);
+end
+
+
+% --- Executes on button press in pushbutton_delmvpcset.
+function pushbutton_delmvpcset_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_delmvpcset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+fulltext = get(handles.listbox_mvpcnames, 'String');
+indxline = length(fulltext);
+fulltext = char(fulltext); % string matrix
+currline = get(handles.listbox_mvpcnames, 'Value');
+
+if currline>=1 && currline' fullname ''])
+ fid_list = fopen( fullname , 'w');
+
+ for i=1:size(fulltext,1)-1
+ fprintf(fid_list,'%s\n', fulltext(i,:));
+ end
+ fclose(fid_list);
+end
+
+
+% --- Executes on button press in button_clearfile.
+function button_clearfile_Callback(hObject, eventdata, handles)
+% hObject handle to button_clearfile (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+set(handles.edit_filelist,'String','');
+set(handles.button_savelist, 'Enable', 'off')
+handles.listname = [];
+% Update handles structure
+guidata(hObject, handles);
+
+
+
+% --- Executes on button press in button_savelistas.
+function button_savelistas_Callback(hObject, eventdata, handles)
+% hObject handle to button_savelistas (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+fulltext = char(get(handles.listbox_mvpcnames,'String'));
+
+if length(fulltext)>1
+
+ fullname = savelist(hObject, eventdata, handles);
+
+ if isempty(fullname)
+ return
+ end
+
+ set(handles.edit_filelist, 'String', fullname )
+ set(handles.button_savelist, 'Enable', 'on')
+ handles.listname = fullname;
+ % Update handles structure
+ guidata(hObject, handles);
+else
+ set(handles.button_savelistas,'Enable','off')
+ msgboxText = 'You have not specified any mvpcset!';
+ title = 'ERPLAB: mvpcaverager GUI few inputs';
+ errorfound(msgboxText, title);
+ set(handles.button_savelistas,'Enable','on')
+ return
+end
+
+
+
+
+% --- Executes on button press in button_savelist.
+function button_savelist_Callback(hObject, eventdata, handles)
+% hObject handle to button_savelist (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+fulltext = char(strtrim(get(handles.listbox_mvpcnames,'String')));
+
+if length(fulltext)>1
+
+ fullname = get(handles.edit_filelist, 'String');
+
+ if ~strcmp(fullname,'') && strcmp(fullname,'new mvpcset')
+
+ fid_list = fopen( fullname , 'w');
+
+ for i=1:size(fulltext,1)
+ fprintf(fid_list,'%s\n', fulltext(i,:));
+ end
+
+ fclose(fid_list);
+ handles.listname = fullname;
+
+ % Update handles structure
+ guidata(hObject, handles);
+ disp(['Saving equation list at ' fullname ' '])
+ else
+ button_savelistas_Callback(hObject, eventdata, handles)
+ return
+ end
+else
+ set(handles.button_savelistas,'Enable','off')
+ msgboxText = 'You have not written any formula yet!';
+ title = 'ERPLAB: mvpcaveragerGUI few inputs';
+ errorfound(msgboxText, title);
+ set(handles.button_savelistas,'Enable','on')
+ return
+end
+
+
+% --- Executes on button press in button_loadlist.
+function button_loadlist_Callback(hObject, eventdata, handles)
+% hObject handle to button_loadlist (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+if nargin<4
+ optionx=0;
+end
+if optionx==0
+ [listname, lispath] = uigetfile({ '*.txt','Text File (*.txt)'; ...
+ '*.*', 'All Files (*.*)'}, ...
+ 'Select an edited list', ...
+ 'MultiSelect', 'off');
+
+ if isequal(listname,0)
+ disp('User selected Cancel')
+ return
+ else
+ fullname = fullfile(lispath, listname);
+ disp(['For MVPCset list user selected ' fullname ' '])
+ end
+else
+ fullname = handles.mvpcset;
+ if isnumeric(fullname)
+ fullname = '';
+ end
+end
+try
+ fid_list = fopen( fullname );
+ formcell = textscan(fid_list, '%[^\n]','CommentStyle','#', 'whitespace', ''); % JLC.05/12/15
+catch
+ fprintf('WARNING: %s was not found or is corrupted\n', fullname)
+ return
+end
+
+lista = formcell{:};
+% extra line forward
+lista = cat(1, lista, {'new mvpcset'});
+lentext = length(lista);
+fclose(fid_list);
+
+if lentext>1
+ set(handles.listbox_mvpcnames,'String',lista);
+ set(handles.edit_filelist,'String',fullname);
+ handles.listname = fullname;
+ set(handles.button_savelist, 'Enable','on')
+
+ % Update handles structure
+ guidata(hObject, handles);
+else
+ msgboxText = 'This list is empty!';
+ title = 'ERPLAB: mvpcaveragerGUI inputs';
+ errorfound(msgboxText, title);
+ handles.listname = [];
+ set(handles.button_savelist, 'Enable','off')
+
+ % Update handles structure
+ guidata(hObject, handles);
+end
+set(handles.listbox_mvpcnames,'String',lista);
+
+
+function edit_filelist_Callback(hObject, eventdata, handles)
+% hObject handle to edit_filelist (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_filelist as text
+% str2double(get(hObject,'String')) returns contents of edit_filelist as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_filelist_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_filelist (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in checkbox_warning.
+function checkbox_warning_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_warning (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_warning
diff --git a/GUIs/mvpcviewerGUI.fig b/GUIs/mvpcviewerGUI.fig
new file mode 100644
index 00000000..05bea015
Binary files /dev/null and b/GUIs/mvpcviewerGUI.fig differ
diff --git a/GUIs/mvpcviewerGUI.m b/GUIs/mvpcviewerGUI.m
new file mode 100644
index 00000000..c23593dc
--- /dev/null
+++ b/GUIs/mvpcviewerGUI.m
@@ -0,0 +1,1469 @@
+function varargout = mvpcviewerGUI(varargin)
+% MVPCVIEWERGUI MATLAB code for mvpcviewerGUI.fig
+% MVPCVIEWERGUI, by itself, creates a new MVPCVIEWERGUI or raises the existing
+% singleton*.
+%
+% H = MVPCVIEWERGUI returns the handle to a new MVPCVIEWERGUI or the handle to
+% the existing singleton*.
+%
+% MVPCVIEWERGUI('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in MVPCVIEWERGUI.M with the given input arguments.
+%
+% MVPCVIEWERGUI('Property','Value',...) creates a new MVPCVIEWERGUI or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before mvpcviewerGUI_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to mvpcviewerGUI_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help mvpcviewerGUI
+
+% Last Modified by GUIDE v2.5 06-Jun-2023 18:10:34
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @mvpcviewerGUI_OpeningFcn, ...
+ 'gui_OutputFcn', @mvpcviewerGUI_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before mvpcviewerGUI is made visible.
+function mvpcviewerGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+% This function has no output args, see OutputFcn.
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% varargin command line arguments to mvpcviewerGUI (see VARARGIN)
+
+% Choose default command line output for mvpcviewerGUI
+handles.output = [];
+
+%defx = erpworkingmemory('pop_geterpvalues');
+% try
+% cerpi = evalin('base', 'CURRENTERP'); % current erp index
+% catch
+% cerpi = 1;
+% end
+% handles.cerpi = cerpi;
+ALLMVPC = varargin{1};
+setArray = 1:length(ALLMVPC);
+
+measurearray = {'Average Decoding Accuracy','Crossnobis Distance','None'};
+
+
+%colors
+cwm = erpworkingmemory('WMColor'); % window color for measurement
+cvl = erpworkingmemory('VLColor'); % line color for measurement
+mwm = erpworkingmemory('WMmouse'); % select window measurement by mouse option
+
+if isempty(cwm)
+ cwm = [0.8490 1.0000 0.1510];
+end
+if isempty(cvl)
+ cvl = [1 0 0];
+end
+if isempty(mwm)
+ mwm = 0;
+end
+
+%handles.defx = defx;
+handles.cwm = cwm;
+handles.cvl = cvl;
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+
+if isempty(ALLMVPC)
+ set(handles.radiobutton2,'Value',1)
+
+ handles.measurearray = {''};
+ handles.meacodes = {''};
+ handles.chance = 0;
+ handles.stderror = 0;
+ handles.alpha = {'0.10','0.20','0.30','0.40','0.50','0.60','0.70','0.80','0.90','1.0'};
+ set(handles.popupmenu_alpha,'String', handles.alpha);
+ set(handles.popupmenu_alpha,'Value',7);
+ set(handles.popupmenu_alpha,'String', handles.alpha);
+ set(handles.popupmenu_alpha,'Value',7);
+ meamenu = 3;
+ set(handles.text_measurementv, 'String', measurearray{meamenu});
+
+
+ handles.ALLMVPA = ALLMVPC;
+ handles.setArray = setArray;
+ handles.iset = 0;
+ handles.dig = 3;
+ handles.x1 = -1.75;
+ handles.x2 = 1.75;
+
+ xlim = [0 30]; %default for empty values
+ ylim = [0 15]; %default for emtpy values
+
+ set(handles.edit_ylim, 'String', num2str(ylim));
+ set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)));
+
+ iset = 0; %empty file
+ set(handles.edit_file, 'String', num2str(iset));
+
+ %set(handles.checkbox_butterflyset,'Enable', 'off');
+ set(handles.checkbox_stderror,'Enable', 'off');
+
+
+ %set(handles.checkbox_butterflyset, 'Enable', 'off')
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+
+ handles.datatype = '';
+
+else
+
+ iset = evalin('base','CURRENTMVPC');
+
+ % set(handles.radiobutton1,'Value',1);
+ set(handles.listbox_mvpcnames,'Enable','on');
+ set(handles.text3,'String','MVPC Menu File Index');
+
+ fnames = {ALLMVPC(:).mvpcname};
+
+ for n = 1:numel(fnames)
+ fnames{n} = char(strcat(['File ' num2str(n) ': '], {' '},fnames{n}));
+ end
+
+
+ set(handles.listbox_mvpcnames,'String',fnames);
+ set(handles.listbox_mvpcnames,'Value',iset);
+
+ if isfield(ALLMVPC(iset), 'DecodingMethod')
+ datatype = ALLMVPC(iset).DecodingMethod;
+
+ else
+ datatype = 'SVM';
+ end
+
+
+ if strcmpi(datatype, 'SVM')
+ meamenu = 1;
+ else
+ meamenu = 2;
+ end
+
+ handles.measurearray = measurearray;
+
+
+ meacodes = {'avgdecodingacc' };
+
+ handles.meacodes = meacodes;
+
+ handles.chance = 1; %set default on
+ set(handles.checkbox_chance,'Value',1); %set default on
+ handles.stderror = 0;
+ handles.alpha = {'0.10','0.20','0.30','0.40','0.50','0.60','0.70','0.80','0.90','1.0'};
+ set(handles.popupmenu_alpha,'String', handles.alpha);
+ set(handles.popupmenu_alpha,'Value',3);
+
+
+ %set(handles.text_measurementv, 'String', measurearray);
+ %[tfm, indxmeaX] = ismember_bc2({moption}, meacodes);
+
+ set(handles.text_measurementv, 'String', measurearray{meamenu});
+ % set(handles.text_measurementv, 'Value', meamenu);
+ % set(handles.text_measurementv, 'Enable', 'inactive');
+
+
+ handles.ALLMVPA = ALLMVPC;
+ handles.ALLMVPA_reset = ALLMVPC;
+ %handles.binArray = binArray;
+ %handles.chanArray = chanArray;
+ handles.setArray = setArray;
+ %handles.ich = 1;
+ %handles.ibin = 1;
+ handles.iset = iset;
+ %handles.orilatency = latency;
+ %handles.blc = blc;
+ %handles.moption = moption;
+ %handles.tittle = tittle;
+ handles.dig = 3;
+ handles.x1 = -1.75;
+ handles.x2 = 1.75;
+
+
+ % ibin = 1;
+ % ich = 1;
+
+ times = ALLMVPC(iset).times;
+ if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(iset).chance*4 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(iset).chance*4];
+
+ end
+
+ else
+ xlim = [min(times) max(times)];;
+ ylim = [abs(min(ALLMVPC(iset).average_score))*-1.10 max(ALLMVPC(iset).average_score)*1.10];
+
+ end
+
+ handles.ylim_set = []; %for user set limits
+ handles.xlim_set = []; %for user set limits
+
+ set(handles.edit_ylim, 'String', num2str(ylim));
+ set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)));
+
+ set(handles.edit_file, 'String', num2str(iset));
+
+ %set(handles.checkbox_butterflyset,'Value', 0);
+ set(handles.checkbox_stderror,'Value', 0);
+
+ if length(setArray)==1
+ % set(handles.checkbox_butterflyset, 'Enable', 'off')
+ % if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ end
+ handles.datatype = datatype;
+
+
+
+ %
+ % Plot figure
+ %
+ % Update handles structure
+ guidata(hObject, handles);
+
+
+ mplotdata(hObject, handles, iset, xlim, ylim);
+
+end
+
+%
+% create random x-values for scatter plot
+%
+% xscatt = rand(1,numel(AMP))*2.5-1.25;
+% handles.xscatt = xscatt;
+% indxsetstr = {''};
+% % end
+% handles.indxsetstr = indxsetstr;
+
+% handles.membin = [];
+% handles.memch = [];
+% handles.memset = [];
+%
+% binvalue = erpworkingmemory('BinHisto'); % value(s) for bin in histogram
+% normhisto = erpworkingmemory('NormHisto'); % normalize histogram
+% chisto = erpworkingmemory('HistoColor'); % histogram color
+% cfitnorm = erpworkingmemory('FnormColor'); % line color for fitted normal distribution
+% fitnormd = erpworkingmemory('FitNormd'); % fit nomal distribution
+%
+% if isempty(binvalue)
+% binvalue = 'auto';
+% end
+% if isempty(normhisto)
+% normhisto = 0;
+% end
+% if isempty(chisto)
+% chisto = [1 0.5 0.2];
+% end
+% if isempty(cfitnorm)
+% cfitnorm = [1 0 0];
+% end
+% if isempty(fitnormd)
+% fitnormd = 0;
+% end
+
+% handles.binvalue = binvalue;
+% handles.normhisto = normhisto;
+% handles.chisto = chisto;
+% handles.cfitnorm = cfitnorm;
+% handles.fitnormd = fitnormd;
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - VIEWER FOR MVPC GUI']); %, 'toolbar','figure')
+
+% Update handles structure
+guidata(hObject, handles);
+
+
+
+% UIWAIT makes mvpaviewerGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+
+
+
+function mplotdata(hObject,handles,iset,xlim,ylim)
+
+setArray = handles.setArray;
+measurearray = handles.measurearray;
+
+
+if ~isempty(handles.ylim_set)
+ %user's preference
+ ylim = handles.ylim_set;
+
+end
+if ~isempty(handles.xlim_set)
+ %users preference
+ xlim = handles.xlim_set;
+end
+
+
+%% only one file
+% pervious version of this code plotted more than one file
+% if checkbox_butterflyset was enabled
+% For the first version of decoding toolbox, Steve
+% decided we only view one file at a time
+
+%setinput = [];
+% if get(handles.checkbox_butterflyset, 'Value')
+% jseta = setArray;
+%
+%
+% else
+setinput = eval(get(handles.edit_file, 'String'));
+
+% if length(setinput)>1
+% jseta = setinput;
+% else
+ jseta = setArray(iset);
+% end
+% end
+
+ALLMVPC = handles.ALLMVPA;
+times = ALLMVPC(iset).times;
+
+%MVPC listbox
+
+fntsz = get(handles.edit_report, 'FontSize');
+set(handles.edit_report, 'FontSize', fntsz*1.5)
+set(handles.edit_report, 'String', sprintf('\nWorking...\n'))
+
+linecols = ["red","green","blue","cyan","magenta","black"];
+linecols_max = repmat(linecols,size(setArray)); %set max amount of colors
+linecols = linecols_max(setArray);
+
+
+
+% p1 = times(1);
+% p2 = times(end);
+% intfactor = 0;
+% if intfactor~=1
+% timex = linspace(p1,p2,round(pnts*intfactor));
+% else
+% timex = timeor;
+% end
+timex = times;
+%
+% Colors
+%
+cwm = handles.cwm;
+cvl = handles.cvl;
+%
+% latmin = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+% latmax = zeros(1, length(jbin)*length(jchannel)*length(jseta));
+axes(handles.axes1);
+% fntsz = get(handles.edit_report, 'FontSize');
+% set(handles.edit_report, 'FontSize', fntsz*1.5 )
+% set(handles.edit_report, 'String', sprintf('\nWorking...\n'))
+%drawnow
+% tic
+for i = 1:numel(jseta)
+
+ seta = jseta(i);
+
+ AverageAccuracy = ALLMVPC(seta).average_score; %index datum(or data)
+
+ if isfield(ALLMVPC(seta), 'DecodingMethod')
+ datatype = ALLMVPC(seta).DecodingMethod;
+ else
+ datatype = 'None';
+ end
+
+
+ if strcmpi(datatype, 'SVM')
+ meamenu = 1;
+ else
+ meamenu = 2;
+ end
+
+ if numel(jseta) > 1
+ set(handles.text_measurementv, 'String', 'Multiple');
+ set(handles.text11,'String','Multiple');
+ else
+ set(handles.text_measurementv, 'String', measurearray{meamenu});
+ if meamenu == 1
+ set(handles.text11,'String','Decoding Accuracy (proportion correct)');
+ elseif meamenu == 2
+ set(handles.text11,'String','Distance (uV)');
+ end
+ end
+
+
+ %plot
+ plot(timex,AverageAccuracy, 'LineWidth',1,'Color',linecols(seta));
+ axis([xlim ylim]);
+ hold on
+
+ if handles.chance == 1
+ chancelvl = ALLMVPC(seta).chance;
+ line([timex(1),timex(end)],[chancelvl,chancelvl],...
+ 'LineStyle','--','Color','black'); %chance line
+
+ end
+
+ if handles.stderror == 1
+ indxalpha = handles.popupmenu_alpha.Value;
+ stdalpha = str2num(handles.alpha{indxalpha});
+ yt1 = AverageAccuracy - ALLMVPC(seta).stderror;
+ yt2 = AverageAccuracy + ALLMVPC(seta).stderror;
+% yt1 = data4plot(1,:,binArray(ibin)) - ERP.binerror(chanArray(i),:,binArray(ibin)).*errorstd;
+% yt2 = data4plot(1,:,binArray(ibin)) + ERP.binerror(chanArray(i),:,binArray(ibin)).*errorstd;
+ ciplot(yt1,yt2, ALLMVPC(seta).times, linecols(seta), stdalpha);
+
+ end
+
+
+
+end
+
+%update scales
+set(handles.edit_ylim, 'String', num2str(ylim));
+set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)));
+
+
+hold off
+
+set(handles.edit_report, 'String', '');
+set(handles.edit_report, 'FontSize', fntsz);
+
+nsetinput = length(setinput);
+if nsetinput<=1
+ set(handles.edit_file, 'String', num2str(jseta))
+ handles.iset = iset;
+ % Update handles structure
+ guidata(hObject, handles);
+end
+
+setlabelx = '';
+% if get(handles.checkbox_butterflyset, 'Value')
+% if length(setArray)>10
+% var1 = vect2colon(setArray, 'Delimiter', 'off');
+% else
+% var1 = num2str(setArray);
+% end
+% for i = 1:numel(jseta)
+% seta = jseta(i);
+% setlabelx{seta} = sprintf('(%s)', ALLMVPC(seta).mvpcname);
+% chancelabelx{seta} = ALLMVPC(seta).chance;
+% foldlabelx{seta} = ALLMVPC(seta).nCrossfolds;
+% methodlabelx{seta} = ALLMVPC(seta).DecodingMethod;
+% end
+%
+if nsetinput == 1
+ if nsetinput>10
+ var1 = vect2colon(jseta, 'Delimiter', 'off');
+ else
+ var1 = num2str(jseta);
+ if nsetinput==1
+ setlabelx = sprintf('(%s)', ALLMVPC(seta).mvpcname);
+ chancelabelx = ALLMVPC(jseta).chance;
+ % foldlabelx = ALLMVPC(jseta).nCrossfolds;
+ methodlabelx = ALLMVPC(jseta).DecodingMethod;
+ end
+
+ end
+else
+ %% what if more than one file is chosen, and with chance levels differnt?
+% if nsetinput>10
+% var1 = vect2colon(jseta, 'Delimiter', 'off');
+% else
+% var1 = num2str(jseta);
+% if nsetinput==1
+% setlabelx = sprintf('(%s)', ALLMVPC(jseta).mvpcname);
+% chancelabelx = ALLMVPC(jseta).nChance;
+% foldlabelx = ALLMVPC(jseta).nCrossfolds;
+% methodlabelx = ALLMVPC(jseta).DecodingMethod;
+% end
+%
+% end
+
+ var1 = vect2colon(jseta, 'Delimiter', 'off');
+end
+
+
+
+
+
+% if ~get(handles.checkbox_butterflybin, 'Value') && ~get(handles.checkbox_butterflychan, 'Value') && ~get(handles.checkbox_butterflyset, 'Value') &&...
+% nsetinput<=1 && nbinput<=1 && nchinput<=1
+% % none checked
+% strfrmt = ['File : %s %s\nBin : %s %s\nChannel: %s %s\nMeasu : %s\nWindow : %s\nLate : %s\nValue : %.' num2str(dig) 'f\n'];
+% values2print = {var1, setlabelx, var2, binlabelx, var3, chanlabelx, tittle, sprintf('%.2f\t', latency), sprintf('%.2f\t', truelat), val};
+% else
+
+% if ~get(handles.checkbox_butterflyset,'Value')
+% strfrmt = ['File : %s %s\nChance level: %.4f \nCrossfold Validation: %i \nDecoding Method: %s '];
+% values2print = {var1, setlabelx, chancelabelx, foldlabelx, methodlabelx};
+% else
+%
+
+% Only one file at a time
+%strfrmt = ['File : %s'];
+
+
+strfrmt = repmat('MVPC Details \nFile %s: %s \nChance: %.4f \nMethod: %s',[1,numel(jseta)]);
+
+p = 1;
+for j = 1:1
+ %only 1 file
+ if p == 1
+ values2print = {var1};
+ end
+ p = p + 1;
+ values2print{p} = setlabelx;
+ p = p + 1;
+ values2print{p} = chancelabelx;
+ p = p + 1;
+ values2print{p} = methodlabelx;
+end
+
+
+repo = sprintf(strfrmt, values2print{:});
+% if ~isempty(nanindxfile) && length(jseta)>1
+% repo = sprintf('%sNaN values found at files: %s', repo, num2str(nanindxfile));
+% end
+set(handles.edit_report, 'String', repo)
+
+%axis([xlim ylim]);
+
+
+% hold off
+drawnow
+
+%nsetinput = length(setinput);
+
+
+
+
+
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = mvpcviewerGUI_OutputFcn(hObject, eventdata, handles)
+% varargout cell array for returning output args (see VARARGOUT);
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Get default command line output from handles structure
+
+varargout{1} = handles.output;
+
+
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+
+
+function edit_file_Callback(hObject, eventdata, handles)
+% hObject handle to edit_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_file as text
+% str2double(get(hObject,'String')) returns contents of edit_file as a double
+
+try
+ iset = eval(get(hObject,'String'));
+catch
+ msgboxText = 'You did not input a valid file number';
+ title_msg = 'ERPLAB: MVPCviewer() error:';
+ errorfound(msgboxText, title_msg);
+ set(hObject,'String',handles.iset);
+ return
+end
+
+if max(iset) > max(handles.setArray)
+ msgboxText = 'You did not input a valid file number';
+ title_msg = 'ERPLAB: MVPCviewer() error:';
+ errorfound(msgboxText, title_msg);
+ set(hObject,'String',handles.iset);
+ return
+end
+
+%update listbox
+set(handles.listbox_mvpcnames, 'Value', iset);
+
+%query reasonable xlim & ylim
+
+ALLMVPC = handles.ALLMVPA;
+times = ALLMVPC(iset).times;
+datatype = ALLMVPC(iset).DecodingMethod;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(iset).chance*4 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(iset).chance*4];
+
+ end
+
+else
+ xlim = [min(times) max(times)];
+ ylim = [abs(min(ALLMVPC(iset).average_score))*-1.10 max(ALLMVPC(iset).average_score)*1.10];
+
+end
+
+%ylim = str2num(get(handles.edit_ylim, 'String' ));
+%xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset, xlim, ylim)
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_file_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in pushbutton_left_file.
+function pushbutton_left_file_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_left_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% tittle = handles.tittle;
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+check_iset = iset-1;
+
+if check_iset<1
+ return; %iset = 1;
+else
+ iset = check_iset;
+end
+%handles.iset = iset;
+
+%update listbox
+set(handles.listbox_mvpcnames,'Value',iset);
+
+% Update handles structure
+guidata(hObject, handles);
+
+%query reasonable xlim & ylim
+
+ALLMVPC = handles.ALLMVPA;
+times = ALLMVPC(iset).times;
+datatype = ALLMVPC(iset).DecodingMethod;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(iset).chance*4 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(iset).chance*4];
+
+ end
+
+else
+ xlim = [min(times) max(times)];
+ ylim = [abs(min(ALLMVPC(iset).average_score))*-1.10 max(ALLMVPC(iset).average_score)*1.10];
+
+end
+
+%ylim = str2num(get(handles.edit_ylim, 'String' ));
+%xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset, xlim, ylim)
+
+
+% --- Executes on button press in pushbutton_right_file.
+function pushbutton_right_file_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_right_file (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+%tittle = handles.tittle;
+setArray = handles.setArray;
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+check_iset = iset+1;
+
+if check_iset>length(setArray)
+ return; %iset = length(setArray);
+else
+ iset = check_iset;
+end
+handles.iset = iset;
+
+set(handles.listbox_mvpcnames,'Value',iset);
+
+% Update handles structure
+guidata(hObject, handles);
+
+ALLMVPC = handles.ALLMVPA;
+times = ALLMVPC(iset).times;
+datatype = ALLMVPC(iset).DecodingMethod;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(iset).chance*4 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(iset).chance*4];
+
+ end
+
+else
+ xlim = [min(times) max(times)];
+ ylim = [abs(min(ALLMVPC(iset).average_score))*-1.10 max(ALLMVPC(iset).average_score)*1.10];
+
+end
+
+% ylim = str2num(get(handles.edit_ylim, 'String' ));
+% xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset,xlim,ylim)
+
+
+% --- Executes on button press in checkbox_butterflyset.
+function checkbox_butterflyset_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_butterflyset (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+setArray = handles.setArray;
+if get(hObject, 'Value')
+ set(handles.edit_file, 'String', vect2colon(setArray, 'Delimiter', 'off'))
+ set(handles.edit_file, 'Enable', 'off');
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+
+else
+ set(handles.edit_file, 'Enable', 'on');
+ setinput = str2num(get(handles.edit_file, 'String'));
+ if length(setinput)>1
+ setinput = setinput(1);
+ [xxx, iset] = closest(setArray, setinput);
+ handles.iset=iset;
+ set(handles.edit_file, 'String', num2str(setinput))
+ end
+ if length(setinput)<=1
+ set(handles.pushbutton_right_file, 'Enable', 'on')
+ set(handles.pushbutton_left_file, 'Enable', 'on')
+ else
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ end
+end
+
+% tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+%
+% if isempty(xlim) || isempty(ylim)
+% return
+% end
+
+% ich = handles.ich;
+% ibin = handles.ibin;
+iset = handles.iset;
+
+mplotdata(hObject, handles, iset, xlim, ylim)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_butterflyset
+
+
+
+function edit_report_Callback(hObject, eventdata, handles)
+% hObject handle to edit_report (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_report as text
+% str2double(get(hObject,'String')) returns contents of edit_report as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_report_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_report (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in checkbox_chance.
+function checkbox_chance_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_chance (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+iset = handles.iset;
+if get(hObject,'Value')
+ handles.chance = 1;
+else
+ handles.chance = 0;
+end
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles,iset,xlim,ylim)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_chance
+
+
+
+function edit_ylim_Callback(hObject, eventdata, handles)
+% hObject handle to edit_ylim (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_ylim as text
+% str2double(get(hObject,'String')) returns contents of edit_ylim as a double
+%tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if length(xlim)~=2 || length(ylim)~=2 || any(isnan(xlim)) || any(isnan(ylim)) || any(isinf(xlim)) || any(isinf(ylim)) || xlim(1)>=xlim(2) || ylim(1)>=ylim(2)
+ msgboxText = 'Invalid scale!\n You must enter 2 numeric values on each range.\tThe first one must be lower than the second one.';
+ title = 'ERPLAB: mvpciewerGUI, invalid baseline input';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+handles.ylim_set = ylim;
+handles.xlim_set = xlim;
+
+guidata(hObject, handles); %maintain set limits
+
+iset = handles.iset;
+
+mplotdata(hObject, handles, iset, xlim, ylim)
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_ylim_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_ylim (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+
+function edit_xlim_Callback(hObject, eventdata, handles)
+% hObject handle to edit_xlim (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of edit_xlim as text
+% str2double(get(hObject,'String')) returns contents of edit_xlim as a double
+%tittle = handles.tittle;
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+if length(xlim)~=2 || length(ylim)~=2 || any(isnan(xlim)) || any(isnan(ylim)) || any(isinf(xlim)) || any(isinf(ylim)) || xlim(1)>=xlim(2) || ylim(1)>=ylim(2)
+ msgboxText = 'Invalid scale!\n You must enter 2 numeric values on each range.\tThe first one must be lower than the second one.';
+ title = 'ERPLAB: mvpciewerGUI, invalid baseline input';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+handles.ylim_set = ylim;
+handles.xlim_set = xlim;
+
+guidata(hObject, handles); %maintain set limits
+
+iset = handles.iset;
+
+mplotdata(hObject, handles, iset, xlim, ylim)
+
+
+% --- Executes during object creation, after setting all properties.
+function edit_xlim_CreateFcn(hObject, eventdata, handles)
+% hObject handle to edit_xlim (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in pushbutton_createplot.
+function pushbutton_createplot_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_createplot (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% h1=handles.axes1;
+% %
+% % Create figure
+% %
+% hbig = figure('Name','ERP VIEWER',...
+% 'NumberTitle','on', 'Tag', 'Viewer_figure');erplab_figtoolbar(hbig);
+% % objects=allchild(h1);
+% copyobj(h1,hbig);
+% opengl software
+OFF_STD = 0.25; % std dev of figure offset
+MIN_OFF = 0.15; % minimum offset for new figure
+BORDER = 0.04; % screen edge tolerance
+
+fig=handles.gui_chassis;
+sel=handles.axes1;
+%
+% Get position for new figure
+%
+set(sel,'Units','normalized');
+place = get(sel,'Position');
+cmap = colormap;
+% newxy = (OFF_STD*randn(1,2))+place(1,1:2);
+% newx = newxy(1);newy=newxy(2);
+%
+% if abs(newx-place(1,1))1-BORDER, newx=1-BORDER-place(3); end
+% if newy+place(4)>1-BORDER, newy=1-BORDER-place(4); end
+
+% newfig = figure('Units','Normalized','Position',[newx,newy,place(1,3:4)]);
+newfig = figure('Units','Normalized','Position', place, 'Name','MVPC VIEWER', 'NumberTitle','on', 'Tag', 'Viewer_figure');
+
+%
+% Copy object to new figure
+%
+set(newfig,'Color',[1 1 1]);
+copyobj(sel,newfig);
+set(gca,'Position',[0.130 0.110 0.775 0.815]);
+set(gca,'Box', 'off')
+colormap(cmap);
+erplab_figtoolbar(newfig)
+
+% %
+% % Increase font size
+% %
+% set(findobj('parent',newfig,'type','axes'),'FontSize',14);
+% set(get(gca,'XLabel'),'FontSize',16)
+% set(get(gca,'YLabel'),'FontSize',16)
+% set(get(gca,'Title'),'Fontsize',16);
+%
+% Add xtick and ytick labels if missing
+%
+% if strcmp(get(gca,'Box'),'on')
+% set(gca,'xticklabelmode','auto')
+% set(gca,'xtickmode','auto')
+% set(gca,'yticklabelmode','auto')
+% set(gca,'ytickmode','auto')
+% end
+%
+% Turn on zoom in the new figure
+%
+% zoom on;
+pause(0.2)
+
+%latency = handles.latency;
+%handles.output = NaN;
+
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+
+% --- Executes on button press in checkbox_stderror.
+function checkbox_stderror_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox_stderror (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox_stderror
+
+iset = handles.iset;
+if get(hObject,'Value')
+ handles.stderror = 1;
+else
+ handles.stderror = 0;
+end
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles,iset,xlim,ylim)
+
+
+% --- Executes on selection change in popupmenu_alpha.
+function popupmenu_alpha_Callback(hObject, eventdata, handles)
+% hObject handle to popupmenu_alpha (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_alpha contents as cell array
+% contents{get(hObject,'Value')} returns selected item from popupmenu_alpha
+iset = handles.iset;
+if get(hObject,'Value')
+ handles.stderror = 1;
+else
+ handles.stderror = 0;
+end
+
+ylim = str2num(get(handles.edit_ylim, 'String' ));
+xlim = str2num(get(handles.edit_xlim, 'String' ));
+
+mplotdata(hObject, handles,iset,xlim,ylim)
+
+
+% --- Executes during object creation, after setting all properties.
+function popupmenu_alpha_CreateFcn(hObject, eventdata, handles)
+% hObject handle to popupmenu_alpha (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: popupmenu controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in radiobutton1.
+function radiobutton1_Callback(hObject, eventdata, handles)
+% hObject handle to radiobutton1 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+set(handles.radiobutton2,'Value',0);
+set(handles.listbox_mvpcnames,'Enable','off');
+set(handles.pushbutton_addmvpc,'Enable','off');
+
+set(handles.text3,'String','MVPC index');
+
+%plot first MVPCset
+
+ALLMVPC = handles.ALLMVPA_reset; %obtain reset value
+setArray = 1:length(ALLMVPC);
+
+ if isfield(ALLMVPC(1), 'DecodingMethod')
+ datatype = ALLMVPC(1).DecodingMethod;
+
+ if strcmpi(datatype,'SVM')
+ % here, treat SEM data like ERP data
+ datatype = 'SVM';
+ % datatype2 = 'SEM';
+ end
+
+ else
+ datatype = 'SVM';
+ end
+
+
+ if strcmpi(datatype, 'SVM')
+ meamenu = 1;
+ else
+ meamenu = 2
+ end
+
+ measurearray = handles.measurearray;
+
+ handles.chance = 0;
+ handles.stderror = 0;
+ handles.alpha = {'0.10','0.20','0.30','0.40','0.50','0.60','0.70','0.80','0.90','1.0'};
+ set(handles.popupmenu_alpha,'String', handles.alpha);
+ set(handles.popupmenu_alpha,'Value',7);
+
+ set(handles.text_measurementv, 'String', measurearray{meamenu});
+
+
+ handles.ALLMVPA = ALLMVPC;
+ %handles.binArray = binArray;
+ %handles.chanArray = chanArray;
+ handles.setArray = setArray;
+ %handles.ich = 1;
+ %handles.ibin = 1;
+ handles.iset = 1;
+ %handles.orilatency = latency;
+ %handles.blc = blc;
+ %handles.moption = moption;
+ %handles.tittle = tittle;
+ handles.dig = 3;
+ handles.x1 = -1.75;
+ handles.x2 = 1.75;
+
+
+
+ iset = 1;
+ times = ALLMVPC(1).times;
+ if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(1).chance*3 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(1).chance*3];
+
+ end
+
+ else
+ xlim = [0 30];
+ ylim = [0 15];
+
+ end
+
+
+ set(handles.edit_ylim, 'String', num2str(ylim));
+ set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)));
+
+ set(handles.edit_file, 'String', num2str(iset));
+
+ set(handles.checkbox_butterflyset,'Value', 0);
+ set(handles.checkbox_stderror,'Value', 0);
+
+ if length(setArray)==1
+ set(handles.checkbox_butterflyset, 'Enable', 'off')
+ % if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ end
+ handles.datatype = datatype;
+
+
+
+ %
+ % Plot figure
+ %
+ % Update handles structure
+ guidata(hObject, handles);
+
+
+ mplotdata(hObject, handles, iset, xlim, ylim);
+
+
+
+
+
+
+
+
+% Hint: get(hObject,'Value') returns toggle state of radiobutton1
+
+
+% --- Executes on button press in radiobutton2.
+function radiobutton2_Callback(hObject, eventdata, handles)
+% hObject handle to radiobutton2 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+set(handles.radiobutton1,'Value',0);
+set(handles.listbox_mvpcnames,'Enable','on');
+set(handles.pushbutton_addmvpc,'Enable','on');
+
+if isempty(get(handles.listbox_mvpcnames,'String'))
+ set(handles.listbox_mvpcnames,'String',{'new mvpcset'});
+ set(handles.edit_file,'String','0');
+else
+
+ set(handles.listbox_mvpcnames,'Value',1);
+ set(handles.listbox_mvpcnames,'String',{'new mvpcset'});
+ set(handles.edit_file,'String','0');
+end
+
+set(handles.text3,'String','File index');
+
+
+
+% Hint: get(hObject,'Value') returns toggle state of radiobutton2
+
+
+% --- Executes on selection change in listbox_mvpcnames.
+function listbox_mvpcnames_Callback(hObject, eventdata, handles)
+% hObject handle to listbox_mvpcnames (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hints: contents = cellstr(get(hObject,'String')) returns listbox_mvpcnames contents as cell array
+% contents{get(hObject,'Value')} returns selected item from listbox_mvpcnames
+
+iset = get(hObject,'Value');
+
+%query reasonable xlim & ylim
+
+ALLMVPC = handles.ALLMVPA;
+times = ALLMVPC(iset).times;
+datatype = ALLMVPC(iset).DecodingMethod;
+if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(iset).chance*4 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(iset).chance*4];
+
+ end
+
+else
+ xlim = [min(times) max(times)];
+ ylim = [abs(min(ALLMVPC(iset).average_score))*-1.10 max(ALLMVPC(iset).average_score)*1.10];
+
+end
+
+%ylim = str2num(get(handles.edit_ylim, 'String' ));
+%xlim = str2num(get(handles.edit_xlim, 'String' ));
+mplotdata(hObject, handles,iset, xlim, ylim)
+
+
+
+% --- Executes during object creation, after setting all properties.
+function listbox_mvpcnames_CreateFcn(hObject, eventdata, handles)
+% hObject handle to listbox_mvpcnames (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles empty - handles not created until after all CreateFcns called
+
+% Hint: listbox controls usually have a white background on Windows.
+% See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on button press in pushbutton_addmvpc.
+function pushbutton_addmvpc_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton_addmvpc (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+%reset listbox
+% handles.listbox_mvpcnames.String = [];
+% handles.listbox_mvpcnames.Value = 0;
+% set(handles.listbox_mvpcnames,'String',{'new mvpcset'});
+% set(handles.edit_file,'String','0');
+
+[mvpcfname, mvpcpathname] = uigetfile({ '*.mvpc','Multivariate Pattern Classification files (*.mvpc)'; ...
+ '*.mat','Matlab (*.mat)'; ...
+ '*.*', 'All Files (*.*)'}, ...
+ 'Select an edited file', ...
+ 'MultiSelect', 'on');
+
+if isequal(mvpcfname,0)
+ disp('User selected Cancel')
+ return
+else
+ if ~iscell(mvpcfname)
+ mvpcfname = {mvpcfname};
+ end
+
+ nmvpcn = length(mvpcfname);
+
+ for i=1:nmvpcn
+ newline = fullfile(mvpcpathname, mvpcfname{i});
+ currline = get(handles.listbox_mvpcnames, 'Value');
+ fulltext = get(handles.listbox_mvpcnames, 'String');
+ indxline = length(fulltext);
+
+ if currline==indxline
+ % extra line forward
+ fulltext = cat(1, fulltext, {'new mvpcset'});
+ set(handles.listbox_mvpcnames, 'Value', currline+1)
+ else
+ set(handles.listbox_mvpcnames, 'Value', currline)
+ resto = fulltext(currline:indxline);
+ fulltext = cat(1, fulltext, {'new mvpcset'});
+ set(handles.listbox_mvpcnames, 'Value', currline+1)
+ [fulltext{currline+1:indxline+1}] = resto{:};
+ end
+
+ fulltext{currline} = newline;
+ set(handles.listbox_mvpcnames, 'String', fulltext)
+ end
+
+ indxline = length(fulltext);
+ handles.indxline = indxline;
+ handles.fulltext = fulltext;
+ handles.listname = [];
+ preindex = 0;
+ for i=1:(numel(handles.fulltext) - 1)
+
+
+ %currline = get(handles.listbox_mvpcnames, 'Value');
+ fullname = handles.listbox_mvpcnames.String{i};
+ fprintf('Loading %s\n', fullname);
+ L = load(fullname, '-mat');
+ MVPC = L.MVPC;
+ % if i == 1
+ % BEST = L.BEST;
+ % else
+ % BEST(i) = L.BEST;
+ % end
+
+ if i == 1
+ ALLMVPC = MVPC;
+
+ else
+ ALLMVPC(i+preindex) = MVPC;
+
+ end
+
+ end
+
+ %plot latest entry
+
+ if isfield(ALLMVPC(end), 'DecodingMethod')
+ datatype = ALLMVPC(end).DecodingMethod;
+
+ if strcmpi(datatype,'SVM')
+ % here, treat SEM data like ERP data
+ datatype = 'SVM';
+ % datatype2 = 'SEM';
+ end
+
+ else
+ datatype = 'SVM';
+ end
+
+
+ if strcmpi(datatype, 'SVM')
+ meamenu = 1;
+ else
+ meamenu = 2
+ end
+
+ measurearray = handles.measurearray ;
+
+
+
+ handles.chance = 0;
+ handles.stderror = 0;
+ handles.alpha = {'0.10','0.20','0.30','0.40','0.50','0.60','0.70','0.80','0.90','1.0'};
+ set(handles.popupmenu_alpha,'String', handles.alpha);
+ set(handles.popupmenu_alpha,'Value',7);
+
+
+ set(handles.text_measurementv, 'String', measurearray{meamenu});
+ % set(handles.text_measurementv, 'Value', meamenu);
+ % set(handles.text_measurementv, 'Enable', 'inactive');
+ setArray = 1:length(ALLMVPC);
+
+ handles.ALLMVPA = ALLMVPC;
+ %handles.binArray = binArray;
+ %handles.chanArray = chanArray;
+ handles.setArray = setArray;
+ %handles.ich = 1;
+ %handles.ibin = 1;
+ handles.iset = setArray(end);
+ %handles.orilatency = latency;
+ %handles.blc = blc;
+ %handles.moption = moption;
+ %handles.tittle = tittle;
+ handles.dig = 3;
+ handles.x1 = -1.75;
+ handles.x2 = 1.75;
+
+
+ % ibin = 1;
+ % ich = 1;
+ iset = setArray(end);
+ times = ALLMVPC(end).times;
+ if strcmpi(datatype, 'SVM')
+ xlim = [min(times) max(times)];
+ if ALLMVPC(end).chance*3 > 1
+ ylim = [0 1];
+ else
+ ylim = [0 ALLMVPC(end).chance*3];
+
+ end
+
+ else
+ xlim = [0 30];
+ ylim = [0 15];
+
+ end
+
+
+ set(handles.edit_ylim, 'String', num2str(ylim));
+ set(handles.edit_xlim, 'String', sprintf('%g %g', round(xlim)));
+
+ set(handles.edit_file, 'String', num2str(iset));
+
+ set(handles.checkbox_butterflyset,'Value', 0);
+ set(handles.checkbox_stderror,'Value', 0);
+
+ if length(setArray)==1
+ set(handles.checkbox_butterflyset, 'Enable', 'off')
+ % if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'off')
+ set(handles.pushbutton_left_file, 'Enable', 'off')
+ else
+ set(handles.checkbox_butterflyset, 'Enable', 'on')
+ % if frdm; set(handles.edit_file, 'Enable', 'off');end
+ set(handles.pushbutton_right_file, 'Enable', 'on')
+ set(handles.pushbutton_left_file, 'Enable', 'on')
+
+ end
+ handles.datatype = datatype;
+
+ % Update handles structure
+ guidata(hObject, handles);
+
+ mplotdata(hObject, handles, iset, xlim, ylim)
+
+
+
+end
+
+
+
+
+
+% --- Executes when user attempts to close gui_chassis.
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+% hObject handle to gui_chassis (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Hint: delete(hObject) closes the figure
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = [];
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
diff --git a/GUIs/plotConfusionGUI.mlapp b/GUIs/plotConfusionGUI.mlapp
new file mode 100644
index 00000000..362d4065
Binary files /dev/null and b/GUIs/plotConfusionGUI.mlapp differ
diff --git a/GUIs/ploterpGUI.fig b/GUIs/ploterpGUI.fig
index cb44f28e..effa142f 100755
Binary files a/GUIs/ploterpGUI.fig and b/GUIs/ploterpGUI.fig differ
diff --git a/GUIs/savemybestGUI.fig b/GUIs/savemybestGUI.fig
new file mode 100644
index 00000000..e5f1d67d
Binary files /dev/null and b/GUIs/savemybestGUI.fig differ
diff --git a/GUIs/savemybestGUI.m b/GUIs/savemybestGUI.m
new file mode 100644
index 00000000..1fcf6416
--- /dev/null
+++ b/GUIs/savemybestGUI.m
@@ -0,0 +1,362 @@
+%
+% Author: Aaron Matthew Simmons & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2009
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function varargout = savemybestGUI(varargin)
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @savemybestGUI_OpeningFcn, ...
+ 'gui_OutputFcn', @savemybestGUI_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+
+if nargin && ischar(varargin{1})
+ if isempty(strfind(varargin{1},' ')) && isempty(str2num(varargin{1})) && isempty(strfind(varargin{1},'&'))
+ gui_State.gui_Callback = str2func(varargin{1});
+ %gui_State.gui_Callback = [];
+ end
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+% -------------------------------------------------------------------------
+function savemybestGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+
+% Choose default command line output for savemybestGUI
+
+try
+ bestname = varargin{1};
+ filename = varargin{2};
+ overw = varargin{3};
+ bestname = bestname{1}; %bypass the cell index if number
+catch
+ bestname = '';
+ filename = '';
+ overw = 0;
+end
+
+
+
+handles.bestnameor = bestname;
+handles.output = [];
+bestmenu = findobj('tag', 'bestsets');
+
+if ~isempty(bestmenu)
+ handles.menubest = get(bestmenu);
+ set(handles.menubest.Children, 'Enable','off');
+end
+
+handles.owfp = 0; % over write file permission
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save BESTset GUI'])
+set(handles.edit_bestname, 'String', bestname);
+
+if ~isempty(filename)
+ set(handles.edit_saveas, 'Enable', 'on');
+ set(handles.edit_saveas, 'String', filename);
+ set(handles.radiobutton_saveas, 'Value', 1);
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'on');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'on');
+ set(handles.pushbutton_browse, 'Enable', 'on');
+else
+ set(handles.edit_saveas, 'String', '');
+ set(handles.radiobutton_saveas, 'Value', 0);
+ set(handles.edit_saveas, 'Enable', 'off');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Visible','off'); %not necessary for BESTset
+ set(handles.pushbutton_browse, 'Enable', 'off');
+end
+if overw==0
+ set(handles.radiobutton_newbestset, 'Value', 1);
+ set(handles.radiobutton_overwrite, 'Value', 0);
+else
+ set(handles.radiobutton_newbestset, 'Value', 0);
+ set(handles.radiobutton_overwrite, 'Value', 1);
+end
+[nset CURRENTBEST] = getallbeststate;
+if nset>0
+ set(handles.text_question,'String', ['Your active BESTset is # ' num2str(CURRENTBEST)],...
+ 'FontWeight','Bold', 'FontSize', 12)
+ set(handles.radiobutton_overwrite,'String', ['Overwrite in memory BESTset # ' num2str(CURRENTBEST)])
+ set(handles.radiobutton_newbestset,'String', ['Create a new BESTset # ' num2str(nset+1)])
+else
+ set(handles.text_question,'String', 'You are creating a new BESTset',...
+ 'FontSize', 12, 'FontWeight','Bold')
+ set(handles.radiobutton_overwrite,'String', 'Overwrite in memory')
+ set(handles.radiobutton_newbestset, 'Value', 1);
+ set(handles.radiobutton_overwrite, 'Value', 0);
+ set(handles.radiobutton_overwrite,'Enable', 'off')
+ set(handles.radiobutton_newbestset,'String', ['Create a new bestset # ' num2str(nset+1)])
+end
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+% Update handles structure
+guidata(hObject, handles);
+
+% help
+% helpbutton
+
+% UIWAIT makes savemybestGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function varargout = savemybestGUI_OutputFcn(hObject, eventdata, handles)
+% Get default command line output from handles structure
+try
+ set(handles.menubest.Children, 'Enable','on');
+catch
+ disp('BESTset menu was not found...')
+end
+varargout{1} = handles.output;
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+% -------------------------------------------------------------------------
+function edit_bestname_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_bestname_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_saveas_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_saveas_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_browse_Callback(hObject, eventdata, handles)
+%
+% Save OUTPUT file
+%
+fndefault = get(handles.edit_saveas,'String');
+[fname, pathname] = uiputfile({'*.best', 'BEST-files (*.best)';},'Save Output file as',...
+ fndefault);
+
+if isequal(fname,0)
+ disp('User selected Cancel')
+ guidata(hObject, handles);
+ handles.owfp = 0; % over write file permission
+ guidata(hObject, handles);
+else
+ set(handles.edit_saveas,'String', fullfile(pathname, fname));
+ disp(['To save BESTset, user selected ', fullfile(pathname, fname)])
+ handles.owfp = 1; % over write file permission
+ guidata(hObject, handles);
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_cancel_Callback(hObject, eventdata, handles)
+handles.output = [];
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function pushbutton_OK_Callback(hObject, eventdata, handles)
+
+bestname = strtrim(get(handles.edit_bestname, 'String'));
+
+if isempty(bestname)
+ msgboxText = 'You must enter a BESTset filename at least!';
+ title = 'ERPLAB: Extract BEST GUI empty BEST filename';
+ errorfound(msgboxText, title);
+ return
+end
+
+fname = strtrim(get(handles.edit_saveas, 'String'));
+overw = get(handles.radiobutton_overwrite, 'Value');
+
+if ~isempty(fname) && get(handles.radiobutton_saveas, 'Value')
+
+ owfp = handles.owfp; % over write file permission
+ [pathstr, name, ext] = fileparts(fname);
+
+ if ~strcmp(ext,'.best') && ~strcmp(ext,'.mat')
+ ext = '.erp';
+ end
+ if strcmp(pathstr,'')
+ pathstr = cd;
+ end
+
+ fullname = fullfile(pathstr, [name ext]);
+
+ if exist(fullname, 'file')~=0 && owfp ==0
+ question{1} = [fullname ' already exists!'];
+ question{2} = 'Do you want to replace it?';
+ title = 'ERPLAB: Overwriting Confirmation';
+ button = askquest(question, title);
+
+ if ~strcmpi(button, 'yes')
+ return
+ end
+ end
+elseif isempty(fname) && get(handles.radiobutton_saveas, 'Value')
+ msgboxText = 'You must enter a filename!';
+ title = 'ERPLAB: Extract BEST GUI empty BEST filename';
+ errorfound(msgboxText, title);
+ return
+else
+ fullname = [];
+end
+
+handles.output = {bestname, fullname, overw};
+% Update handles structure
+guidata(hObject, handles);
+
+uiresume(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function radiobutton_saveas_Callback(hObject, eventdata, handles)
+if get(hObject, 'Value')
+ set(handles.edit_saveas, 'Enable', 'on');
+ set(handles.pushbutton_browse, 'Enable', 'on');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'on');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'on');
+else
+ set(handles.edit_saveas, 'Enable', 'off');
+ set(handles.pushbutton_browse, 'Enable', 'off');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'off');
+ set(handles.edit_saveas, 'String', '');
+end
+
+% -----------------------------------------------------------------------
+function pushbutton_same_as_filename_Callback(hObject, eventdata, handles)
+fname = get(handles.edit_saveas, 'String');
+%erpname = get(handles.edit_bestname, 'String');
+if strcmp(fname,'')
+ msgboxText = 'You must enter a filename first!';
+ title = 'ERPLAB: Extract BEST GUI empty BESTname';
+ errorfound(msgboxText, title);
+ return
+end
+[pathstr, fname, ext] = fileparts(fname);
+bestname = fname;
+set(handles.edit_bestname, 'String', bestname);
+
+% -------------------------------------------------------------------------
+function pushbutton_same_as_bestname_Callback(hObject, eventdata, handles)
+fname = get(handles.edit_saveas, 'String');
+bestname = get(handles.edit_bestname, 'String');
+if strcmp(bestname,'')
+ msgboxText = 'You must enter an bestname!';
+ title = 'ERPLAB: Extract BEST GUI empty bestname';
+ errorfound(msgboxText, title);
+ return
+end
+if ~strcmp(fname,'')
+ [pathstr, name, ext] = fileparts(fname);
+ name = bestname;
+ if ~strcmp(ext,'.best') && ~strcmp(ext,'.mat');
+ ext = '.best';
+ end
+
+ fname = fullfile(pathstr,[name ext]);
+else
+ fname=[bestname '.best'];
+end
+set(handles.edit_saveas, 'String', fname);
+
+% -------------------------------------------------------------------------
+function radiobutton_overwrite_Callback(hObject, eventdata, handles)
+
+if get(hObject,'Value')
+ set(handles.radiobutton_newbestset,'Value',0)
+ bestname = strtrim(get(handles.edit_bestname, 'String'));
+ if isempty(bestname)
+ bestname = handles.bestnameor;
+ set(handles.edit_bestname, 'String', bestname);
+ end
+else
+ set(handles.radiobutton_overwrite, 'Value',1);
+end
+
+% -------------------------------------------------------------------------
+function radiobutton_newbestset_Callback(hObject, eventdata, handles)
+
+if get(hObject,'Value')
+ set(handles.radiobutton_overwrite, 'Value',0);
+ bestname = strtrim(get(handles.edit_bestname, 'String'));
+
+ if isempty(bestname)
+ bestname = handles.bestnameor;
+ set(handles.edit_bestname, 'String', bestname);
+ end
+else
+ set(handles.radiobutton_newbestset, 'Value',1);
+
+end
+
+% -----------------------------------------------------------------------
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = '';
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
+
+
+% % --- Executes on button press in pushbutton_same_as_bestname.
+% function pushbutton_same_as_bestname_Callback(hObject, eventdata, handles)
+% % hObject handle to pushbutton_same_as_bestname (see GCBO)
+% % eventdata reserved - to be defined in a future version of MATLAB
+% % handles structure with handles and user data (see GUIDATA)
diff --git a/GUIs/savemymvpcGUI.fig b/GUIs/savemymvpcGUI.fig
new file mode 100644
index 00000000..5a9237c5
Binary files /dev/null and b/GUIs/savemymvpcGUI.fig differ
diff --git a/GUIs/savemymvpcGUI.m b/GUIs/savemymvpcGUI.m
new file mode 100644
index 00000000..5ee27e8a
--- /dev/null
+++ b/GUIs/savemymvpcGUI.m
@@ -0,0 +1,362 @@
+%
+% Author: Aaron Matthew Simmons & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2009
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function varargout = savemymvpcGUI(varargin)
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @savemymvpcGUI_OpeningFcn, ...
+ 'gui_OutputFcn', @savemymvpcGUI_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+
+if nargin && ischar(varargin{1})
+ if isempty(strfind(varargin{1},' ')) && isempty(str2num(varargin{1})) && isempty(strfind(varargin{1},'&'))
+ gui_State.gui_Callback = str2func(varargin{1});
+ %gui_State.gui_Callback = [];
+ end
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+% -------------------------------------------------------------------------
+function savemymvpcGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+
+% Choose default command line output for savemymvpcGUI
+
+try
+ bestname = varargin{1};
+ filename = varargin{2};
+ overw = varargin{3};
+ bestname = bestname{1}; %bypass the cell index if number
+catch
+ bestname = '';
+ filename = '';
+ overw = 0;
+end
+
+
+
+handles.bestnameor = bestname;
+handles.output = [];
+bestmenu = findobj('tag', 'mvpcsets');
+
+if ~isempty(bestmenu)
+ handles.menubest = get(bestmenu);
+ set(handles.menubest.Children, 'Enable','off');
+end
+
+handles.owfp = 0; % over write file permission
+
+%
+% Name & version
+%
+version = geterplabversion;
+set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save MVPCset GUI'])
+set(handles.edit_bestname, 'String', bestname);
+
+if ~isempty(filename)
+ set(handles.edit_saveas, 'Enable', 'on');
+ set(handles.edit_saveas, 'String', filename);
+ set(handles.radiobutton_saveas, 'Value', 1);
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'on');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'on');
+ set(handles.pushbutton_browse, 'Enable', 'on');
+else
+ set(handles.edit_saveas, 'String', '');
+ set(handles.radiobutton_saveas, 'Value', 0);
+ set(handles.edit_saveas, 'Enable', 'off');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Visible','off'); %not necessary for BESTset
+ set(handles.pushbutton_browse, 'Enable', 'off');
+end
+if overw==0
+ set(handles.radiobutton_newbestset, 'Value', 1);
+ set(handles.radiobutton_overwrite, 'Value', 0);
+else
+ set(handles.radiobutton_newbestset, 'Value', 0);
+ set(handles.radiobutton_overwrite, 'Value', 1);
+end
+[nset, CURRENTMVPC] = getallmvpcstate;
+if nset>0
+ set(handles.text_question,'String', ['Your active MVPCset is # ' num2str(CURRENTMVPC)],...
+ 'FontWeight','Bold', 'FontSize', 12)
+ set(handles.radiobutton_overwrite,'String', ['Overwrite in memory MVPCset # ' num2str(CURRENTMVPC)])
+ set(handles.radiobutton_newbestset,'String', ['Create a new MVPCset # ' num2str(nset+1)])
+else
+ set(handles.text_question,'String', 'You are creating a new MVPCset',...
+ 'FontSize', 12, 'FontWeight','Bold')
+ set(handles.radiobutton_overwrite,'String', 'Overwrite in memory')
+ set(handles.radiobutton_newbestset, 'Value', 1);
+ set(handles.radiobutton_overwrite, 'Value', 0);
+ set(handles.radiobutton_overwrite,'Enable', 'off')
+ set(handles.radiobutton_newbestset,'String', ['Create a new MVPCset # ' num2str(nset+1)])
+end
+
+%
+% Color GUI
+%
+handles = painterplab(handles);
+
+%
+% Set font size
+%
+handles = setfonterplab(handles);
+
+% Update handles structure
+guidata(hObject, handles);
+
+% help
+% helpbutton
+
+% UIWAIT makes savemymvpcGUI wait for user response (see UIRESUME)
+uiwait(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function varargout = savemymvpcGUI_OutputFcn(hObject, eventdata, handles)
+% Get default command line output from handles structure
+try
+ set(handles.menubest.Children, 'Enable','on');
+catch
+ disp('MVPCset menu was not found...')
+end
+varargout{1} = handles.output;
+% The figure can be deleted now
+delete(handles.gui_chassis);
+pause(0.1)
+
+% -------------------------------------------------------------------------
+function edit_bestname_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_bestname_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function edit_saveas_Callback(hObject, eventdata, handles)
+
+% -------------------------------------------------------------------------
+function edit_saveas_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_browse_Callback(hObject, eventdata, handles)
+%
+% Save OUTPUT file
+%
+fndefault = get(handles.edit_saveas,'String');
+[fname, pathname] = uiputfile({'*.mvpc', 'MVPC-files (*.mvpc)';},'Save Output file as',...
+ fndefault);
+
+if isequal(fname,0)
+ disp('User selected Cancel')
+ guidata(hObject, handles);
+ handles.owfp = 0; % over write file permission
+ guidata(hObject, handles);
+else
+ set(handles.edit_saveas,'String', fullfile(pathname, fname));
+ disp(['To save MVPCset, user selected ', fullfile(pathname, fname)])
+ handles.owfp = 1; % over write file permission
+ guidata(hObject, handles);
+end
+
+% -------------------------------------------------------------------------
+function pushbutton_cancel_Callback(hObject, eventdata, handles)
+handles.output = [];
+% Update handles structure
+guidata(hObject, handles);
+uiresume(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function pushbutton_OK_Callback(hObject, eventdata, handles)
+
+bestname = strtrim(get(handles.edit_bestname, 'String'));
+
+if isempty(bestname)
+ msgboxText = 'You must enter a MVPCset filename at least!';
+ title = 'ERPLAB: empty MVPC filename';
+ errorfound(msgboxText, title);
+ return
+end
+
+fname = strtrim(get(handles.edit_saveas, 'String'));
+overw = get(handles.radiobutton_overwrite, 'Value');
+
+if ~isempty(fname) && get(handles.radiobutton_saveas, 'Value')
+
+ owfp = handles.owfp; % over write file permission
+ [pathstr, name, ext] = fileparts(fname);
+
+ if ~strcmp(ext,'.mvpc') && ~strcmp(ext,'.mat')
+ ext = '.erp';
+ end
+ if strcmp(pathstr,'')
+ pathstr = cd;
+ end
+
+ fullname = fullfile(pathstr, [name ext]);
+
+ if exist(fullname, 'file')~=0 && owfp ==0
+ question{1} = [fullname ' already exists!'];
+ question{2} = 'Do you want to replace it?';
+ title = 'ERPLAB: Overwriting Confirmation';
+ button = askquest(question, title);
+
+ if ~strcmpi(button, 'yes')
+ return
+ end
+ end
+elseif isempty(fname) && get(handles.radiobutton_saveas, 'Value')
+ msgboxText = 'You must enter a filename!';
+ title = 'ERPLAB: Extract BEST GUI empty BEST filename';
+ errorfound(msgboxText, title);
+ return
+else
+ fullname = [];
+end
+
+handles.output = {bestname, fullname, overw};
+% Update handles structure
+guidata(hObject, handles);
+
+uiresume(handles.gui_chassis);
+
+% -------------------------------------------------------------------------
+function radiobutton_saveas_Callback(hObject, eventdata, handles)
+if get(hObject, 'Value')
+ set(handles.edit_saveas, 'Enable', 'on');
+ set(handles.pushbutton_browse, 'Enable', 'on');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'on');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'on');
+else
+ set(handles.edit_saveas, 'Enable', 'off');
+ set(handles.pushbutton_browse, 'Enable', 'off');
+ set(handles.pushbutton_same_as_bestname, 'Enable', 'off');
+ set(handles.pushbutton_same_as_filename, 'Enable', 'off');
+ set(handles.edit_saveas, 'String', '');
+end
+
+% -----------------------------------------------------------------------
+function pushbutton_same_as_filename_Callback(hObject, eventdata, handles)
+fname = get(handles.edit_saveas, 'String');
+%erpname = get(handles.edit_bestname, 'String');
+if strcmp(fname,'')
+ msgboxText = 'You must enter a filename first!';
+ title = 'ERPLAB: empty MVPCname';
+ errorfound(msgboxText, title);
+ return
+end
+[pathstr, fname, ext] = fileparts(fname);
+bestname = fname;
+set(handles.edit_bestname, 'String', bestname);
+
+% -------------------------------------------------------------------------
+function pushbutton_same_as_bestname_Callback(hObject, eventdata, handles)
+fname = get(handles.edit_saveas, 'String');
+bestname = get(handles.edit_bestname, 'String');
+if strcmp(bestname,'')
+ msgboxText = 'You must enter an mvpcname!';
+ title = 'ERPLAB: empty mvpcname';
+ errorfound(msgboxText, title);
+ return
+end
+if ~strcmp(fname,'')
+ [pathstr, name, ext] = fileparts(fname);
+ name = bestname;
+ if ~strcmp(ext,'.mvpc') && ~strcmp(ext,'.mat');
+ ext = '.mvpc';
+ end
+
+ fname = fullfile(pathstr,[name ext]);
+else
+ fname=[bestname '.mvpc'];
+end
+set(handles.edit_saveas, 'String', fname);
+
+% -------------------------------------------------------------------------
+function radiobutton_overwrite_Callback(hObject, eventdata, handles)
+
+if get(hObject,'Value')
+ set(handles.radiobutton_newbestset,'Value',0)
+ bestname = strtrim(get(handles.edit_bestname, 'String'));
+ if isempty(bestname)
+ bestname = handles.bestnameor;
+ set(handles.edit_bestname, 'String', bestname);
+ end
+else
+ set(handles.radiobutton_overwrite, 'Value',1);
+end
+
+% -------------------------------------------------------------------------
+function radiobutton_newbestset_Callback(hObject, eventdata, handles)
+
+if get(hObject,'Value')
+ set(handles.radiobutton_overwrite, 'Value',0);
+ bestname = strtrim(get(handles.edit_bestname, 'String'));
+
+ if isempty(bestname)
+ bestname = handles.bestnameor;
+ set(handles.edit_bestname, 'String', bestname);
+ end
+else
+ set(handles.radiobutton_newbestset, 'Value',1);
+
+end
+
+% -----------------------------------------------------------------------
+function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
+
+if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
+ %The GUI is still in UIWAIT, us UIRESUME
+ handles.output = '';
+ %Update handles structure
+ guidata(hObject, handles);
+ uiresume(handles.gui_chassis);
+else
+ % The GUI is no longer waiting, just close it
+ delete(handles.gui_chassis);
+end
+
+
+% % --- Executes on button press in pushbutton_same_as_bestname.
+% function pushbutton_same_as_bestname_Callback(hObject, eventdata, handles)
+% % hObject handle to pushbutton_same_as_bestname (see GCBO)
+% % eventdata reserved - to be defined in a future version of MATLAB
+% % handles structure with handles and user data (see GUIDATA)
diff --git a/GUIs/scalplotGUI.fig b/GUIs/scalplotGUI.fig
index 058a6019..fa559078 100755
Binary files a/GUIs/scalplotGUI.fig and b/GUIs/scalplotGUI.fig differ
diff --git a/eegplugin_erplab.m b/eegplugin_erplab.m
old mode 100755
new mode 100644
index 4c17d863..370ef150
--- a/eegplugin_erplab.m
+++ b/eegplugin_erplab.m
@@ -1,10 +1,10 @@
-% Author: Guanghui Zhang, Aaron Matthew Simmons,
-% Andrew X Stewart, Javier Lopez-Calderon & Steven Luck
+% Author: Aaron Matthew Simmons, Guanghui Zhang, Andrew X Stewart,
+% Javier Lopez-Calderon & Steven Luck
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
-% 2007-2020
-% Version 9.20
+% 2007-2023
+% Version 10.0
%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
%
@@ -29,12 +29,11 @@
function currvers = eegplugin_erplab(fig, trystrs, catchstrs)
-
-
-
+erplab_default_values % script
+currvers = ['erplab' erplabver];
if nargin < 3
- error('eegplugin_erplab requires 3 arguments');
+ error('eegplugin_erplab requires 3 arguments');
end
%
@@ -42,7 +41,7 @@
%
p = which('eegplugin_erplab','-all');
if length(p)>1
- fprintf('\nERPLAB WARNING: More than one ERPLAB folder was found.\n\n');
+ fprintf('\nERPLAB WARNING: More than one ERPLAB folder was found.\n\n');
end
p = p{1};
p = p(1:findstr(p,'eegplugin_erplab.m')-1);
@@ -50,10 +49,10 @@
addpath(genpath(p))
-
try
clearvars observe_ERPDAT;
clearvars v_ERPDAT;
+
catch
end
@@ -72,9 +71,6 @@
observe_ERPDAT.Count_currentERP = 0;
observe_ERPDAT.Process_messg = 0;%%change end
-
-
-
%
% CHECK VERSION NUMBER & FOLDER NAME
% Grab the end of the path, like '7.0'
@@ -97,19 +93,19 @@
% CHECK EEGLAB Version
%
if exist('memoryerp.erpm','file')==2
- iserpmem = 1; % file for memory exists
+ iserpmem = 1; % file for memory exists
else
- iserpmem = 0; % does not exist file for memory
+ iserpmem = 0; % does not exist file for memory
end
egv = regexp(eeg_getversion,'^(\d+)\.+','tokens','ignorecase');
eegversion = str2num(char(egv{:}));
check_matlab_version;
if eegversion==11
- if iserpmem==1
- warning('ERPLAB:Warning', 'ERPLAB is not compatible with EEGLAB 11. Please try either a newer or an older version of EEGLAB.')
- else
- warndlg(sprintf('ERPLAB is not compatible with EEGLAB 11.\nPlease try either a newer or an older version of EEGLAB.'),'!! Warning !!', 'modal')
- end
+ if iserpmem==1
+ warning('ERPLAB:Warning', 'ERPLAB is not compatible with EEGLAB 11. Please try either a newer or an older version of EEGLAB.')
+ else
+ warndlg(sprintf('ERPLAB is not compatible with EEGLAB 11.\nPlease try either a newer or an older version of EEGLAB.'),'!! Warning !!', 'modal')
+ end
end
%
@@ -120,13 +116,13 @@
filenames = {filst.name};
if length(filenames)>3 % '.' '..' 'erplab_box_readme.md'
- recycle on;
- delete(fullfile(dirBox,'*'))
- fprintf('\nERPLAB WARNING: Temporary files (from your last session) within erplab_Box folder were sent to recycle bin.\n\n')
-
- file_id = fopen(fullfile(dirBox, 'erplab_box_readme.md'), 'w');
- fprintf(file_id, 'This is a placeholder file, so that git does not delete the `erplab_Box` folder.');
- fclose(file_id);
+ recycle on;
+ delete(fullfile(dirBox,'*'))
+ fprintf('\nERPLAB WARNING: Temporary files (from your last session) within erplab_Box folder were sent to recycle bin.\n\n')
+
+ file_id = fopen(fullfile(dirBox, 'erplab_box_readme.md'), 'w');
+ fprintf(file_id, 'This is a placeholder file, so that git does not delete the `erplab_Box` folder.');
+ fclose(file_id);
end
%
@@ -135,44 +131,44 @@
% Check erpmem version matches current version
if iserpmem
- oldmem = load(fullfile(p,'memoryerp.erpm'), '-mat');
- memver = oldmem.erplabver;
- if strcmp(memver,erplabver) == 0
- disp('Updating erpmem with current version number')
- mshock = oldmem.mshock;
- save(fullfile(p,'memoryerp.erpm'),'erplabrel','erplabver','ColorB','ColorF','errorColorB', 'errorColorF','fontsizeGUI','fontunitsGUI','mshock');
- end
+ oldmem = load(fullfile(p,'memoryerp.erpm'), '-mat');
+ memver = oldmem.erplabver;
+ if strcmp(memver,erplabver) == 0
+ disp('Updating erpmem with current version number')
+ mshock = oldmem.mshock;
+ save(fullfile(p,'memoryerp.erpm'),'erplabrel','erplabver','ColorB','ColorF','errorColorB', 'errorColorF','fontsizeGUI','fontunitsGUI','mshock');
+ end
end
if iserpmem==0
- mshock = 0;
- try
- % saves memory file
- %
- % IMPORTANT: If this file (saved variables inside memoryerp.erpm) is modified then also must be modified the same line at erplabamnesia.m
- %
- save(fullfile(p,'memoryerp.erpm'),'erplabrel','erplabver','ColorB','ColorF','errorColorB', 'errorColorF','fontsizeGUI','fontunitsGUI','mshock');
- catch
- % saves memory variable at workspace
- msgboxText = ['\nERPLAB could not find a file for storing its GUI memory or \n'...
- 'does not have permission for writting on it.\n\n'...
- 'Therefore, ERPLAB''s memory will be stored at Matlab''s workspace and will last 1 session.\n\n'];
-
- % message on command window
- fprintf('%s\n', repmat('*',1,50));
- fprintf('"Houston, we''ve had a problem here": \n %s\n', sprintf(msgboxText));
- bottomline = 'If you think this is a bug, please report the error to erplabtoolbox@gmail.com and not to the EEGLAB developers.';
- disp(bottomline)
- fprintf('%s\n', repmat('*',1,50));
-
- %
- % IMPORTANT: If this strucure (vmemoryerp) is modified then also must be modified the same line at erplabamnesia.m
- %
- vmemoryerp = struct('erplabrel',erplabrel,'erplabver',erplabver,'ColorB',ColorB,'ColorF',ColorF,'fontsizeGUI',fontsizeGUI,...
- 'fontunitsGUI',fontunitsGUI,'mshock',mshock, 'errorColorF', errorColorF, 'errorColorB', errorColorB);
- assignin('base','vmemoryerp',vmemoryerp);
- end
+ mshock = 0;
+ try
+ % saves memory file
+ %
+ % IMPORTANT: If this file (saved variables inside memoryerp.erpm) is modified then also must be modified the same line at erplabamnesia.m
+ %
+ save(fullfile(p,'memoryerp.erpm'),'erplabrel','erplabver','ColorB','ColorF','errorColorB', 'errorColorF','fontsizeGUI','fontunitsGUI','mshock');
+ catch
+ % saves memory variable at workspace
+ msgboxText = ['\nERPLAB could not find a file for storing its GUI memory or \n'...
+ 'does not have permission for writting on it.\n\n'...
+ 'Therefore, ERPLAB''s memory will be stored at Matlab''s workspace and will last 1 session.\n\n'];
+
+ % message on command window
+ fprintf('%s\n', repmat('*',1,50));
+ fprintf('"Houston, we''ve had a problem here": \n %s\n', sprintf(msgboxText));
+ bottomline = 'If you think this is a bug, please report the error to erplabtoolbox@gmail.com and not to the EEGLAB developers.';
+ disp(bottomline)
+ fprintf('%s\n', repmat('*',1,50));
+
+ %
+ % IMPORTANT: If this strucure (vmemoryerp) is modified then also must be modified the same line at erplabamnesia.m
+ %
+ vmemoryerp = struct('erplabrel',erplabrel,'erplabver',erplabver,'ColorB',ColorB,'ColorF',ColorF,'fontsizeGUI',fontsizeGUI,...
+ 'fontunitsGUI',fontunitsGUI,'mshock',mshock, 'errorColorF', errorColorF, 'errorColorB', errorColorB);
+ assignin('base','vmemoryerp',vmemoryerp);
+ end
end
%
@@ -204,7 +200,11 @@
global ALLERP
global ALLBEST
global ALLMVPC
-
+try
+ ALLERP = evalin('base', 'ALLERP');
+ ALLERP = [];
+catch
+end
%---------------------------------------------------------------------------------------------------
% |
%
@@ -214,7 +214,7 @@
e_catch = 'catch, eeglab_error; LASTCOM= ''''; clear EEGTMP ALLEEGTMP STUDYTMP; end;';
nocheck = e_try;
storeallcall = [ 'if ~isempty(ALLEEG) & ~isempty(ALLEEG(1).data), ALLEEG = eeg_checkset(ALLEEG);' ...
- 'EEG = eeg_retrieve(ALLEEG, CURRENTSET); eegh(''ALLEEG = eeg_checkset(ALLEEG); EEG = eeg_retrieve(ALLEEG, CURRENTSET);''); end;' ];
+ 'EEG = eeg_retrieve(ALLEEG, CURRENTSET); eegh(''ALLEEG = eeg_checkset(ALLEEG); EEG = eeg_retrieve(ALLEEG, CURRENTSET);''); end;' ];
ifeeg = 'if ~isempty(LASTCOM) & ~isempty(EEG),';
e_storeall_nh = [e_catch 'eegh(LASTCOM);' ifeeg storeallcall 'disp(''Done.''); end; eeglab(''redraw'');'];
% cb_loaderplabset = [ nocheck '[ALLEEG EEG CURRENTSET LASTCOM] = pop_loadmerplabset(ALLEEG, EEG);' e_storeall_nh];
@@ -232,14 +232,14 @@
% ERPLAB NEST-MENU (ERPLAB at the EEGLAB's Main Menu)
%
if ispc % windows
- wfactor1 = 1.20;
- wfactor2 = 1.21;
+ wfactor1 = 1.20;
+ wfactor2 = 1.21;
elseif ismac % Mac OSX
- wfactor1 = 1.45;
- wfactor2 = 1.46;
+ wfactor1 = 1.45;
+ wfactor2 = 1.46;
else
- wfactor1 = 1.30;
- wfactor2 = 1.31;
+ wfactor1 = 1.30;
+ wfactor2 = 1.31;
end
posmainfig = get(gcf,'Position');
hframe = findobj('parent', gcf,'tag','Frame1');
@@ -347,14 +347,27 @@
comDQQsave = ['save_data_quality(ERP);'];
comDQQprint = ['dataquality_measure = print_data_quality(ERP);'];
comDQQinfo = ['erpset_summary;'];
-comDQQpreavg = ['pop_DQ_preavg(ALLEEG)'];
+comDQQpreavg = ['pop_DQ_preavg(ALLEEG)'];
+
+
+%% BEST callbacks
+comExtractBest = ['[BEST] = pop_extractbest(ALLEEG);'];
+comCombineBest = ['[BEST] = pop_combineBESTbins(ALLBEST);'];
+comSaveBEST = ['[BEST] = pop_savemybest(BEST, ''gui'', ''saveas'',''History'',''gui'');'];
+comLoadBEST = ['[BEST, ALLBEST] = pop_loadbest('''');'];
+comDelBest = ['[ALLBEST] = pop_deletebestset(ALLBEST);'];
+%% MVPC callbacks
+comSpatDecode = ['[MVPC] = pop_decoding(ALLBEST);'];
+comLoadMVPC = ['[MVPC, ALLMVPC] = pop_loadmvpc('''');'];
+comSaveMVPC = ['[MVPC] = pop_savemymvpc(MVPC,''gui'',''saveas'');'];
+comAvgMVPC = ['[MVPC] = pop_mvpcaverager(ALLMVPC);'];
+comDelMVPC = ['[ALLMVPC] = pop_deletemvpcset(ALLMVPC);'];
+comViewMVPC = ['mvpcviewerGUI(ALLMVPC);'];
+comPlotCF = ['pop_plotconfusions(ALLMVPC)'];
+comExportMVPC =['[MVPC] = pop_mvpc2text(MVPC);'];
+%comDelMVPC =
-%% MVPA callbacks
-%comExtractBest = ['[BEST] = pop_extractbest(ALLEEG);'];
-%comSpatDecode = ['[MVPA] = pop_decoding('''');'];
-%comSaveBEST = ['[BEST] = pop_savemybest(BEST, ''gui'', ''saveas'');'];
-%comLoadBEST = ['[BEST, ALLBEST] = pop_loadbest('''');'];
@@ -445,16 +458,16 @@
erpverMenu = uimenu( submenu, ...
'Label' , [' *** ERPLAB v' erplabver ' ***'], ...
- 'tag' , 'erpver', ...
- 'separator', 'off', ...
+ 'tag' , 'erpver', ...
+ 'separator', 'off', ...
'userdata' , 'startup:off;continuous:off;epoch:off;study:off;erpset:off');
%% Continuous EEG Preprocessing Submenu
preProcMenu = uimenu( submenu, ...
'Label' , 'Preprocess EEG', ...
- 'tag' , 'PreprocessContinuousEEG', ...
- 'separator', 'on', ...
+ 'tag' , 'PreprocessContinuousEEG', ...
+ 'separator', 'on', ...
'userdata' , [ ...
'startup:on;' ...
'continuous:on;' ...
@@ -476,7 +489,7 @@
'userdata' , preProcFunctions_userdata);
% Shift Event Codes
uimenu( preProcMenu, ...
- 'Label' , 'Shift Event Codes (continuous EEG)', ...
+ 'Label' , 'Shift Event Codes (continuous EEG)', ...
'CallBack', comShiftEvents, ...
'userdata', preProcFunctions_userdata);
% Delete Time Segments
@@ -492,13 +505,13 @@
% Selective Electrode Interpolation
uimenu( preProcMenu, ...
'Label' , 'Selective Electrode Interpolation', ...
- 'CallBack', comInterpolateElectrodes, ...
+ 'CallBack', comInterpolateElectrodes, ...
'userdata', preProcFunctions_userdata);
%Continuous Spectral EEG Data Quality
uimenu( preProcMenu, ...
'Label', 'Spectral Data Quality (continuous EEG)', ...
'CallBack', comDFT, ...
- 'userdata', preProcFunctions_userdata);
+ 'userdata', preProcFunctions_userdata);
@@ -575,16 +588,28 @@
%% BIN-EPOCHED Data (BEST sets)
-%uimenu(submenu,'Label','Extract Bin-Epoched Single Trial (BEST) Data','CallBack',comExtractBest,'separator','on','userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on');
-%uimenu(submenu,'Label','Save current BESTset as','CallBack',comSaveBEST,'userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on');
-%uimenu(submenu,'Label','Load BEST','CallBack',comLoadBEST,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on');
-
+mBEST = uimenu(submenu,'Label','Bin-Epoched Single Trial (BEST) Tools','separator','on','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Extract Bin-Epoched Single Trial (BEST) Data','CallBack',comExtractBest,'separator','off','userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Combine BESTset bins across trials','CallBack',comCombineBest,'separator','off','userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Load existing BESTset(s)','CallBack',comLoadBEST,'separator','on','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Clear BESTset(s)','CallBack',comDelBest,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Save current BESTset as','CallBack',comSaveBEST,'userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(mBEST,'Label','Currently Loaded BESTsets:','tag','bestsets', 'separator','on','foregroundcolor','#0072BD','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:off;bestset:on;mvpcset:on');
%% Multivariate Pattern Analysis
-%MVPAmenu = uimenu( submenu,'Label','MVPA','separator','on','tag','MVPAset','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:off');
-% BESTmenu = uimenu(MVPAmenu,'Label','Currently loaded BESTsets','tag','LoadedBEST','separator','on','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:off');
-%uimenu(MVPAmenu,'Label','ERP Decoding','separator','on','CallBack',comSpatDecode,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:off');
-%set(MVPAmenu, 'enable','off');
+MVPCmenu = uimenu( submenu,'Label','Multivariate Patten Classification (MVPC) Tools (BETA)','separator','on','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:off;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','ERP Decoding','CallBack',comSpatDecode,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Average across MVPCsets (Grand Average)','CallBack',comAvgMVPC,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Plot MVPC Results','CallBack',comViewMVPC,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Plot Confusion Matrix','CallBack',comPlotCF,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Load existing MVPCset(s)','CallBack',comLoadMVPC,'separator','on','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Clear MVPCset(s)','CallBack',comDelMVPC,'userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on');
+uimenu(MVPCmenu,'Label','Save current MVPCset as','CallBack',comSaveMVPC,'userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Export MVPC results','CallBack',comExportMVPC,'separator','on','userdata','startup:off;continuous:off;epoch:on;study:off;erpset:on;bestset:on;mvpcset:on');
+uimenu(MVPCmenu,'Label','Currently Loaded MVPCsets:','tag','mvpcsets', 'separator','on','foregroundcolor','#0072BD','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:off;bestset:on;mvpcset:on');
+
+
+set(MVPCmenu, 'enable','off');
@@ -609,7 +634,7 @@
%
mERPLOT = uimenu( submenu,'Label','Plot ERP','tag','ERPlot','separator','on','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
uimenu( mERPLOT,'Label','Plot ERP waveforms ','CallBack', comPLOT,'userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
-% uimenu( mERPLOT,'Label','ERP Waveform Viewer ','CallBack', comPLOTV,'userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
+uimenu( mERPLOT,'Label','Advanced ERP Waveform Viewer (Beta Version) ','CallBack', comPLOTV,'userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
uimenu( mERPLOT,'Label','Plot ERP scalp maps ','CallBack', comSCALP,'userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
uimenu( mERPLOT,'Label','Print plotted figure(s) to a file','CallBack', comEXPPDF,'separator','on','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
uimenu( mERPLOT,'Label','Edit ERP channel location table','CallBack', comCHLOCTABLE,'separator','on','userdata','startup:on;continuous:on;epoch:on;study:off;erpset:on');
@@ -687,7 +712,7 @@
uimenu( mUTI,'Label','Reset event code bytes','CallBack', comRECB,'separator','on','userdata','startup:off;continuous:on;epoch:off;study:off;erpset:off');
uimenu( mUTI,'Label','Save current ERPset history for scripting','CallBack', comSaveH,'separator','on','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
uimenu( mUTI,'Label','Find more here! (for scripting) ','CallBack','web(''https://github.com/lucklab/erplab/wiki/Scripting-Guide'',''-browser'');','separator','on',...
- 'userdata','startup:on;continuous:on;epoch:on;study:on;erpset:on');
+ 'userdata','startup:on;continuous:on;epoch:on;study:on;erpset:on');
uimenu( mUTI,'Label','Simulate EEG/ERP data (alpha version)','CallBack',comESIM,'separator','on' );
@@ -738,16 +763,8 @@
%set(erpmenu,'position', 9); % Requesting a specific postion confuses the EEGLAB file menu order as of Matlab R2020a. Let's leave this off for now. AXS Nov 2020
set(erpmenu,'enable','off');
-%% Create BEST Main Menu
-
-%bestmenu = uimenu( menuERPLAB,'Label','BESTsets','separator','on','tag','bestsets','userdata','startup:off;continuous:off;epoch:off;study:off;erpset:on');
-%set(erpmenu,'position', 9); % Requesting a specific postion confuses the EEGLAB file menu order as of Matlab R2020a. Let's leave this off for now. AXS Nov 2020
-%set(bestmenu,'enable','off');
-
-%% Create MVPA MAIN MENU
-% %
diff --git a/erplab_default_values.m b/erplab_default_values.m
index f885ce66..65135c76 100755
--- a/erplab_default_values.m
+++ b/erplab_default_values.m
@@ -1,5 +1,5 @@
-erplabver = '9.20'; % current erplab version
-erplabrel = '16-May-2023'; % DOB
+erplabver = '10.0'; % current erplab version
+erplabrel = '21-July-2023'; % DOB
erplabdeveloper = 'Simmons&Zhang';
%ColorB = [170 180 195]/255; % old background color (until version 3)
%ColorB = [0.9216 0.8353 0.6078]; % background color for version 4
diff --git a/functions/SqrtCrossNobis_Distance.m b/functions/SqrtCrossNobis_Distance.m
new file mode 100644
index 00000000..599cced9
--- /dev/null
+++ b/functions/SqrtCrossNobis_Distance.m
@@ -0,0 +1,112 @@
+function CrossNobis_Distance = SqrtCrossNobis_Distance(measurementsA, labelsA, measurementsB, labelsB)
+ %this function calculates the crossvalidated mahalanobis (i.e., "crossnobis")
+ %distance between the conditions specified in labels across the values specified
+ %in measurements, cross-validated across set A and set B
+
+ %"measurements" should be a nTrials x nFeatures matrix. nFeatures
+ %corresponds to the number of recording channels (e.g., electrodes)
+
+ %"labels" should be a column vector of length = nTrials, with the value in each
+ %row corresponding to the condition label for the current trial.
+
+ %Extract the number of trials (nTrials) and number of features (nFeatures)
+ %for the measurements, and the number of conditions (nConditions) for the
+ %labels. Note: sets A and B should be of the same size.
+ [nTrials, nFeatures] = size(measurementsA);
+ conditions = unique(labelsA);
+ nConditions = numel(conditions);
+
+ %compute number of distances to calculate (each distance is a pairwise
+ %comparison between conditions)
+ Permutations = nchoosek(conditions,2);
+ nPermutations = size(Permutations,1);
+
+ %pre-allocate matrices for means and variances
+ class_meanA = zeros(nConditions,nFeatures); % class means for set A
+ class_covA = zeros(nFeatures); % within-class variability for set A
+ class_meanB = zeros(nConditions,nFeatures); % class means for set B
+
+ %NOTE: we only need to calculate the covariance for Set A because the "scaling"
+ %by variance is done based on the variance of the underlying
+ %distribution from which the samples were drawn. Because Set A and Set
+ %B were drawn from the same distribution, we only calculate the
+ %covariance matrix for that set, and then scale our distance
+ %calculation by that.
+
+ for k=1:nConditions
+ %select labels in the current class of interest
+ msk=labelsA==conditions(k);
+
+ %number of samples in k-th class
+ n=sum(msk);
+
+ %select measurements from current set
+ class_samples=measurementsA(msk,:);
+
+ class_meanA(k,:) = sum(class_samples,1)/n; % class mean
+ res = bsxfun(@minus,class_samples,class_meanA(k,:)); % residuals
+ class_covA = class_covA+res'*res; % estimate common covariance matrix
+ end
+
+ %[class_covA,shrinkage] = cov1para(class_meanA);
+ class_covA = class_covA/nTrials; %scale covariance matrix by number of observations
+ %class_covA = inv(class_covA);
+
+ %apply regularization to the covariance matrix. This step is needed because
+ %extreme values (especially near zero) can render the covariance matrix
+ %non-invertible, which disallows us from scaling the class means by the
+ %variance. however, the current regularization is a bit "klugey" -- it might be
+ %preferable to use a "shrinkage" algorithm, as in Ledoit & Wolf (2003).
+ %I haven't figured out how to implement that, yet.
+
+ regularization=0.01;
+ reg=eye(nFeatures)*trace(class_covA)/max(1,nFeatures);
+ class_cov_reg=class_covA+reg*regularization;
+
+ for k=1:nConditions
+ %select labels in the current class of interest
+ msk=labelsB==conditions(k);
+
+ %number of samples in k-th class
+ n=sum(msk);
+
+ %select measurements from current set
+ class_samples=measurementsB(msk,:);
+
+ class_meanB(k,:) = sum(class_samples,1)/n; % class mean
+ end
+
+ %compute class vectors for each set, sclaed by the regularized
+ %covariance matrix
+ class_vectorA = class_meanA / class_cov_reg;
+ %class_vectorA = class_meanA * class_covA;
+ %class_vectorA = class_meanA / class_covA;
+ class_vectorB = class_meanB;
+
+ % first, compute the (squared) distance for each feature channel: (conditionX-conditionY)_SetA * (conditionX-conditionY)_SetB
+ temp_dist = zeros(1,nFeatures);
+ for j = 1:nFeatures
+ for k = 1:nPermutations
+ temp_dist(k,j) = ((class_vectorA(Permutations(k,1),j) - class_vectorA(Permutations(k,2),j)) * (class_vectorB(Permutations(k,1),j) - class_vectorB(Permutations(k,2),j)));
+ end
+ end
+
+ % now, square root the above to get the distance for each feature channel
+ % note that the negative distances signs are changed to positive,
+ % square rooted, then returned to their negative value
+ for j = 1:nFeatures
+ for k = 1:nPermutations
+ if temp_dist(k,j) >= 0
+ temp_dist(k,j) = sqrt(temp_dist(k,j));
+ else
+ temp_dist(k,j) = -1*(sqrt(-1 * temp_dist(k,j)));
+ end
+ end
+ end
+
+ CrossNobis_Distance = nan(nPermutations,1);
+ %sum the distances from each feature channel
+ for i = 1:nPermutations
+ CrossNobis_Distance(i,1) = sum(temp_dist(i,:)); %cross-validated mahalanobis distance
+ end
+
\ No newline at end of file
diff --git a/functions/averageSVM.m b/functions/averageSVM.m
new file mode 100644
index 00000000..7454dcbf
--- /dev/null
+++ b/functions/averageSVM.m
@@ -0,0 +1,80 @@
+function [mvpc] = averageSVM(mvpc, smoothing)
+
+% Create the decoding accuracy at each time point (averaged over classes)
+
+Nblock = mvpc.nCrossfolds;
+Nitr = mvpc.nIter;
+Ntp = length(mvpc.times);
+Nclasses = mvpc.nClasses;
+Nruns = Nblock*Nitr;
+%chancelvl = 1/Nclasses;
+
+DecodingAccuracy = nan(Ntp,Nruns);
+Coded_Predictions = nan(Ntp,Nruns,Nclasses);
+% We will compute decoding accuracy per subject in DecodingAccuracy,
+% enter DecodingAccuracy into AverageAccuray, then overwrite next subj.
+
+%% load SVM_ECOC output files
+
+%if classcoding == 2 %1vAll
+% Obtain predictions from SVM-ECOC model
+svmPrediction = squeeze(mvpc.raw_predictions);
+% tstTargets = squeeze(ALLMVPA(seta).targets);
+
+
+TrueAnswer = reshape([1:Nclasses],[Nclasses,1]);
+
+
+for r = 1:Nruns
+ for tp = 1:Ntp
+ prediction = squeeze(svmPrediction(tp,r,:));
+ Err = TrueAnswer - prediction;
+ ACC = mean(Err == 0);
+ coded = Err == 0;
+ DecodingAccuracy(tp,r) = ACC;
+ Coded_Predictions(tp,r,:) = coded;
+
+
+
+ end
+end
+
+grandAvg = mean(DecodingAccuracy,2); %average across runs (i.e. binomial sample estimate or probability of success)
+qgrandAvg = 1-grandAvg; % (i.e. sample estimate of failure)
+% Perform temporal smoothing (5 point moving avg)
+if smoothing == 1
+ smoothed = nan(1,Ntp);
+ for tAvg = 1:Ntp
+ if tAvg ==1
+ smoothed(tAvg) = mean(grandAvg((tAvg):(tAvg+2)));
+ elseif tAvg ==2
+ smoothed(tAvg) = mean(grandAvg((tAvg-1):(tAvg+2)));
+ elseif tAvg == (Ntp-1)
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg+1)));
+ elseif tAvg == Ntp
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg)));
+ else
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg+2)));
+ end
+
+ end
+
+else
+ smoothed = grandAvg';
+end
+
+% else %1V1 case?
+%
+% end
+
+
+
+% Save smoothe data
+mvpc.average_score = smoothed;
+%standard error (assume binomial distribution)
+mvpc.stderror = sqrt((grandAvg.*qgrandAvg)/(Nblock*Nitr*Nclasses))';
+
+% se = sqrt((p*q*Nclasses)/Nruns);
+% mvpc.stderror = repmat(se,[1,Ntp]);
+
+end
\ No newline at end of file
diff --git a/functions/avgconfusionCM.m b/functions/avgconfusionCM.m
new file mode 100644
index 00000000..2accbcc4
--- /dev/null
+++ b/functions/avgconfusionCM.m
@@ -0,0 +1,45 @@
+function mvpc = avgconfusionCM(mvpc, xdist)
+% create confusion matrix for crossnobis classification
+%%%%% THIS FUNCTION IS A PART OF ERPLAB ***
+
+
+%obtain permutations label
+conditions = 1:mvpc.nClasses;
+Permutations = nchoosek(conditions,2);
+idx = [2 1];
+Permutations_lower = Permutations(:,idx);
+
+%average pairwise distance across iteration
+avg_distance_itr = squeeze(mean(xdist,2));
+npoints = size(avg_distance_itr,1) ;
+
+%confusion matrix empty
+nconditions = numel(conditions);
+cf = zeros(nconditions,nconditions,npoints); %same order as in SVM dimensionwise
+
+%index lower square
+for t = 1:npoints
+ %upper diagonal then lower diagonal
+ for i = 1:size(Permutations,1)
+ loc = Permutations(i,:);
+ x = loc(1);
+ y = loc(2);
+
+ loc_bottom = Permutations_lower(i,:);
+
+ z = loc_bottom(1);
+ w = loc_bottom(2);
+
+ %index
+ cf(x,y,t) = avg_distance_itr(t,i);
+ cf(z,w,t) = avg_distance_itr(t,i);
+ end
+
+
+end
+
+mvpc.confusions.scores = cf;
+mvpc.confusions.labels = mvpc.classlabels;
+
+
+
diff --git a/functions/avgconfusionSVM.m b/functions/avgconfusionSVM.m
new file mode 100644
index 00000000..df7b049f
--- /dev/null
+++ b/functions/avgconfusionSVM.m
@@ -0,0 +1,53 @@
+function [mvpc] = avgconfusionSVM(mvpc, truelabel, predictedlabel)
+
+% this function reshapes the decorder outputs
+% and creates mvpa.raw_accuracy_1vsall
+Nclasses = mvpc.nClasses;
+
+% if classcoding == 2
+[Nitr, Nblock, Ntp, nBins] = size(truelabel);
+runs = Nitr*Nblock; %"run" is combination of iteration and fold
+
+reshape_predictions = reshape(predictedlabel,[runs,Ntp,nBins]);
+predictions = permute(reshape_predictions,[2 1 3]);
+
+reshape_truelabels = reshape(truelabel,[runs,Ntp,nBins]);
+truelabels = permute(reshape_truelabels,[2 1 3]);
+%predictions = Timepoint x Run x Class
+%save predictions
+%mvpc.raw_predictions = predictions ;
+
+% TrueAnswer = reshape([1:Nclasses],[Nclasses,1]);
+
+%preallocate confusions at each tp
+confusions = zeros(nBins,nBins,Ntp);
+
+for tp = 1:Ntp
+
+ %pmats
+ pred = squeeze(predictions(tp,:,:));
+ pmat_tp = reshape(pred,[1 Nclasses*runs]);
+
+ %tmats
+ trues = squeeze(truelabels(tp,:,:));
+ tmat_tp = reshape(trues,[1 Nclasses*runs]);
+
+ [C,c3] = confusionmat(tmat_tp, pmat_tp);
+ confusions(:,:,tp) = C/(unique(sum(C,2))); % row is true labels, column is predicted labels
+
+end
+
+mvpc.confusions.scores = confusions;
+mvpc.confusions.labels = mvpc.classlabels;
+
+
+% elseif classcoding == 1
+% %create for 1v1 case
+%
+%
+% else
+% disp('No SVM coding output?')
+% return
+% end
+
+end
\ No newline at end of file
diff --git a/functions/best2memory.m b/functions/best2memory.m
new file mode 100644
index 00000000..eb205a83
--- /dev/null
+++ b/functions/best2memory.m
@@ -0,0 +1,36 @@
+
+function best2memory(BEST,indx)
+
+bestm = findobj('tag','linbest');
+nbestset = length(bestm);
+
+for s = 1:nbestset
+
+ if s == nbestset-indx+1 %bottomup to topdown counting
+ set(bestm(s),'checked','on');
+ menutitle = ['BESTset' ...
+ num2str(nbestset-s+1) ': ' BEST.bestname ' '];
+ set(bestm(s), 'Label', menutitle);
+
+ else
+ set(bestm(s),'checked','off');
+ currname = get(bestm(s),'Label');
+ menutitle = regexprep(currname,'| ','', 'ignorecase');
+ menutitle = regexprep(menutitle, '\s+', ' ');
+ menutitle = regexprep(menutitle,'BESTset \d+',['BESTset ' num2str(nbestset-s+1)], 'ignorecase');
+ set( bestm(s), 'Label', menutitle);
+
+ end
+
+
+end
+
+CURRENTBEST = indx;
+assignin('base','CURRENTBEST',CURRENTBEST);
+assignin('base','BEST',BEST);
+
+fprintf('\n------------------------------------------------------\n');
+fprintf('BESTset #%g is ACTIVE\n', indx);
+fprintf('------------------------------------------------------\n');
+
+end
\ No newline at end of file
diff --git a/functions/buildBESTstruct.m b/functions/buildBESTstruct.m
new file mode 100644
index 00000000..f294a3af
--- /dev/null
+++ b/functions/buildBESTstruct.m
@@ -0,0 +1,30 @@
+function [BEST] = buildBESTstruct(EEG)
+
+BEST = []; %empty BEST
+
+if nargin <1
+ BEST = [];
+end
+
+if isempty(EEG)
+ EEG.epoch =[];
+end
+if ~isempty(EEG.epoch) %epoched
+ nbin = EEG.EVENTLIST.nbin;
+ BEST.version = 1.0; %ERPLAB version
+ %MVPA.subj = [];
+ BEST.bestname = EEG.setname;
+ BEST.filename = EEG.setname;
+ BEST.filepath = EEG.filepath;
+ BEST.nbin = nbin;
+ BEST.pnts = EEG.pnts; %same across all bins
+ BEST.srate = EEG.srate;
+ BEST.xmin = EEG.xmin;
+ BEST.xmax = EEG.xmax;
+ BEST.times = EEG.times;
+ BEST.nbchan = EEG.nbchan;
+ BEST.chanlocs = EEG.chanlocs;
+ BEST.bindesc = {EEG.EVENTLIST.bdf.description};
+ BEST.original_bin = {EEG.EVENTLIST.bdf.namebin};
+ BEST.EEGhistory = EEG.history;
+end
\ No newline at end of file
diff --git a/functions/buildMVPAstruct.m b/functions/buildMVPAstruct.m
new file mode 100644
index 00000000..e3bffd37
--- /dev/null
+++ b/functions/buildMVPAstruct.m
@@ -0,0 +1,65 @@
+function [mvpa] = buildMVPAstruct(ALLBEST,relevantChans,nIter,nCrossBlocks,DataTimes,equalT,SVMcoding,method)
+
+mvpa = []; %empty mvpa
+
+if nargin < 1
+ mvpa.header.subjectID = '';
+ mvpa.header.mvpa_version = 1;
+ mvpa.header.electrodes = ALLBEST.chanlocs;
+ mvpa.header.nClasses = ALLBEST.nbin; % # of bins
+ mvpa.header.nIter = 0;
+ mvpa.header.nCrossfolds = 0; %[] if tw.
+ mvpa.header.nChance = 1/mvpa.header.nClasses; %chance
+ mvpa.header.nSampling = ALLBEST.srate; %updated fs
+ mvpa.header.pnts = ALLBEST.pnts;
+ mvpa.header.SVMcoding = [];
+ mvpa.header.DecodingAccuracy = '';
+ mvpa.header.DecodingMethod = '';
+ mvpa.header.DecodingDistance = [];
+ mvpa.header.grandaverage = 'no';
+ mvpa.header.window = ''; %point or twindow
+ mvpa.header.equalTrials = 1; %1: floor across files, %2 floor within files, %0 don't floor.
+ mvpa.header.n_trials_per_bin = ALLBEST.n_trials_per_bin;
+
+ %mvpa fields
+ mvpa.epoch.pre = ALLBEST.times(1); % Set epoch start in ms (from imported data)
+ mvpa.epoch.post = ALLBEST.times(end); % Set epoch end in ms (from imported data)
+ mvpa.times = ALLBEST.times; %timepoints actually decoded
+
+else
+ mvpa.header.subjectID = ALLBEST.bestname;
+ mvpa.header.mvpa_version = 1;
+ mvpa.header.electrodes = relevantChans;
+ mvpa.header.nClasses = ALLBEST.nbin; % # of bins
+ mvpa.header.nIter = nIter;
+ mvpa.header.nCrossfolds = nCrossBlocks; %[] if tw.
+ mvpa.header.nChance = 1/mvpa.header.nClasses; %chance
+ mvpa.header.nSampling = ALLBEST.srate; %updated fs
+ mvpa.header.pnts = ALLBEST.pnts;
+ if SVMcoding == 1
+ mvpa.header.OneVsOne = 'yes';
+ mvpa.header.OneVsAll ='no';
+ elseif SVMcoding == 2
+ mvpa.header.OneVsOne ='no';
+ mvpa.header.OneVsAll='yes';
+ elseif isempty(SVMcoding)
+ mvpa.header.OneVsOne ='no';
+ mvpa.header.OneVsAll = 'no';
+ end
+ mvpa.header.DecodingAccuracy = 'yes';
+ if method == 1
+ mvpa.header.DecodingMethod = 'SVM';
+ elseif method == 2
+ mvpa.header.DecodingMethod = 'Crossnobis';
+ end
+ mvpa.header.DecodingDistance = [];
+ mvpa.header.grandaverage = 'no';
+ mvpa.header.window = 'point'; %point or twindow
+ mvpa.header.equalTrials = equalT; %1: floor across files, %2 floor within files, %0 don't floor.
+ mvpa.header.n_trials_per_bin = ALLBEST.n_trials_per_bin;
+
+ %mvpa fields
+ mvpa.epoch.pre = DataTimes(1); % Set epoch start (from imported data)
+ mvpa.epoch.post = DataTimes(2); % Set epoch end (from imported data)
+ mvpa.times = ALLBEST.times; %timepoints actually decoded
+end
\ No newline at end of file
diff --git a/functions/buildMVPCstruct.m b/functions/buildMVPCstruct.m
new file mode 100644
index 00000000..406354a9
--- /dev/null
+++ b/functions/buildMVPCstruct.m
@@ -0,0 +1,79 @@
+function [mvpc] = buildMVPCstruct(ALLBEST,relevantChans,nIter,nCrossBlocks,DataTimes,equalT,classcoding,method)
+
+mvpc = []; %empty mvpa
+
+if nargin < 1
+ mvpc.mvpcname = '';
+ mvpc.filename = '';
+ mvpc.filepath = '';
+ mvpc.electrodes = 1:length(ALLBEST.chanlocs);
+ mvpc.chanlocs = ALLBEST.chanlocs;
+ mvpc.nClasses = ALLBEST.nbin; % # of bins
+ mvpc.chance = 1/mvpc.header.nClasses; %chance
+ mvpc.classlabels = ALLBEST.bindesc;
+ mvpc.nIter = 0;
+ mvpc.nCrossfolds = 0; %[] if tw.
+ mvpc.srate = ALLBEST.srate; %updated fs
+ mvpc.pnts = ALLBEST.pnts;
+ mvpc.classcoding = 0;
+ mvpc.DecodingUnit = 'None'; %Accuracy vs Distance vs None
+ mvpc.DecodingMethod = '';
+ mvpc.average_status = 'single_subject';
+ mvpc.equalTrials = equalT; %str
+ mvpc.n_trials_per_class = ALLBEST.n_trials_per_bin;
+ mvpc.saved = 'no';
+ mvpc.epoch.pre = ALLBEST.times(1); % Set epoch start in ms (from imported data)
+ mvpc.epoch.post = ALLBEST.times(end); % Set epoch end in ms (from imported data)
+ mvpc.times = ALLBEST.times; %timepoints actually decoded
+ mvpc.mvpc_version = 1;
+
+else
+ try
+ mvpc.mvpcname = ALLBEST.mvpcname;% if data went through decoding GUI
+ catch
+ mvpc.mvpcname = ALLBEST.bestname;
+ end
+ mvpc.filename = ALLBEST.filename;
+ mvpc.filepath = ALLBEST.filepath;
+ mvpc.electrodes = relevantChans;
+ mvpc.chanlocs = ALLBEST.chanlocs(relevantChans);
+ mvpc.nClasses = ALLBEST.nbin; % # of bins
+ if method == 1
+ mvpc.chance = 1/mvpc.nClasses; %chance
+ elseif method == 2
+ mvpc.chance = 0; %0 uV for crossnobis
+ end
+ mvpc.classlabels = ALLBEST.bindesc;
+ mvpc.nIter = nIter;
+ mvpc.nCrossfolds = nCrossBlocks; %[] if tw.
+ mvpc.srate = ALLBEST.srate; %updated fs
+ mvpc.pnts = ALLBEST.pnts;
+ if classcoding == 1
+ mvpc.classcoding.OneVsOne = 'yes';
+ mvpc.classcoding.OneVsAll ='no';
+ elseif classcoding == 2
+ mvpc.classcoding.OneVsOne ='no';
+ mvpc.classcoding.OneVsAll='yes';
+ else
+ mvpc.classcoding.OneVsOne ='no';
+ mvpc.classcoding.OneVsAll = 'no';
+ end
+ if method == 1
+ mvpc.DecodingUnit= 'proportion correct'; % if svm='%correct', crossnobis: "uV" for crossnobis
+ mvpc.DecodingMethod = 'SVM';
+ elseif method == 2
+ mvpc.DecodingUnit = 'uV';
+ mvpc.DecodingMethod = 'Crossnobis';
+ end
+ mvpc.average_status = 'single_subject';
+ mvpc.equalTrials = equalT; %str
+ mvpc.n_trials_per_class = ALLBEST.n_trials_per_bin;
+ mvpc.saved = 'no';
+ mvpc.epoch.pre = DataTimes(1); % Set epoch start (from imported data)
+ mvpc.epoch.post = DataTimes(2); % Set epoch end (from imported data)
+ mvpc.times = ALLBEST.times; %timepoints actually decoded
+ mvpc.mvpc_version = 1;
+
+
+
+end
\ No newline at end of file
diff --git a/functions/checkmultiBEST.m b/functions/checkmultiBEST.m
new file mode 100644
index 00000000..dcfe253e
--- /dev/null
+++ b/functions/checkmultiBEST.m
@@ -0,0 +1,71 @@
+%% CHECK BEST WITH MULTIPLE FILES
+% Once BEST structure is created (for one file, or more than one file,
+% check to see if fields are correct
+% Checks for more than one subject:
+% Same number of bins
+% Same bin labels
+% That there are at least two bins (chance = 50%)
+
+
+function checking = checkmultiBEST(BEST)
+
+ %multiple files
+ try
+ %take the first file's properties and check against each subseqent
+ bins_in_data1 = numel(BEST(1).binwise_data);
+
+ if bins_in_data1 < 2
+ %needs to be at least 2 bins
+ msgText = 'Must have at least two classes for decoding!';
+ title = 'ERPLAB: Invalid number of classes';
+ errorfound(msgText,title);
+ checking = 0;
+ return
+ end
+
+
+
+ for n = 1:numel(BEST)
+ bin_in_data = numel(BEST(n).binwise_data);
+ if bin_in_data == bins_in_data1
+
+ else
+ error();
+ end
+
+ end
+
+
+ if numel(BEST) ~= 1
+ if isequaln(BEST.bindesc)
+
+ else
+ error();
+ end
+ end
+ checking = 1;
+
+ catch
+
+ if numel(BEST) == 1
+
+ bins_in_data1 = numel(BEST(1).binwise_data);
+ if bins_in_data1 < 2
+ msgText = 'Must have at least two classes for decoding!';
+ title = 'ERPLAB: Invalid number of classes';
+ errorfound(msgText,title);
+ checking = 0;
+ else
+ checking = 1;
+ end
+
+ else
+ checking = 0;
+ % disp('Error: multiple BEST files do not match!');
+ % error();
+ end
+
+ end
+
+
+end
\ No newline at end of file
diff --git a/functions/combineBESTbins.m b/functions/combineBESTbins.m
new file mode 100644
index 00000000..fbac57a9
--- /dev/null
+++ b/functions/combineBESTbins.m
@@ -0,0 +1,53 @@
+function BEST = combineBESTbins(BEST,new_bins,new_labels)
+
+n_bins = size(new_bins,2);
+
+BEST.nbin = n_bins;
+BEST.bindesc = new_labels';
+BEST.original_bin = {}; %erase due to new BEST being combined
+
+
+new_binwise_data = struct();
+n_trials_per_bin = NaN(1,numel(new_bins));
+
+%% combine bins
+for b = 1:n_bins
+
+ selected_bins = new_bins{b};
+ if ischar(selected_bins) || isstring(selected_bins)
+ selected_bins = str2num(selected_bins);
+ end
+
+ if numel(selected_bins) == 1
+ data_splice = BEST.binwise_data(selected_bins).data;
+ n_trials_per_bin(b) = size(data_splice,3); %ntrials
+ new_binwise_data(b).data = data_splice;
+
+
+ else
+
+ for j = 1:numel(selected_bins)
+
+
+ bin_index = selected_bins(j);
+ data_splices{j} = BEST.binwise_data(bin_index).data;
+
+
+ end
+
+ C = cat(3,data_splices{:}); %combine trials
+ n_trials_per_bin(b) = size(C,3); %ntrials
+ new_binwise_data(b).data = C;
+
+ end
+ clear data_splices;
+
+end
+
+
+BEST.binwise_data = new_binwise_data;
+BEST.n_trials_per_bin = n_trials_per_bin;
+BEST.saved = 'no';
+
+
+end
\ No newline at end of file
diff --git a/functions/crossnobis.m b/functions/crossnobis.m
new file mode 100644
index 00000000..449f7328
--- /dev/null
+++ b/functions/crossnobis.m
@@ -0,0 +1,192 @@
+
+function [MVPC, ALLMVPC] = crossnobis(ALLBEST, nIter, nCrossBlocks, DataTimes,relevantChans,classcoding,equalT,ParWorkers,method)
+
+%% Subject List:
+nSubs = length(ALLBEST); % # files = # subjects
+
+%% Step 9: Loop through participants
+for s = 1:nSubs %crossnobis is performed within each subject independently
+
+ %% Parameters to set per subject
+ BEST = ALLBEST(s);
+ mvpc = buildMVPCstruct(BEST,relevantChans, nIter, nCrossBlocks, DataTimes,equalT,classcoding,method);
+
+ % for brevity in analysis
+ nBins = mvpc.nClasses;
+ nIter = mvpc.nIter;
+ nPerms = nchoosek(nBins,2); %total # pairwise comparisions
+ dataTime = BEST.times; %times of imported data
+ %nBlocks = mvpc.nCrossfolds;
+ % nElectrodes = length(mvpc.electrodes);
+ nSamps = length(mvpc.times);
+ try
+ sn = BEST.mvpcname; %if data went through decoding GUI
+ catch
+ sn = BEST.bestname;
+ end
+
+ %progress output to command window
+ fprintf('*** Currently Decoding (Crossnobis) Subject:\t%s ***\n ',sn); %is Decoding the word to use for crossnobis?
+
+ % grab EEG data from bin-list organized data
+ eegs = BEST.binwise_data;
+ nPerBin = BEST.n_trials_per_bin;
+ % we create index of timpoint of interests from original data
+ tois = ismember(dataTime,dataTime);
+
+
+% % Preallocate Matrices
+ final_xDist = nan(nSamps,nIter,nPerms);
+% %BetaWeights_Raw = nan(nIter,nSamps,nBlocks,nElectrodes);
+% %BetaWeights_Corr = BetaWeights_Raw;
+
+
+ if nBins ~= max(size(eegs))
+ error('Error. nBins dne # of bins in dataset!');
+ % Code to be used on a bin-epoched dataset for one
+ % class only (e.g. Orientation). Users may
+ % try to bin multiple classes in one BDF.
+ % This is not currently allowed.
+ end
+
+ %% Create labels/data object for each subject
+ %probably slow if not preallocating memory...
+ %but generalizable to all bin-epoched datasets
+ xlabels = []; %pronounced "cross-labels"
+
+ for binN = 1:numel(eegs)
+
+ xlabels_temp = repmat(binN, [nPerBin(binN) 1]);
+
+ xlabels = [xlabels; xlabels_temp];
+ end
+
+ % create new crossnobis data array &
+ % obtain timepoints of interest (resample)
+ % (NChan x nTP x nTrials(ideally randomized) x Nlabels)
+
+ for b = 1:numel(nPerBin)
+ ntrial = size(eegs(b).data,3);
+ shuff_list = randperm(ntrial);
+
+ %so we always allow the specified number of trials per bin
+ %(nPerBin) by choosing from a (potentially) larger set of trials
+ %within the bin
+
+ idx_list = shuff_list(1:nPerBin(b));
+
+ indexed_data = eegs(b).data(:,:,idx_list);
+ eegs(b).data = indexed_data;
+
+ end
+
+
+
+ xdata = cat(3, eegs.data); %pronounced "cross-data"
+ xdata = xdata(:,tois,:); %resampled data
+
+
+ %% Step 8: Loop through each iteration with random shuffling
+ tic % start timing iteration loop
+
+ %% Perform Cross-Nobis analysis at each requested time-point
+ for iter = 1:nIter
+ fprintf('Subject: %s, Iteration: %i / %i \n', sn, iter, nIter);
+ parfor (nTp = 1:nSamps,ParWorkers)
+
+ % structs to hold shuffled data
+ a_full_bin_label= struct();
+ b_full_bin_label= struct();
+
+ a_full_bin_data = struct();
+ b_full_bin_data = struct();
+
+
+ for bin = 1:nBins
+ binT = nPerBin(bin); %number of trials in bin
+ halfT = floor(binT/2); %number of half of trials in bin floored
+
+ %obtain index of trials of current bin
+ binIndex = (xlabels==bin);
+
+
+ %trial equalization here
+ %create logical indexs for labels and data
+ %length(shuffInd) should always equal the total number of
+ %trials in a bin after flooring (ie truncated to allow for even split)
+
+ shuffInd = [repmat(1,[halfT,1]); repmat(0,[halfT,1])];
+
+ %RANDOMIZING HERE
+ %creates shuffled logical index
+ %so from the current bin, we are always
+ %indexing a different mix of trials every iteration
+ shuffInd_a = logical(shuffle(shuffInd));
+ shuffInd_b = ~shuffInd_a;
+
+ % subset the xdata for current bin
+ full_labels = xlabels(binIndex);
+ full_data = xdata(:,:,binIndex);
+
+ %from full_data, subset into two sets (a and b).
+ %On each interation, trials in both sets will be a different
+ % subset of equally mixed and indexed trials from current
+ % bin. Bins do not have to be equal to other bins
+ % but the sets a and b are equal.
+ adata = full_data(:,:,shuffInd_a);
+ bdata = full_data(:,:,shuffInd_b);
+ adata_tp = squeeze(adata(relevantChans,nTp,:));
+ adata_tp = permute(adata_tp, [2 1]);
+ bdata_tp = squeeze(bdata(relevantChans,nTp,:));
+ bdata_tp = permute(bdata_tp, [2 1]);
+
+ a_full_bin_label(bin).labels = full_labels(1:halfT);
+ b_full_bin_label(bin).labels = full_labels(1:halfT);
+ a_full_bin_data(bin).data = adata_tp;
+ b_full_bin_data(bin).data = bdata_tp;
+
+ end
+
+ %create arrays for input into function
+ a_complete_labels = cat(1, a_full_bin_label.labels);
+ b_complete_labels = cat(1, b_full_bin_label.labels);
+
+ a_complete_data_tp = cat(1, a_full_bin_data.data);
+ b_complete_data_tp = cat(1, b_full_bin_data.data);
+
+
+
+ xDist = SqrtCrossNobis_Distance(a_complete_data_tp, ...
+ a_complete_labels,b_complete_data_tp, b_complete_labels);
+
+ final_xDist(nTp,iter,:) = xDist;
+ end
+ end
+
+ toc % stop timing the iteration loop
+
+ mvpc.details = [];
+ mvpc.raw_predictions = final_xDist;
+
+ avg_distance_iter = squeeze(mean(final_xDist,2))';
+ avg_distance_scores = squeeze(mean(avg_distance_iter,1));
+
+ mvpc.average_score = avg_distance_scores;
+ mvpc = avgconfusionCM(mvpc, final_xDist);
+ mvpc.stderror = std(avg_distance_iter)/sqrt(size(final_xDist,1));
+
+
+ %probably a better way
+ if nSubs == 1
+
+ MVPC = mvpc;
+ ALLMVPC = mvpc;
+ else
+
+ MVPC = mvpc;
+ ALLMVPC(s) = mvpc;
+ end
+
+
+
+end
diff --git a/functions/erp2memory.m b/functions/erp2memory.m
index 3b6ca3a3..12e1735d 100755
--- a/functions/erp2memory.m
+++ b/functions/erp2memory.m
@@ -83,7 +83,8 @@ function erp2memory(ERP, indx)
end
observe_ERPDAT.CURRENTERP = CURRENTERP;
observe_ERPDAT.ERP = ALLERP(CURRENTERP);
- observe_ERPDAT.Two_GUI = 1;
+% observe_ERPDAT.Two_GUI = 1;
+
end
@@ -122,7 +123,7 @@ function erp2memory(ERP, indx)
% mainerplab = findobj(W_MAIN, 'tag', submenu);
% erpmenu = findobj('erpmenu','type', 'uimenu');
-
+% erpworkingmemory('ERPLAB_ERPWaviewer',1);
end
diff --git a/functions/erp_decoding.m b/functions/erp_decoding.m
new file mode 100644
index 00000000..f8964370
--- /dev/null
+++ b/functions/erp_decoding.m
@@ -0,0 +1,316 @@
+% ERP decoding algorithm for Decoding Toolbox
+
+%Function written by Aaron Simmons (UC Davis)
+%Original Algorithm Author: Gi-Yeul Bae (Arizona State University)
+
+
+function [MVPC, ALLMVPC] = erp_decoding(ALLBEST, nIter, nCrossBlocks, DataTimes,relevantChans,classcoding,equalT,ParWorkers,method)
+
+% Parallelization: This script utilizes Matlab parallelization ...
+% if cannot parallelize, ParWorkers = 0, or ParWorkers set to 0 by users.
+
+
+%% Check presence of Matlab Statistics and Machine Learning Toolbox
+% This toolbox is required for the SVM classification
+V = ver;
+Vname = {V.Name};
+if ~(any(strcmp(Vname, 'Statistics and Machine Learning Toolbox')))
+ error('Error. Statistics and Machine Learning toolbox not found.');
+end
+
+
+%% Subject List:
+nSubs = length(ALLBEST); % # files = # subjects
+
+%% Step 9: Loop through participants
+for s = 1:nSubs %decoding is performed within each subject independently
+
+ %% Parameters to set per subject
+ % Main structure is mvpa.
+
+ %load subject BESTset & build mvpa dataset
+ BEST = ALLBEST(s);
+ mvpc = buildMVPCstruct(BEST,relevantChans, nIter, nCrossBlocks, DataTimes,equalT,classcoding,method);
+
+ % The electrode channel list is mapped 1:1 with respect to your
+ % electrode channel configuration (e.g., channel 1 is FP1 in our EEG cap)
+ % Check if the label for each electrode corresponds to the electrode
+ % labeling of your own EEG system
+ ReleventChan = relevantChans; %electrodes
+
+
+ % for brevity in analysis
+ nBins = mvpc.nClasses;
+ nIter = mvpc.nIter;
+ nBlocks = mvpc.nCrossfolds;
+ nElectrodes = length(mvpc.electrodes);
+ nSamps = length(mvpc.times);
+ try
+ sn = BEST.mvpcname; %if data went through decoding GUI
+ catch
+ sn = BEST.bestname;
+ end
+
+
+ %progress output to command window
+ fprintf('*** Currently Decoding (SVM) Subject:\t%s ***\n ',sn);
+
+ %% Data Loading/preallocation per subject
+
+ % grab EEG data from bin-list organized data
+ eegs = BEST.binwise_data;
+ nPerBin = BEST.n_trials_per_bin;
+
+ % Preallocate Matrices
+ svm_predict = nan(nIter,nBlocks, nSamps,nBins); % a matrix to save prediction from SVM
+ tst_target = nan(nIter,nBlocks,nSamps,nBins); % a matrix to save true target values
+ if nBins > 2
+ if classcoding == 1
+ nDecoders = nchoosek(nBins,2); %onevsone (SVM only)
+ elseif classcoding == 2
+ nDecoders = nchoosek(nBins,1); %onevsall (SVM only)
+ end
+ else
+ %binary decoder
+ nDecoders = 1;
+ end
+ BetaWeights_Raw = nan(nIter,nSamps,nBlocks,nDecoders,nElectrodes);
+ %BetaWeights_Corr = BetaWeights_Raw;
+
+ % create svmECOC.block structure to save block assignments
+ % mvpa.blocks=struct();
+
+ if nBins ~= max(size(eegs))
+ error('Error. nBins dne # of bins in dataset!');
+ % Code to be used on a bin-epoched dataset for one
+ % class only (e.g. Orientation). Users may
+ % try to bin multiple classes in one BDF.
+ % This is not currently allowed.
+ end
+
+
+ %% Step 8: Loop through each iteration with random shuffling
+ tic % start timing iteration loop
+
+ % progress checker
+
+
+ for iter = 1:nIter
+
+
+ %update waitbar & message
+ fprintf('Subject: %s, Iteration: %i / %i \n', sn, iter, nIter);
+
+ %% Obtaining AVG. EEG (ERP spatial dist)
+ % within each block at each time point
+ % stored in blockDat_filtData
+
+ %preallocate & rewrite per each iteration
+ blockDat_filtData = nan(nBins*nBlocks,nElectrodes,nSamps);
+ labels = nan(nBins*nBlocks,1); % bin labels for averaged & filtered EEG data
+ blockNum = nan(nBins*nBlocks,1); % block numbers for averaged & filtered EEG data
+
+
+
+
+ bCnt = 1; %initialize binblock counter
+
+ % this code operates and creates ERPs at each bin
+ % and organizes that into approprate block
+
+ %% shuffling, binning, & averaging
+ for bin = 1:nBins
+
+
+ % We will use as many possible trials per
+ % bin having accounted already for artifacts (required, not
+ % changable by subject yet).
+ % Following logic controlled by specifying equalize_trials in pop_decoding
+
+ %Drop excess trials
+ nPerBinBlock = floor(nPerBin/nBlocks); %array for nPerBin
+
+ if ~any(nPerBinBlock)
+ %for single trial decoding or trials less than nBlocks
+
+ nPerBinBlock = nPerBin;
+ end
+
+
+ %grab current bin with correct # of electrodes & samps
+ eeg_now = eegs(bin).data(ReleventChan,:,:);
+
+ true_ntrials = size(eeg_now,3);
+ min_trial_sparsity = floor(true_ntrials/nBlocks); % max
+
+ %Obtain index within each shuffled bin
+ %shuffBin = randperm((nPerBinBlock(bin))*nBlocks)';
+ shuffBin = randperm(min_trial_sparsity*nBlocks)';
+
+ %Preallocate arrays
+
+% blocks = nan(size(shuffBin));
+% shuffBlocks = nan(size(shuffBin));
+
+ x = repmat((1:nBlocks)',nPerBinBlock(bin),1); %blockindex
+ x2 = shuffBin(1:length(x)); %trial index within bin
+
+ blocks = nan(size(x));
+ %shuffBlocks = nan(size(x));
+
+ %arrage block order within bins
+% x = repmat((1:nBlocks)',nPerBinBlock(bin),1);
+% x2 = shuffBin(1:length(x));
+ %due to common floor option, x and x2 may different sizes
+ %shuffBlocks(shuffBin) = x;
+ % [~,blocks] = ismember(shuffBin, x);
+ %shuffBlocks(shuffBin) = x2;
+
+
+
+ %unshuffled block assignment
+ %blocks(shuffBin) = shuffBlocks;
+ blocks(:,1) = x; %block assignment
+ blocks(:,2) = x2; %trial number
+
+ % save block assignment
+ blockID = ['iter' num2str(iter) 'bin' num2str(bin)];
+
+ mvpc.details.info.blockassignment.(blockID) = blocks; % block assignment
+ mvpc.details.n_trials_per_erp(bin) = nPerBinBlock(bin);
+
+
+
+ %create ERP average and place into blockDat_filtData struct
+ %this results in nBins*nBlocks amount of ERP spatial
+ %distributions (across nChans) at each sample/timepoint
+
+ %% Step 1: computing ERPs based on random subset of trials for each block
+ for bl = 1:nBlocks
+
+ %unmask trial within block
+ unMasktrial = x2(x == bl);
+
+ %blockDat_filtData(bCnt,:,:) = squeeze(mean(eeg_now(:,:,blocks==bl),3));
+ if nPerBinBlock(bin) == 1
+ blockDat_filtData(bCnt,:,:) = eeg_now(:,:,(unMasktrial)); %single trial
+ else
+ blockDat_filtData(bCnt,:,:) = squeeze(mean(eeg_now(:,:,(unMasktrial)),3));
+ end
+
+ labels(bCnt) = bin; %used for arranging classification obj.
+
+ blockNum(bCnt) = bl;
+
+ bCnt = bCnt+1;
+
+ end
+
+ end
+
+
+ %% Step 7: Loop through each timepoint
+ % Do SVM_ECOC at each time point
+ parfor (t = 1:nSamps,ParWorkers)
+ %for t = 1:nSamps
+ mdl = [];
+ % grab data for timepoint t
+ %toi = ismember(times,times(t)-svmECOC.window/2:times(t)+svmECOC.window/2);
+
+ % average across time window of interest
+ % here, you can parse nBin*nBlock across all channels (ERP spatial dist)
+ dataAtTimeT = squeeze(mean(blockDat_filtData(:,:,t),3));
+
+ %% Step 6: Cross-validation for-loop
+ for i=1:nBlocks % loop through blocks, holding each out as the test set
+
+
+ %% Step 2 & Step 4: Assigning training and testing data sets
+ trnl = labels(blockNum~=i); % training labels
+
+ tstl = labels(blockNum==i); % test labels
+
+ trnD = dataAtTimeT(blockNum~=i,:); % training data
+
+ tstD = dataAtTimeT(blockNum==i,:); % test data
+
+ %% Step 3: Training
+ if classcoding == 2 %onevsall
+ if nBins == 2
+ mdl = fitcsvm(trnD,trnl); %binary decoder
+ else
+ mdl = fitcecoc(trnD,trnl, 'Coding','onevsall','Learners','SVM' ); %train support vector mahcine
+ end
+
+ elseif classcoding == 1 %onevsone
+ mdl = fitcecoc(trnD,trnl, 'Coding','onevsone','Learners','SVM' ); %train support vector mahcine
+ else
+ error('Decoding Toolbox has unspecified SVMcoding');
+ end
+
+ %% Step 5: Testing
+ LabelPredicted = predict(mdl, tstD); % predict classes for new data
+
+ svm_predict(iter,i,t,:) = LabelPredicted; % save predicted labels
+
+ tst_target(iter,i,t,:) = tstl; % save true target labels
+
+ if nBins > 2
+ for d = 1:nDecoders
+ BetaWeights_Raw(iter,t,i,d,:) = mdl.BinaryLearners{d}.Beta;% SVM weights uncorrected
+ end
+ else
+ %binary decoder
+ for d = 1:nDecoders
+ BetaWeights_Raw(iter,t,i,d,:) = mdl.Beta;% SVM weights uncorrected
+ end
+ end
+ %BetaWeights_Corr(iter,t,i,:) = double(cov(trnD))*mdl.Beta;% SVM weights after correction
+
+
+
+ end % end of block: Step 6: cross-validation
+
+ end % end of time points: Step 7: Decoding each time point
+
+ end % end of iteration: Step 8: iteration with random shuffling
+
+
+ toc % stop timing the iteration loop
+
+ % mvpc.details.CodingMatrix = mdl.CodingMatrix;
+ mvpc.details.BetaWeightsRaw = BetaWeights_Raw;
+ mvpc = rawscoreSVM(mvpc, tst_target, svm_predict); %compute raw method/decoder scores
+ mvpc = averageSVM(mvpc,0); %average accuracy across runs, %no smoothing
+ mvpc = avgconfusionSVM(mvpc,tst_target, svm_predict);
+
+ % mvpc.BetaWeights_Raw = BetaWeights_Raw;
+ % mvpc.BetaWeights_Corr = BetaWeights_Corr;
+
+ %create the MVPA output
+ %output decoding results in main svmECOC structure
+
+
+
+
+% mvpa.targets = tst_target;
+% mvpa.modelPredict = svm_predict;
+ % mvpa.nBlocks = nBlocks;
+
+
+
+
+ %probably a better way
+ if nSubs == 1
+
+ MVPC = mvpc;
+ ALLMVPC = mvpc;
+ else
+
+ MVPC = mvpc;
+ ALLMVPC(s) = mvpc;
+ end
+
+
+
+end % end of subject loop: Step 9: Decoding for each participant
\ No newline at end of file
diff --git a/functions/erplab.m b/functions/erplab.m
index 19e7feb3..e8153668 100755
--- a/functions/erplab.m
+++ b/functions/erplab.m
@@ -54,6 +54,9 @@ function erplab(dosomething)
pop_erphelpscript;
case 'redraw'
option = 0;
+ erp_check = 0;
+ best_check = 0;
+ mvpc_check = 0;
try
ALLERP = evalin('base', 'ALLERP');
catch
@@ -65,7 +68,8 @@ function erplab(dosomething)
ERP =[];
end
if isempty(ALLERP) && isempty(ERP)
- return
+ %return
+ erp_check = 1;
elseif isempty(ALLERP) && ~isempty(ERP)
ALLERP = ERP;
CURRENTERP =1;
@@ -88,9 +92,106 @@ function erplab(dosomething)
assignin('base','ALLERP', ALLERP); % save to workspace
assignin('base','CURRENTERP', CURRENTERP); % save to workspace
end
- eeglab redraw
- pause(0.1)
- updatemenuerp(ALLERP, option);
+
+ %% BESTsets
+
+ try
+ ALLBEST = evalin('base', 'ALLBEST');
+ catch
+ ALLBEST = [];
+ end
+ try
+ BEST = evalin('base', 'BEST');
+ catch
+ BEST =[];
+ end
+ if isempty(ALLBEST) && isempty(BEST)
+ %return
+ best_check = 1;
+ elseif isempty(ALLBEST) && ~isempty(BEST)
+ ALLBEST = BEST;
+ CURRENTBEST =1;
+ assignin('base','CURRENTBEST', CURRENTBEST); % save to workspace
+ assignin('base','ALLBEST', ALLBEST); % save to workspace
+ else
+ try
+ CURRENTBEST = evalin('base', 'CURRENTBEST');
+ if CURRENTBEST<=0 || isempty(CURRENTBEST)
+ CURRENTBEST=1;
+ end
+ catch
+ CURRENTBEST = 1;
+ end
+ nbest = length(ALLBEST);
+ if CURRENTBEST<=nbest
+ option = 1;
+ end
+ assignin('base','ALLBEST', ALLBEST); % save to workspace
+ assignin('base','CURRENTBEST', CURRENTBEST); % save to workspace
+ end
+
+ %% MVPC sets
+
+ try
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ catch
+ ALLMVPC = [];
+ end
+ try
+ MVPC = evalin('base', 'MVPC');
+ catch
+ MVPC =[];
+ end
+ if isempty(ALLMVPC) && isempty(MVPC)
+ %return
+ mvpc_check = 1;
+ elseif isempty(ALLMVPC) && ~isempty(MVPC)
+ ALLMVPC = MVPC;
+ CURRENTMVPC =1;
+ assignin('base','CURRENTMVPC', CURRENTMVPC); % save to workspace
+ assignin('base','ALLMVPC', ALLMVPC); % save to workspace
+ else
+ try
+ CURRENTMVPC = evalin('base', 'CURRENTMVPC');
+ if CURRENTMVPC<=0 || isempty(CURRENTMVPC)
+ CURRENTMVPC=1;
+ end
+ catch
+ CURRENTMVPC = 1;
+ end
+ nmvpc = length(ALLMVPC);
+ if CURRENTMVPC<=nmvpc
+ option = 1;
+ end
+ assignin('base','ALLMVPC', ALLMVPC); % save to workspace
+ assignin('base','CURRENTMVPC', CURRENTMVPC); % save to workspace
+ end
+
+
+ if erp_check == 0
+ eeglab redraw
+ pause(0.1)
+ updatemenuerp(ALLERP, option);
+ end
+
+ % redraws = 0; %since eeglab can't identify these data yet
+ if best_check == 0
+ eeglab redraw
+ % redraws = 1;
+ pause(0.1)
+ updatemenubest(ALLBEST,option);
+ end
+
+ if mvpc_check == 0
+% if redraws == 0
+% eeglab redraw
+% end
+ eeglab redraw
+ pause(0.1)
+ updatemenumvpc(ALLMVPC,option);
+
+ end
+
case 'amnesia'
erplabamnesia
case 'freedom'
diff --git a/functions/erpworkingmemory.m b/functions/erpworkingmemory.m
index ebfd7ff4..a123ea27 100755
--- a/functions/erpworkingmemory.m
+++ b/functions/erpworkingmemory.m
@@ -1,4 +1,4 @@
-% PURPOSE : encodes and retrieves ERPLAB's working memory
+% PURPOSE : encodes and retrieves ERPLAB's working memory
%
% FORMAT :
%
@@ -18,7 +18,7 @@
% EXAMPLE 1: encode pop_appenderp's memory (values currently being used)
%
% erpworkingmemory('pop_appenderp', { optioni, erpset, prefixlist });
-%
+%
%
% EXAMPLE 2: retrieve pop_appenderp's memory (values last used)
%
@@ -26,16 +26,16 @@
%
%
% *** This function is part of ERPLAB Toolbox ***
-% Author: Javier Lopez-Calderon
+% Author: Javier Lopez-Calderon &Guanghui Zhang
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
-% 2009
+% 2009 & 2022
%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
%
% ERPLAB Toolbox
-% Copyright © 2007 The Regents of the University of California
+% Copyright © 2007 The Regents of the University of California
% Created by Javier Lopez-Calderon and Steven Luck
% Center for Mind and Brain, University of California, Davis,
% javlopez@ucdavis.edu, sjluck@ucdavis.edu
@@ -56,94 +56,133 @@
function output = erpworkingmemory(field, input2store)
output = [];
if nargin<1
- help erpworkingmemory
- return
+ help erpworkingmemory
+ return
end
try
- vmemoryerp = evalin('base', 'vmemoryerp');
+ vmemoryerp = evalin('base', 'vmemoryerp');
catch
- vmemoryerp = [];
+ vmemoryerp = [];
+end
+
+ERPtooltype = erpgettoolversion('tooltype');
+if ~isempty(ERPtooltype)
+ if strcmpi(ERPtooltype,'EStudio')
+ Toolabel = 1;%%Get label from work space to confirm whether EStudio was executed.
+ else
+ Toolabel = 0;
+ end
+else
+ Toolabel = 1;
end
+
+
if nargin==1 % read
- if ~isempty(vmemoryerp) % variable at the workspace for storing/reading memory
-% try
-% v = memoryerp;
-% catch
-% msgboxText = 'ERPLAB could not load the variable, at workspace, called "memoryerp"';
-% try
-% cprintf([0.45 0.45 0.45], sprintf(msgboxText', erplabmemoryfile));
-% catch
-% fprintf(msgboxText);
-% end
-% output = [];
-% return
-% end
- if isfield(vmemoryerp, field)
- output = vmemoryerp.(field);
- else
- output = [];
- end
- else % file for storing/reading memory
- try
- p = which('eegplugin_erplab');
- p = p(1:findstr(p,'eegplugin_erplab.m')-1);
- v = load(fullfile(p,'memoryerp.erpm'), '-mat');
- catch
- msgboxText = ['ERPLAB (erpworkingmemory.m) could not find "memoryerp.erpm" or does not have permission for reading it.\n'...
- 'Please, run EEGLAB once again or go to ERPLAB''s Setting menu and specify/create a new memory file.\n'];
- try
- cprintf([0.45 0.45 0.45], msgboxText');
- catch
- fprintf(msgboxText);
- end
- output = [];
- return
- end
- if isfield(v, field)
- output = v.(field);
- else
- output = [];
- end
+ if ~isempty(vmemoryerp) % variable at the workspace for storing/reading memory
+ % try
+ % v = memoryerp;
+ % catch
+ % msgboxText = 'ERPLAB could not load the variable, at workspace, called "memoryerp"';
+ % try
+ % cprintf([0.45 0.45 0.45], sprintf(msgboxText', erplabmemoryfile));
+ % catch
+ % fprintf(msgboxText);
+ % end
+ % output = [];
+ % return
+ % end
+ if isfield(vmemoryerp, field)
+ output = vmemoryerp.(field);
+ else
+ output = [];
+ end
+ else % file for storing/reading memory
+ try
+ if Toolabel==1%%When using EStudio
+ p = which('o_ERPDAT');
+ p = p(1:findstr(p,'o_ERPDAT.m')-1);
+ v = load(fullfile(p,'memoryerpstudio.erpm'), '-mat');
+ else%%When using ERPLAB
+ p = which('eegplugin_erplab');
+ p = p(1:findstr(p,'eegplugin_erplab.m')-1);
+ v = load(fullfile(p,'memoryerp.erpm'), '-mat');
+ end
+ catch
+ if Toolabel==1%%When using EStudio
+ msgboxText = ['ERPLAB Studio (erpworkingmemory.m) could not find "memoryerpstudio.erpm" or does not have permission for reading it.\n'...
+ 'Please, run EEGLAB once again or go to ERPLAB''s Setting menu and specify/create a new memory file.\n'];
+ else
+ msgboxText = ['ERPLAB Studio (erpworkingmemory.m) could not find "memoryerpstudio.erpm" or does not have permission for reading it.\n'...
+ 'Please, run EEGLAB Studio once again or go to EStudio''s Setting menu and specify/create a new memory file.\n'];
+
+ end
+
+ try
+ cprintf([0.45 0.45 0.45], msgboxText');
+ catch
+ fprintf(msgboxText);
+ end
+ output = [];
+ return
+ end
+ if isfield(v, field)
+ output = v.(field);
+ else
+ output = [];
end
- return
+ end
+ return
elseif nargin==2 % write
- if ~isempty(vmemoryerp) % variable at the workspace for storing/reading memory
- try
- vmemoryerp.(field) = input2store;
- assignin('base','vmemoryerp', vmemoryerp);
- catch
- msgboxText = 'ERPLAB (erpworkingmemory.m) could not write to the variable called vmemoryerp, at workspace.';
- try
- cprintf([0.45 0.45 0.45], sprintf(msgboxText', erplabmemoryfile));
- catch
- fprintf(msgboxText);
- end
- return
- end
- else % file for storing/reading memory
- try
- eval([field '=input2store;'])
- p = which('eegplugin_erplab');
- p = p(1:findstr(p,'eegplugin_erplab.m')-1);
- save(fullfile(p,'memoryerp.erpm'), field,'-append');
- catch
- msgboxText = ['ERPLAB could not find "memoryerp.erpm" or does not have permission for writting on it.\n'...
- 'Please, run EEGLAB once again or go to ERPLAB''s Setting menu and specify/create a new memory file.\n'];
- try
- cprintf([0.45 0.45 0.45], msgboxText');
- catch
- fprintf(msgboxText);
- end
- return
- end
+ if ~isempty(vmemoryerp) % variable at the workspace for storing/reading memory
+ try
+ vmemoryerp.(field) = input2store;
+ assignin('base','vmemoryerp', vmemoryerp);
+ catch
+ msgboxText = 'ERPLAB (erpworkingmemory.m) could not write to the variable called vmemoryerp, at workspace.';
+ try
+ cprintf([0.45 0.45 0.45], sprintf(msgboxText', erplabmemoryfile));
+ catch
+ fprintf(msgboxText);
+ end
+ return
end
-else % invalid inputs
- msgboxText = 'Wrong number of inputs for erpworkingmemory.m\n';
+ else % file for storing/reading memory
try
- cprintf([0.45 0.45 0.45], msgboxText');
+ if Toolabel==1%%When using EStudio
+ eval([field '=input2store;'])
+ p = which('o_ERPDAT');
+ p = p(1:findstr(p,'o_ERPDAT.m')-1);
+ save(fullfile(p,'memoryerpstudio.erpm'), field,'-append');
+
+ else%%When using ERPLAB
+ eval([field '=input2store;'])
+ p = which('eegplugin_erplab');
+ p = p(1:findstr(p,'eegplugin_erplab.m')-1);
+ save(fullfile(p,'memoryerp.erpm'), field,'-append');
+ end
catch
+ if Toolabel==1%%When using EStudio
+ msgboxText = ['ERPLAB Studio could not find "memoryerpstudio.erpm" or does not have permission for writting on it.\n'...
+ 'Please, run EEGLAB Studio once again or go to EStudio''s Setting menu and specify/create a new memory file.\n'];
+ else
+ msgboxText = ['ERPLAB could not find "memoryerp.erpm" or does not have permission for writting on it.\n'...
+ 'Please, run EEGLAB once again or go to ERPLAB''s Setting menu and specify/create a new memory file.\n'];
+ end
+ try
+ cprintf([0.45 0.45 0.45], msgboxText');
+ catch
fprintf(msgboxText);
+ end
+ return
end
- output = [];
- return
+ end
+else % invalid inputs
+ msgboxText = 'Wrong number of inputs for erpworkingmemory.m\n';
+ try
+ cprintf([0.45 0.45 0.45], msgboxText');
+ catch
+ fprintf(msgboxText);
+ end
+ output = [];
+ return
end
\ No newline at end of file
diff --git a/functions/getallbeststate.m b/functions/getallbeststate.m
new file mode 100644
index 00000000..1516c7e3
--- /dev/null
+++ b/functions/getallbeststate.m
@@ -0,0 +1,40 @@
+% PURPOSE: gets current pointer for ALLBEST structure and its size
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function [nset CURRENTBEST] = getallbeststate
+try
+ ALLBEST = evalin('base', 'ALLBEST');
+ CURRENTBEST = evalin('base', 'CURRENTBEST');
+catch
+ ALLBEST = [];
+ CURRENTBEST = [];
+end
+nset = length(ALLBEST);
diff --git a/functions/getallmvpcstate.m b/functions/getallmvpcstate.m
new file mode 100644
index 00000000..5372c3c2
--- /dev/null
+++ b/functions/getallmvpcstate.m
@@ -0,0 +1,40 @@
+% PURPOSE: gets current pointer for ALLMVPC structure and its size
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function [nset CURRENTMVPC] = getallbeststate
+try
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ CURRENTMVPC = evalin('base', 'CURRENTMVPC');
+catch
+ ALLMVPC = [];
+ CURRENTMVPC = [];
+end
+nset = length(ALLMVPC);
diff --git a/functions/isbeststruct.m b/functions/isbeststruct.m
new file mode 100644
index 00000000..c1e982ac
--- /dev/null
+++ b/functions/isbeststruct.m
@@ -0,0 +1,97 @@
+% PURPOSE: tests whether input is a valid BEST structure or not.
+%
+% FORMAT:
+%
+% value = isbeststruct(input);
+%
+% value = 1 means input is a valid BEST structure; 0 otherwise.
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function value = isbeststruct(input)
+try
+ if ~isstruct(input)
+ value = 0;
+ return
+ end
+
+ %
+ % Main ERP fields
+ %
+ ref_field = { 'bestname',...
+ 'filename',...
+ 'filepath',...
+ 'nbin',...
+ 'pnts',...
+ 'srate',...
+ 'xmin',...
+ 'xmax',...
+ 'times',...
+ 'nbchan',...
+ 'chanlocs',...
+ 'bindesc',...
+ 'original_bin',...
+ 'EEGhistory',...
+ 'binwise_data',...
+ 'n_trials_per_bin',...
+ 'saved',...
+ 'version'};
+% 'workfiles',...
+% 'subject',...
+% 'nchan',...
+% 'nbin',...
+% 'pnts',...
+% 'srate',...
+% 'xmin',...
+% 'xmax',...
+% 'times',...
+% 'bindata',...
+% 'ntrials',...
+% 'isfilt',...
+% 'chanlocs',...
+% 'ref',...
+% 'bindescr',...
+% 'saved',...
+
+ BESTX = input(:);
+ fnam = fieldnames(BESTX);
+ tf = ismember_bc2(ref_field, fnam );
+
+ if nnz(tf)== length(ref_field)
+ value = 1;
+ else
+ value = 0;
+ end
+catch
+ value = 0;
+ return
+end
+
+
diff --git a/functions/mvpc2memory.m b/functions/mvpc2memory.m
new file mode 100644
index 00000000..2a98eba7
--- /dev/null
+++ b/functions/mvpc2memory.m
@@ -0,0 +1,36 @@
+
+function mvpc2memory(MVPC,indx)
+
+mvpcm = findobj('tag','linmvpc');
+nmvpcset = length(mvpcm);
+
+for s = 1:nmvpcset
+
+ if s == nmvpcset-indx+1 %bottomup to topdown counting
+ set(mvpcm(s),'checked','on');
+ menutitle = ['MVPCset' ...
+ num2str(nmvpcset-s+1) ': ' MVPC.mvpcname ' '];
+ set(mvpcm(s), 'Label', menutitle);
+
+ else
+ set(mvpcm(s),'checked','off');
+ currname = get(mvpcm(s),'Label');
+ menutitle = regexprep(currname,'| ','', 'ignorecase');
+ menutitle = regexprep(menutitle, '\s+', ' ');
+ menutitle = regexprep(menutitle,'MVPCset \d+',['MVPCset ' num2str(nmvpcset-s+1)], 'ignorecase');
+ set( mvpcm(s), 'Label', menutitle);
+
+ end
+
+
+end
+
+CURRENTMVPC = indx;
+assignin('base','CURRENTMVPC',CURRENTMVPC);
+assignin('base','MVPC',MVPC);
+
+fprintf('\n------------------------------------------------------\n');
+fprintf('MVPCset #%g is ACTIVE\n', indx);
+fprintf('------------------------------------------------------\n');
+
+end
\ No newline at end of file
diff --git a/functions/mvpc2text.m b/functions/mvpc2text.m
new file mode 100644
index 00000000..707bea58
--- /dev/null
+++ b/functions/mvpc2text.m
@@ -0,0 +1,161 @@
+% PURPOSE : subroutine for pop_export2text
+%
+% FORMAT :
+%
+% serror = export2text(ERP, filename, time, timeunit, transpose)
+%
+%
+% INPUTS :
+%
+% MVPC - MVPCset (ERPLAB structure)
+% filename - filename of outputted file
+% time' - 1=include time values; 0=don't include time values
+% timeunit' - 1=seconds; 1E-3=milliseconds
+% transpose' - 1= (points=rows) & (values=columns)
+% 0= (values=rows) & (points=column)
+%
+% OUTPUTS
+%
+% serror - error report. 0 means no errors found; 1 means something went wrong...
+% file - text file
+%
+%
+% See also pop_mvpc2text.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function serror = export2text(MVPC, filename, time, timeunit, transpose)
+serror = 0; % no errors
+%nbin = length(binArray);
+
+[pathstr, prefname1, ext] = fileparts(filename);
+
+if strcmp(ext,'')
+ ext = '.txt';
+end
+precision = 4;
+prefname2 = fullfile(pathstr, prefname1);
+try
+ disp('Your MVPC results have been exported into the following files:')
+% for ibin=1:nbin
+
+ %
+ % ERP data
+ %
+ data = MVPC.average_score;
+
+ %
+ % add time axis
+ %
+ if time==1
+ %fprintf('bin #%g\n', ibin);
+ time_val = (MVPC.times/1000)/timeunit; %Nov 2010
+ auxdata = zeros(size(data,1) + 1, size(data,2));
+ auxdata(1,:) = time_val;
+ auxdata(2:end,:) = data;
+ data = auxdata; clear auxdata;
+ end
+
+ %
+ % transpose and write to disk
+ %
+ %strbindescr = MVPC.bindescr{binArray(ibin)};
+ % strbindescr = regexprep(strbindescr,'\\|\/|\*|\#|\$|\@|\:','_'); % replace forbidden characters
+ binfilename = [ prefname2 ext ]; % ...and add ext
+ fid = fopen(binfilename, 'w');
+
+ if transpose==1 % no transpose
+
+ %
+ % writing electrodes
+ %
+ strprintf = '';
+ for index = 1:size(data,1)
+ if time==1 % show time values
+ tmpind = index-1;
+ else
+ tmpind = index;
+ end
+
+ if tmpind > 0
+% if ~isempty(MVPC.chanlocs)
+% labx = MVPC.chanlocs(tmpind).labels;
+% labx = regexprep(labx,'\\|\/|\*|\#|\$|\@','_'); % replace forbidden characters
+% fprintf(fid, '%s\t', labx);
+% else
+ fprintf(fid, '\t');
+% end
+ else
+ fprintf(fid, 'time\t\n');
+ end
+
+ strprintf = [ strprintf '%.' num2str(precision) 'f\t' ];
+ end
+
+ strprintf(end) = 'n';
+
+% if electrodes==1
+% fprintf(fid, '\n');
+% end
+ fprintf(fid, strprintf, data);
+ else % transpose
+
+ %
+ % writing electrodes
+ %
+ for index = 1:size(data,1)
+ if time==1
+ tmpind = index-1;
+ else
+ tmpind = index;
+ end
+% if electrodes==1
+% if tmpind > 0
+% if ~isempty(MVPC.chanlocs)
+% labx = MVPC.chanlocs(tmpind).labels;
+% labx = regexprep(labx,'\\|\/|\*|\#|\$|\@','_'); % replace forbidden characters.
+% fprintf(fid,'%s\t', labx);
+% else
+% fprintf(fid,'%d\t', tmpind);
+% end
+% else
+% fprintf(fid, 'time\t');
+% end
+% end
+ fprintf(fid,[ '%.' num2str(precision) 'f\t' ], data(index, :));
+ fprintf(fid, '\n');
+ end
+ end
+ fclose(fid);
+ % disp(['' binfilename]);
+% end
+catch
+ serror = 1; %something went wrong
+end
+fprintf('\n');
diff --git a/functions/mvpcaverager.m b/functions/mvpcaverager.m
new file mode 100644
index 00000000..9834dd3a
--- /dev/null
+++ b/functions/mvpcaverager.m
@@ -0,0 +1,177 @@
+function [MVPC, serror, msgboxText] = mvpcaverager(ALLMVPC, lista, optioni, mvpcset, nfile, stderror,warnon)
+%Only averages across decoding accuracy per subject (SVM 1vall).
+%Does not yet average across SMV (1v1) and Crossnobis Distance.
+
+serror = 0 ;
+msgboxText = '';
+
+%Reads in the correct ALLMVPC set
+ds = 1;
+for j = 1:nfile
+
+ if optioni==1
+ fprintf('Loading %s...\n', lista{j});
+ MVPCX = load(lista{j}, '-mat');
+ MVPCT = MVPCX.MVPC;
+ else
+ MVPCT = ALLMVPC(mvpcset(j));
+ end
+
+ if j>1
+
+ % basic test for number of points
+ if pre_pnts ~= MVPCT.pnts
+ msgboxText = sprintf('MVPCsets #%g and #%g have different number of points!', j-1, j);
+ title = 'ERPLAB: pop_gaverager() Error';
+ errorfound(msgboxText, title);
+ serror = 1;
+ break
+ end
+
+ if warnon == 1
+ % basic test for number of channels (for now...)
+ if pre_nchan ~= size(MVPCT.electrodes,2)
+ msgwrng = sprintf('MVPCsets #%g and #%g have different number of channels!', j-1, j);
+ cprintf([1 0.52 0.2], '%s\n\n', msgwrng);
+
+ %title = 'ERPLAB: pop_gaverager() Error';
+ %errorfound(msgboxText, title);
+ %serror = 1;
+ %break
+ end
+
+
+
+ % basic test for number of bins (for now...)
+ if pre_nClasses ~= MVPCT.nClasses
+ msgwrng = sprintf('MVPCsets #%g and #%g have different number of classes!', j-1, j);
+ cprintf([1 0.52 0.2], '%s\n\n', msgwrng);
+ %title = 'ERPLAB: pop_gaverager() Error';
+ %errorfound(msgboxText, title);
+ %return
+ %serror = 1;
+ %break
+ end
+
+ if pre_nIter ~= MVPCT.nIter
+ msgwrng = sprintf('MVPCsets #%g and #%g have different number of Iterations!', j-1, j);
+ cprintf([1 0.52 0.2], '%s\n\n', msgwrng);
+ %title = 'ERPLAB: pop_gaverager() Error';
+ %errorfound(msgboxText, title);
+ %return
+ %serror = 1;
+ %break
+ end
+
+ if pre_nCrossfolds ~= MVPCT.nCrossfolds
+ msgwrng = sprintf('MVPCsets #%g and #%g have different number of Iterations!', j-1, j);
+ cprintf([1 0.52 0.2], '%s\n\n', msgwrng);
+ %title = 'ERPLAB: pop_gaverager() Error';
+ %errorfound(msgboxText, title);
+ %return
+ %serror = 1;
+ %break
+ end
+
+
+
+ % basic test for data type (for now...)
+ if ~strcmpi(pre_dtype, MVPCT.DecodingMethod)
+ msgwrng = sprintf('MVPCsets #%g and #%g have different type of data (see ALLMVPC.datatype)', j-1, j);
+ cprintf([1 0.52 0.2], '%s\n\n', msgwrng);
+ %errorfound(msgboxText, title);
+ %return
+% serror = 1;
+% break
+ end
+
+
+ end
+
+ end
+
+
+
+
+ pre_nchan = size(MVPCT.electrodes,2);
+ pre_pnts = MVPCT.pnts;
+ pre_nCrossfolds = MVPCT.nCrossfolds;
+ pre_nClasses = MVPCT.nClasses;
+ pre_nIter = MVPCT.nIter;
+ pre_dtype = MVPCT.DecodingMethod;
+ %
+ % Preparing MVPC struct (first MVPC)
+ %
+ if ds==1
+% workfileArray = ERPT.workfiles;
+% [nch, npnts, nbin] = size(ERPT.bindata);
+ sumMVPC = zeros(1,MVPCT.pnts);
+ if stderror
+ sumMVPC2 = zeros(nfile,MVPCT.pnts);
+ end
+ sumCFs =zeros(MVPCT.nClasses,MVPCT.nClasses,MVPCT.pnts);
+% naccepted = zeros(1,nbin);
+% auxnaccepted = zeros(1,nbin); % ###
+% nrejected = zeros(1,nbin);
+% ninvalid = zeros(1,nbin);
+% narflags = zeros(nbin,8);
+ % ERPset
+ MVPC.mvpcname = [];
+ MVPC.filename = [];
+ MVPC.filepath = [];
+ MVPC.electrodes = MVPCT.electrodes;
+ MVPC.chanlocs = MVPCT.chanlocs;
+ MVPC.nClasses = MVPCT.nClasses;
+ MVPC.chance = MVPCT.chance;
+ MVPC.classlabels = MVPCT.classlabels;
+ MVPC.nIter = MVPCT.nIter;
+ MVPC.nCrossfolds = MVPCT.nCrossfolds;
+ MVPC.srate = MVPCT.srate;
+ MVPC.pnts = MVPCT.pnts;
+ MVPC.classcoding.OneVsOne = MVPCT.classcoding.OneVsOne;
+ MVPC.classcoding.OneVsAll = MVPCT.classcoding.OneVsAll;
+ MVPC.DecodingUnit = MVPCT.DecodingUnit;
+ MVPC.DecodingMethod = MVPCT.DecodingMethod;
+ MVPC.average_status = 'grandaverage';
+ MVPC.equalTrials = 'grandavg'; %%%%%%%%%%%%%%%%%%%%%%%
+ MVPC.n_trials_per_class = 'grandavg'; %%%%%%%%%%%%%%%%
+ MVPC.saved = 'no';
+ MVPC.epoch = MVPCT.epoch;
+ MVPC.times = MVPCT.times;
+ MVPC.mvpc_version = MVPCT.mvpc_version;
+ MVPC.details = 'grandavg';
+ MVPC.raw_predictions = 'grandavg';
+ MVPC.average_score = [];
+ MVPC.confusions.scores = [];
+ MVPC.confusions.labels = MVPCT.confusions.labels;
+
+
+% EVEL = ERPT.EVENTLIST;
+% ALLEVENTLIST(1:length(EVEL)) = EVEL;
+ else
+% EVEL = ERPT.EVENTLIST;
+% ALLEVENTLIST(end+1:end+length(EVEL)) = EVEL;
+ end
+
+ sumMVPC = sumMVPC + MVPCT.average_score; % cumulative sum: Sum(xi)
+ sumCFs = sumCFs + MVPCT.confusions.scores;
+
+ if stderror
+ sumMVPC2(j,:) = MVPCT.average_score;
+
+ end
+
+ ds = ds+1; % counter for clean MVPCsets (keep it that way until Steve might eventually decide to reject subjects automatically...)
+
+
+end
+
+%get average across MVPCsets
+MVPC.average_score = sumMVPC/nfile;
+MVPC.confusions.scores = sumCFs/nfile;
+
+if stderror
+ MVPC.stderror = squeeze(std(sumMVPC2,1))/sqrt(nfile);
+end
+
+end
\ No newline at end of file
diff --git a/functions/painterplabapp.m b/functions/painterplabapp.m
new file mode 100644
index 00000000..b56a5d65
--- /dev/null
+++ b/functions/painterplabapp.m
@@ -0,0 +1,105 @@
+% PURPOSE : sets background and foreground color of the current ERPLAB's GUI
+% Updated for APP designer
+%
+% FORMAT :
+%
+% handles = painterplab(handles, type);
+%
+% handles - GUI's handles structure
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Javier Lopez-Calderon
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2009
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function painterplabapp(app, type)
+if nargin<2
+ type = 0;
+end
+if type==0
+ %
+ % Color GUI
+ %
+ ColorB = erpworkingmemory('ColorB');
+ ColorF = erpworkingmemory('ColorF');
+elseif type==1
+ ColorB = [1 0.9 0.3];
+ ColorF = [0 0 0];
+end
+if isempty(ColorB)
+ ColorB = [0.7020 0.7647 0.8392];
+ %ColorB = [0.83 0.82 0.79];
+end
+if isempty(ColorF)
+ ColorF = [0 0 0];
+end
+ColorB2 = [0.6020 0.6647 0.7392];
+filedsn = fieldnames(app);
+
+% GUI's objects' color background
+for kk=1:length(filedsn)
+ mstr = regexpi(filedsn{kk},'^figure|^axes1|^nbin|^edit|^listbox|^EEG|^ERP|togglebutton_summary|^pushbutton|totline|indxline|ERP_figure|Scalp_figure|counterchanwin|counterbinwin|Label_BG1|Label_BG2','match');
+ if isempty(mstr)
+ try
+ num = app.(filedsn{kk});
+ numType = num.Type;
+ if (~strcmpi(numType,'uinumericeditfield') && ~strcmpi(numType,'uieditfield') && ~strcmpi(numType,'uibutton') && ~strcmpi(numType,'uitable'))
+ if ~iscell(num) && ~isstruct(num)
+ if num~=1
+ try
+ set(num, 'BackgroundColor', ColorB2)
+ catch
+ end
+
+ try
+ set(num,'HighlightColor',[1 1 1])
+ catch
+ end
+
+
+ try
+ set(num, 'ForegroundColor', ColorF)
+ catch
+
+ end
+ end
+ end
+ end
+ catch
+ end
+
+ end
+end
+
+% GUI's color background
+try
+ set(app.UIFigure, 'Color', ColorB)
+ %disp('Mira:')
+ %num
+ %filedsn{kk}
+catch
+end
\ No newline at end of file
diff --git a/functions/preloadBEST.m b/functions/preloadBEST.m
new file mode 100644
index 00000000..87e79ba8
--- /dev/null
+++ b/functions/preloadBEST.m
@@ -0,0 +1,29 @@
+% PURPOSE: Loads a current BEST structure (if any) from the workspace
+% Otherwise, load ALLBEST(CURRENTBEST); Otherwise, BEST = []
+%
+% To avoid clearing an already filled BEST structure after an
+% interrupted process (for instance, after error) or canceling
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function BEST = preloadBEST
+try
+ BEST = evalin('base', 'BEST');
+catch
+ BEST = [];
+end
+if isempty(BEST)
+ try
+ ALLBEST = evalin('base', 'ALLBEST');
+ k = evalin('base', 'CURRENTBEST');
+ BEST = ALLBEST(k);
+ catch
+ BEST = [];
+ end
+end
diff --git a/functions/preloadMVPA.m b/functions/preloadMVPA.m
new file mode 100644
index 00000000..dbcdbb00
--- /dev/null
+++ b/functions/preloadMVPA.m
@@ -0,0 +1,29 @@
+% PURPOSE: Loads a current MVPA structure (if any) from the workspace
+% Otherwise, load ALLMVPA(CURRENTMVPA); Otherwise, MVPA = []
+%
+% To avoid clearing an already filled MVPA structure after an
+% interrupted process (for instance, after error) or canceling
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function MVPA = preloadMVPA
+try
+ MVPA = evalin('base', 'MVPA');
+catch
+ MVPA = [];
+end
+if isempty(MVPA)
+ try
+ ALLMVPA = evalin('base', 'ALLMVPA');
+ k = evalin('base', 'CURRENTMVPA');
+ MVPA = ALLMVPA(k);
+ catch
+ MVPA = [];
+ end
+end
diff --git a/functions/preloadMVPC.m b/functions/preloadMVPC.m
new file mode 100644
index 00000000..7f862a3b
--- /dev/null
+++ b/functions/preloadMVPC.m
@@ -0,0 +1,29 @@
+% PURPOSE: Loads a current MVPC structure (if any) from the workspace
+% Otherwise, load ALLMVPC(CURRENTMVPC); Otherwise, MVPC = []
+%
+% To avoid clearing an already filled MVPA structure after an
+% interrupted process (for instance, after error) or canceling
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function MVPC = preloadMVPC
+try
+ MVPC = evalin('base', 'MVPC');
+catch
+ MVPC = [];
+end
+if isempty(MVPC)
+ try
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ k = evalin('base', 'CURRENTMVPC');
+ MVPC = ALLMVPC(k);
+ catch
+ MVPC = [];
+ end
+end
diff --git a/functions/rawscoreSVM.m b/functions/rawscoreSVM.m
new file mode 100644
index 00000000..e1807aa2
--- /dev/null
+++ b/functions/rawscoreSVM.m
@@ -0,0 +1,40 @@
+function [mvpc] = rawscoreSVM(mvpc, truelabel, predictedlabel)
+
+% this function reshapes the decorder outputs
+% and creates mvpa.raw_accuracy_1vsall
+
+%if classcoding == 2
+[Nitr, Nblock, Ntp, nBins] = size(truelabel);
+runs = Nitr*Nblock; %"run" is combination of iteration and fold
+
+reshape_predictions = reshape(predictedlabel,[runs,Ntp,nBins]);
+predictions = permute(reshape_predictions,[2 1 3]);
+%predictions = Timepoint x Run x Class
+%save predictions
+mvpc.raw_predictions = predictions ;
+
+% mvpa.raw_accuracy_1vAll = struct();
+%
+% ind = 1;
+% for tp = 1:Ntp
+% for run = 1:runs
+% mvpa.raw_accuracy_1vAll(ind).TimePoint = tp;
+% mvpa.raw_accuracy_1vAll(ind).Run = run;
+% for b = 1:nBins
+% mvpa.raw_accuracy_1vAll(ind).(strcat('Class_',num2str(b))) = ...
+% predictions(tp,run,b);
+% end
+% ind = ind + 1;
+% end
+% end
+
+
+% %create for 1v1 case
+
+
+%else
+% disp('No SVM coding output?')
+% return
+%end
+
+end
\ No newline at end of file
diff --git a/functions/saveBEST.m b/functions/saveBEST.m
new file mode 100644
index 00000000..ae10d2ab
--- /dev/null
+++ b/functions/saveBEST.m
@@ -0,0 +1,97 @@
+function [BEST, serror, filenamex] = saveBEST(BEST,filenamex,modegui,warnop)
+
+serror = 0;
+
+if nargin < 1
+ help saveBEST
+ return
+
+end
+
+if nargin<4
+ warnop = 0 ; % no warning for overwriting a file
+end
+if nargin<3
+ modegui = 0; % no uiputfile
+end
+
+
+% Save MVPA file (save as)
+BESTaux = BEST;
+namef = filenamex;
+
+if modegui == 1
+ [pathstr, namedef, ext] = fileparts(char(namef));
+ [bestfilename, bestpathname, indxs] = uiputfile({'*.best','BEST (*.best)'}, ...
+ 'Save BEST structure as',...
+ namedef);
+
+ if isequal(bestfilename,0)
+ disp('User selected Cancel')
+ serror = 1;
+ return
+ end
+
+ [pathstr, bestfilename, ext] = fileparts(bestfilename) ;
+
+ if indxs==1
+ ext = '.best';
+ elseif indxs==2
+ ext = '.best';
+ end
+else %direct saving
+ if isempty(filenamex)
+ disp('User selected Cancel')
+ serror =1;
+ return
+ end
+ [bestpathname, bestfilename, ext] = fileparts(filenamex);
+ ext = '.best';
+
+end
+
+disp(['Saving Bin-Epoched Single-Trial (BEST) Data Matrix (.mat) at ' bestpathname '...'] )
+
+
+if isequal(bestfilename,0)
+ disp('User selected Cancel')
+ serror=1;
+ return
+else
+% if isempty(ERP.erpname)
+% ERP.erpname = erpfilename; % without extension
+% end
+
+ BEST.filename = [bestfilename ext];
+ BEST.filepath = bestpathname;
+ BEST.saved ='yes';
+
+% %checking = checkERP(ERP);
+%
+% if checking==0
+% msgboxText = 'Error: ERP structure has error.';
+% tittle = 'ERPLAB: pop_saveERP() error:';
+% errorfound(msgboxText, tittle);
+% serror = 1;
+% ERP = ERPaux;
+% return
+% end
+
+ filenamex = fullfile(bestpathname, [bestfilename ext]);
+
+ if exist(filenamex, 'file')~=0 && warnop==1
+ msgboxText = ['This Bin-Epoched Single-Trial (BEST) Data already exist.\n'...;
+ 'Would you like to overwrite it?'];
+ title = 'ERPLAB: WARNING!';
+ button = askquest(sprintf(msgboxText), title);
+ if strcmpi(button,'no')
+ disp('User canceled')
+ BEST = BESTaux;
+ return
+ end
+ end
+ save(filenamex, 'BEST');
+end
+
+
+return
diff --git a/functions/savemvpc.m b/functions/savemvpc.m
new file mode 100644
index 00000000..8297b666
--- /dev/null
+++ b/functions/savemvpc.m
@@ -0,0 +1,115 @@
+function [MVPC, filenamex, serror] = savemvpc(MVPC,filenamex,modegui,warnop)
+
+serror = 0;
+
+if nargin < 1
+ help savemvpc
+ return
+
+end
+
+if nargin<4
+ warnop = 1 ; % no warning for overwriting a file
+end
+if nargin<3
+ modegui = 0; % no uiputfile
+end
+
+
+% Save MVPA file (save as)
+MVPCaux = MVPC;
+namef = filenamex;
+
+if modegui == 1
+ [pathstr, namedef, ext] = fileparts(char(namef));
+ [mvpcfilename, mvpcpathname, indxs] = uiputfile({'*.mvpc','MVPC (*.mvpc)'}, ...
+ 'Save MVPC structure as',...
+ namedef);
+
+ if isequal(mvpcfilename,0)
+ disp('User selected Cancel')
+ serror = 1;
+ return
+ end
+
+ [pathstr, mvpcfilename, ext] = fileparts(mvpcfilename) ;
+
+ if indxs==1
+ ext = '.mvpc';
+ elseif indxs==2
+ ext = '.mvpc';
+ end
+else %direct saving
+ if isempty(filenamex)
+ disp('User selected Cancel')
+ serror =1;
+ return
+ end
+ [mvpcpathname, mvpcfilename, ext] = fileparts(filenamex);
+ ext = '.mvpc';
+
+end
+try
+disp(['Saving Multivariate Pattern Classification (MVPC) Data Matrix (.mvpc) at ' mvpcpathname{1} '...'] )
+catch
+disp(['Saving Multivariate Pattern Classification (MVPC) Data Matrix (.mvpc) at ' mvpcpathname '...'] )
+end
+
+if isequal(mvpcfilename,0)
+ disp('User selected Cancel')
+ serror=1;
+ return
+else
+ % if isempty(ERP.erpname)
+ % ERP.erpname = erpfilename; % without extension
+ % end
+ if numel(MVPC) == 1
+ MVPC.filename = [mvpcfilename ext];
+ MVPC.filepath = mvpcpathname;
+ MVPC.saved ='yes';
+
+ else
+ for f = 1:length(MVPC)
+ MVPC(f).filename = [mvpcfilename{f} ext];
+ MVPC(f).filepath = mvpcpathname{f};
+ MVPC(f).saved ='yes';
+ end
+ end
+end
+
+% %checking = checkERP(ERP);
+%
+% if checking==0
+% msgboxText = 'Error: ERP structure has error.';
+% tittle = 'ERPLAB: pop_saveERP() error:';
+% errorfound(msgboxText, tittle);
+% serror = 1;
+% ERP = ERPaux;
+% return
+% end
+%% SAVING
+storeMVPC = MVPC;
+for f = 1:length(storeMVPC)
+ MVPC = storeMVPC(f);
+ try
+ filenamex = fullfile(mvpcpathname{f}, [mvpcfilename{f} ext]);
+ catch
+ filenamex = fullfile(mvpcpathname, [mvpcfilename ext]);
+ end
+ if exist(filenamex, 'file')~=0 && warnop==1
+ msgboxText = ['This MVPC Data already exist.\n'...;
+ 'Would you like to overwrite it?'];
+ title = 'ERPLAB: WARNING!';
+ button = askquest(sprintf(msgboxText), title);
+ if strcmpi(button,'no')
+ disp('User canceled')
+ MVPC = MVPCaux;
+ return
+ end
+ end
+ save(filenamex, 'MVPC');
+end
+
+MVPC = storeMVPC; %reset the output to be the full set of multipe MVPC (if applicable)
+
+return
diff --git a/functions/scoreSVM.m b/functions/scoreSVM.m
new file mode 100644
index 00000000..15115f5c
--- /dev/null
+++ b/functions/scoreSVM.m
@@ -0,0 +1,56 @@
+function [mvpa] = scoreSVM(mvpa, truelabel, predictedlabel)
+
+ [Nitr, Nblock, Ntp, nBins] = size(truelabel);
+
+ DecodingAccuracy = nan(Ntp,Nblock,Nitr);
+
+ % Obtain predictions from SVM-ECOC model
+ svmPrediction = squeeze(predictedlabel);
+ tstTargets = squeeze(truelabel);
+
+
+ %% Step 5: Compute decoding accuracy of each decoding trial
+ for block = 1:Nblock
+ for itr = 1:Nitr
+ for tp = 1:Ntp
+
+ prediction = squeeze(svmPrediction(itr,tp,block,:)); % this is predictions from models
+ TrueAnswer = squeeze(tstTargets(itr,tp,block,:)); % this is predictions from models
+ Err = TrueAnswer - prediction; %compute error. No error = 0
+ ACC = mean(Err==0); %Correct hit = 0 (avg propotion of vector of 1s and 0s)
+ DecodingAccuracy(tp,block,itr) = ACC; % average decoding accuracy at tp & block
+
+ end
+ end
+ end
+
+ % Average across block and iterations
+ grandAvg = squeeze(mean(mean(DecodingAccuracy,2),3));
+
+ % Perform temporal smoothing (5 point moving avg)
+ smoothed = nan(1,Ntp);
+ for tAvg = 1:Ntp
+ if tAvg ==1
+ smoothed(tAvg) = mean(grandAvg((tAvg):(tAvg+2)));
+ elseif tAvg ==2
+ smoothed(tAvg) = mean(grandAvg((tAvg-1):(tAvg+2)));
+ elseif tAvg == (Ntp-1)
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg+1)));
+ elseif tAvg == Ntp
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg)));
+ else
+ smoothed(tAvg) = mean(grandAvg((tAvg-2):(tAvg+2)));
+ end
+
+ end
+
+ % Save smoothe data
+ AverageAccuracy(seta,:) =smoothed; % average across iteration and block
+
+
+ reshape_targ = reshape(svm_predict,[Nitr*Nblock,Ntp,nBins]);
+ final_targ = permute(new_targ,[2 1 3]);
+
+
+
+end
\ No newline at end of file
diff --git a/functions/updatemenubest.m b/functions/updatemenubest.m
new file mode 100644
index 00000000..1ad40d22
--- /dev/null
+++ b/functions/updatemenubest.m
@@ -0,0 +1,100 @@
+% PURPOSE: updates BESTset menu
+
+
+function updatemenubest(ALLBEST,overw)
+if nargin<2
+ overw=0; % overwrite bestset menu? 0=no; 1=yes; -1=delete
+end
+
+%
+% Checks BESTsets menu status
+%
+BESTmenu = findobj('tag', 'bestsets');
+statbestm = get(BESTmenu, 'Enable');
+if strcmp(statbestm,'off')
+ set(BESTmenu, 'Enable', 'on'); % activates bestsets menu
+end
+
+maxindexbest = length(ALLBEST);
+BESTSETMENU = zeros(1,maxindexbest);
+bestsetlist = findobj('tag','linbest');
+
+if isempty(bestsetlist)
+ nbestset = 0;
+ overw = 0 ; %add a new bestset
+elseif length(bestsetlist) > maxindexbest
+ nbestset = length(bestsetlist);
+ overw = -1; %delete bestset
+elseif length(bestsetlist) < maxindexbest
+ nbestset = length(bestsetlist);
+ overw = 0; %add bestset
+
+else
+ nbestset = length(bestsetlist);
+end
+
+if overw == 1
+ %overwrite. Just change the current bestset
+
+ for s = 1:nbestset
+ strcheck = get(bestsetlist(s), 'checked');
+
+ if strcmp(strcheck,'on')
+ catchindx = nbestset-s+1;
+ bestn = ALLBEST(nbestset-s+1).bestname;
+ menutitle = sprintf('BESTset %d: %s', nbestset-s+1,bestn);
+ set(bestsetlist(s), 'Label', menutitle);
+ end
+
+ end
+ best2memory(ALLBEST(catchindx),catchindx);
+
+elseif overw == 0 || overw == -1
+
+ if overw == 0 %add a new bestset to the bestset menu
+ indexbest = nbestset + 1;
+ else %delete bestset from menu
+ menux = findobj(0, 'tag', 'bestsets');
+ h = get(menux);
+ delete(h.Children);
+ indexbest = 1;
+ if maxindexbest==0
+ assignin('base','CURRENTBEST', 0); % save to workspace
+ set(BESTmenu, 'enable', 'off');
+ return
+ end
+ end
+
+ while indexbest <= maxindexbest
+ BESTSETMENU(indexbest) = uimenu(BESTmenu, 'tag', 'linbest');
+ fbest = ['best2memory(ALLBEST(' num2str(indexbest) '),' num2str(indexbest) ');'];
+ bestn = ALLBEST(indexbest).bestname;
+ if iscell(bestn)
+ bestn = '';
+ end
+ menutitle = ['BESTset ' num2str(indexbest) ': ' bestn ' '];
+ set( BESTSETMENU(indexbest), 'Label', menutitle);
+ set( BESTSETMENU(indexbest), 'CallBack', fbest );
+ set( BESTSETMENU(indexbest), 'Enable', 'on' );
+ indexbest = indexbest + 1;
+
+ end
+
+ if maxindexbest ~= 0
+ best2memory(ALLBEST(maxindexbest),maxindexbest);
+ end
+
+
+
+
+else
+ error('ERPLAB sasys: wrong input parameter')
+
+
+
+end
+
+eeglab redraw;
+%set(BESTmenu, 'Enable', 'on'); % activates erpsets menu after redraw (eeglab hack)
+
+end
\ No newline at end of file
diff --git a/functions/updatemenuerp.m b/functions/updatemenuerp.m
index cb391a78..33d2002b 100755
--- a/functions/updatemenuerp.m
+++ b/functions/updatemenuerp.m
@@ -92,11 +92,11 @@ function updatemenuerp(ALLERP, overw)
assignin('base','CURRENTERP', 0); % save to workspace
set(erpmenu, 'enable', 'off');
%%changed by GH Apr 2023
- observe_ERPDAT.ALLERP = [];
- observe_ERPDAT.Two_GUI = 1;
- cprintf('red',['\n ERP Wave Viewer will be closed because ALLERP is empty.\n\n']);
+% observe_ERPDAT.ALLERP = [];
+% observe_ERPDAT.Two_GUI = 1;
+% cprintf('red',['\n ERP Wave Viewer will be closed because ALLERP is empty.\n\n']);
%%change end
-
+ erpworkingmemory('ERPLAB_ERPWaviewer',1);
return
end
end
@@ -147,22 +147,22 @@ function updatemenuerp(ALLERP, overw)
set(option2, 'enable', 'off');
set(option3, 'enable', 'off');
end
-
+erpworkingmemory('ERPLAB_ERPWaviewer',1);
%%changed GZ Mar. 2023
-CURRENTERP = maxindexerp;
-if ~isempty(ALLERP)%%if
- observe_ERPDAT.ALLERP =ALLERP;
- if isempty(CURRENTERP) || CURRENTERP<=0 || CURRENTERP> length(ALLERP)
- CURRENTERP= length(ALLERP);
- end
- observe_ERPDAT.CURRENTERP = CURRENTERP;
- observe_ERPDAT.ERP = ALLERP(CURRENTERP);
- observe_ERPDAT.Two_GUI = 1;
-else
- observe_ERPDAT.ALLERP = [];
- observe_ERPDAT.Two_GUI = 1;
-end
+% CURRENTERP = maxindexerp;
+% if ~isempty(ALLERP)%%if
+% observe_ERPDAT.ALLERP =ALLERP;
+% if isempty(CURRENTERP) || CURRENTERP<=0 || CURRENTERP> length(ALLERP)
+% CURRENTERP= length(ALLERP);
+% end
+% observe_ERPDAT.CURRENTERP = CURRENTERP;
+% observe_ERPDAT.ERP = ALLERP(CURRENTERP);
+% observe_ERPDAT.Two_GUI = 1;
+% else
+% observe_ERPDAT.ALLERP = [];
+% observe_ERPDAT.Two_GUI = 1;
+% end
end
diff --git a/functions/updatemenumvpc.m b/functions/updatemenumvpc.m
new file mode 100644
index 00000000..7a3fc876
--- /dev/null
+++ b/functions/updatemenumvpc.m
@@ -0,0 +1,100 @@
+% PURPOSE: updates MVPCset menu
+
+
+function updatemenumvpc(ALLMVPC,overw)
+if nargin<2
+ overw=0; % overwrite MVPCset menu? 0=no; 1=yes; -1=delete
+end
+
+%
+% Checks MVPCset menu status
+%
+MVPCmenu = findobj('tag', 'mvpcsets');
+statbestm = get(MVPCmenu, 'Enable');
+if strcmp(statbestm,'off')
+ set(MVPCmenu, 'Enable', 'on'); % activates bestsets menu
+end
+
+maxindexmvpc = length(ALLMVPC);
+MVPCSETMENU = zeros(1,maxindexmvpc);
+mvpcsetlist = findobj('tag','linmvpc');
+
+if isempty(mvpcsetlist)
+ nmvpcset = 0;
+ overw = 0 ; %add a new MVPCset
+elseif length(mvpcsetlist) > maxindexmvpc
+ nmvpcset = length(mvpcsetlist);
+ overw = -1; %delete MVPCset
+elseif length(mvpcsetlist) < maxindexmvpc
+ nmvpcset = length(mvpcsetlist);
+ overw = 0; %add MVPCset
+
+else
+ nmvpcset = length(mvpcsetlist);
+end
+
+if overw == 1
+ %overwrite. Just change the current bestset
+
+ for s = 1:nmvpcset
+ strcheck = get(mvpcsetlist(s), 'checked');
+
+ if strcmp(strcheck,'on')
+ catchindx = nmvpcset-s+1;
+ mvpcn = ALLMVPC(nmvpcset-s+1).mvpcname;
+ menutitle = sprintf('MVPCset %d: %s', nmvpcset-s+1,mvpcn);
+ set(mvpcsetlist(s), 'Label', menutitle);
+ end
+
+ end
+ mvpc2memory(ALLMVPC(catchindx),catchindx);
+
+elseif overw == 0 || overw == -1
+
+ if overw == 0 %add a new bestset to the bestset menu
+ indexmvpc = nmvpcset + 1;
+ else %delete bestset from menu
+ menux = findobj(0, 'tag', 'mvpcsets');
+ h = get(menux);
+ delete(h.Children);
+ indexmvpc = 1;
+ if maxindexmvpc==0
+ assignin('base','CURRENTMVPC', 0); % save to workspace
+ set(MVPCmenu, 'enable', 'off');
+ return
+ end
+ end
+
+ while indexmvpc <= maxindexmvpc
+ MVPCSETMENU(indexmvpc) = uimenu(MVPCmenu, 'tag', 'linmvpc');
+ fmvpc = ['mvpc2memory(ALLMVPC(' num2str(indexmvpc) '),' num2str(indexmvpc) ');'];
+ mvpcn = ALLMVPC(indexmvpc).mvpcname;
+ if iscell(mvpcn)
+ mvpcn = '';
+ end
+ menutitle = ['MVPCset ' num2str(indexmvpc) ': ' mvpcn ' '];
+ set( MVPCSETMENU(indexmvpc), 'Label', menutitle);
+ set( MVPCSETMENU(indexmvpc), 'CallBack', fmvpc );
+ set( MVPCSETMENU(indexmvpc), 'Enable', 'on' );
+ indexmvpc = indexmvpc + 1;
+
+ end
+
+ if maxindexmvpc ~= 0
+ mvpc2memory(ALLMVPC(maxindexmvpc),maxindexmvpc);
+ end
+
+
+
+
+else
+ error('ERPLAB sasys: wrong input parameter')
+
+
+
+end
+
+eeglab redraw;
+%set(MVPCmenu, 'Enable', 'on'); % activates erpsets menu after redraw (eeglab hack)
+
+end
\ No newline at end of file
diff --git a/functions/window2sample.m b/functions/window2sample.m
index f535215b..cc057272 100755
--- a/functions/window2sample.m
+++ b/functions/window2sample.m
@@ -56,7 +56,13 @@
if strcmpi(datatype, 'ERP')
Ktime = 1000; % ms
- toffsa = abs(round(ERPLAB.xmin*fs))+1;
+ try
+ toffsa = abs(round(ERPLAB.xmin*fs))+1;
+ catch
+ ERPLAB.xmin = ERPLAB.times(1)/Ktime;
+ ERPLAB.xmax = ERPLAB.times(end)/Ktime;
+ toffsa = abs(round(ERPLAB.xmin*fs))+1;
+ end
else % FFT
Ktime = 1; % sec or Hz
toffsa = 0;
diff --git a/pop_functions/pop_combineBESTbins.m b/pop_functions/pop_combineBESTbins.m
new file mode 100644
index 00000000..f870e49b
--- /dev/null
+++ b/pop_functions/pop_combineBESTbins.m
@@ -0,0 +1,289 @@
+% PURPOSE : Combine bins within a BEST file. Outputs BEST file with
+% combined bin appended at the end of BESTset.
+%
+% FORMAT :
+%
+% >> [BEST] = pop_combineBESTbins(BEST,parameters);
+%
+% INPUTS :
+%
+% BEST - input BEST dataset
+%
+% The available input parameters are as follows:
+%
+% 'bins_to_combine' - Cell array of bins to combine where each
+% element is a set of bin indexes from BEST.
+% 'bin_labels' - Cell array of bin description names for
+% each newly combined bin.
+% Length of cellarray must equal 'bins_to_combine'
+%
+% 'SaveAs' - (optional) open GUI for saving BESTset.
+% 'on'/'off' (Default: off)
+% - (if "off", will not update in BESTset menu)
+% - if scripting, use "off" and pop_savemybest()
+%
+% OUTPUTS :
+%
+% BEST - output BEST structure
+%
+% EXAMPLE :
+%
+% [BEST] = pop_combineBESTbins(BEST,'bins_to_combine',{[1,2,3],[4,5,6]}, ...
+% 'bin_labels',{'Combined bins 1,2,3','Combined bins 4,5,6'});
+%
+% See also: pop_savemybest.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons and Steven J Luck.
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function [BEST] = pop_combineBESTbins(ALLBEST,varargin)
+com = '';
+
+%preload BEST
+BEST = preloadBEST;
+
+if nargin < 1
+ help pop_combineBESTbins
+ return
+end
+
+
+if nargin == 1 %open GUI
+ currdata = evalin('base','CURRENTBEST');
+
+ if currdata == 0
+ msgboxText = 'pop_combineBESTbins() error: cannot work an empty dataset!!!';
+ title = 'ERPLAB: No data';
+ errorfound(msgboxText, title);
+ return
+
+ end
+
+ def = erpworkingmemory('pop_combineBESTbins');
+
+ if isempty(def)
+ def = {{[]},{[]}};
+ %1 binindex(s) from old BEST that will create new BEST
+ %2 binlabel(s) from oldBEST taht will create new BEST
+
+ end
+
+
+
+
+ app = feval('combinebestbinsGUI',ALLBEST,currdata,def);
+ waitfor(app,'FinishButton',1);
+
+ try
+ res = app.output;
+ app.delete; %delete app from view
+ pause(0.5); %wait for app to leave
+ catch
+ disp('User selected Cancel')
+ return
+ end
+
+
+ BEST = res{1};
+ nbins = res{2}.bini;
+ nlabels = res{2}.labels;
+
+ def = {nbins,nlabels};
+ erpworkingmemory('pop_combineBESTbins',def);
+
+ [BEST] = pop_combineBESTbins(ALLBEST,'BESTindex',currdata, 'bins_to_combine',nbins,'bin_labels',nlabels, ...
+ 'Saveas','on', 'History','gui');
+
+ pause(0.1);
+ return
+
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLBEST');
+
+
+p.addParamValue('BESTindex', 1,@isnumeric); % erpset index or input file (default: first BESTset in ALLBEST)
+p.addParamValue('bins_to_combine',{}); %array of channel indicies (def: all channels)
+p.addParamValue('bin_labels',{});
+p.addParamValue('Saveas','off');
+p.addParamValue('History','script');
+
+
+% Parsing
+p.parse(ALLBEST, varargin{:});
+
+idx_bestset = p.Results.BESTindex;
+new_bins = p.Results.bins_to_combine;
+new_labels = p.Results.bin_labels;
+
+%% choose BESTsets
+if ~isempty(idx_bestset)
+ BEST = ALLBEST(idx_bestset) ;
+else
+ BEST = ALLBEST(1); %just do the first one
+end
+
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+
+%% bin-combiner routine
+
+BEST = combineBESTbins(BEST, new_bins, new_labels);
+
+%
+% History
+%
+skipfields = {'ALLBEST', 'Saveas','Warning','History'};
+
+
+fn = fieldnames(p.Results);
+explica = 0;
+if length(idx_bestset)==1 && idx_bestset(1)==1
+ inputvari = 'BEST'; % Thanks to Felix Bacigalupo for this suggestion. Dic 12, 2011
+ skipfields = [skipfields 'ALLBEST' 'BESTindex']; % SL
+else
+ if length(idx_bestset)==1
+ explica = 1;
+ end
+ inputvari = inputname(1);
+end
+bestcom = sprintf( 'BEST = pop_combineBESTbins( %s ', inputvari);
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ bestcom = sprintf( '%s, ''%s'', ''%s''', bestcom, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ if all(cellfun(@isnumeric, fn2res))
+ %fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ fn2resstr =cell2mat(cellfun(@vect2colon,fn2res,'UniformOutput',false));
+
+ else
+ fn2resstr = '';
+ for kk=1:numel(fn2res)
+ auxcont = fn2res{kk};
+ if ischar(auxcont)
+ fn2resstr = [fn2resstr '''' auxcont ''',' ];
+ else
+ fn2resstr = [fn2resstr ' ' vect2colon(auxcont, 'Delimiter', 'on')];
+ end
+
+ end
+ fn2resstr(end) = []; %take out last comma
+
+ end
+ fnformat = '{%s}';
+ elseif isnumeric(fn2res)
+ %fn2resstr = num2str(fn2res); fnformat = '%s';
+ fn2res = mat2colon(fn2res);
+ fn2resstr = num2str(fn2res); fnformat = '%s';
+ elseif isstruct(fn2res)
+ fn2resstr = 'ALLBEST'; fnformat = '%s';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+
+% if strcmpi(fn2com,'BESTindex')
+% bestcom = sprintf( ['%s, ''%s'', [', fnformat,']'], bestcom, fn2com, fn2resstr);
+% else
+ bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+ % end
+
+ %bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+ end
+ end
+ end
+end
+bestcom = sprintf( '%s );', bestcom);
+
+
+%% save function
+
+if issaveas
+ [BEST, issave] = pop_savemybest(BEST,'gui','erplab');
+ if issave>0
+ if issave==2
+ %erpcom = sprintf('%s\n%s', erpcom, erpcom_save);
+ msgwrng = '*** Your BESTset was saved on your hard drive.***';
+ else
+ msgwrng = '*** Warning: Your BESTset was only saved on the workspace.***';
+ end
+ else
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ end
+ try cprintf([1 0.52 0.2], '%s\n\n', msgwrng); catch,fprintf('%s\n\n', msgwrng);end ;
+end
+
+switch shist
+ case 1 % from GUI
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ displayEquiComERP(bestcom);
+ if explica
+ try
+ cprintf([0.1333, 0.5451, 0.1333], '%%IMPORTANT: For pop_combineBESTbins, you may use BEST instead of ALLBEST, and remove "''BESTindex'',%g"\n',idx_bestset);
+ catch
+ fprintf('%%IMPORTANT: For pop_combineBESTbins, you may use BEST instead of ALLBEST, and remove ''BESTindex'',%g:\n',idx_bestset);
+ end
+ end
+ case 2 % from script
+ % ERP = erphistory(ERP, [], bestcom, 1);
+ case 3
+ % implicit
+ otherwise % off or none
+ bestcom = '';
+end
+
+
+return
diff --git a/pop_functions/pop_decoding.m b/pop_functions/pop_decoding.m
new file mode 100644
index 00000000..49101cd5
--- /dev/null
+++ b/pop_functions/pop_decoding.m
@@ -0,0 +1,869 @@
+% PURPOSE : Decode BEST files after setting parameters.
+%
+% FORMAT :
+%
+% >> MVPC = pop_decoding(ALLBEST)
+%
+% INPUTS :
+%
+% BEST or ALLBEST - input dataset (BESTset) or input ALLBEST (via
+% decoding toolbox GUI)
+%
+% The available parameters are as follows:
+%
+% 'BESTindex' - Index of BESTset(s) to decode when contained
+% within the ALLBEST structure
+% If supplying one BESTset using BEST structure this value
+% must be equal to 1 or left unspecified.
+% Def: [1]
+%
+% 'Classes ' - Index array of classes to decode across.
+% Classes are defined as the index of the bins
+% contained within the BESTset prior to decoding.
+%
+% 'Channels' - Index of channels to use. Def: all channels
+%
+% 'nIter' - Amount of iterations to run decoding per BESTset.
+% Def: 100
+%
+% 'nCrossblocks' - Amount of Crossfold Validation blocks where
+% Ntrials/nCrossblocks = Ntrials(ERP) / Def: 3
+%
+% 'DecodeTimes' - 2-element array denoting epoch start and end times
+% e.g.: [start_epoch_decoding end_epoch_decoding]
+% Default: use whole epoch length.
+%
+% 'Decode_Every_Npoint' - Decode every timepoint (T) points where 1 point =
+% 1/sampling rate (in ms). Effectively resampling
+% the decoding analysis. For example, a
+% value of 1 decodes every timepoint.
+% Def: [1]
+%
+% 'EqualizeTrials' - (Optional) Equalizing the amount of trials per ERP.
+% - 'classes': Across classes within BESTset
+% - 'best': Across BESTsets (if more than 1 BESTset)
+% - 'floor': Using Common Floor Value
+%
+% 'FloorValue' - (Optional) Equalize amount of trials per ERP across all
+% classes (and BESTsets) to this value. If
+% specified, overides the 'EqualizeTrials'
+% argument.
+%
+%
+% 'Method' - Classification method:
+% - 'SVM' (default) using fitcecoc()
+% - if BESTset has only two classes/binary,
+% algorithm uses fitcsvm()
+% - 'Crossnobis'
+%
+% 'classcoding' - If classification method is 'SVM':
+% - 'OneVsOne'
+% - 'OneVsAll' (def)
+%
+% 'SaveAs' - (optional) open GUI for saving MVPCset. Not
+% useful if scripting; use separate pop_savemymvpc().
+% 'on'/'off' (Default: off)
+% (if "off", will not update in MVPCset menu)
+% 'ParCompute' - (optional) Use parallelization to make decoding
+% faster. Uses as many available cores. Must have 'Parallel
+% Computing Toolbox' installed. 'on'/'off' (Def)
+%
+%
+% OUTPUTS :
+%
+% MVPC - output MVPC dataset
+%
+% EXAMPLE :
+%
+% MVPC = pop_decoding(BEST,'Classes',[1:4],'Channels',[1:27 33:64], 'nIter', 10, 'nCrossblocks',3, ...
+% 'DecodeTimes',[-500,1496], 'Decode_Every_Npoint',5,'EqualizeTrials','classes',...
+% 'Method','SVM', 'classcoding','OneVsAll', ...
+% 'ParCompute','on');
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function [MVPC] = pop_decoding(ALLBEST, varargin)
+com = '';
+
+% check Signal Processing Toolbox (SPT)
+if exist('filtfilt','file')~= 2
+ msgboxText = 'ERROR: You currently do not have the Signal Processing Toolbox installed. Please contact your system administration or MATLAB to install "Signal Processing Toolbox" to your MATLAB version';
+ title = 'ERPLAB: Missing Signal Processing Toolbox';
+ errorfound(msgboxText, title);
+ return
+end
+
+% check Statistics and Machine Learning toolbox
+v = ver;
+hasSMT = any(strcmp(cellstr(char(v.Name)), 'Statistics and Machine Learning Toolbox'));
+
+if hasSMT ~= 1
+ msgboxText = ['Error: You currently do not have the Statistics and Machine Learning toolbox, an offiical MATLAB toolbox add-on. ...' ...
+ 'Please contact MATHWORKS or your system admin to install this for your MATLAB version'];
+ title = 'ERPLAB: Missing Statistics and Machine Learning Toolbox';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+try
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ % preindex = length(ALLMVPC);
+catch
+ disp('WARNING: ALLMVPC structure was not found. ERPLAB will create an empty one.')
+ ALLMVPC = [];
+ % preindex = 0;
+end
+
+%preload MVPAC
+MVPC = preloadMVPC;
+
+if nargin<1
+ help pop_decoding
+ return
+end
+
+if nargin == 1 %GUI
+
+ if isstruct(ALLBEST)
+ if ~isbeststruct(ALLBEST(1))
+ ALLBEST = [];
+ %nbinx = 1;
+ %nchanx = 1;
+ else
+ %nbinx = ALLBEST(1).nbin;
+ %nchanx = ALLBEST(1).nbchan;
+ end
+
+ else
+ ALLBEST = [];
+ % nbinx = 1;
+ % nchanx = 1;
+ end
+
+ cbesti = evalin('base','CURRENTBEST'); %current BEST index
+
+ %working memory
+ def = erpworkingmemory('pop_decoding');
+ %def = []; %for now, def always empty, always default to "load from hard drive".
+ if isempty(def)
+ if isempty(ALLBEST)
+ inp1 = 1; %from hard drive
+ bestseti = []; %index of bestsets to use
+ else
+ inp1 = 0; %from bestset menu
+ bestseti = 1:length(ALLBEST);
+
+ end
+
+ %decodeClassInd = 1:numel(ALLBEST(indexBEST(1)).binwise_data)
+ def = {inp1 bestseti [] 100 3 1 [] 1 2 1 1 2 0 []};
+
+ %def1 = input mode (1 means from HD, 0 from bestsetmenu, 2 current bestset)
+ %def2 = bestset index (see above)
+ %def3 = chanArray
+ %def4 = nIter (def = 100)
+ %def5 = nCrossBlocks (def = 3)
+ %def6 = epochTimes (1:all, 2: pre, 3: post, 4:custom) (Def = 1/all)
+ %def7 = decodeTimes ([start,end]; def = []); % IN MS!
+ %def8 = decode_every_Npoint (1 = every point)
+ %def9 = Equalize Trials (0: don't equalize/ 1:equalize across bins/ 2: eqalize across
+ % bins & best (def)/ 3: Common Floor)
+ %def10 = Common Floor Value (def: 1);
+ %def11 = classifer (1: SVM / 2: Crossnobis - def: SVM)
+ %def12 = SVM coding (1: 1vs1 / 2: 1vsAll or empty - def: 1vsALL)
+ %def13 = parCompute (def = 0)
+ %def14 = DecodeClasses ;
+
+ %DEFUNCT = output filename (def = filename.mvpa in pwd) *DEFUNCT
+ %DEFUNCT = output path (def = cd); *DEFUNCT
+
+
+
+ else
+ %if working memory is NOT empty
+ if ~isempty(ALLBEST)
+ if isnumeric(def{2})
+ [uu,mm] = unique_bc2(def{2},'first');
+ bestset_list_sorted = [def{2}(sort(mm))];
+ bestset_list = bestset_list_sorted(bestset_list_sorted <= length(ALLBEST));
+ if isempty(bestset_list)
+ def{2} = cbesti; %if nothing in list, just go with current
+ else
+ def{2} = bestset_list;
+ end
+
+
+
+
+ end
+ end
+
+
+
+ end
+
+
+ %% Call GUI for decoding parameters parameters
+ %app = feval('decodingGUI', ALLBEST, filename, filepath, cbesti); %cludgy way
+ app = feval('decodingGUI', ALLBEST, def, cbesti); %cludgy way
+ waitfor(app,'FinishButton',1);
+ try
+ decoding_res = app.output; %NO you don't want to output BEST, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.5); %wait for app to leave
+ catch
+ disp('User selected Cancel')
+ return
+ end
+
+ %parse arguments
+ if isempty(ALLBEST) %if no BESTset was passed to GUI
+ ALLBEST = decoding_res{1}; %use the GUI output
+ %but if BESTset was passed to GUI, use indexes to index
+ %the desired BESTsets
+ end
+ inp1 = decoding_res{2};
+ indexBEST = decoding_res{3};
+ relevantChans = decoding_res{4};
+ nIter = decoding_res{5};
+ nCrossBlocks = decoding_res{6};
+ epoch_times = decoding_res{7};
+ decodeTimes = decoding_res{8}; %in s
+ decode_every_Npoint = decoding_res{9};
+ equalizeTrials = decoding_res{10};
+ floorValue = decoding_res{11};
+ selected_method = decoding_res{12};
+ classcoding = decoding_res{13};
+% file_out = decoding_res{13};
+% path_out = decoding_res{14};
+ ParCompute = decoding_res{14};
+ decodeClasses = decoding_res{15};
+
+ %save in working memory
+ %Steve decided that equalize trials should always be defaulted if using
+ %the GUI
+
+ def = { inp1, indexBEST, relevantChans, nIter, nCrossBlocks, epoch_times, ...
+ decodeTimes, decode_every_Npoint, 2, floorValue, ...
+ selected_method, classcoding, ParCompute,decodeClasses};
+ erpworkingmemory('pop_decoding',def);
+
+ %for input into sommersault, change decodeTimes to ms
+ decodeTimes = decodeTimes* 1000;
+
+ if equalizeTrials == 1
+ seqtr = 'classes';
+ floorValue = [];
+
+ elseif equalizeTrials == 2
+ seqtr = 'best';
+ floorValue = [];
+ elseif equalizeTrials == 3
+ seqtr = 'floor';
+
+ else
+ seqtr ='none';
+ floorValue = [];
+ end
+
+ if selected_method == 1 %svm
+ smethod = 'SVM';
+
+ elseif selected_method == 2
+ smethod = 'Crossnobis';
+ end
+
+ if classcoding == 1
+ strcoding = 'OneVsOne';
+ elseif classcoding == 2
+ strcoding = 'OneVsAll';
+ else
+ strcoding = 'none';
+ end
+
+ if ParCompute
+ spar = 'on';
+ else
+ spar = 'off';
+ end
+
+ if isempty(decodeClasses)
+ %across all classes in BESTset(s)
+ decodeClasses = 1:numel(ALLBEST(indexBEST(1)).binwise_data);
+ end
+
+
+
+ [MVPC] = pop_decoding(ALLBEST,'BESTindex', indexBEST, 'Classes', decodeClasses, ...
+ 'Channels', relevantChans, ...
+ 'nIter',nIter,'nCrossblocks',nCrossBlocks, ...
+ 'DecodeTimes', decodeTimes, 'Decode_Every_Npoint',decode_every_Npoint, ...
+ 'EqualizeTrials', seqtr, 'FloorValue',floorValue,'Method', smethod, ...
+ 'classcoding',strcoding, 'Saveas','on', 'ParCompute',spar, 'History','gui');
+
+ pause(0.1);
+ return
+
+
+
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLBEST');
+
+% option(s)
+p.addParamValue('BESTindex', 1,@isnumeric); % erpset index or input file (default: first BESTset in ALLBEST)
+p.addParamValue('Classes',[],@isnumeric);
+p.addParamValue('Channels',[], @isnumeric); %array of channel indicies (def: all channels)
+%p.addParamValue('nBins',0); %total number of bins/decoding labels/decoding levels
+p.addParamValue('nIter',100, @isnumeric); % total number of decoding iterations (def: 100 iters)
+p.addParamValue('nCrossblocks',3, @isnumeric); % total number of crossblock validations (def: 3 crossblocks)
+%p.addParamValue('nDatatimes',[]); %struct with fields pre(start),post(end) epoch times (def: entire epoch)
+%p.addParamValue('SampleTimes',[]); %array of epoch sampling times in ms, i.e. EEG.times (def: all times)
+p.addParamValue('DecodeTimes',[],@isnumeric); %[start end](in ms)
+p.addParamValue('Decode_Every_Npoint',1, @isnumeric); %(def = all times(1) // must be positive number )
+p.addParamValue('EqualizeTrials', 'none', @ischar); % def: equalize trials across bins & BESTsets (2)
+p.addParamValue('FloorValue', [], @isnumeric);
+p.addParamValue('Method','SVM',@ischar); %method (1:SVM/2:Crossnobis);
+p.addParamValue('classcoding','OneVsAll',@ischar); % SVMcoding(1:oneVsone/2:oneVsall);
+p.addParamValue('Saveas','off',@ischar);
+p.addParamValue('ParCompute','off', @ischar); %attempt parallization across CPU cores (def: false)
+p.addParamValue('History','script');
+
+% Parsing
+p.parse(ALLBEST, varargin{:});
+idx_bestset = p.Results.BESTindex;
+decodeClasses = p.Results.Classes;
+chanArray = p.Results.Channels;
+nIter = p.Results.nIter;
+nCrossblocks = p.Results.nCrossblocks;
+decodeTimes = p.Results.DecodeTimes;
+Decode_every_Npoint = p.Results.Decode_Every_Npoint;
+equalize_trials = p.Results.EqualizeTrials;
+floor_value = p.Results.FloorValue;
+smethod = p.Results.Method;
+strcoding = p.Results.classcoding;
+% filename_out = p.Results.filename_out;
+% pathname_out = p.Results.path_out;
+sParCompute = p.Results.ParCompute;
+
+
+%if user is scripting command
+if isempty(decodeClasses)
+ decodeClasses = 1:numel(ALLBEST(idx_bestset(1)).binwise_data);
+end
+
+%history
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+%parallelization
+if strcmpi(sParCompute, 'on') || strcmpi(sParCompute,'yes')
+ ParCompute = 1;
+else
+ ParCompute = 0;
+end
+
+
+
+
+%% choose BESTsets
+if ~isempty(idx_bestset)
+ ALLBEST = ALLBEST(idx_bestset) ;
+else
+ ALLBEST = ALLBEST(1); %just do the first one
+end
+
+
+%% Check ALLBEST
+checking = checkmultiBEST(ALLBEST);
+
+if ~checking
+ disp('Sorry, your BEST files do not agree with each other in terms of classes and channels')
+ return
+end
+
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+
+% Save routine only for Decoding Toolbox GUI
+if issaveas == 1
+ [res] = mvpc_save_multi_file(ALLBEST,1:numel(ALLBEST),'');
+%
+ if isempty(res)
+ disp('User selected cancel');
+ return
+ end
+
+ ALLBEST = res{1};
+ % file_out = {ALLBEST.filename};
+ % file_path = {ALLBEST.filepath};
+
+ %after using the save multple files,
+ %don't automaticaly assume they want to save
+
+end
+
+
+
+%create/update the times field in each BESTset
+
+% use the specificed [start,end] epoch variable (which need to be
+% specified)
+% test requirement that 0 time-sample point must be included!
+
+if Decode_every_Npoint < 1
+ msgText = 'Must specify a positive value > 1 for decoding every Nth point'
+ title = 'ERPLAB: Wrong Value for Decoding every Nth point'
+ errorfound(msgText,title);
+ return
+end
+
+original_times = ALLBEST(1).times; %take first BESTset as standard
+if isempty(decodeTimes)
+
+ decodeTimes = [ALLBEST(1).xmin*1000 ALLBEST(1).xmax*1000]; %convert s to ms
+
+end
+
+fs = ALLBEST(1).srate;
+[xp1, xp2, checkw] = window2sample(ALLBEST(1), decodeTimes(1:2) , fs, 'relaxed');
+
+if checkw==1
+ msgboxText = 'Time window cannot be larger than epoch.';
+ title = 'ERPLAB';
+ errorfound(msgboxText, title);
+ app.EpochRange.Value = 'Input Custom Range';
+ %set(handles.radiobutton_yauto, 'Value',0)
+ %drawnow
+ return
+elseif checkw==2
+ msgboxText = 'Too narrow time window (are the start and end times reversed?)';
+ title = 'ERPLAB';
+ errorfound(msgboxText, title);
+ app.EpochRange.Value = 'Input Custom Range';
+ %set(handles.radiobutton_yauto, 'Value',0)
+ %drawnow
+ return
+end
+
+
+start_epoch = decodeTimes(1); %ms
+end_epoch = decodeTimes(2);%ms
+
+
+%check valid times and round to nearest time
+[startms,ind_start,latdiffms(1)] = closest(original_times,start_epoch);
+[endms,ind_end,latdiffms(2)] = closest(original_times,end_epoch);
+
+tm_zero = find(original_times== 0); %always include tm point = 0ms
+tm_zero_to_begin= (tm_zero:-Decode_every_Npoint:ind_start);
+tm_zero_to_end = (tm_zero:Decode_every_Npoint:ind_end);
+decoding_times_index = sort(unique_bc2([tm_zero_to_begin tm_zero_to_end]));
+
+[~,decode_begin] = closest(decoding_times_index,ind_start);
+[~,decode_end] = closest(decoding_times_index,ind_end);
+
+%update to user defined times (but also includes 0ms in
+%sampling)
+decoding_times_index = decoding_times_index(decode_begin:decode_end);
+
+if ms2sample(latdiffms(1),fs)~=0 %JLC.10/16/2013
+ latency(1) = start_epoch;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Lower latency limit %.3f ms was adjusted to %.3f ms \n', latency(1), original_times(decoding_times_index(1)));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ start_epoch = original_times(decoding_times_index(1));
+
+
+end
+
+if ms2sample(latdiffms(2),fs)~=0 %JLC.10/16/2013
+ latency(2) = end_epoch;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Upper latency limit %.3f ms was adjusted to %.3f ms \n', latency(2), original_times(decoding_times_index(end)));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+ end_epoch = original_times(decoding_times_index(end));
+
+end
+
+if (start_epoch ~= original_times(decoding_times_index(1))) | ...
+ (end_epoch ~= original_times(decoding_times_index(end)))
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Lower latency limit %.3f ms was adjusted to %.3f ms \n', start_epoch, original_times(decoding_times_index(1)));
+ fprintf('WARNING: Upper latency limit %.3f ms was adjusted to %.3f ms \n', end_epoch, original_times(decoding_times_index(end)));
+ fprintf('WARNING: This adjustment was necessary due to sampling. \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+end
+
+
+decodeTimes = [original_times(decoding_times_index(1)) original_times(decoding_times_index(end))];
+
+%decode_index = decoding_times_index;
+ntimes = numel(decoding_times_index);
+
+
+
+%% update ALLBEST.times & ALLBEST.binwisedata, ALLBEST.pnts,
+
+k = numel(ALLBEST);
+bins = numel(ALLBEST(1).binwise_data);
+for b = 1:k
+ ALLBEST(b).xmin = decodeTimes(1)/1000;
+ ALLBEST(b).xmax = decodeTimes(2)/1000;
+ npnts_old = ALLBEST(b).pnts;
+ ALLBEST(b).pnts = ntimes;
+ ALLBEST(b).times = original_times(decoding_times_index);
+ if Decode_every_Npoint ~= 1
+ %update fs if not decoding every timepoint
+ fs = ALLBEST(b).srate;
+ samps = 1/fs;
+ epochtime = (samps*npnts_old) *1000;% ms
+ new_fs = (ntimes/epochtime) *1000;
+ ALLBEST(b).srate = new_fs;
+ end
+
+ for i = 1:bins
+ ALLBEST(b).binwise_data(i).data = ALLBEST(b).binwise_data(i).data(:,decoding_times_index,:);
+ end
+
+
+ %% logic for choosing the classes and chance prior to equalizing trials
+
+
+ %select chosen classes
+ ALLBEST(b).binwise_data = ALLBEST(b).binwise_data(decodeClasses);
+ ALLBEST(b).bindesc = ALLBEST(b).bindesc(decodeClasses);
+ ALLBEST(b).original_bin = ALLBEST(b).original_bin(decodeClasses);
+ ALLBEST(b).n_trials_per_bin = ALLBEST(b).n_trials_per_bin(decodeClasses);
+ ALLBEST(b).nbin = numel(decodeClasses);
+
+
+end
+
+
+
+
+%% reset the trial counts according to nperbinblock/Equalize Trials
+
+nbins = ALLBEST.nbin;
+nsubs = numel(ALLBEST);
+
+if ~isempty(floor_value)
+ %in case user only supplies the floor value
+ % we will assume they meant to floor
+ equalize_trials = 'floor';
+end
+
+if nsubs == 1 && strcmpi(equalize_trials,'best')
+ %cannot equalize trials across BESTset if only one BESTset
+ equalize_trials = 'classes';
+end
+
+if strcmpi(equalize_trials,'best') % equalize across best files
+
+ trials_acr_best = [ALLBEST(:).n_trials_per_bin];
+ minCnt = min(trials_acr_best);
+ %nPerBinBlock = floor(minCnt/nCrossblocks);
+
+ for s = 1:nsubs
+ for tr = 1:nbins
+ ALLBEST(s).n_trials_per_bin(tr) = minCnt;
+ end
+ end
+
+
+elseif strcmpi(equalize_trials,'classes') %equalize bins within best files
+
+ for s = 1:nsubs
+ trials_acr_sub = ALLBEST(s).n_trials_per_bin;
+ minCnt = min(trials_acr_sub);
+
+ for tr = 1:nbins
+ ALLBEST(s).n_trials_per_bin(tr) = minCnt;
+ end
+
+ end
+elseif strcmpi(equalize_trials,'floor')
+
+
+ %use common floor_value
+ for s = 1:nsubs
+
+ %check floor value validity
+ if strcmpi(smethod,'SVM')
+ test_val = floor(min(ALLBEST(s).n_trials_per_bin)/nCrossblocks);
+ else
+ test_val = min(ALLBEST(s).n_trials_per_bin);
+ end
+
+ if floor_value > test_val
+ msgboxTest = sprintf('You selected an invalid floor %i. The value exceeds the max the number of trials within cross-validation blocks',floor_value);
+ title = 'ERPLAB: Cross-Validation error';
+ errorfound(msgboxTest, title);
+
+ return
+ end
+
+ if floor_value < 1
+ msgboxTest = sprintf('You selected an invalid floor %i. You cannot go less than 1 trial per ERP',floor_value);
+ title = 'ERPLAB: Cross-Validation error';
+ errorfound(msgboxTest, title);
+
+ return
+
+ end
+
+
+ for tr = 1:nbins
+ if strcmpi(smethod,'SVM')
+ ALLBEST(s).n_trials_per_bin(tr) = floor_value * nCrossblocks;
+ else
+ ALLBEST(s).n_trials_per_bin(tr) = floor_value; %crossnobis
+ end
+ end
+ end
+
+ %error check this floor_value
+
+
+
+else
+ if strcmpi(smethod,'SVM')
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: You have disabled the option for equating the number of trials across classes. \n');
+ fprintf('WARNING: This is almost always a very bad idea. \n');
+ fprintf('WARNING: Disabling this option will almost certainly artificially inflate the decoding accuracy, creating bogus effects. \n');
+ fprintf('WARNING:In addition, you should report that you disabled it in your Method section, which will likely cause your paper to be rejected \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+ end
+end
+
+
+if ParCompute == 1
+ % delete(gcp)
+ try
+ par_profile = parpool;
+ ParWorkers = (par_profile.NumWorkers) -1 ; %all but one
+ catch
+ %opened parallel pool profile already
+ par_profile = gcp ;
+ ParWorkers = par_profile.NumWorkers - 1 ; %all but one
+ end
+ %display num of parallel workers
+ fprintf('ERPLAB will use %i parallel workers (Max # Workers - 1) for decoding...\n',ParWorkers);
+
+else
+ ParWorkers = 0; %makes parfor run without workers, even if pool is open.
+end
+
+if strcmpi(smethod,'SVM')
+ method = 1;
+else
+ method = 2; %crossnobis
+end
+
+if strcmpi(strcoding,'OneVsOne')
+ classcoding = 1;
+elseif strcmpi(strcoding,'OneVsAll')
+ classcoding = 2;
+else
+ classcoding = 0; %any not-multinomial pattern classification (binary decoders, crossnobis, etc)
+end
+
+
+%% Enter algorithm
+
+
+if method == 1 %SVM
+ [MVPC, ALLMVPC] = erp_decoding(ALLBEST,nIter,nCrossblocks,decodeTimes,chanArray,classcoding,equalize_trials,ParWorkers,method);
+elseif method == 2 %crossnobis
+ [MVPC, ALLMVPC] = crossnobis(ALLBEST,nIter,0,decodeTimes,chanArray,classcoding,equalize_trials,ParWorkers,method);
+end
+
+
+%
+%History
+%
+
+
+
+skipfields = {'ALLBEST', 'Saveas','History'};
+
+
+fn = fieldnames(p.Results);
+explica = 0;
+if length(idx_bestset)==1 && idx_bestset(1)==1
+ inputvari = 'BEST'; % Thanks to Felix Bacigalupo for this suggestion. Dic 12, 2011
+ skipfields = [skipfields 'BESTindex']; % SL
+else
+ if length(idx_bestset)==1
+ explica = 1;
+ end
+ inputvari = inputname(1);
+end
+
+if method == 2
+ %crossfolds don't matter in crossnobis
+ skipfields = [skipfields 'ALLBEST' 'nCrossblocks']; % SL
+end
+
+
+% if strcmpi(smethod,'Crossnobis')
+% skipfields = [skipfields 'classcoding'];
+% end
+
+bestcom = sprintf( 'MVPC = pop_decoding( %s ', inputvari);
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ bestcom = sprintf( '%s, ''%s'', ''%s''', bestcom, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ if all(cellfun(@isnumeric, fn2res))
+ %fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ fn2resstr =cell2mat(cellfun(@vect2colon,fn2res,'UniformOutput',false));
+
+ else
+ fn2resstr = '';
+ for kk=1:numel(fn2res)
+ auxcont = fn2res{kk};
+ if ischar(auxcont)
+ fn2resstr = [fn2resstr '''' auxcont ''',' ];
+ else
+ fn2resstr = [fn2resstr ' ' vect2colon(auxcont, 'Delimiter', 'on')];
+ end
+
+ end
+ fn2resstr(end) = []; %take out last comma
+
+ end
+ fnformat = '{%s}';
+ elseif isnumeric(fn2res)
+ fn2res = mat2colon(fn2res);
+ fn2resstr = num2str(fn2res); fnformat = '%s';
+ elseif isstruct(fn2res)
+ fn2resstr = 'ALLBEST'; fnformat = '%s';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+
+% if strcmpi(fn2com,'BESTindex')
+% bestcom = sprintf( ['%s, ''%s'', [', fnformat,']'], bestcom, fn2com, fn2resstr);
+% else
+ bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+% end
+
+ %bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+ end
+ end
+ end
+end
+bestcom = sprintf( '%s );', bestcom);
+
+
+
+switch shist
+ case 1 % from GUI
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ displayEquiComERP(bestcom);
+ if explica
+ try
+ cprintf([0.1333, 0.5451, 0.1333], '%%IMPORTANT: For pop_decoding(), you may use BEST instead of ALLBEST, and remove "''BESTindex'',%g"\n',idx_bestset);
+ catch
+ fprintf('%%IMPORTANT: For pop_decoding(), you may use BEST instead of ALLBEST, and remove ''BESTindex'',%g:\n',idx_bestset);
+ end
+ end
+ case 2 % from script
+ % ERP = erphistory(ERP, [], bestcom, 1);
+ case 3
+ % implicit
+ otherwise % off or none
+ bestcom = '';
+end
+
+
+%if saveas == 0, use pop_decoding per subject to output 1 MVPC file (even
+%though pop_decoding has the ability to do multiple decodings at one time (do through GUI).
+if issaveas == 1
+ [MVPC,issave] = pop_savemymvpc(MVPC,'ALLMVPC',ALLMVPC,'gui','erplab','History','erplab');
+ %since argument is 'erplab', will save as specified in MVPC fields, and
+ %update MVPC menu accordingly.
+ if issave > 0
+ if issave == 2
+ msgwrng = '*** Your MVPCset was saved on your hard drive.***';
+ else
+ msgwrng = '*** Warning: Your MVPCset was only saved on the workspace.***';
+ end
+ else
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ end
+
+ try cprintf([1 0.52 0.2], '%s\n\n', msgwrng); catch,fprintf('%s\n\n', msgwrng);end ;
+end
+
+
+
+
+return
+
+
+
+
+
+
+
diff --git a/pop_functions/pop_deletebestset.m b/pop_functions/pop_deletebestset.m
new file mode 100644
index 00000000..69a90dc9
--- /dev/null
+++ b/pop_functions/pop_deletebestset.m
@@ -0,0 +1,214 @@
+% PURPOSE : Clears BESTset(s) for BESTset menu
+%
+% FORMAT :
+%
+% >> ALLBEST = pop_deletebestset( ALLBEST, index);
+%
+% EXAMPLE :
+%
+% >> ALLBEST = pop_deletbestset( ALLBEST, [3 5]);
+%
+% INPUTS :
+%
+% ALLERP - Includes all BESTsets in workspace
+% Index - BESTset(s) that you want to clear from the workspace
+%
+% OUTPUTS :
+%
+% - updated (output) ALLBEST. Will include all BESTsets, minus that deleted
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function [ALLBEST] = pop_deletebest(ALLBEST, varargin)
+
+%erpcom = '';
+if nargin<1
+ help pop_deletebestset
+end
+if nargin==1
+ try
+ CURRENTBEST = evalin('base', 'CURRENTBEST');
+ catch
+ CURRENTBEST = 0;
+ end
+ if CURRENTBEST == 0
+ msgboxText = 'BESTsets menu is already empty...';
+ title = 'ERPLAB: no BESTset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ prompt = {'BESTset(s) to clear:'};
+ dlg_title = 'Delete BESTset(s)';
+ num_lines = 1;
+ def = {num2str(CURRENTBEST)}; %01-13-2009
+
+ %
+ % open window
+ %
+ answer = inputvalue(prompt,dlg_title,num_lines,def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ bestindex = str2num(answer{1});
+ nerpset = length(ALLBEST);
+ bestindex = unique_bc2(bestindex);
+
+ if isempty(bestindex)
+ msgboxText = 'Wrong bestset index(es)';
+ title = 'ERPLAB: unrecognizable bestset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+ if max(bestindex)>nerpset || min(bestindex)<1
+ bestm = findobj('tag', 'linbest');
+ bestmenu = length(bestm);
+ if max(bestindex)<=bestmenu && bestmenu>=1 && max(bestindex)>=1
+ %...
+ else
+ msgboxText = ['Wrong BESTset index(es)\n'...
+ 'Check your BESTset menu or write length(ALLBEST) at command window for comprobation'];
+ title = 'ERPLAB: pop_deletebestset not existing BESTset(s)';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ end
+
+ %
+ % Somersault
+ %
+ [ALLBEST] = pop_deletebestset(ALLBEST, 'BESTsets', bestindex, 'Saveas', 'on','History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLBEST');
+% option(s)
+p.addParamValue('BESTsets', 1); % bestset index or input file
+p.addParamValue('Warning', 'off', @ischar); % history from scripting
+p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('History', 'script', @ischar); % history from scripting
+p.parse(ALLBEST, varargin{:});
+
+
+bestindex = p.Results.BESTsets;
+if strcmpi(p.Results.Warning,'on')
+ warnop = 1;
+else
+ warnop = 0;
+end
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+nerpset = length(ALLBEST);
+bestindex = unique_bc2(bestindex);
+
+if isempty(bestindex)
+ msgboxText = 'Wrong BESTset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+if max(bestindex)>nerpset || min(bestindex)<1
+ msgboxText = 'Wrong BESTset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+detect = ~ismember_bc2(1:nerpset,bestindex);
+newindex = find(detect);
+if isempty(newindex)
+ ALLBEST = [];
+else
+ ALLBEST = ALLBEST(newindex);
+end
+if issaveas
+ updatemenubest(ALLBEST, -1);
+ assignin('base','ALLBEST',ALLBEST); % save to workspace. Dec 5, 2012
+end
+% erpcom = sprintf('ALLERP = pop_deleterpset( ALLERP, [%s]);', num2str(erpindex));
+%
+% History
+%
+% skipfields = {'ALLERP', 'History'};
+% fn = fieldnames(p.Results);
+% erpcom = sprintf( '%s = pop_deleterpset( %s ', inputname(1), inputname(1) );
+% for q=1:length(fn)
+% fn2com = fn{q};
+% if ~ismember_bc2(fn2com, skipfields)
+% fn2res = p.Results.(fn2com);
+% if ~isempty(fn2res)
+% if ischar(fn2res)
+% if ~strcmpi(fn2res,'off')
+% erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
+% end
+% else
+% if iscell(fn2res)
+% if ischar([fn2res{:}])
+% fn2resstr = sprintf('''%s'' ', fn2res{:});
+% else
+% fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+% end
+% fnformat = '{%s}';
+% else
+% fn2resstr = vect2colon(fn2res, 'Sort','on');
+% fnformat = '%s';
+% end
+% if strcmpi(fn2com,'Criterion')
+% if p.Results.Criterion<100
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% else
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% end
+% end
+% end
+% end
+% erpcom = sprintf( '%s );', erpcom);
+%
+% % get history from script. ERP
+% switch shist
+% case 1 % from GUI
+% displayEquiComERP(erpcom);
+% case 2 % from script
+% for i=1:length(ALLBEST)
+% ALLBEST(i) = erphistory(ALLBEST(i), [], erpcom, 1);
+% end
+% case 3
+% % implicit
+%
+% %for i=1:length(ALLERP)
+% % ALLERP(i) = erphistory(ALLERP(i), [], erpcom, 1);
+% %end
+% %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+% otherwise %off or none
+% erpcom = '';
+% end
+
+%
+% Completion statement
+%
+msg2end
+%eeglab redraw
+return
diff --git a/pop_functions/pop_deletemvpc.m b/pop_functions/pop_deletemvpc.m
new file mode 100644
index 00000000..d0543e68
--- /dev/null
+++ b/pop_functions/pop_deletemvpc.m
@@ -0,0 +1,214 @@
+% PURPOSE : Clears MVPCset(s) from MVPC menu
+%
+% FORMAT :
+%
+% >> ALLMVPC = pop_deletemvpc( ALLMVPC, index);
+%
+% EXAMPLE :
+%
+% >> ALLMVPC = pop_deletbestset( ALLMVPC, [3 5]);
+%
+% INPUTS :
+%
+% ALLERP - Includes all MVPCsets in workspace
+% Index - MVPCset(s) that you want to clear from the workspace
+%
+% OUTPUTS :
+%
+% - updated (output) ALLMVPC. Will include all MVPCsets, minus that deleted
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function [ALLBEST] = pop_deletemvpc(ALLBEST, varargin)
+
+%erpcom = '';
+if nargin<1
+ help pop_deletebestset
+end
+if nargin==1
+ try
+ CURRENTBEST = evalin('base', 'CURRENTBEST');
+ catch
+ CURRENTBEST = 0;
+ end
+ if CURRENTBEST == 0
+ msgboxText = 'BESTsets menu is already empty...';
+ title = 'ERPLAB: no BESTset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ prompt = {'BESTset(s) to clear:'};
+ dlg_title = 'Delete BESTset(s)';
+ num_lines = 1;
+ def = {num2str(CURRENTBEST)}; %01-13-2009
+
+ %
+ % open window
+ %
+ answer = inputvalue(prompt,dlg_title,num_lines,def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ bestindex = str2num(answer{1});
+ nerpset = length(ALLBEST);
+ bestindex = unique_bc2(bestindex);
+
+ if isempty(bestindex)
+ msgboxText = 'Wrong bestset index(es)';
+ title = 'ERPLAB: unrecognizable bestset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+ if max(bestindex)>nerpset || min(bestindex)<1
+ bestm = findobj('tag', 'linbest');
+ bestmenu = length(bestm);
+ if max(bestindex)<=bestmenu && bestmenu>=1 && max(bestindex)>=1
+ %...
+ else
+ msgboxText = ['Wrong BESTset index(es)\n'...
+ 'Check your BESTset menu or write length(ALLBEST) at command window for comprobation'];
+ title = 'ERPLAB: pop_deletebestset not existing BESTset(s)';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ end
+
+ %
+ % Somersault
+ %
+ [ALLBEST] = pop_deletebestset(ALLBEST, 'BESTsets', bestindex, 'Saveas', 'on','History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLBEST');
+% option(s)
+p.addParamValue('BESTsets', 1); % bestset index or input file
+p.addParamValue('Warning', 'off', @ischar); % history from scripting
+p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('History', 'script', @ischar); % history from scripting
+p.parse(ALLBEST, varargin{:});
+
+
+bestindex = p.Results.BESTsets;
+if strcmpi(p.Results.Warning,'on')
+ warnop = 1;
+else
+ warnop = 0;
+end
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+nerpset = length(ALLBEST);
+bestindex = unique_bc2(bestindex);
+
+if isempty(bestindex)
+ msgboxText = 'Wrong erpset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+if max(bestindex)>nerpset || min(bestindex)<1
+ msgboxText = 'Wrong erpset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+detect = ~ismember_bc2(1:nerpset,bestindex);
+newindex = find(detect);
+if isempty(newindex)
+ ALLBEST = [];
+else
+ ALLBEST = ALLBEST(newindex);
+end
+if issaveas
+ updatemenubest(ALLBEST, -1);
+ assignin('base','ALLBEST',ALLBEST); % save to workspace. Dec 5, 2012
+end
+% erpcom = sprintf('ALLERP = pop_deleterpset( ALLERP, [%s]);', num2str(erpindex));
+%
+% History
+%
+% skipfields = {'ALLERP', 'History'};
+% fn = fieldnames(p.Results);
+% erpcom = sprintf( '%s = pop_deleterpset( %s ', inputname(1), inputname(1) );
+% for q=1:length(fn)
+% fn2com = fn{q};
+% if ~ismember_bc2(fn2com, skipfields)
+% fn2res = p.Results.(fn2com);
+% if ~isempty(fn2res)
+% if ischar(fn2res)
+% if ~strcmpi(fn2res,'off')
+% erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
+% end
+% else
+% if iscell(fn2res)
+% if ischar([fn2res{:}])
+% fn2resstr = sprintf('''%s'' ', fn2res{:});
+% else
+% fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+% end
+% fnformat = '{%s}';
+% else
+% fn2resstr = vect2colon(fn2res, 'Sort','on');
+% fnformat = '%s';
+% end
+% if strcmpi(fn2com,'Criterion')
+% if p.Results.Criterion<100
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% else
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% end
+% end
+% end
+% end
+% erpcom = sprintf( '%s );', erpcom);
+%
+% % get history from script. ERP
+% switch shist
+% case 1 % from GUI
+% displayEquiComERP(erpcom);
+% case 2 % from script
+% for i=1:length(ALLBEST)
+% ALLBEST(i) = erphistory(ALLBEST(i), [], erpcom, 1);
+% end
+% case 3
+% % implicit
+%
+% %for i=1:length(ALLERP)
+% % ALLERP(i) = erphistory(ALLERP(i), [], erpcom, 1);
+% %end
+% %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+% otherwise %off or none
+% erpcom = '';
+% end
+
+%
+% Completion statement
+%
+msg2end
+%eeglab redraw
+return
diff --git a/pop_functions/pop_deletemvpcset.m b/pop_functions/pop_deletemvpcset.m
new file mode 100644
index 00000000..a7287e3d
--- /dev/null
+++ b/pop_functions/pop_deletemvpcset.m
@@ -0,0 +1,214 @@
+% PURPOSE : Clears MVPCset(s) from MVPC menu
+%
+% FORMAT :
+%
+% >> ALLMVPC = pop_deletemvpc( ALLMVPC, index);
+%
+% EXAMPLE :
+%
+% >> ALLMVPC = pop_deletbestset( ALLMVPC, [3 5]);
+%
+% INPUTS :
+%
+% ALLERP - Includes all MVPCsets in workspace
+% Index - MVPCset(s) that you want to clear from the workspace
+%
+% OUTPUTS :
+%
+% - updated (output) ALLMVPC. Will include all MVPCsets, minus that deleted
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+function [ALLMVPC] = pop_deletemvpcset(ALLMVPC, varargin)
+
+%erpcom = '';
+if nargin<1
+ help pop_deletemvpcset
+end
+if nargin==1
+ try
+ CURRENTMVPC = evalin('base', 'CURRENTMVPC');
+ catch
+ CURRENTMVPC = 0;
+ end
+ if CURRENTMVPC == 0
+ msgboxText = 'MVPCsets menu is already empty...';
+ title = 'ERPLAB: no MVPCset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ prompt = {'MVPCset(s) to clear:'};
+ dlg_title = 'Delete MVPCset(s)';
+ num_lines = 1;
+ def = {num2str(CURRENTMVPC)}; %01-13-2009
+
+ %
+ % open window
+ %
+ answer = inputvalue(prompt,dlg_title,num_lines,def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ mvpcindex = str2num(answer{1});
+ nmvpcset = length(ALLMVPC);
+ mvpcindex = unique_bc2(mvpcindex);
+
+ if isempty(mvpcindex)
+ msgboxText = 'Wrong MVPCset index(es)';
+ title = 'ERPLAB: unrecognizable MVPCset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+ if max(mvpcindex)>nmvpcset || min(mvpcindex)<1
+ mvpcm = findobj('tag', 'linmvpc');
+ mvpcmenu = length(mvpcm);
+ if max(mvpcindex)<=mvpcmenu && mvpcmenu>=1 && max(mvpcindex)>=1
+ %...
+ else
+ msgboxText = ['Wrong MVPCset index(es)\n'...
+ 'Check your MVPCset menu or write length(ALLMVPC) at command window for comprobation'];
+ title = 'ERPLAB: pop_deletemvpcset not existing MVPCset(s)';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ end
+
+ %
+ % Somersault
+ %
+ [ALLMVPC] = pop_deletemvpcset(ALLMVPC, 'MVPCsets', mvpcindex, 'Saveas', 'on','History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLMVPC');
+% option(s)
+p.addParamValue('MVPCsets', 1); % bestset index or input file
+p.addParamValue('Warning', 'off', @ischar); % history from scripting
+p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('History', 'script', @ischar); % history from scripting
+p.parse(ALLMVPC, varargin{:});
+
+
+mvpcindex = p.Results.MVPCsets;
+if strcmpi(p.Results.Warning,'on')
+ warnop = 1;
+else
+ warnop = 0;
+end
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+nmvpcset = length(ALLMVPC);
+mvpcindex = unique_bc2(mvpcindex);
+
+if isempty(mvpcindex)
+ msgboxText = 'Wrong MVPCset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+if max(mvpcindex)>nmvpcset || min(mvpcindex)<1
+ msgboxText = 'Wrong MVPCset index(es)';
+ error(['ERPLAB says: ' msgboxText])
+end
+detect = ~ismember_bc2(1:nmvpcset,mvpcindex);
+newindex = find(detect);
+if isempty(newindex)
+ ALLMVPC = [];
+else
+ ALLMVPC = ALLMVPC(newindex);
+end
+if issaveas
+ updatemenumvpc(ALLMVPC, -1);
+ assignin('base','ALLMVPC',ALLMVPC); % save to workspace. Dec 5, 2012
+end
+% erpcom = sprintf('ALLERP = pop_deleterpset( ALLERP, [%s]);', num2str(erpindex));
+%
+% History
+%
+% skipfields = {'ALLERP', 'History'};
+% fn = fieldnames(p.Results);
+% erpcom = sprintf( '%s = pop_deleterpset( %s ', inputname(1), inputname(1) );
+% for q=1:length(fn)
+% fn2com = fn{q};
+% if ~ismember_bc2(fn2com, skipfields)
+% fn2res = p.Results.(fn2com);
+% if ~isempty(fn2res)
+% if ischar(fn2res)
+% if ~strcmpi(fn2res,'off')
+% erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
+% end
+% else
+% if iscell(fn2res)
+% if ischar([fn2res{:}])
+% fn2resstr = sprintf('''%s'' ', fn2res{:});
+% else
+% fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+% end
+% fnformat = '{%s}';
+% else
+% fn2resstr = vect2colon(fn2res, 'Sort','on');
+% fnformat = '%s';
+% end
+% if strcmpi(fn2com,'Criterion')
+% if p.Results.Criterion<100
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% else
+% erpcom = sprintf( ['%s, ''%s'', ' fnformat], erpcom, fn2com, fn2resstr);
+% end
+% end
+% end
+% end
+% end
+% erpcom = sprintf( '%s );', erpcom);
+%
+% % get history from script. ERP
+% switch shist
+% case 1 % from GUI
+% displayEquiComERP(erpcom);
+% case 2 % from script
+% for i=1:length(ALLBEST)
+% ALLBEST(i) = erphistory(ALLBEST(i), [], erpcom, 1);
+% end
+% case 3
+% % implicit
+%
+% %for i=1:length(ALLERP)
+% % ALLERP(i) = erphistory(ALLERP(i), [], erpcom, 1);
+% %end
+% %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+% otherwise %off or none
+% erpcom = '';
+% end
+
+%
+% Completion statement
+%
+msg2end
+%eeglab redraw
+return
diff --git a/pop_functions/pop_extractbest.m b/pop_functions/pop_extractbest.m
new file mode 100644
index 00000000..17cb2d4d
--- /dev/null
+++ b/pop_functions/pop_extractbest.m
@@ -0,0 +1,454 @@
+% PURPOSE : Create BEST (.mat) file for the loaded subject bin-epoched (.set) file for decoding analyses.
+%
+% FORMAT :
+%
+% >> [BEST] = pop_extractBEST(ALLEEG,parameters);
+%
+% INPUTS :
+%
+% EEG or ALLEEG - input EEG dataset
+%
+% The available input parameters are as follows:
+
+%
+% 'DSindex' - dataset index when dataset are contained within the ALLEEG structure.
+% For a single bin-epoched dataset using EEG structure this value must be equal to 1 or
+% left unspecified.
+% 'Bins' - Bin index array as indicated in binlister file. Example: [1:4]
+% - If not supplied, all bins will be included
+% in BESTset.
+% 'Criterion' - Inclusion/exclusion of marked epochs during
+% artifact detection:
+% 'all' - include all epochs (ignore artifact detections)
+% 'good' - exclude epochs marked during artifact detection
+% 'bad' - include only epochs marked with artifact rejection
+% Default: 'good';
+% 'ExcludeBoundary' - exclude epochs having boundary events.
+% 'on'(def)/'off'
+% 'BandPass' - If desired, bandpass filtering: [Low_edge_freq High_edge_freq], e.g [8 12];
+% 'SaveAs' - (optional) open GUI for saving BESTset. Not
+% useful if scripting; use separate call to pop_savemybest().
+% 'on'/'off' (Default: off)
+% - (if "off", will not update in BESTset menu)
+%
+% OUTPUTS :
+%
+% BEST - output BEST structure
+%
+% EXAMPLE :
+%
+% [BEST] = pop_extractBEST(ALLEEG,'DSindex',currdata,'Bins',bins_to_use,'ApplyFS', cmk_fs, ...
+% 'ApplyBP', cmk_bp, 'Bandpass', bpfreq);
+%
+% See also: pop_savemybest.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons and Steven J Luck.
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function [BEST] = pop_extractbest(ALLEEG,varargin)
+com= '';
+
+BEST = preloadBEST;
+
+
+if nargin<1
+ help pop_extractBEST
+ return
+end
+
+if isobject(ALLEEG)
+ whenEEGisanObject
+ return
+end
+
+
+if nargin ==1 %GUI case, ALLEEG is input
+
+ currdata = evalin('base', 'CURRENTSET'); %obtain currently loaded set's index
+
+ if currdata==0
+ msgboxText = 'pop_extractBEST() error: cannot work an empty dataset!!!';
+ title = 'ERPLAB: No data';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ serror = erplab_eegscanner(ALLEEG(currdata),'pop_extractBEST', 2,0,1,0,1); %requires epoch & event list
+
+
+ if serror
+ % need to create error checker if
+ %1: not epoched
+ %2: no eventlist (for bin descriptions)
+ return
+ end
+
+ % create working memory
+ def = erpworkingmemory('pop_extractBEST');
+
+ nbins = ALLEEG(currdata).EVENTLIST.nbin;
+
+
+ if isempty(def)
+ def = {1:nbins,0,{'',''},1,1};
+
+ %1: choose all bins (Def)
+ %2: apply freq- transform (1 yes 0 no);
+ %3: bandpass freqs
+ %4: include into epochs (def 1: exclude AD flagged epochs)
+ %5: exclude epochs with boundary events (def 1:YES, exclude)
+ end
+
+
+
+
+ %Call GUIs
+
+ %subroutine: binselector
+ % using APP DESIGNER:
+ % cludgy of using a GUI app with output
+
+ %bins_to_use = binselectorGUI(ALLEEG,currdata); %typical way
+ app = feval('binselectorGUI', ALLEEG, currdata, def); %cludgy way
+ waitfor(app, 'FinishButton',1);
+
+ %outputs & delete gui
+ try
+ res = app.output;
+ catch
+ disp('User canceled');
+ return
+ end
+ bins_to_use = app.output{1}; %selected bins
+ cmk_bp = double(app.output{2}); %apply bandpass?
+ bpfreq = cell2mat(app.output{3}); %bandpass frequncies
+ artcrite = double(app.output{4});
+ exclude_be = app.output{5};
+
+ if cmk_bp == 0
+ bpfreq = [];
+ end
+
+ app.delete; %delete app/app_object from view
+
+ %set working memeory
+ erpworkingmemory('pop_extractBEST',res);
+
+
+ if isempty(bins_to_use)
+ disp('User selected Cancel')
+ return
+ end
+%
+% if ~isempty(bpfreq)
+% bpfreq = str2num(bpfreq);
+% end
+
+ if artcrite == 0
+ crit = 'all';
+ elseif artcrite == 1
+ crit = 'good';
+ elseif artcrite == 2
+ crit = 'bad';
+ end
+
+ if exclude_be == 1
+ excbound = 'on';
+
+ else
+ excbound = 'off';
+ end
+
+ %
+ % Somersault
+ %
+
+% pop_extractBEST(ALLEEG,'DSindex',currdata,'Bins',bins_to_use,...
+% 'ApplyBP', cmk_bp, 'Bandpass', bpfreq, 'Filename', filename_empty, 'Filepath', filepath_empty);
+
+ [BEST] = pop_extractbest(ALLEEG,'DSindex',currdata,'Bins',bins_to_use,...
+ 'Criterion', crit, 'ExcludeBoundary',excbound, ...
+ 'Bandpass', bpfreq,'Saveas', 'on','History','gui');
+
+ pause(0.1)
+ return
+
+
+end
+
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+% input(s)
+p.addRequired('ALLEEG', @isstruct);
+% option(s)
+p.addParamValue('DSindex', 1,@isnumeric); %defaults to 1
+p.addParamValue('Bins', [], @isnumeric);
+%p.addParamValue('ApplyBP', 0, @isnumeric);
+p.addParamValue('Bandpass', [], @isnumeric);
+p.addParamValue('Criterion','good',@ischar);
+p.addParamValue('ExcludeBoundary','on',@ischar);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History','script',@ischar);
+
+
+p.parse(ALLEEG, varargin{:});
+
+setindex = p.Results.DSindex;
+bin_ind = p.Results.Bins;
+%bandpass_on = p.Results.ApplyBP;
+bandpass_freq = p.Results.Bandpass;
+artcrite = p.Results.Criterion;
+exclude_be = p.Results.ExcludeBoundary;
+
+if isempty(bin_ind)
+ %if no bins input, then use all bins
+ bin_ind = 1:(ALLEEG.EVENTLIST.nbin);
+end
+
+
+
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+
+if strcmpi(artcrite,'all')
+ artif = 0;
+elseif strcmpi(artcrite,'good')
+ artif = 1;
+elseif strcmpi(artcrite,'bad')
+ artif = 2;
+end
+
+if strcmpi(exclude_be,'on')
+ excbound = 1;
+elseif strcmpi(exclude_be,'off')
+ excbound = 2;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+
+
+%main EEG struct
+EEG2 = ALLEEG(setindex);
+fs_original = EEG2.srate; % need original FS (for frequency transformation)
+
+
+if ~isempty(bandpass_freq)
+ nElectrodes = EEG2.nbchan;
+ filtData = nan(EEG2.trials, EEG2.nbchan,EEG2.pnts);
+ unfiltData = permute(EEG2.data,[3 1 2]);
+
+ for c = 1:nElectrodes
+
+ filtData(:,c,:) =abs(hilbert(eegfilt(squeeze(unfiltData(:,c,:)),fs_original,bandpass_freq(1,1),bandpass_freq(1,2))')').^2; %Instantaneous power
+ end
+
+
+end
+
+
+%Obtain indexed EEGSET
+% Thanks to AXS, adapted binepEEG_to_binorgEEG.m code following:
+
+dim_data = numel(size(EEG2.data));
+if dim_data ~= 3
+ msgboxText = 'pop_extractBEST() error: cannot work on continuous data! Please ensure data is epoched (not continuous)';
+ title = 'ERPLAB: No data';
+ errorfound(msgboxText, title);
+ %error('binepEEG_to_binorgEEG works on bin-epoched EEG. Please ensure data is epoched (not continuous) and has bin labels');
+end
+
+
+% Prepare info for averager call
+% Excludes epochs marked with artifacts and that contains boundary events
+stderror = 1; apod = []; nfft = []; dcompu = 1; avgText =0;
+
+% Call ERP Averager subfunction, populating the epoch_list
+[ERP2, EVENTLISTi, countbiORI, countbinINV, countbinOK, countflags, workfname,epoch_list] = averager(EEG2, artif, stderror, excbound, dcompu, nfft, apod, avgText);
+
+if ~isempty(bandpass_freq) %if bandpassed, add filtered data to EEG2
+
+ filtData = permute(filtData,[2 3 1]);
+ EEG2.data = filtData;
+
+end
+
+
+% Create BEST structure fields from .set file data (subroutine)
+BEST = buildBESTstruct(EEG2); %BIN-EPOCHED SINGLE TRIAL (BEST)
+nbin = BEST.nbin;
+
+% Prepare binorg data structure
+for bin = 1:nbin
+
+ BEST.binwise_data(bin).data = EEG2.data(:,:,epoch_list(bin).good_bep_indx);
+ BEST.n_trials_per_bin(bin) = numel(epoch_list(bin).good_bep_indx);
+
+end
+
+%output only the selected bins
+BEST.binwise_data = BEST.binwise_data([bin_ind]);
+BEST.n_trials_per_bin = BEST.n_trials_per_bin([bin_ind]);
+BEST.bindesc = BEST.bindesc([bin_ind]);
+BEST.original_bin = BEST.original_bin([bin_ind]);
+BEST.nbin = length(bin_ind);
+
+%
+% History
+%
+skipfields = {'ALLEEG', 'Saveas','Warning','History'};
+if isempty(bandpass_freq) == 1 % ERP
+ skipfields = [skipfields 'Bandpass'];
+end
+% if isfield(p.Results,'DQ_spec') == 0 || isempty(p.Results.DQ_spec)
+% skipfields = [skipfields 'DQ_spec']; % skip DQ spec in History if it was absent
+% elseif isfield(p.Results.DQ_spec(1),'comments') && numel(p.Results.DQ_spec(1).comments) >= 1
+% if strcmpi(p.Results.DQ_spec(1).comments{1},'defaults')
+% skipfields = [skipfields 'DQ_spec']; % skip DQ spec in History if default was used
+% end
+% end
+fn = fieldnames(p.Results);
+explica = 0;
+if length(setindex)==1 && setindex(1)==1
+ inputvari = 'EEG'; % Thanks to Felix Bacigalupo for this suggestion. Dic 12, 2011
+ skipfields = [skipfields 'DSindex']; % SL
+else
+ if length(setindex)==1
+ explica = 1;
+ end
+ inputvari = inputname(1);
+end
+bestcom = sprintf( 'BEST = pop_extractbest( %s ', inputvari);
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ bestcom = sprintf( '%s, ''%s'', ''%s''', bestcom, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ if all(cellfun(@isnumeric, fn2res))
+ fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ else
+ fn2resstr = '';
+ for kk=1:length(fn2res)
+ auxcont = fn2res{kk};
+ if ischar(auxcont);
+ fn2resstr = [fn2resstr '''' auxcont ''''];
+ else
+ fn2resstr = [fn2resstr ' ' vect2colon(auxcont, 'Delimiter', 'on')];
+ end
+ end
+ end
+ fnformat = '{%s}';
+ elseif isnumeric(fn2res)
+ fn2res = mat2colon(fn2res);
+ fn2resstr = num2str(fn2res); fnformat = '%s';
+ elseif isstruct(fn2res)
+ fn2resstr = 'DQ_spec_structure'; fnformat = '%s';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+
+% if strcmpi(fn2com,'DSindex') || strcmpi(fn2com,'Bins') || strcmpi(fn2com,'Bandpass')
+% bestcom = sprintf( ['%s, ''%s'', [', fnformat,']'], bestcom, fn2com, fn2resstr);
+% else
+ bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+% end
+
+ %bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+ end
+ end
+ end
+end
+bestcom = sprintf( '%s );', bestcom);
+
+
+
+switch shist
+ case 1 % from GUI
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ displayEquiComERP(bestcom);
+ if explica
+ try
+ cprintf([0.1333, 0.5451, 0.1333], '%%IMPORTANT: For pop_extractbest, you may use EEG instead of ALLEEG, and remove "''DSindex'',%g"\n',setindex);
+ catch
+ fprintf('%%IMPORTANT: For pop_extractbest, you may use EEG instead of ALLEEG, and remove ''DSindex'',%g:\n',setindex);
+ end
+ end
+ case 2 % from script
+ % ERP = erphistory(ERP, [], bestcom, 1);
+ case 3
+ % implicit
+ otherwise % off or none
+ bestcom = '';
+end
+
+%
+% Save BESTset
+%
+
+if issaveas
+ [BEST, issave] = pop_savemybest(BEST,'gui','erplab');
+ if issave>0
+ if issave==2
+ % erpcom = sprintf('%s\n%s', erpcom, erpcom_save);
+ msgwrng = '*** Your BESTset was saved on your hard drive.***';
+ else
+ msgwrng = '*** Warning: Your BESTset was only saved on the workspace.***';
+ end
+ else
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ end
+ try cprintf([1 0.52 0.2], '%s\n\n', msgwrng); catch,fprintf('%s\n\n', msgwrng);end ;
+end
+
+
+msg2end
+return
\ No newline at end of file
diff --git a/pop_functions/pop_loadbest.m b/pop_functions/pop_loadbest.m
new file mode 100644
index 00000000..083c2758
--- /dev/null
+++ b/pop_functions/pop_loadbest.m
@@ -0,0 +1,303 @@
+% PURPOSE : Loads BESTset(s)
+%
+% FORMAT :
+%
+% BEST = pop_loadbest(parameters);
+%
+% PARAMETERS :
+%
+% 'filename' - BESTset filename
+% 'filepath' - BESTset's filepath
+% 'Warning' - 'on'/'off'(Def)
+% 'UpdateMainGui' - 'on'/'off'(Def)
+%
+%
+% OUTPUTS :
+%
+% BEST - output BESTset
+%
+%
+% Example :
+%
+% BEST = pop_loadbest( 'filename', 'Face_Emotion_302_ICA_removed.best', 'filepath',...
+% pwd);
+
+
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+
+function [BEST, ALLBEST] = pop_loadbest(varargin)
+BEST = preloadBEST;
+try
+ ALLBEST = evalin('base', 'ALLBEST');
+ preindex = length(ALLBEST);
+
+catch
+ disp('WARNING: ALLBEST structure was not found. ERPLAB will create an empty one.')
+ ALLBEST = [];
+ %ALLERP = buildERPstruct([]);
+ preindex = 0;
+
+end
+
+if nargin <1
+ help pop_loadbest
+
+ return
+
+end
+
+
+if nargin == 1
+ filename = varargin{1};
+ if strcmpi(filename,'workspace')
+ filepath = '';
+ else
+ if isempty(filename)
+ [filename, filepath] = uigetfile({'*.best','BEST (*.best)'},...
+ 'Load BEST','MultiSelect', 'on');
+ if isequal(filename,0)
+ disp('User selected Cancel')
+ return
+ end
+
+ %
+ % test current directory
+ %
+ %changecd(filepath) % Steve does not like this...
+ else
+ filepath = cd;
+ end
+ end
+
+ %
+ % Somersault
+ %
+
+ [BEST, ALLBEST] = pop_loadbest('filename', filename, 'filepath', filepath, 'Warning', 'on', 'UpdateMainGui', 'on','History','gui');
+ return
+
+
+
+end
+
+
+% parsing inputs
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+% option(s)
+p.addParamValue('filename', '');
+p.addParamValue('filepath', '', @ischar);
+p.addParamValue('overwrite', 'off', @ischar);
+p.addParamValue('Warning', 'off', @ischar);
+%p.addParamValue('multiload', 'off', @ischar); % ERP stores ALLERP's contain (ERP = ...), otherwise [ERP ALLERP] = ... must to be specified.
+p.addParamValue('UpdateMainGui', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(varargin{:});
+
+filename = strtrim(p.Results.filename);
+filepath = strtrim(p.Results.filepath);
+
+if strcmpi(filename,'workspace')
+ filepath = '';
+ nfile = 1;
+ loadfrom = 0; % load from workspace
+else
+ loadfrom = 1; % load from: 1=hard drive; 0=workspace
+end
+
+if strcmpi(p.Results.Warning,'on')
+ popupwin = 1;
+else
+ popupwin = 0;
+end
+if strcmpi(p.Results.UpdateMainGui,'on')
+ updatemaingui = 1;
+else
+ updatemaingui = 0;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+% if strcmpi(p.Results.multiload,'on')
+% multiload = 1;
+% else
+% multiload = 0;
+% end
+
+if loadfrom==1
+ if iscell(filename)
+ nfile = length(filename);
+ inputfname = filename;
+ else
+ nfile = 1;
+ inputfname = {filename};
+ end
+else
+ inputfname = {'workspace'};
+end
+
+
+inputpath = filepath;
+errorf = 0; % no error found, by default
+conti = 1; % continue? 1=yes; 0=no
+% if strcmpi(p.Results.overwrite,'on')||strcmpi(p.Results.overwrite,'yes')
+% ovatmenu = 1;
+% else
+% ovatmenu = 0;
+% end
+
+
+for i=1:nfile
+ if loadfrom==1
+ fullname = fullfile(inputpath, inputfname{i});
+ fprintf('Loading %s\n', fullname);
+ L = load(fullname, '-mat');
+ BEST = L.BEST;
+% if i == 1
+% BEST = L.BEST;
+% else
+% BEST(i) = L.BEST;
+% end
+ else
+ BEST = evalin('base', 'BEST');
+ end
+
+ %
+ % Skipping all "checking" features for now
+ % - see pop_loaderp() for "checking ERP" routine
+ %
+
+ if i == 1 && isempty(ALLBEST)
+ ALLBEST = BEST;
+
+ else
+ ALLBEST(i+preindex) = BEST;
+
+
+ end
+
+
+end
+
+if conti==0
+ return
+end
+
+% if nargout==1 && multiload==1
+% BEST = ALLBEST;
+% end
+
+if nfile==1
+ outv = 'BEST';
+else
+ outv = '[BEST ALLBEST]';
+end
+
+
+
+
+
+%% see line 280 in pop_loaderp
+if updatemaingui % update erpset menu at main gui
+ assignin('base','ALLBEST',ALLBEST); % save to workspace
+ updatemenubest(ALLBEST); % add a new bestset to the bestset menu
+end
+
+fn = fieldnames(p.Results);
+bestcom = sprintf( '%s = pop_loadbest(', outv);
+skipfields = {'UpdateMainGui', 'Warning','History','overwrite'};
+
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if iscell(fn2res) % 10-21-11
+ nc = length(fn2res);
+ xfn2res = sprintf('{''%s''', fn2res{1} );
+ for f=2:nc
+ xfn2res = sprintf('%s, ''%s''', xfn2res, fn2res{f} );
+ end
+ fn2res = sprintf('%s}', xfn2res);
+ else
+ if ~strcmpi(fn2res,'off') %&& ~strcmpi(fn2res,'on')
+ fn2res = ['''' fn2res ''''];
+ end
+ end
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ if q==1
+ bestcom = sprintf( '%s ''%s'', %s', bestcom, fn2com, fn2res);
+ else
+ bestcom = sprintf( '%s, ''%s'', %s', bestcom, fn2com, fn2res);
+ end
+ end
+ else
+ bestcom = sprintf( '%s, ''%s'', %s', bestcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ end
+ end
+ end
+end
+bestcom = sprintf( '%s );', bestcom);
+
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(bestcom);
+ case 2 % from script
+ %ERP = erphistory(ERP, [], erpcom, 1);
+ case 3
+ % implicit
+ % ERP = erphistory(ERP, [], erpcom, 1);
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ otherwise %off or none
+ % erpcom = '';
+ return
+end
+
+
+prefunc = dbstack;
+nf = length(unique_bc2({prefunc.name}));
+if nf==1
+ msg2end
+end
+
+
+return
\ No newline at end of file
diff --git a/pop_functions/pop_loadmvpc.m b/pop_functions/pop_loadmvpc.m
new file mode 100644
index 00000000..fdd9009e
--- /dev/null
+++ b/pop_functions/pop_loadmvpc.m
@@ -0,0 +1,319 @@
+% PURPOSE : Loads MVPCset(s)
+%
+% FORMAT :
+%
+% MVPC = pop_loadmvpc(parameters);
+%
+% PARAMETERS :
+%
+% 'filename' - MVPCset filename
+% 'filepath' - MVPCset's filepath
+% 'Warning' - 'on'/'off' (def)
+% 'UpdateMainGui' - 'on'/'off' (def)
+%
+%
+% OUTPUTS :
+%
+% MVPC - output MVPCset
+%
+%
+% EXAMPLE 1 : Load a single ERPset
+%
+% MVPC = pop_loadmvpc( 'filename', 'Face_Emotion_302_ICA_removed.mvpc', 'filepath',...
+% pwd );
+%
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function [MVPC, ALLMVPC] = pop_loadmvpc(varargin)
+
+MVPC = preloadMVPC;
+
+try
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ preindex = length(ALLMVPC);
+
+catch
+ disp('WARNING: ALLMVPC structure was not found. ERPLAB will create an empty one.')
+ ALLMVPC = [];
+ %ALLERP = buildERPstruct([]);
+ preindex = 0;
+
+end
+
+if nargin <1
+ help pop_loadmvpc
+
+ return
+
+end
+
+if nargin == 1
+ filename = varargin{1};
+ if strcmpi(filename,'workspace') || strcmpi(filename,'decodingtoolbox')
+ filepath = '';
+ else
+ if isempty(filename)
+ [filename, filepath] = uigetfile({'*.mvpc','MVPC (*.mvpc)'},...
+ 'Load MVPC','MultiSelect', 'on');
+ if isequal(filename,0)
+ disp('User selected Cancel')
+ return
+ end
+
+ %
+ % test current directory
+ %
+ %changecd(filepath) % Steve does not like this...
+ else
+ filepath = cd;
+ end
+ end
+
+ %
+ % Somersault
+ %
+
+ [MVPC, ALLMVPC] = pop_loadmvpc('filename', filename, 'filepath', filepath, 'Warning', 'on', 'UpdateMainGui', 'on', 'multiload', 'off','History','gui');
+ return
+
+
+
+end
+
+
+% parsing inputs
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+% option(s)
+p.addParamValue('filename', '');
+p.addParamValue('filepath', '', @ischar);
+p.addParamValue('overwrite', 'off', @ischar);
+p.addParamValue('Warning', 'off', @ischar);
+p.addParamValue('multiload', 'off', @ischar); % ERP stores ALLERP's contain (ERP = ...), otherwise [ERP ALLERP] = ... must to be specified.
+p.addParamValue('UpdateMainGui', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(varargin{:});
+
+filename = strtrim(p.Results.filename);
+filepath = strtrim(p.Results.filepath);
+
+if strcmpi(filename,'workspace')
+ filepath = '';
+ nfile = 1;
+ loadfrom = 0; % load from workspace
+elseif strcmpi(filename,'decodingtoolbox')
+ filepath = '';
+ ALLMVPC2 = evalin('base', 'ALLMVPC2');
+ nfile = length(ALLMVPC2);
+ preindex = length(ALLMVPC);
+ loadfrom = 2; % load from workspace
+else
+ loadfrom = 1; % load from: 1=hard drive; 0=workspace
+end
+
+
+if strcmpi(p.Results.Warning,'on')
+ popupwin = 1;
+else
+ popupwin = 0;
+end
+if strcmpi(p.Results.UpdateMainGui,'on')
+ updatemaingui = 1;
+else
+ updatemaingui = 0;
+end
+if strcmpi(p.Results.multiload,'on')
+ multiload = 1;
+else
+ multiload = 0;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+if loadfrom==1
+ if iscell(filename)
+ nfile = length(filename);
+ inputfname = filename;
+ else
+ nfile = 1;
+ inputfname = {filename};
+ end
+else
+ if strcmpi(filename,'workspace')
+ inputfname = {'workspace'};
+ else
+ inputfname = {'workspace'};
+ end
+end
+
+inputpath = filepath;
+errorf = 0; % no error found, by default
+conti = 1; % continue? 1=yes; 0=no
+
+if loadfrom == 1 || loadfrom == 0
+ for i=1:nfile
+ if loadfrom==1
+ fullname = fullfile(inputpath, inputfname{i});
+ fprintf('Loading %s\n', fullname);
+ L = load(fullname, '-mat');
+ MVPC = L.MVPC;
+ % if i == 1
+ % BEST = L.BEST;
+ % else
+ % BEST(i) = L.BEST;
+ % end
+ else
+ MVPC = evalin('base', 'MVPC');
+
+ end
+
+
+ if i == 1 && isempty(ALLMVPC)
+ ALLMVPC = MVPC;
+
+ else
+ ALLMVPC(i+preindex) = MVPC;
+
+ end
+
+ end
+elseif loadfrom == 2
+ % if loaded from GUI decoding toolbox
+
+ if isempty(ALLMVPC)
+ ALLMVPC = ALLMVPC2;
+ else
+
+ for i= 1:nfile
+ ALLMVPC(i+preindex) = ALLMVPC2(i);
+ end
+
+ end
+
+
+end
+
+if nargout==1 && multiload==1
+
+ MVPC = ALLMVPC(end);
+end
+
+if nfile==1
+ outv = 'MVPC';
+else
+ outv = '[MVPC ALLMVPC]';
+end
+
+if exist("ALLMVPC2")
+ %clear from base
+ evalin('base', 'clear ALLMVPC2');
+end
+
+
+
+if updatemaingui % update erpset menu at main gui
+ assignin('base','ALLMVPC',ALLMVPC); % save to workspace
+ updatemenumvpc(ALLMVPC); % add a new bestset to the bestset menu
+end
+
+
+fn = fieldnames(p.Results);
+mvpccom = sprintf( '%s = pop_loadmvpc(', outv);
+skipfields = {'UpdateMainGui', 'Warning','History', 'multiload'};
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if iscell(fn2res) % 10-21-11
+ nc = length(fn2res);
+ xfn2res = sprintf('{''%s''', fn2res{1} );
+ for f=2:nc
+ xfn2res = sprintf('%s, ''%s''', xfn2res, fn2res{f} );
+ end
+ fn2res = sprintf('%s}', xfn2res);
+ else
+ if ~strcmpi(fn2res,'off') %&& ~strcmpi(fn2res,'on')
+ fn2res = ['''' fn2res ''''];
+ end
+ end
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ if q==1
+ mvpccom = sprintf( '%s ''%s'', %s', mvpccom, fn2com, fn2res);
+ else
+ mvpccom = sprintf( '%s, ''%s'', %s', mvpccom, fn2com, fn2res);
+ end
+ end
+ else
+ mvpccom = sprintf( '%s, ''%s'', %s', mvpccom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ end
+ end
+ end
+end
+mvpccom = sprintf( '%s );', mvpccom);
+
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(mvpccom);
+ case 2 % from script
+ % ERP = erphistory(ERP, [], erpcom, 1);
+ case 3
+ % implicit
+ % ERP = erphistory(ERP, [], erpcom, 1);
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ otherwise %off or none
+ %erpcom = '';
+ return
+end
+
+
+
+prefunc = dbstack;
+nf = length(unique_bc2({prefunc.name}));
+if nf==1
+ msg2end
+end
+
+
+
+
+return
diff --git a/pop_functions/pop_mvpc2text.m b/pop_functions/pop_mvpc2text.m
new file mode 100644
index 00000000..044e71bc
--- /dev/null
+++ b/pop_functions/pop_mvpc2text.m
@@ -0,0 +1,257 @@
+
+% PURPOSE : Exports MVPC set to text
+%
+% FORMAT :
+%
+% MVPC = pop_mvpc2text(MVPC, filename, binArray, parameters)
+%
+%
+% INPUTS :
+%
+% MVPC - MVPCset (ERPLAB structure)
+% filename - filename of outputted file
+%
+%
+% The available parameters are as follows:
+%
+% 'time' - 'on'=include time values; 'off'=don't include time values
+% 'timeunit' - 1=seconds; 1E-3=milliseconds
+% 'electrodes' - 'on'=include electrode labels' 'off'=don't include electrode labels
+% 'transpose' - 'on'= (points=rows) & (electrode=columns)
+% 'off' = (electrode=rows) & (points=column)
+% 'precision' - [float] number of significant digits in output. Default 4.
+%
+% OUTPUTS
+%
+% - text file
+%
+%
+% EXAMPLE :
+%
+% MVPC = pop_mvpc2text( MVPC, '/Users/amsimmon/Documents/filename.txt',
+% 'time', 'on', 'timeunit', 0.001 )
+%
+%
+% See also mvpc2textGUI.m mvpc2text.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+%
+% BUGs FIXED
+% Jan 3, 2012. Replace forbidden characters for bindesc and chan labels. Thanks Naomi Bleich
+function [MVPC, mvpccom] = pop_mvpc2text(MVPC, filename, varargin)
+mvpccom = '';
+if nargin < 1
+ help pop_mvpc2text;
+ return;
+end
+if isempty(MVPC)
+ msgboxText = 'No MVPCset was found!';
+ title_msg = 'ERPLAB: pop_mvpc2text() error:';
+ errorfound(msgboxText, title_msg);
+ return
+end
+if ~isfield(MVPC, 'average_score') %or use if DecodingUnit == 'None'?
+ msgboxText = 'pop_mvpct2text cannot export an empty ERP dataset';
+ title = 'ERPLAB: pop_mvpc2text() error:';
+ errorfound(msgboxText, title);
+ return
+end
+
+if nargin==1
+ def = erpworkingmemory('pop_mvpc2text');
+ if isempty(def)
+ def = {1,1E-3, 0,''};
+ %istime
+ %timeunit
+ %transpose
+ %precision
+ %filename
+ end
+
+ %
+ % Call GUI
+ %
+ %answer = mvpc2textGUI(MVPC, def); %app designer
+
+ app = feval('mvpc2textGUI',MVPC,def);
+ waitfor(app,'FinishButton',1);
+
+ try
+ answer = app.output; %NO you don't want to output BEST, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.5); %wait for app to leave
+ catch
+ disp('User selected Cancel');
+ return
+ end
+
+ istime = answer{1};
+ tunit = answer{2};
+ transpa = answer{3};
+ filename = answer{4};
+
+ erpworkingmemory('pop_mvpc2text', answer);
+
+ if istime
+ time = 'on';
+ else
+ time = 'off';
+ end
+
+ if transpa
+ tra = 'on';
+ else
+ tra = 'off';
+ end
+
+
+
+ %
+ % Somersault
+ %
+ [MVPC, mvpccom] = pop_mvpc2text(MVPC, filename, 'time', time, 'timeunit', tunit, ...
+ 'transpose', tra,'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('MVPC');
+p.addRequired('filename', @ischar);
+%p.addRequired('binArray', @isnumeric);
+% option(s)
+p.addParamValue('time', 'on', @ischar);
+p.addParamValue('timeunit', 1E-3, @isnumeric); % milliseconds by default
+p.addParamValue('transpose', 'on', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(MVPC, filename, varargin{:});
+
+if strcmpi(p.Results.time, 'on')
+ time = 1;
+else
+ time = 0;
+end
+timeunit = p.Results.timeunit;
+
+if strcmpi(p.Results.transpose, 'on')
+ transpose = 1;
+else
+ transpose = 0;
+end
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+%precision = p.Results.precision;
+
+%
+% subroutine
+%
+serror = mvpc2text(MVPC, filename,time, timeunit, transpose);
+
+if serror==1
+ msgboxText = 'Something went wrong...\n';
+ etitle = 'ERPLAB: appenderpGUI inputs';
+ errorfound(sprintf(msgboxText), etitle);
+ return
+end
+
+%
+% History
+%
+skipfields = {'MVPC', 'filename','History'};
+fn = fieldnames(p.Results);
+mvpccom = sprintf( 'pop_mvpc2text( %s, ''%s'', %s', inputname(1), filename );
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ mvpccom = sprintf( '%s ''%s'', ''%s''', mvpccom, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ if ischar([fn2res{:}])
+ fn2resstr = sprintf('''%s'' ', fn2res{:});
+ else
+ fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ end
+ fnformat = '{%s}';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+ if strcmpi(fn2com,'Criterion')
+ if p.Results.Criterion<100
+ mvpccom = sprintf( ['%s, ''%s'', ' fnformat], mvpccom, fn2com, fn2resstr);
+ end
+ else
+ mvpccom = sprintf( ['%s, ''%s'', ' fnformat], mvpccom, fn2com, fn2resstr);
+ end
+ end
+ end
+ end
+end
+mvpccom = sprintf( '%s );', mvpccom);
+% get history from script. ERP
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(mvpccom);
+ case 2 % from script
+ MVPC = erphistory(MVPC, [], mvpccom, 1);
+ case 3
+ % implicit
+ %ERP = erphistory(ERP, [], erpcom, 1);
+ %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ otherwise %off or none
+ mvpccom = '';
+end
+
+%
+% Completion statement
+%
+msg2end
+return
+
+
+
+
+
diff --git a/pop_functions/pop_mvpcaverager.m b/pop_functions/pop_mvpcaverager.m
new file mode 100644
index 00000000..6d114fdb
--- /dev/null
+++ b/pop_functions/pop_mvpcaverager.m
@@ -0,0 +1,356 @@
+% PURPOSE : Averages across MVPCsets (grand average)
+%
+% FORMAT :
+%
+% MVPC = pop_mvpcaverager( ALLMVPC , Parameters);
+%
+%
+% INPUTS :
+%
+% ALLMVPC - structure array of MVPC structures (MVPCsets)
+%
+% The available parameters are as follows:
+%
+% 'Mvpcsets' - index(es) pointing to MVPC structures within ALLMVPC (only valid when ALLMVPC is specified)
+% 'SEM' - Get standard error of the mean. 'on' or 'off'
+% 'Warning' - Warning 'on' or 'off' (def)
+%
+% OUTPUTS :
+%
+% MVPC - data structure containing the average of all specified MVPC datasets.
+%
+%
+% EXAMPLE :
+%
+% MVPC = pop_mvpcaverager( ALLMVPC , 'Mvpcsets', [1 2], 'SEM', 'on' );
+%
+%
+%
+% See also mvpcaveragerGUI.m mvpcaverager.m pop_mvpcaverager.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons, Javier Lopez-Calderon & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+
+function [MVPC] = pop_mvpcaverager(ALLMVPC,varargin)
+% mvpccom '';
+MVPC = preloadMVPC;
+
+if nargin==1 % GUI
+ if ~iscell(ALLMVPC) && ~ischar(ALLMVPC)
+ if isstruct(ALLMVPC)
+% iserp = iserpstruct(ALLMVPC(1));
+% if ~iserp
+% ALLMVPC = [];
+% end
+ actualnset = length(ALLMVPC);
+ else
+ ALLMVPC = [];
+ actualnset = 0;
+ end
+
+ def = erpworkingmemory('pop_mvpcaverager');
+ if isempty(def)
+ def = { actualnset 0 '' 1 1};
+ else
+ def{1}=actualnset;
+ end
+ if isnumeric(def{3}) && ~isempty(ALLMVPC) %if ALLMVPC indexs are supplied
+ if max(def{3})>length(ALLMVPC)
+ def{3} = def{3}(def{3}<=length(ALLMVPC));
+ end
+ if isempty(def{3})
+ def{3} = 1;
+ end
+ end
+
+ % def{2} = 0; %aaron: until I fix lists, always load mvpcmenu
+
+ %
+ % Open Grand Average GUI
+ %
+ answer = mvpcaveragerGUI(def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ optioni = answer{1}; %1 means from a filelist, 0 means from mvpcsets menu
+ mvpcset = answer{2};
+ stderror = answer{3}; % 0;1
+ warnon = answer {4};
+
+
+ if optioni==1 % from files
+ filelist = mvpcset;
+ disp(['pop_gaverager(): For file-List, user selected ', filelist])
+ ALLMVPC = {ALLMVPC, filelist}; % truco
+ else % from mvpcsets menu
+ %mvpcset = mvpcset;
+ end
+
+ %def = {actualnset, optioni, mvpcset,stderror};
+ def = {actualnset, optioni, mvpcset,stderror,warnon};
+ erpworkingmemory('pop_mvpcaverager', def);
+ if stderror==1
+ stdsstr = 'on';
+ else
+ stdsstr = 'off';
+ end
+ if warnon==1
+ warnon_str = 'on';
+ else
+ warnon_str = 'off';
+ end
+ %
+ % Somersault
+ %
+ %[ERP erpcom] = pop_gaverager(ALLMVPC, 'mvpcsets', mvpcset, 'Loadlist', filelist,'Criterion', artcrite,...
+ % 'SEM', stdsstr, 'Weighted', wavgstr, 'Saveas', 'on');
+ [MVPC] = pop_mvpcaverager(ALLMVPC, 'Mvpcsets', mvpcset, 'SEM', stdsstr,...
+ 'Warning', warnon_str, 'Saveas','on','History', 'gui');
+ pause(0.1)
+ return
+ else
+ fprintf('pop_mvpcaverager() was called using a single (non-struct) input argument.\n\n');
+ end
+end
+
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLMVPC');
+% option(s)
+p.addParamValue('MVPCindex', 1); % same as Erpsets
+p.addParamValue('Mvpcsets', []);
+p.addParamValue('SEM', 'off', @ischar); % 'on', 'off'
+p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('Warning', 'off', @ischar); % 'on', 'off'
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLMVPC, varargin{:});
+
+mvpcset = p.Results.Mvpcsets;
+
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+
+if isempty(mvpcset)
+ mvpcset = p.Results.MVPCindex;
+end
+
+if isempty(mvpcset)
+ error('ERPLAB says: "MVPCsets" parameter was not specified.');
+end
+
+lista = '';
+if isnumeric(mvpcset)
+ nfile = length(mvpcset);
+ optioni = 0 ;
+else
+ optioni = 1; %from file
+ filelist = '';
+ if iscell(ALLMVPC) % from the GUI, when ALLMVPC exist and user picks a list up as well
+ filelist = ALLMVPC{2};
+ ALLMVPC = ALLMVPC{1};
+ elseif ischar(ALLMVPC) % from script, when user picks a list.
+ filelist = ALLMVPC;
+ else
+ error('ERPLAB says: "Mvpcsets" parameter is not valid.')
+ end
+ if ~iscell(filelist) && ~isempty(filelist)
+ if exist(filelist, 'file')~=2
+ error('ERPLAB:error', 'ERPLAB says: File %s does not exist.', filelist)
+ end
+ disp(['For file-List, user selected ', filelist])
+
+ %
+ % open file containing the erp list
+ %
+ fid_list = fopen( filelist );
+ formcell = textscan(fid_list, '%[^\n]','CommentStyle','#', 'whitespace', '');
+ lista = formcell{:};
+ lista = strtrim(lista); % this fixes the bag described by Darren Tanner and Katherine Stavropoulos
+ nfile = length(lista);
+ fclose(fid_list);
+ else
+ error('ERPLAB says: error at pop_appenderp(). Unrecognizable input ')
+ end
+end
+
+if ismember_bc2({p.Results.SEM}, {'on','yes'})
+ stderror = 1;
+else
+ stderror = 0;
+end
+
+if ismember_bc2({p.Results.Warning}, {'on','yes'})
+ warnon = 1;
+else
+ warnon = 0;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+
+
+%
+%subroutine
+%
+
+MVPCaux = MVPC;
+[MVPC, serror, msgboxText] = mvpcaverager(ALLMVPC, lista, optioni, mvpcset, nfile, stderror,warnon);
+
+
+if serror>0
+ title = 'ERPLAB: gaverager() Error';
+ errorfound(msgboxText, title);
+ return
+end
+
+% Completion statement
+%
+msg2end
+
+
+% Construct the History string
+% load with the appropriate input args
+skipfields = {'ALLMVPC', 'Saveas', 'Warning','History'};
+if isstruct(ALLMVPC) && optioni~=1 % from files
+ DATIN = inputname(1);
+else
+ %DATIN = ['''' ALLERP ''''];
+ DATIN = sprintf('''%s''', filelist);
+ skipfields = [skipfields, 'Mvpcsets'];
+end
+
+fn = fieldnames(p.Results);
+mvpccom = sprintf( 'MVPC = pop_mvpcaverager( %s ', DATIN);
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ % Examine the variable type for the argument used, load that in to
+ % the History string appropriately
+ arg_value_here = fn2res;
+ if isempty(arg_value_here)
+ write_this_one = 0;
+ else
+ if ischar(arg_value_here)
+ if strcmpi(fn2res,'off')
+ write_this_one = 0;
+ end
+ else
+ write_this_one = 1;
+ end
+ end
+
+ if write_this_one % if an argument value is not empty
+
+ if ischar(fn2res)
+ fnformat = '''%s'''; fn2resstr = fn2res;
+ elseif isnumeric(fn2res)
+ fn2resstr = num2str(fn2res); fnformat = '%s';
+ elseif isstruct(fn2res)
+ fn2resstr = 'DQ_spec_structure'; fnformat = '%s';
+ elseif iscell(fn2res)
+ if ischar([fn2res{:}])
+ fn2resstr = sprintf('''%s'' ', fn2res{:});
+ else
+ fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ end
+ fnformat = '{%s}';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+
+
+ if strcmpi(fn2com,'Criterion')
+ if p.Results.Criterion<100
+ mvpccom = sprintf( ['%s, ''%s'', ' fnformat], mvpccom, fn2com, fn2resstr);
+ end
+ else
+ if strcmpi(fn2com,'Mvpcsets') %ams fixed for Erpsets str
+ mvpccom = sprintf( ['%s, ''%s'', [', fnformat,']'], mvpccom, fn2com, fn2resstr);
+ else
+ mvpccom = sprintf( ['%s, ''%s'', ' fnformat ], mvpccom, fn2com, fn2resstr);
+ end
+ end
+ end
+ end
+end
+
+mvpccom = sprintf( '%s );', mvpccom);
+
+
+if issaveas
+
+
+ [MVPC, issave] = pop_savemymvpc(MVPC,'gui','averager');
+ if issave>0
+ if issave==2
+ % erpcom = sprintf('%s\n%s', erpcom, erpcom_save);
+ msgwrng = '*** Your ERPset was saved on your hard drive.***';
+ else
+ msgwrng = '*** Warning: Your ERPset was only saved on the workspace.***';
+ end
+ else
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ MVPC = MVPCaux;
+ end
+ try cprintf([1 0.52 0.2], '%s\n\n', msgwrng); catch,fprintf('%s\n\n', msgwrng);end ;
+end
+
+% get history from script. ERP
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(mvpccom);
+ case 2 % from script
+ %ERP = erphistory(ERP, [], erpcom, 1);
+ case 3
+ % implicit
+ otherwise %off or none
+ erpcom = '';
+ return
+end
+
+return
\ No newline at end of file
diff --git a/pop_functions/pop_plotconfusions.m b/pop_functions/pop_plotconfusions.m
new file mode 100644
index 00000000..709ed5ef
--- /dev/null
+++ b/pop_functions/pop_plotconfusions.m
@@ -0,0 +1,640 @@
+% PURPOSE : Plot confusion matricies from MVPC data
+%
+% FORMAT :
+%
+% >> pop_plotconfusions(MVPC, Times, Type)
+%
+% INPUTS (Required) :
+%
+% MVPC or ALLMVPC - input dataset (MVPCset) or input ALLMVCP
+%
+% Times - array of times (in milliseconds) to plot
+% depending on the 'Type' input paramter.
+%
+% If 'Type' is 'Timepoint', then output will be one
+% plot for every timepoint included in the array.
+% For example, [200 220 240] will draw three plots
+% each at 200ms, 220ms, and 240ms.
+%
+% If 'Type' is 'Average', then output will be one
+% plot averaged across the times in 'Times'. For
+% example, [200 240] will draw one plot that shows
+% the confusion matrix average across 200ms-240ms.
+%
+%
+% Type - string 'Timepoint' OR 'Average'
+%
+% -Timepoint: Confusion matrix at a timepoint (specified in 'Times').
+% -Average: Confusion matrix averaged across
+% timepoints
+% (specified in 'Times').
+%
+%
+% The available parameters are as follows:
+%
+% 'MVPCindex' - Index of MVPCset(s) to use when contained
+% within the ALLMVPC structure
+% If supplying only one MVPCset using MVPC structure this value
+% must be equal to 1 or left unspecified.
+% Def: [1]
+%
+% 'Saveas' - 'on'/'off'(def)
+%
+% 'Filepath' - Path to save plots ('Saveas' must be 'on');
+% default path: current working directory.
+%
+% 'Format' -Format of saved file*: 'fig'(def)/'png'
+% *('Saveas' must be 'on')
+%
+% 'Colormap' - Colormap for coloring of confusion matrix heatmap cells
+% Predefined colormap options:
+% {'default','viridis','gray','parula','cool', 'jet','hsv', 'hot' };
+%
+%
+%
+% EXAMPLE :
+%
+% pop_plotconfusions( ALLMVPC, 'Times', [ 200], 'Type', 'timepoint', 'MVPCindex', [ 11], 'Format', 'fig', 'Colormap', 'default');
+%
+% See also: plotconfusions.mlapp
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+function pop_plotconfusions(ALLMVPC,Times,Type,varargin)
+
+MVPC = preloadMVPC;
+
+if nargin == 1 %GUI
+
+ currdata = evalin('base','CURRENTMVPC');
+
+ if currdata == 0
+ msgboxText = 'pop_plotconfusions() error: cannot work an empty dataset!!!';
+ title = 'ERPLAB: No MVPC data';
+ errorfound(msgboxText, title);
+ return
+
+ end
+
+ if ~iscell(ALLMVPC) && ~ischar(ALLMVPC)
+
+ def = erpworkingmemory('pop_plotconfusions');
+ if isempty(def)
+ def = {1 1 1 [] 1};
+ %def{1} = plot menu (1: tp confusion 2:mean confusion two
+ % latency)
+ %def{2} = colormap
+ %def{3} = format (1: fig, 2: png);
+ %def{4} = times in [];
+ %def{5} = save(1/def) or no save
+ end
+
+
+
+ %
+ % Open plot confusion GUI
+ %
+ app = feval('plotConfusionGUI',ALLMVPC,currdata,def);
+ waitfor(app,'FinishButton',1);
+
+ try
+ answer = app.output; %NO you don't want to output BEST, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.5); %wait for app to leave
+ catch
+ disp('User selected Cancel')
+ return
+ end
+
+
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ plot_menu = answer{1}; %plot_menu
+ plot_cmap = answer{2};%plot_colormap
+ tp = answer{3}; % 0;1
+ pname = answer{4};
+ frmt = answer{5};
+ savec = answer{6};
+ %warnon = answer {4};
+ cmaps = {'default','viridis','gray','parula','cool', 'jet','hsv', 'hot' };
+ frmts = {'fig','png'};
+
+% if optioni==1 % from files
+% filelist = mvpcset;
+% disp(['pop_gaverager(): For file-List, user selected ', filelist])
+% ALLMVPC = {ALLMVPC, filelist}; % truco
+% else % from mvpcsets menu
+% %mvpcset = mvpcset;
+% end
+
+ %def = {actualnset, optioni, mvpcset,stderror};
+ def = {plot_menu, plot_cmap,frmt, tp, savec};
+ erpworkingmemory('pop_plotconfusions', def);
+% if stderror==1
+% stdsstr = 'on';
+% else
+% stdsstr = 'off';
+% end
+% if warnon==1
+% warnon_str = 'on';
+% else
+% warnon_str = 'off';
+% end
+
+ if plot_menu == 1
+ %single timepoint confusion matrix
+ meas = 'timepoint';
+
+ elseif plot_menu==2
+ %average across time window confusion matrix
+
+ meas = 'average';
+
+ end
+
+ if savec == 1
+ savestr = 'on';
+ else
+ savestr = 'off';
+ end
+ %
+ % Somersault
+ %
+
+ pop_plotconfusions(ALLMVPC, 'Times',tp,'Type',meas, 'MVPCindex',currdata,...
+ 'filepath',pname, 'Colormap', cmaps{plot_cmap}, 'Format',frmts{frmt}, 'Saveas',savestr,'History', 'gui');
+ pause(0.1)
+ return
+ else
+ fprintf('pop_plotconfusions() was called using a single (non-struct) input argument.\n\n');
+ end
+
+
+
+
+end
+
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLMVPC');
+% option(s)
+p.addParamValue('Times',[],@isnumeric);
+p.addParamValue('Type',[],@ischar);
+p.addParamValue('MVPCindex', 1); % same as Erpsets
+p.addParamValue('Colormap', 'default', @ischar);
+p.addParamValue('Format', 'fig', @ischar);
+p.addParamValue('Filepath',pwd,@ischar);
+p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('Warning', 'off', @ischar); % 'on', 'off'
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLMVPC, Times, Type, varargin{:});
+mvpci = p.Results.MVPCindex;
+meas = p.Results.Type;
+tp = p.Results.Times;
+cmap = p.Results.Colormap;
+pname = p.Results.Filepath;
+frmt = p.Results.Format;
+
+if isempty(meas)
+ disp('Input paramter [Type] is empty for this function!') ;
+ return
+end
+
+if isempty(tp)
+ disp('Input paramter [Times] is empty for this function!') ;
+ return
+end
+
+if ismember_bc2({p.Results.Saveas}, {'on','yes'})
+ issaveas = 1;
+else
+ issaveas = 0;
+end
+
+
+%history
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+
+if isempty(mvpci)
+ MVPC = ALLMVPC;
+else
+ MVPC = ALLMVPC(mvpci);
+end
+
+cf_scores = MVPC.confusions.scores;
+cf_labels = MVPC.confusions.labels;
+cf_strings = convertCharsToStrings(cf_labels);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Time conversions
+%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+orig_times = MVPC.times;
+epoch_window = [orig_times(1) orig_times(end)];
+fs = MVPC.srate;
+xxlim = tp;
+
+
+if strcmpi(meas,'average')
+ if isempty(xxlim) | length(xxlim) <2
+ msgboxText = 'You have not specified a time range';
+ title = 'ERPLAB: latencies input';
+ errorfound(msgboxText, title);
+ % set(handles.radiobutton_yauto, 'Value',0)
+ % drawnow
+ return
+ end
+
+end
+
+if strcmpi(meas,'timepoint')
+
+ if numel(xxlim) == 1
+ %only one timepoint
+ if xxlim < round(epoch_window(1),2)
+
+ % Revert to default time range
+ tscale = epoch_window(1); %change from s to ms
+ aux_xxlim = tscale;
+
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Time %.3f ms was adjusted to %.3f ms \n', xxlim, epoch_window(1));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+
+ elseif ~ismember(xxlim, round(orig_times,2))
+ %check that time is actually within the data
+
+
+ [value,ind] = closest(orig_times,xxlim);
+ aux_xxlim = value;
+
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Time %.3f ms was adjusted to %.3f ms \n', xxlim, aux_xxlim);
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+
+ else
+ aux_xxlim = xxlim;
+ end
+
+
+ else
+ %range of timepoints are input
+ if xxlim(1) < round(epoch_window(1),2)
+
+ % Revert to earliest time
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Lower limit %.3f ms was adjusted to %.3f ms \n', xxlim(1), epoch_window(1));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ xxlim(1) = epoch_window(1);
+
+ end
+
+ check_vals = ismember(xxlim, round(orig_times,2));
+ z = nnz(~check_vals);
+
+ if z > 0
+ %check that times are actually within the new
+ %resampling period
+
+ [value,ind] = closest(orig_times,xxlim);
+
+ tscale = mat2colon(value,'delimiter','off');
+
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Times %s ms were adjusted to %s ms \n', ['[' num2str(xxlim) ']'], ['[' num2str(tscale) ']']);
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ aux_xxlim = value;
+
+
+
+ else
+ aux_xxlim = xxlim;
+ end
+
+
+ end
+
+else
+ %aveerage across two timepoints
+ if xxlim(1) < round(epoch_window(1),2)
+
+
+ % Revert to default time range
+ tscale = epoch_window(1); %change from s to ms
+ %aux_xxlim = tscale;
+
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Start time %.3f ms was adjusted to %.3f ms \n', xxlim(1), epoch_window(1));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ aux_xxlim(1) = tscale;
+
+
+ elseif ~ismember(xxlim(1), round(orig_times,2))
+ %check that start time is actually within the new
+ %resampling period
+
+ [value,ind] = closest(orig_times,xxlim(1));
+
+ % set(app.TPspinner,'Value',value);
+ % app.TPspinner.Value = value;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Start time %.3f ms was adjusted to %.3f ms \n', xxlim(1), value);
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ aux_xxlim(1) = value;
+
+
+
+ else
+ aux_xxlim(1) = xxlim(1);
+ end
+
+
+ if xxlim(2)> round(epoch_window(end),2)
+
+ tscale(2) = epoch_window(end);
+
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: End time %.3f ms was adjusted to %.3f ms \n', xxlim(2), tscale(2));
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ aux_xxlim(2)= tscale(2);
+
+ elseif ~ismember(xxlim(2), round(orig_times,2))
+ %check that end time is actually within the new
+ %resampling period
+
+ [value,ind] = closest(orig_times,xxlim(2));
+
+ % set(app.TPspinner,'Value',value);
+ % app.TPspinner.Value = value;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: End time %.3f ms was adjusted to %.3f ms \n', xxlim(2), value);
+ fprintf('WARNING: This adjustment was necessary due to sampling \n');
+ fprintf('%s\n\n', repmat('*',1,60));
+
+ aux_xxlim(2) = value;
+
+ else
+ aux_xxlim(2) = xxlim(2);
+ end
+end
+
+
+
+if strcmpi(meas,'average')
+ [xp1, xp2, checkw] = window2sample(MVPC, aux_xxlim(1:2) , fs, 'relaxed');
+
+ if checkw==1
+ msgboxText = 'Time window cannot be larger than epoch.';
+ title = 'ERPLAB';
+ errorfound(msgboxText, title);
+ return
+ elseif checkw==2
+ msgboxText = 'Too narrow time window (are the start and end times reversed?)';
+ title = 'ERPLAB';
+ errorfound(msgboxText, title);
+ return
+ end
+end
+
+%reset tp
+tp = aux_xxlim;
+
+%obtain time-point indices
+time_ind = [];
+for i = 1:numel(tp)
+ time_ind(i) = find(tp(i) == orig_times);
+end
+
+
+avg_win = 0 ;
+%choose measurment & plot
+if strcmpi(meas,'timepoint')
+ if numel(time_ind) == 1
+ cf_scores = cf_scores(:,:,time_ind);
+ Npts = 1;
+ else
+ %multiple plots at 1 time point
+ cf_scores = cf_scores(:,:,time_ind);
+ Npts = numel(time_ind);
+ end
+
+elseif strcmpi(meas,'average')
+ idx = time_ind(1):time_ind(2);
+ cf_scores = cf_scores(:,:,idx);
+ cf_scores = squeeze(mean(cf_scores,3));
+ Npts = 1;
+ avg_win = 1;
+end
+
+
+%% plot
+for pnt = 1:Npts
+
+ figure; %new figure for every plot
+ C = cf_scores(:,:,pnt);
+ %C = flipud(C); %flips element values in matrix to align with Bae&Luck 2018, but doesn't flip row labels
+ %cf_string2 = fliplr(cf_strings); % flips row labels
+
+ %swap rows and columns of matrix as per Steve
+ Cnew = permute(C,[2 1]);
+ Cnew = flipud(Cnew);
+ cf_string2 = fliplr(cf_strings); % flips row labels
+
+ h = heatmap(cf_strings,cf_string2,Cnew);
+ if ~strcmpi(cmap,'default')
+ h.Colormap = eval(cmap);
+ end
+
+ %labels
+
+ if strcmpi(MVPC.DecodingMethod,'SVM')
+ if avg_win == 1
+ h.Title = ['Confusion Matrix across ', num2str(tp(1)),'ms-',num2str(tp(2)), 'ms (Average Decoding Accuracy)'];
+ else
+ h.Title = ['Confusion Matrix @ ', num2str(tp(pnt)), ' ms (Average Decoding Accuracy)'];
+
+ end
+
+ h.YLabel = 'Predicted Labels';
+ h.XLabel = 'True Labels';
+ else
+ if avg_win == 1
+ h.Title = ['Confusion Matrix across ', num2str(tp(1)),'ms-',num2str(tp(2)), 'ms (Average Distance)'];
+ else
+ h.Title = ['Confusion Matrix @ ', num2str(tp(pnt)), ' ms (Average Distance)'];
+
+ end
+ h.YLabel = 'Class';
+ h.XLabel = 'Class';
+ end
+
+
+ if issaveas == 1
+ if avg_win == 1
+ fname = [pname '/ConfusionMatrix_', num2str(tp(1)),'-',num2str(tp(2)),'ms'];
+ else
+ fname = [pname '/ConfusionMatrix_', num2str(tp(pnt)) 'ms'];
+ end
+ saveas(h, fname, frmt);
+
+ end
+ clear h ;
+end
+
+
+
+skipfields = {'ALLMVPC','History'};
+
+
+fn_old = fieldnames(p.Results);
+fn = {fn_old{1} fn_old{8} fn_old{9} fn_old{7} fn_old{5} fn_old{6} fn_old{4} fn_old{2} fn_old{3} fn_old{10}};
+explica = 0;
+
+if length(mvpci)==1 && mvpci(1)==1
+ inputvari = 'MVPC'; % Thanks to Felix Bacigalupo for this suggestion. Dic 12, 2011
+ skipfields = [skipfields 'MVPCindex']; % SL
+else
+ if length(mvpci)==1
+ explica = 1;
+ end
+ inputvari = inputname(1);
+end
+
+if issaveas ~= 1
+ skipfields = [skipfields 'Filepath'];
+end
+
+
+mvpccom = sprintf( 'pop_plotconfusions( %s', inputvari);
+for q=1:length(fn)
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ mvpccom = sprintf( '%s, ''%s'', ''%s''', mvpccom, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ if all(cellfun(@isnumeric, fn2res))
+ %fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ fn2resstr =cell2mat(cellfun(@vect2colon,fn2res,'UniformOutput',false));
+
+ else
+ fn2resstr = '';
+ for kk=1:numel(fn2res)
+ auxcont = fn2res{kk};
+ if ischar(auxcont)
+ fn2resstr = [fn2resstr '''' auxcont ''',' ];
+ else
+ fn2resstr = [fn2resstr ' ' vect2colon(auxcont, 'Delimiter', 'on')];
+ end
+
+ end
+ fn2resstr(end) = []; %take out last comma
+
+ end
+ fnformat = '{%s}';
+ elseif isnumeric(fn2res)
+ fn2res = mat2colon(fn2res);
+ fn2resstr = num2str(fn2res); fnformat = '%s';
+ elseif isstruct(fn2res)
+ fn2resstr = 'ALLMVPC'; fnformat = '%s';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ end
+
+% if strcmpi(fn2com,'BESTindex')
+% bestcom = sprintf( ['%s, ''%s'', [', fnformat,']'], bestcom, fn2com, fn2resstr);
+% else
+ mvpccom = sprintf( ['%s, ''%s'', ' fnformat], mvpccom, fn2com, fn2resstr);
+% end
+
+ %bestcom = sprintf( ['%s, ''%s'', ' fnformat], bestcom, fn2com, fn2resstr);
+ end
+ end
+ end
+end
+mvpccom = sprintf( '%s );', mvpccom);
+
+
+
+switch shist
+ case 1 % from GUI
+ % fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ displayEquiComERP(mvpccom);
+ if explica
+ try
+ cprintf([0.1333, 0.5451, 0.1333], '%%IMPORTANT: For pop_plotconfusions(), you may use MVPC instead of ALLMVPC, and remove "''MVPCindex'',%g"\n',mvpci);
+ catch
+ fprintf('%%IMPORTANT: For pop_plotconfusions(), you may use MVPC instead of ALLMVPC, and remove ''MVCPindex'',%g:\n',mvpci);
+ end
+ end
+ case 2 % from script
+ % ERP = erphistory(ERP, [], bestcom, 1);
+ case 3
+ % implicit
+ otherwise % off or none
+ mvpccom = '';
+end
+
+
+end
\ No newline at end of file
diff --git a/pop_functions/pop_savemybest.m b/pop_functions/pop_savemybest.m
new file mode 100644
index 00000000..c495c441
--- /dev/null
+++ b/pop_functions/pop_savemybest.m
@@ -0,0 +1,361 @@
+% PURPOSE : Save BEST (.mat) file.
+%
+% FORMAT :
+%
+% >> [BEST] = pop_savemybest(BEST, parameters);
+%
+% INPUTS :
+%
+% BEST - Bin-Epoched Single Trial (BEST) structure
+%
+% The available input parameters are as follows:
+% 'bestname' - BESTname to be saved
+% 'filename' - Output filename string as .best extension
+% 'filepath' - Output file path
+% 'gui' - 'save', 'saveas', 'erplab', or 'none'
+% - 'save' allows to save file to hard disk
+% - 'saveas' allows to save file disk, user
+% choose desination with GUI and/or with new
+% specified filename.
+% - 'none': for used with scriping; specify
+% file name and path; no GUI popup
+% 'overwriteatmenu' - overwrite bestset at bestset menu
+% 'on'/'off'
+% 'warning' - warning if overwriting file with same filename: 'on'(default)/off'
+%
+%
+% Optional INPUTS :
+% 'modegui' - If 0 (Default), directly saves the file at filepath (NO GUI)
+% If 1, save window GUI pops up to confirm save path.
+%
+%
+% EXAMPLE :
+%
+%
+%
+% See also: savemybestGUI.m savebest.m
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function [BEST, issave] = pop_savemybest(BEST, varargin)
+issave = 0 ;
+com = '';
+
+
+if nargin<1
+ help pop_savemybest
+ return
+end
+
+% parse inputs
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('BEST');
+
+%optional
+p.addParamValue('bestname', '', @ischar);
+p.addParamValue('filename', '', @ischar); %EEG.filename
+p.addParamValue('filepath', '', @ischar);
+p.addParamValue('gui','no',@ischar); % or 'save', or 'saveas', or 'erplab'
+p.addParamValue('overwriteatmenu','no',@ischar);
+p.addParamValue('Warning','off',@ischar); % on/off warning for existing file
+p.addParamValue('History','script',@ischar);
+
+p.parse(BEST, varargin{:});
+
+if isempty(BEST)
+ msgboxText = 'No Bin-Epoched Single-Trial (BEST) Data was found!';
+ title_msg = 'ERPLAB: pop_savemybest() error:';
+ errorfound(msgboxText, title_msg);
+ return
+end
+
+%extract vars
+
+filenamex = strtrim(p.Results.filename);
+filepathx = strtrim(p.Results.filepath);
+fullfilename = fullfile(filepathx, filenamex); % full path
+bestname = p.Results.bestname;
+overw = p.Results.overwriteatmenu;
+
+
+if isempty(bestname)
+ bestname = BEST.bestname;
+else
+ BEST.bestname = bestname;
+end
+
+if strcmpi(overw,'yes')||strcmpi(overw,'on')
+ overw = 1;
+else
+ overw = 0;
+end
+
+if strcmpi(p.Results.Warning,'on')
+ warnop = 1;
+else
+ warnop = 0;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'gui') || strcmpi(p.Results.History,'erplab')
+ shist = 1; % gui
+
+else
+ shist = 0; % off
+end
+
+
+%
+%Setting saving
+%
+
+if strcmpi(p.Results.gui,'erplab') % open GUI to save BESTset
+ if overw == 0
+
+ %
+ % Call GUI
+ %
+%
+
+ if ~isempty(bestname)
+ bestname = {bestname};
+
+ end
+
+ answer = savemybestGUI(bestname, fullfilename,0);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+ bestname = answer{1};
+ if isempty(bestname)
+ disp('User selected Cancel') % change
+ return
+ end
+
+ fullfilename = answer{2};
+ overw = answer{3}; % over write in memory? 1=yes
+
+ else
+ %do not open gui, and overwrite bestset at bestset menu
+ bestname = BEST.bestname;
+ fullfilename = '';
+ end
+
+ BEST.bestname = bestname;
+ BEST.filename = '';
+ BEST.filepath = '';
+ BEST.saved = 'no';
+ modegui = 0; % do not open GUI to save
+ warnop = 1;
+ shist = 1; %change history to implicit beacuse called from pop_extractbest()
+
+elseif strcmpi(p.Results.gui, 'save') %just save, no ask
+ if isempty(BEST.bestname)
+ modegui = 2; % open a "save as" window to save
+ filenamex = strtrim(p.Results.filename);
+ filepathx = strtrim(p.Results.filepath);
+ fullfilename = fullfile(filepathx, filenamex); % full path. 10-20-11
+ %fullfilename = p.Results.filename;
+ else
+ modegui = 1;
+ fullfilename = fullfile(BEST.filepath,BEST.filename);
+ warnop = 0;
+ end
+ overw = 1; % overwrite on menu
+
+% "SAVE AS" .
+elseif strcmpi(p.Results.gui,'saveas')
+ if isempty(fullfilename)
+
+ try
+ filenamex = BEST.bestname;
+ filepathx = pwd;
+ fullfilename = fullfile(filepathx, filenamex); % full path
+ catch
+ %fullfilename = fullfile(ERP.filepath, ERP.filename);
+ msgboxText = 'No file path was found?!';
+ title_msg = 'ERPLAB: pop_savemymvpc() error:';
+ errorfound(msgboxText, title_msg);
+ return
+ end
+ end
+ overw = 1;
+ modegui = 2;
+else
+ overw = 0;
+ modegui = 3; %savefrom script
+ if isempty(fullfilename)
+ fullfilename = fullfile(BEST.filepath, BEST.filename);
+ if isempty(fullfilename)
+ error('ERPLAB says: You must specify a filename (path included) to save your BESTset.')
+ end
+ fprintf('\nNOTE: Since ''filename'' and ''filepath'' were not specified, \nERPLAB used BEST.filename and BEST.filepath to save your ERPset.\n\n');
+ end
+% if isempty(erpname)
+% erpname = ERP.erpname;
+% else
+% ERP.erpname = erpname;
+% end
+% if isempty(erpname)
+% error('ERPLAB says: You must specify an erpname to save your ERPset.')
+% end
+%
+
+end
+
+
+%
+% Saving
+%
+if modegui == 0
+ % "save-as" filepath has already been gathered from erplab GUI
+ % so NO extra gui will show (modegui =0)
+
+ if ~isempty(fullfilename)
+ %disp(['Saving BESTset at ' fullfilename '...'] )
+ [BEST, serror] = saveBEST(BEST, fullfilename, 0, warnop); %modegui = 0
+ if serror==1
+ return
+ end
+ issave = 2;
+ else % or the is no fullfilename (so no saving, just update menu)
+ issave = 1;
+ end
+
+elseif modegui == 1 %"save" filepath has not been gathered yet, open new GUI
+
+ if ~isempty(fullfilename)
+ %disp(['Saving BESTset at ' fullfilename '...'] )
+ [BEST, serror] = saveBEST(BEST, fullfilename, 0, warnop);
+ if serror==1
+ return
+ end
+ issave = 2; %saved on harddrive
+ else
+ issave = 1; %saved only on workspace
+ end
+
+elseif modegui==2
+ % save as (open window)
+ %disp(['Saving BEST at ' fullfilename '...'] )
+ [BEST, serror,fullfilename] = saveBEST(BEST, fullfilename, 1, warnop);
+ if serror==1
+
+ return
+ end
+ issave = 2;
+
+elseif modegui==3 %save by script
+ overw = 2; %skip loading it into the menu
+ if ~isempty(fullfilename)
+ %disp(['Saving BESTset at ' fullfilename '...'] )
+ [BEST, serror] = saveBEST(BEST, fullfilename, 0, warnop);
+ if serror==1
+ return
+ end
+ issave = 2;
+ else
+ issave = 1;
+ end
+ %msg2end
+ return
+else
+ error('ERPLAB says: Oops! error at pop_savemybest()');
+
+end
+
+
+%overwriting in BESTset menu list
+if overw==1
+
+ ALLBEST = evalin('base', 'ALLBEST');
+ CURRENTBEST = evalin('base', 'CURRENTBEST');
+ ALLBEST(CURRENTBEST) = BEST;
+ assignin('base','ALLBEST',ALLBEST); % save to workspace
+ updatemenubest(ALLBEST,1) % overwrite erpset at erpsetmenu
+
+elseif overw == 0
+ assignin('base','BEST',BEST);
+ pop_loadbest('filename', 'workspace', 'UpdateMainGui', 'on');
+ if issave ~= 2
+ issave = 1;
+ end
+
+
+end
+
+
+%
+%history
+%
+if isempty(fullfilename)
+ pname='';
+ fname='';
+ ext='';
+else
+ [pname, fname, ext] = fileparts(fullfilename) ; %10-20-11
+end
+fname = [fname ext];
+bestcom = sprintf('%s = pop_savemybest(%s', inputname(1), inputname(1));
+if ~isempty(bestname)
+ bestcom = sprintf('%s, ''bestname'', ''%s''', bestcom, bestname);
+end
+if ~isempty(fname)
+ bestcom = sprintf('%s, ''filename'', ''%s''', bestcom, fname);
+end
+if ~isempty(pname)
+ bestcom = sprintf('%s, ''filepath'', ''%s''', bestcom, pname);
+ if warnop==1
+ bestcom = sprintf('%s, ''Warning'', ''on''', bestcom);
+ end
+end
+bestcom = sprintf('%s);', bestcom);
+
+
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(bestcom);
+ case 2 % from script
+ %ERP = erphistory(ERP, [], erpcom, 1);
+ case 3 % implicit
+ % just using erpcom
+ otherwise %off or none
+ bestcom = '';
+ return
+end
+
+end
diff --git a/pop_functions/pop_savemymvpc.m b/pop_functions/pop_savemymvpc.m
new file mode 100644
index 00000000..21a434a4
--- /dev/null
+++ b/pop_functions/pop_savemymvpc.m
@@ -0,0 +1,394 @@
+% PURPOSE : Save MVPC (.mvpc) file.
+%
+% FORMAT :
+%
+% >> [MVPC] = pop_savemymvpc(MVPC, parameters);
+%
+% INPUTS :
+%
+% MVPC - Multivariate Pattern Classification (MVPC) structure
+%
+% The available input parameters are as follows:
+% 'mvpcname' - mvpc name to be saved
+% 'filename' - Output filename string as .best extension
+% 'filepath' - Output file path
+% 'gui' - 'save', 'saveas', 'erplab', or 'none'
+% - 'save' allows to save file to hard disk
+% - 'saveas' allows to change bestname, save to
+% hard disk
+% 'overwriteatmenu' - overwrite bestset at bestset menu
+% 'on'/'off'
+% 'warning' - warning if overwriting file with same filename: 'on'(default)/off'
+%
+%
+% Optional INPUTS :
+% 'modegui' - If 0 (Default), directly saves the file at filepath (NO GUI)
+% If 1, save window GUI pops up to confirm save path.
+%
+%
+% EXAMPLE :
+%
+% pop_savemymvpc( EEG , 'Channel', 1:16, 'Flag', 1, 'Threshold', 100, 'Twindow', [ -200 798], 'Windowsize', 200, 'Windowstep', 100 );
+%
+% See also: savemymvpcGUI.m savemvpc
+%
+% *** This function is part of ERPLAB Toolbox ***
+% Author: Aaron Matthew Simmons
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2022
+
+%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
+%
+% ERPLAB Toolbox
+% Copyright © 2007 The Regents of the University of California
+% Created by Javier Lopez-Calderon and Steven Luck
+% Center for Mind and Brain, University of California, Davis,
+% javlopez@ucdavis.edu, sjluck@ucdavis.edu
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see .
+
+
+function [MVPC, issave] = pop_savemymvpc(MVPC,varargin)
+issave = 0;
+com = '';
+
+if nargin <1
+ help pop_savemymvpc
+ return
+end
+% parse inputs
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('MVPC');
+
+
+%optional
+%optional
+p.addParamValue('ALLMVPC',[]); %only for the decoding toolbox gui
+p.addParamValue('mvpcname', '', @ischar);
+p.addParamValue('filename', '', @ischar); %EEG.filename
+p.addParamValue('filepath', '', @ischar);
+p.addParamValue('gui','no',@ischar); % or 'save', or 'saveas', or 'erplab'
+p.addParamValue('overwriteatmenu','no',@ischar);
+p.addParamValue('Warning','on',@ischar); % on/off warning for existing file
+p.addParamValue('modegui',1,@isnumeric);
+p.addParamValue('History','script',@ischar);
+
+
+p.parse(MVPC,varargin{:});
+
+if isempty(MVPC)
+ msgboxText = 'No Multivariate Pattern Classification (MVPC) Data was found!';
+ title_msg = 'ERPLAB: pop_savemymvpc() error:';
+ errorfound(msgboxText, title_msg);
+ return
+end
+
+ALLMVPC = p.Results.ALLMVPC;
+filenamex = strtrim(p.Results.filename);
+filepathx = strtrim(p.Results.filepath);
+fullfilename = fullfile(filepathx, filenamex); % full path
+mvpcname = p.Results.mvpcname;
+overw = p.Results.overwriteatmenu;
+modegui = p.Results.modegui;
+
+if isempty(mvpcname)
+ mvpcname = MVPC.mvpcname;
+else
+ MVPC.mvpcname = mvpcname;
+end
+
+if strcmpi(overw,'yes')||strcmpi(overw,'on')
+ overw = 1;
+else
+ overw = 0;
+end
+
+if strcmpi(p.Results.Warning,'on')
+ warnop = 1;
+else
+ warnop = 0;
+end
+
+if strcmpi(p.Results.History,'implicit')
+ shist = 3; % implicit
+elseif strcmpi(p.Results.History,'script')
+ shist = 2; % script
+elseif strcmpi(p.Results.History,'erplab')
+ shist = 1; % gui
+else
+ shist = 0; % off
+end
+
+
+if strcmpi(p.Results.gui,'erplab') % open GUI to save MVPCset
+
+ if overw == 0
+ %GUI was already opened in pop_decoding
+ %MVPC filenames and pathnames already established
+ %Use ALLMVPC rather than MVPC since could be multiple saves
+
+ filename = {ALLMVPC.filename};
+ filepathx = {ALLMVPC.filepath};
+
+ if ~isempty([ALLMVPC(:).filename]) && ~isempty([ALLMVPC(:).filepath])
+ fullfilename = strcat(filepathx(:),filesep,filename(:));
+ else
+ fullfilename = '';
+ shist = 0; %they did not specify to save to harddisk
+ end
+ overw = 0; %no option to overwrite mvpcset
+ else
+ %do not open gui, and overwrite mvpcset at mvpcset menu
+ mvpcname = {ALLMVPC.mvpcname};
+ fullfilename = '';
+
+ end
+
+ for i=1:numel(ALLMVPC)
+ ALLMVPC(i).saved = 'no';
+ end
+ modegui = 0;
+ warnop = 1;
+
+elseif strcmpi(p.Results.gui,'averager')
+
+
+ if ~isempty(mvpcname)
+ mvpcname = {mvpcname}
+ end
+
+ answer = savemymvpcGUI(mvpcname, fullfilename, 0);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+ MVPC.mvpcname = answer{1};
+ mvpcname = answer{1};
+ fullfilename = answer{2};
+ if isempty(mvpcname)
+ disp('User selected Cancel') % change
+ return
+ end
+
+ overw = 0;
+ modegui = 1;
+
+
+
+
+
+
+elseif strcmpi(p.Results.gui, 'save') %just save, no ask
+ if isempty(MVPC.mvpcname)
+ modegui = 2; % open a "save as" window to save
+ filenamex = strtrim(p.Results.filename);
+ filepathx = strtrim(p.Results.filepath);
+ fullfilename = fullfile(filepathx, filenamex); % full path. 10-20-11
+ %fullfilename = p.Results.filename;
+ else
+ modegui = 1;
+ fullfilename = fullfile(MVPC.filepath,MVPC.filename);
+ warnop = 0;
+ end
+ overw = 0; % overwrite on menu
+
+% "SAVE AS" .
+elseif strcmpi(p.Results.gui,'saveas')
+ if isempty(fullfilename)
+
+ try
+ filenamex = MVPC.mvpcname;
+ filepathx = pwd;
+ fullfilename = fullfile(filepathx, filenamex); % full path
+ catch
+ %fullfilename = fullfile(ERP.filepath, ERP.filename);
+ msgboxText = 'No file path was found?!';
+ title_msg = 'ERPLAB: pop_savemymvpc() error:';
+ errorfound(msgboxText, title_msg);
+ return
+ end
+ end
+ overw = 1;
+ modegui = 2;
+ shist = 1; % gui
+else
+ overw = 0;
+ modegui = 3; %savefrom script
+ if isempty(fullfilename)
+ fullfilename = fullfile(BEST.filepath, BEST.filename);
+ if isempty(fullfilename)
+ error('ERPLAB says: You must specify a filename (path included) to save your BESTset.')
+ end
+ fprintf('\nNOTE: Since ''filename'' and ''filepath'' were not specified, \nERPLAB used BEST.filename and BEST.filepath to save your ERPset.\n\n');
+ end
+
+
+
+
+end
+
+if modegui == 0
+ % "save-as" fullfilepath already been gathered from multifilesave erplab GUI
+ if ~isempty(fullfilename)
+ [MVPC,fullfilename,serror] = savemvpc(ALLMVPC, fullfilename, 0, warnop);
+
+ issave = 2; %saved on hard drive
+ if serror == 1
+ return
+ end
+ else
+ issave =1 ;
+ end
+
+
+
+
+
+elseif modegui == 1 %save directly
+
+ if ~isempty(fullfilename)
+ %disp(['Saving BESTset at ' fullfilename '...'] )
+ [MVPC, ~, serror] = savemvpc(MVPC, fullfilename, 0, warnop);
+ if serror==1
+ return
+ end
+ issave = 2; %saved on harddrive
+ else
+ issave = 1; %saved only on workspace
+ end
+
+elseif modegui == 2
+
+
+ %disp(['Saving BESTset at ' fullfilename '...'] )
+ [MVPC, fullfilename, serror] = savemvpc(MVPC, fullfilename, 1);
+ if serror==1
+ return
+ end
+ issave = 2; %saved on harddrive
+
+elseif modegui == 3 % save from script
+ if ~isempty(fullfilename)
+
+ [MVPC,~, serror] = savemvpc(MVPC, fullfilename, 0, warnop);
+ if serror==1
+ return
+ end
+ issave = 2;
+ else
+ issave = 1;
+ end
+ %msg2end
+ return
+
+else
+ error('ERPLAB says: Oops! error at pop_savemymvpc');
+
+
+end
+
+%overwriting in MVPCset menu list
+if overw==1
+ %this isn't possible if using Decoding GUI toolbox
+ ALLMVPC = evalin('base', 'ALLMVPC');
+ CURRENTMVPC = evalin('base', 'CURRENTMVPC');
+ ALLMVPC(CURRENTMVPC) = MVPC;
+ assignin('base','ALLERP',ALLMVPC); % save to workspace
+ updatemenumvpc(ALLMVPC,1) % overwrite erpset at erpsetmenu
+
+
+else
+ if strcmpi(p.Results.gui,'erplab')
+ %in case of many mvpc sets through Decoding GUI toolbox
+ assignin('base','ALLMVPC2',ALLMVPC)
+ pop_loadmvpc('filename', 'decodingtoolbox', 'UpdateMainGui', 'on');
+
+ else
+ assignin('base','MVPC',MVPC);
+ pop_loadmvpc('filename', 'workspace', 'UpdateMainGui', 'on');
+ end
+
+ if issave ~= 2
+ issave = 1;
+ end
+
+
+end
+
+
+if isempty(fullfilename)
+ fname = '';
+ pname = '';
+else
+ [pname, fname, ext] = fileparts(fullfilename);
+end
+ext = '.mvpc';
+fname = [fname ext];
+mvpccom = sprintf('%s = pop_savemymvpc(%s', inputname(1), inputname(1));
+if ~isempty(mvpcname)
+ mvpccom = sprintf('%s, ''mvpcname'', ''%s''', mvpccom, mvpcname);
+end
+if ~isempty(fname)
+ mvpccom = sprintf('%s, ''filename'', ''%s''', mvpccom, fname);
+end
+if ~isempty(filepathx)
+ mvpccom = sprintf('%s, ''filepath'', ''%s''', mvpccom, pname);
+ if warnop==1
+ mvpccom = sprintf('%s, ''Warning'', ''on''', mvpccom);
+ end
+end
+mvpccom = sprintf('%s);', mvpccom);
+
+%
+% Completion statement
+%
+prefunc = dbstack;
+nf = length(unique_bc2({prefunc.name}));
+if nf==1
+ msg2end
+end
+% get history from script. ERP
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(mvpccom);
+ case 2 % from script
+ %ERP = erphistory(ERP, [], erpcom, 1);
+ case 3 % implicit
+ % just using erpcom
+ otherwise %off or none
+ mvpccom = '';
+ return
+end
+
+
+
+%only output the last MVPC set
+MVPC = MVPC(end);
+
+return
+
+
+
+
+
+
+
+
+
+
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERPLAB_ERP_Viewer.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERPLAB_ERP_Viewer.m
index 13bf1d1d..2404bd3a 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERPLAB_ERP_Viewer.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERPLAB_ERP_Viewer.m
@@ -5,7 +5,7 @@
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
-% 2022
+% 2022 & 2023
% ERPLAB Studio Toolbox
%
@@ -35,6 +35,9 @@
% Now with more in nested functions
function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Parameterfile)
+tic;%
+disp(' ERP Waveform Viewer is launching...');
+
global viewer_ERPDAT;
global gui_erp_waviewer;
@@ -60,6 +63,31 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
catch
end
+if exist('memoryerpstudiopanels.erpm','file')==2
+ iserpmem = 1; % file for memory exists
+else
+ iserpmem = 0; % does not exist file for memory
+end
+if iserpmem==0
+ p1 = which('o_ERPDAT');
+ p1 = p1(1:findstr(p1,'o_ERPDAT.m')-1);
+ save(fullfile(p1,'memoryerpstudiopanels.erpm'),'ERPtooltype')
+end
+
+
+
+if exist('memoryerpstudio.erpm','file')==2
+ iserpmem = 1; % file for memory exists
+else
+ iserpmem = 0; % does not exist file for memory
+end
+if iserpmem==0
+ p1 = which('o_ERPDAT');
+ p1 = p1(1:findstr(p1,'o_ERPDAT.m')-1);
+ save(fullfile(p1,'memoryerpstudio.erpm'),'ERPtooltype')
+end
+
+
if nargin<1
beep;
disp('ERP_wave_viewer() error: ALLERP should be imported.');
@@ -139,7 +167,7 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
return;
end
-
+erpworkingmemory('ERPLAB_ERPWaviewer',0);%%Update the Viewer based on the changes in ERPLAB
% if ~strcmpi(ERPtooltype,'EStudio')
% addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
% addlistener(viewer_ERPDAT,'v_currentERP_change',@v_currentERP_change);
@@ -156,11 +184,11 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
%3 means there are some errors for processing procedure
viewer_ERPDAT.count_legend=0;%% this is to capture the changes of legend name
viewer_ERPDAT.page_xyaxis=0;%%get the changes of x/y axis based on the changed pages or selected ERPsets
-viewer_ERPDAT.count_loadproper = 0;
+viewer_ERPDAT.loadproper_count = 0;
viewer_ERPDAT.Process_messg = 0;
viewer_ERPDAT.count_twopanels = 0;%% Automaticlly saving the changes on the other panel if the current panel is changed
viewer_ERPDAT.Reset_Waviewer_panel = 0;
-
+viewer_ERPDAT.ERPset_Chan_bin_label=0;
viewer_ERPDAT.ALLERP = ALLERP;
viewer_ERPDAT.ERP_bin = binArray;
viewer_ERPDAT.ERP_chan = chanArray;
@@ -192,7 +220,6 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
ERPwaviewer.SelectERPIdx =selectedERP_index;
ERPwaviewer.bin = binArray;
ERPwaviewer.chan = chanArray;
-ERPwaviewer.erp_binchan_op = 1;%% 1. Auto; 2.Custom
ERPwaviewer.binchan_op = 1;%% 1. Auto; 2.Custom
ERPwaviewer.plot_org.Grid = 1; %1.Channels; 2.Bins; 3. ERPsets; 4. None
@@ -209,19 +236,19 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
ERPwaviewer.PageIndex = 1;
ERPwaviewer.baselinecorr = 'none';
ERPwaviewer.chanbinsetlabel = [];
-ERPwaviewer.figbackgdcolor = [];
+ERPwaviewer.figbackgdcolor = [1 1 1];
ERPwaviewer.figname = 'My Viewer';
+ERPwaviewer.FigOutpos=[];
assignin('base','ALLERPwaviewer',ERPwaviewer);
-estudioworkingmemory('zoomSpace',0);%%sett for zoom in and zoom out
+% estudioworkingmemory('zoomSpace',0);%%sett for zoom in and zoom out
try
close(gui_erp_waviewer.Window);%%close previous GUI if exists
catch
end
-gui_erp_waviewer = struct();
-gui_erp_waviewer = createInterface();
+createInterface_ERPWave_viewer(ERPtooltype);
f_redrawERP_viewer_test();
if ~isempty( Parameterfile)%% update the panels based on the saved file
@@ -253,13 +280,13 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
end
end
assignin('base','ALLERPwaviewer',Parameterfile);
- viewer_ERPDAT.count_loadproper = viewer_ERPDAT.count_loadproper+1;
+ viewer_ERPDAT.loadproper_count = 1;
f_redrawERP_viewer_test();
end
+timeElapsed = toc;
+fprintf([32,'It took',32,num2str(timeElapsed),'s to launch ERP Waveform Viewer.\n\n']);
- function gui_erp_waviewer = createInterface();
- ERPtooltype = erpgettoolversion('tooltype');
-
+ function createInterface_ERPWave_viewer(ERPtooltype);
if strcmpi(ERPtooltype,'EStudio')
try
[version reldate] = geterplabstudioversion;
@@ -292,23 +319,37 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
'MenuBar', 'none', ...
'Toolbar', 'none', ...
'HandleVisibility', 'off', 'tag', 'rollover');
+ ScreenPos = [];
-
- new_pos = [1 1 1000 1000];
+ new_pos= erpworkingmemory('ERPWaveScreenPos');
+ if isempty(new_pos)
+ new_pos = [0.01,0.01,75,75];
+ erpworkingmemory('ERPWaveScreenPos',new_pos);
+ end
+ try
+ ScreenPos = get( groot, 'Screensize' );
+ catch
+ ScreenPos = get( 0, 'Screensize' );
+ end
+ gui_erp_waviewer.screen_pos = new_pos;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
set(gui_erp_waviewer.Window, 'Position', new_pos);
% + View menu
gui_erp_waviewer.exit = uimenu( gui_erp_waviewer.Window, 'Label','Exit', 'Callback', @onExit);
+
gui_erp_waviewer.help = uimenu( gui_erp_waviewer.Window, 'Label', 'Help', 'Callback', @onhelp);
%%-----------Setting------------------------------------------------
%% Create tabs
- context_tabs = uix.VBox('Parent', gui_erp_waviewer.Window);
+ gui_erp_waviewer.Window.Resize = 0;
+
+ context_tabs = uix.VBox('Parent', gui_erp_waviewer.Window);%,'SizeChangedFcn',@WAviewerResize
gui_erp_waviewer.tabERP = uix.HBoxFlex( 'Parent', context_tabs, 'Spacing', 10,'BackgroundColor',ColorBviewer_def);
%% Arrange the main interface for ERP panel (Tab3)
gui_erp_waviewer.ViewBox = uix.VBox('Parent', gui_erp_waviewer.tabERP,'BackgroundColor',ColorBviewer_def);
-
+ gui_erp_waviewer.Resize = 0;
gui_erp_waviewer.ViewPanel = uix.BoxPanel('Parent', gui_erp_waviewer.ViewBox,'TitleColor',ColorBviewer_def,'ForegroundColor','k');%
gui_erp_waviewer.ViewContainer = uicontainer('Parent', gui_erp_waviewer.ViewPanel);
@@ -324,7 +365,7 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
% + Create the settings window panels for ERP panel
gui_erp_waviewer.panel{1} = f_ERPsets_waviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
- gui_erp_waviewer.panelSizes(1) = 280;
+ gui_erp_waviewer.panelSizes(1) = 255;
gui_erp_waviewer.panel{2} = f_ERP_Binchan_waviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
gui_erp_waviewer.panelSizes(2) = 280;
@@ -333,19 +374,19 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
gui_erp_waviewer.panelSizes(3) = 490;
gui_erp_waviewer.panel{4} = f_ERP_plotorg_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
- gui_erp_waviewer.panelSizes(4) = 405;
+ gui_erp_waviewer.panelSizes(4) = 385;
gui_erp_waviewer.panel{5} = f_ERP_labelset_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
gui_erp_waviewer.panelSizes(5) = 200;
gui_erp_waviewer.panel{6} = f_ERP_lineset_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
- gui_erp_waviewer.panelSizes(6) = 555;
+ gui_erp_waviewer.panelSizes(6) = 375;
gui_erp_waviewer.panel{7} = f_ERP_otherset_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
gui_erp_waviewer.panelSizes(7) = 225;
gui_erp_waviewer.panel{8} = f_ERP_property_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
- gui_erp_waviewer.panelSizes(8) = 90;
+ gui_erp_waviewer.panelSizes(8) = 130;
set(gui_erp_waviewer.settingLayout, 'Heights', gui_erp_waviewer.panelSizes);
gui_erp_waviewer.panelscroll.Heights = sum(gui_erp_waviewer.panelSizes);
@@ -359,7 +400,7 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
set( gui_erp_waviewer.panel{6}, 'MinimizeFcn', {@nMinimize, 6});
set( gui_erp_waviewer.panel{7}, 'MinimizeFcn', {@nMinimize, 7});
set( gui_erp_waviewer.panel{8}, 'MinimizeFcn', {@nMinimize, 8});
- whichpanel = [4:8];
+ whichpanel = [3:8];
for Numofpanel = 1:length(whichpanel)
minned = gui_erp_waviewer.panel{whichpanel(Numofpanel)}.IsMinimized;
szs = get( gui_erp_waviewer.settingLayout, 'Sizes' );
@@ -376,8 +417,8 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
%% + Create the view
p = gui_erp_waviewer.ViewContainer;
gui_erp_waviewer.ViewAxes = uiextras.HBox( 'Parent', p,'BackgroundColor',ColorBviewer_def);
-
- end % createInterface
+ gui_erp_waviewer.Resize=1;
+ end % createInterface_ERPWave_viewer
function nMinimize( eventSource, eventData, whichpanel) %#ok
@@ -425,8 +466,19 @@ function onExit(~,~)
%%-------------Help for my Viewer------------------------------------------
function onhelp(~,~)
-
end
+%%Resize the GUI automatically as the user changes the size of the window at run-time.
+% function WAviewerResize(~,~)
+% if gui_erp_waviewer.Resize ~= 0
+% new_pos = gui_erp_waviewer.Window.Position;
+% erpworkingmemory('ERPWaveScreenPos',new_pos);
+% gui_erp_waviewer.screen_pos = new_pos;
+% % set(gui_erp_waviewer.Window, 'Position', new_pos);
+% f_redrawERP_viewer_test();
+% end
+% end
+
+
%%%%%%%%%%%%%%%%%%%%%%%
end % end of the function
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.fig b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.fig
index bd47ae8f..d5671987 100644
Binary files a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.fig and b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.fig differ
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.m
index 226b107b..01dafaad 100644
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/ERP_layoutstringGUI.m
@@ -20,27 +20,22 @@
%-----------------------------------------------------------------------------------
function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
+f = waitbar(0.1,'Loading Custom Grid Locations GUI...');
handles.output = [];
-
try
- plotArray = varargin{1};
+ plotArrayFormt = varargin{1};
catch
for ii = 1:100
- plotArray{ii,1} = ['chan-',num2str(ii)];
+ plotArrayFormt{ii,1} = ['chan-',num2str(ii)];
+ % plotArrayFormt{ii,1} = [num2str(ii)];
end
end
-for jj = 1:length(plotArray)
- plotArrayFormt(jj,1) = {char(plotArray{jj})};
-end
-plotArrayFormt(length(plotArrayFormt)+1) = {'None'};
-
-try
- plotArrayFormtOlder = varargin{2};
-catch
- plotArrayFormtOlder = plotArrayFormt;
+plotArrayFormtnew =cell(1000000,1);
+for jj = 1:length(plotArrayFormt)
+ plotArrayFormtnew(jj,1) = {char(plotArrayFormt{jj})};
end
-
-handles.plotArrayFormtOlder = plotArrayFormtOlder;
+plotArrayFormt = plotArrayFormtnew;
+plotArray = plotArrayFormt;
handles.plotArrayFormt = plotArrayFormt;
@@ -50,75 +45,126 @@ function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
catch
plotBox = plotBoxdef;
end
+
+try
+ AllabelArray = varargin{4};
+catch
+ AllabelArray =plotArrayFormt;
+end
+handles.AllabelArray = AllabelArray;
+
+% usedIndex = zeros(length(AllabelArray),1);
+% for jj = 1:length(AllabelArray)
+% for ii = 1:length(plotArrayFormt)
+% if strcmp(AllabelArray{jj},plotArrayFormt{ii})
+% usedIndex(jj) = 1;
+% end
+% end
+% end
+% handles.usedIndex = usedIndex;
+
+% f = waitbar(0.2,'Loading Custtom Grid Layout GUI...');
Numrows = plotBox(1);
Numcolumns = plotBox(2);
% GridinforDatadef = cell(Numrows,Numcolumns);
-count = 0;
-for Numofrows = 1:Numrows
- for Numofcolumns = 1:Numcolumns
- count = count +1;
- if count> numel(plotArray)
- GridinforDatadef{Numofrows,Numofcolumns} = char('None');
- else
- GridinforDatadef{Numofrows,Numofcolumns} = char(plotArray{count});
- end
- end
-end
+% count = 0;
+% for Numofrows = 1:Numrows
+% for Numofcolumns = 1:Numcolumns
+% count = count +1;
+% if count> numel(plotArray)
+% GridinforDatadef{Numofrows,Numofcolumns} = '';
+% else
+% GridinforDatadef{Numofrows,Numofcolumns} = char(plotArray{count});
+% end
+% end
+% end
try
- GridinforData = varargin{4};
+ GridinforData = varargin{2};
catch
- GridinforData = GridinforDatadef;
-end
-if isempty(GridinforData)
- GridinforData = GridinforDatadef;
-end
-
-if size(GridinforData,1)~= Numrows || size(GridinforData,2)~= Numcolumns
- GridinforData = GridinforDatadef;
-end
-FonsizeDefault = f_get_default_fontsize();
-% tablePosition = handles.uitable1_layout.Position;
-for Numofcolumns = 1:Numcolumns
- if size(plotArrayFormt,1) > size(plotArrayFormt,2)
- columFormat{Numofcolumns} = plotArrayFormt';
- else
- columFormat{Numofcolumns} = plotArrayFormt;
- end
- ColumnEditable(Numofcolumns) =1;
- ColumnName{1,Numofcolumns} = char(['C',num2str(Numofcolumns)]);
- % ColumnWidth{Numofcolumns} =tablePosition(3)/(Numcolumns+0.2);
+ % GridinforData = GridinforDatadef;
+ GridinforData ='';
end
+handles.GridinforData = GridinforData;
+handles.GridinforData_def = GridinforData;
+% if isempty(GridinforData)
+% GridinforData = GridinforDatadef;
+% end
+% if size(GridinforData,1)~= Numrows || size(GridinforData,2)~= Numcolumns
+% GridinforData = GridinforDatadef;
+% end
-for Numofrows = 1:Numrows
- RowName{1,Numofrows} = char(['R',num2str(Numofrows)]);
-end
-set(handles.uitable1_layout,'Data',GridinforData);
-handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
-% handles.uitable1_layout.ColumnWidth = ColumnWidth;
-handles.uitable1_layout.ColumnName = ColumnName;
-handles.uitable1_layout.RowName = RowName;
-handles.uitable1_layout.ColumnFormat = columFormat;
-handles.uitable1_layout.FontSize = FonsizeDefault;
+% FonsizeDefault = f_get_default_fontsize();
+% % tablePosition = handles.uitable1_layout.Position;
+% for Numofcolumns = 1:Numcolumns
+% columFormat{Numofcolumns} = 'char';
+% ColumnEditable(Numofcolumns) =1;
+% ColumnName{1,Numofcolumns} = char(['C',num2str(Numofcolumns)]);
+% end
%
+% for Numofrows = 1:Numrows
+% RowName{1,Numofrows} = char(['R',num2str(Numofrows)]);
+% end
+% set(handles.uitable1_layout,'Data',GridinforData);
+% handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
+% handles.uitable1_layout.ColumnName = ColumnName;
+% handles.uitable1_layout.RowName = RowName;
+% handles.uitable1_layout.ColumnFormat = columFormat;
+% handles.uitable1_layout.FontSize = FonsizeDefault;
+% handles.uitable1_layout.CellEditCallback = {@MakerLabels,handles};
+
+% f = waitbar(0.7,'Loading Custtom Grid Layout GUI...');
+
+% [plotArrayFormt] = f_MarkLabels_gridlocations_ERP_Waveiwer(GridinforData,usedIndex,AllabelArray);
+% handles.listbox_Labels.String = '';
+% handles.listbox_Labels.String = plotArrayFormt;
+% %
% Color GUI
%
% handles = painterplab(handles);
[version reldate,ColorBdef,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
set(handles.gui_chassis, 'Color', ColorBviewer_def);
+handles.textrow5.BackgroundColor = ColorBviewer_def;
+handles.text6_columns.BackgroundColor = ColorBviewer_def;
+handles.text7_message.BackgroundColor = ColorBviewer_def;
+% handles.listbox_Labels.Min = 0;
+% handles.listbox_Labels.Max =1;
+% handles.listbox_Labels.Enable = 'off';
+% handles.listbox_Labels.Value = 1;
+
+handles.text_rownum.String = num2str(Numrows);
+handles.edit1_columnsNum.String = num2str(Numcolumns);
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
+
+% Data = handles.uitable1_layout.Data;
+%
+% Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+% try
+% SingleCell = AllabelArray{handles.listbox_Labels.Value};
+% catch
+% SingleCell = AllabelArray{1};
+% end
+% Data = f_add_bgcolor_cell(Data,SingleCell);
+% handles.uitable1_layout.Data=Data;
+%%
+
+handles = Datacreate(plotBox,GridinforData,plotArrayFormt,AllabelArray,handles);
+
%
% Set font size
%
-% handles = setfonterplab(handles);
+handles = setfonterplab(handles);
% Update handles structure
-
-
guidata(hObject, handles);
-set(handles.gui_chassis, 'Name', 'Plot Organinzation > Grid Layout', 'WindowStyle','modal');
-
+set(handles.gui_chassis, 'Name', 'Plot Organization > Customize Grid Locations', 'WindowStyle','modal');
+waitbar(1,f,'Loading Custom Grid Locations GUI: Complete');
+try
+ close(f);
+catch
+end
% UIWAIT makes ERP_layoutstringGUI wait for user response (see UIRESUME)
uiwait(handles.gui_chassis);
@@ -134,14 +180,7 @@ function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
delete(handles.gui_chassis);
pause(0.1)
-%----------------------------------------------------------------------------------
-% function listbox_list_Callback(hObject, eventdata, handles)
-%
-% %----------------------------------------------------------------------------------
-% function listbox_list_CreateFcn(hObject, eventdata, handles)
-% if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-% set(hObject,'BackgroundColor','white');
-% end
+
%----------------------------------------------------------------------------------
function pushbutton_cancel_Callback(hObject, eventdata, handles)
@@ -149,13 +188,42 @@ function pushbutton_cancel_Callback(hObject, eventdata, handles)
% Update handles structure
guidata(hObject, handles);
uiresume(handles.gui_chassis);
+
+
%----------------------------------------------------------------------------------
function pushbutton_ok_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+Data = handles.uitable1_layout.Data;
+AllabelArray=handles.AllabelArray;
+Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
-Data = get(handles.uitable1_layout, 'Data');
-plotArrayFormt = handles.plotArrayFormt;
-handles.output = {Data,plotArrayFormt};
+Labels_used = unique_str(Data);
+if ~isempty(Labels_used)
+ Labels_new ='';
+ count = 0;
+ for ii = 1:length(Labels_used)
+ if ~isempty(Labels_used{ii,1})
+ count = count+1;
+ Labels_new{count,1} = char(Labels_used{ii,1});
+
+ end
+ end
+ Labels_used = Labels_new;
+end
+Labels_usedIndex = [];
+if ~isempty(Labels_used) && ~isempty(AllabelArray)
+ count = 0;
+ for ii = 1:length(AllabelArray)
+ for jj = 1:length(Labels_used)
+ if strcmp(AllabelArray{ii},Labels_used{jj})
+ count = count+1;
+ Labels_usedIndex(count) = ii;
+ end
+ end
+ end
+end
+handles.output = {Data,Labels_used,Labels_usedIndex};
% Update handles structure
guidata(hObject, handles);
uiresume(handles.gui_chassis);
@@ -171,81 +239,611 @@ function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
end
-% --- Executes on button press in pushbutton_edit.
-function pushbutton_edit_Callback(hObject, eventdata, handles)
-plotArrayFormt = handles.plotArrayFormt;
-plotArrayFormtOld=handles.plotArrayFormtOlder;
-for ii = 1:length(plotArrayFormtOld)-1
- plotArrayFormtOldin{ii,1} = plotArrayFormtOld{ii};
+% --- Executes on button press in pushbutton_clearall.
+function pushbutton_clearall_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+%%clear all labels
+Data = handles.uitable1_layout.Data;
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ Data{ii,jj} = '';
+ end
end
-[Numrows,Numcolumns]= size(plotArrayFormt);
+handles.GridinforData = Data;
+handles.uitable1_layout.Data = Data;
+AllabelArray = handles.AllabelArray ;
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(Data,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
+guidata(hObject, handles);
-if Numrows ==1 && Numcolumns>=2
- for Numofcolumns = 1:Numcolumns-1
- plotArrayFormtin{Numofcolumns,1} = char(plotArrayFormt{Numofcolumns});
- end
-elseif Numrows >=2 && Numcolumns==1
- for Numofrows = 1:Numrows-1
- plotArrayFormtin{Numofrows,1} = char(plotArrayFormt{Numofrows});
- end
+
+% --- Executes on selection change in listbox_Labels.
+function listbox_Labels_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
+
+Data = handles.uitable1_layout.Data;
+
+AllabelArray = handles.AllabelArray ;
+Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+try
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
+catch
+ SingleCell = AllabelArray{1};
+end
+Data = f_add_bgcolor_cell(Data,SingleCell);
+handles.uitable1_layout.Data=Data;
+guidata(hObject, handles);
+
+
+
+% --- Executes during object creation, after setting all properties.
+function listbox_Labels_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
+end
+
+
+function MakerLabels(~,~, handles)
+Data = handles.uitable1_layout.Data;
+%%check the changed labels
+AllabelArray = handles.AllabelArray ;
+[Data, EmptyStr] = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+handles.uitable1_layout.Data = Data;
+handles.GridinforData = Data;
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(Data,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+if ~strcmp(EmptyStr,',') && ~strcmp(string(EmptyStr)," ") && ~isempty(EmptyStr)
+ handles.text7_message.String = sprintf([EmptyStr,32,'do(es)not match with items in the right panel.']);
else
+ handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
+end
+
+
+
+% --- Executes on button press in pushbutton_default.
+function pushbutton_default_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+GridinforData = handles.GridinforData_def;
+[Numrows,Numcolumns] = size(GridinforData);
+for Numofcolumns = 1:Numcolumns
+ columFormat{Numofcolumns} = 'char';
+ ColumnEditable(Numofcolumns) =1;
+ ColumnName{1,Numofcolumns} = char(['C',num2str(Numofcolumns)]);
+end
+
+for Numofrows = 1:Numrows
+ RowName{1,Numofrows} = char(['R',num2str(Numofrows)]);
+end
+set(handles.uitable1_layout,'Data',GridinforData);
+handles.GridinforData = GridinforData;
+handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
+handles.uitable1_layout.ColumnName = ColumnName;
+handles.uitable1_layout.RowName = RowName;
+handles.uitable1_layout.ColumnFormat = columFormat;
+
+AllabelArray = handles.AllabelArray ;
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(GridinforData,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+handles.text_rownum.String = num2str(Numrows);
+handles.edit1_columnsNum.String = num2str(Numcolumns);
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
+Data = handles.uitable1_layout.Data;
+
+Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+try
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
+catch
+ SingleCell = AllabelArray{1};
+end
+Data = f_add_bgcolor_cell(Data,SingleCell);
+handles.uitable1_layout.Data=Data;
+
+guidata(hObject, handles);
+
+
+
+function edit1_columnsNum_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+columNum = str2num(get(hObject,'String'));
+Data= handles.uitable1_layout.Data;
+if isempty(columNum) || columNum<=0
+ handles.text7_message.String = '"Columns" should be a positive number.';
+ handles.edit1_columnsNum.String = size(Data,2);
return;
end
+RowsNum = str2num(handles.text_rownum.String);
+if isempty(RowsNum) || RowsNum<=0
+ RowsNum = size(Data,1);
+end
+cuntNum = 0;
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ cuntNum = cuntNum+1;
+ DataOld{cuntNum} = char(Data{ii,jj});
+ end
+end
+
+AllabelArray = handles.AllabelArray;
+count1 = 0;
+for Numofrow = 1:RowsNum
+ for Numofcolumn = 1:columNum
+ count1 = count1+1;
+ try
+ DataNew{Numofrow,Numofcolumn} = DataOld{count1} ;
+ catch
+ DataNew{Numofrow,Numofcolumn}='';
+ end
+ end
+end
+for Numofcolumn = 1:columNum
+ columFormat{Numofcolumn} = 'char';
+ ColumnEditable(Numofcolumn) =1;
+ ColumnName{1,Numofcolumn} = char(['C',num2str(Numofcolumn)]);
+end
+handles.GridinforData = DataNew;
+handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
+handles.uitable1_layout.ColumnName = ColumnName;
+handles.uitable1_layout.ColumnFormat = columFormat;
+handles.uitable1_layout.Data=DataNew;
+DataNew = f_checktable_gridlocations_waviewer(DataNew,AllabelArray);
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(DataNew,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
try
- ERPwaviewerin = evalin('base','ALLERPwaviewer');
- PLOTORG(1) = ERPwaviewerin.plot_org.Grid;
- PLOTORG(2) = ERPwaviewerin.plot_org.Overlay ;
- PLOTORG(3) = ERPwaviewerin.plot_org.Pages;
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
catch
- PLOTORG = [1 2 3];
+ SingleCell = AllabelArray{1};
+end
+Data = f_add_bgcolor_cell(DataNew,SingleCell);
+handles.uitable1_layout.Data=Data;
+guidata(hObject, handles);
+
+
+
+
+
+% --- Executes during object creation, after setting all properties.
+function edit1_columnsNum_CreateFcn(hObject, eventdata, handles)
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+ set(hObject,'BackgroundColor','white');
end
-changedoutput = editlayoutstringGUI(plotArrayFormtOldin,plotArrayFormtin,PLOTORG);
-if isempty(changedoutput)
+
+
+function text_rownum_Callback(hObject, eventdata, handles)
+handles.text7_message.String = '';
+RowsNum = str2num(get(hObject,'String'));
+Data= handles.uitable1_layout.Data;
+if isempty(RowsNum) || RowsNum<=0
+ handles.text7_message.String = '"Rows" should be a positive number.';
+ handles.text_rownum.String = size(Data,1);
return;
end
+columNum = str2num(handles.edit1_columnsNum.String);
+if isempty(columNum) || columNum<=0
+ columNum = size(Data,2);
+end
+cuntNum = 0;
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ cuntNum = cuntNum+1;
+ DataOld{cuntNum} = char(Data{ii,jj});
+ end
+end
+
+AllabelArray = handles.AllabelArray;
+count1 = 0;
+for Numofrow = 1:RowsNum
+ RowName{1,Numofrow} = char(['R',num2str(Numofrow)]);
+ for Numofcolumn = 1:columNum
+ count1 = count1+1;
+ try
+ DataNew{Numofrow,Numofcolumn} = DataOld{count1} ;
+ catch
+ DataNew{Numofrow,Numofcolumn}='';
+ end
+ end
+end
+handles.GridinforData = DataNew;
+handles.uitable1_layout.RowName = RowName;
+handles.uitable1_layout.Data = [];
+handles.uitable1_layout.Data=DataNew;
+DataNew = f_checktable_gridlocations_waviewer(DataNew,AllabelArray);
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(DataNew,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+
+handles.text7_message.String = sprintf([' In the right panel:\n Blue labels: unused.\n Red labels: used more than once.\n Black labels: used once.\n *: Selected in main GUI.']);
try
- for Numofrows = 1:size(changedoutput)
- changeStr{Numofrows} = char(changedoutput{Numofrows,2});
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
+catch
+ SingleCell = AllabelArray{1};
+end
+DataNew = f_add_bgcolor_cell(DataNew,SingleCell);
+handles.uitable1_layout.Data=DataNew;
+guidata(hObject, handles);
+
+
+
+%%Mark the labels with different colors(blue: unused; black:used; red:Repeated;* means items were selected in the main GUI)
+% function [LabelStrout] = f_MarkLabels_gridlocations_ERP_Waveiwer(Gridata,LabelStr,AllabelArray)
+% usedIndex = zeros(length(AllabelArray),1);
+% for jj = 1:length(AllabelArray)
+% for ii = 1:length(LabelStr)
+% if strcmp(AllabelArray{jj},LabelStr{ii})
+% usedIndex(jj) = 1;
+% end
+% end
+% end
+%
+% LabelsFlag = [0 0 0];
+% for ii = 1:length(AllabelArray)
+% code1 = 0;
+% for jj = 1:size(Gridata,1)
+% for kk = 1:size(Gridata,2)
+% if strcmp(AllabelArray{ii},Gridata{jj,kk})
+% code1 = code1+1;
+% end
+% end
+% end
+%
+% if usedIndex(ii)==1%% the item will be marked with * if the labels was selected
+% % AllabelArray{ii} = strcat(AllabelArray{ii},'*');
+% Numstr = strcat('*',num2str(ii));
+% else
+% Numstr = strcat(num2str(ii));
+% end
+%
+% if code1 ==0
+% LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+% LabelsFlag(1) = 1;
+% elseif code1 >1
+% LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+% LabelsFlag(3) = 1;
+% else
+% LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+% LabelsFlag(2) = 1;
+% end
+% end
+
+
+function Data = f_add_bgcolor_cell(Data,SingleCell)
+colergen = @(color,text) [''];
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ if strcmp(Data{ii,jj},SingleCell)
+ hex_color_here = ['#' dec2hex(255,2) dec2hex(255,2) dec2hex(0,2)];
+ Data{ii,jj} = colergen(hex_color_here,Data{ii,jj});
+ end
end
+end
+
+
+% function [Data, EPStr]= f_checktable_gridlocations_waviewer(Data,LabelStr)
+% countEp = 0;
+% EPStr = '';
+% for ii = 1:size(Data,1)
+% for jj = 1:size(Data,2)
+% count = 0;
+% for kk = 1:length(LabelStr)
+% Data1= strrep(Data{ii,jj},'','');
+% Data1 = strrep(Data1,'
','');
+% Data{ii,jj} = char(Data1);
+% if strcmp(strtrim(char(LabelStr{kk})),strtrim(char(Data{ii,jj})))
+% Data{ii,jj} = char(LabelStr{kk});
+% count = count +1;
+% end
+% end
+% if count==0
+% countEp = countEp+1;
+% if countEp==1
+% if ischar(Data{ii,jj})
+% if ~isempty(Data{ii,jj})
+% EPStr = char(Data{ii,jj});
+% end
+% elseif isnumeric(Data{ii,jj})
+% if ~isempty(Data{ii,jj})
+% EPStr = num2str(Data{ii,jj});
+% end
+% end
+% else
+% if ischar(Data{ii,jj})
+% if ~isempty(Data{ii,jj})
+% EPStr = strcat(EPStr,',',char(Data{ii,jj}));
+% end
+% elseif isnumeric(Data{ii,jj})
+% if ~isempty(Data{ii,jj})
+% EPStr = strcat(EPStr,',',num2str(Data{ii,jj}));
+% end
+% end
+% end
+% Data{ii,jj} = '';
+% end
+% end
+% end
+
+
+
+function Labels_used = unique_str(Data)
+Labels_used{1,1} = Data{1,1};
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ if ismember_bc2(Data{ii,jj}, Labels_used)
+ else
+ if ~isempty(char(Data{ii,jj}))
+ Labels_used{length(Labels_used)+1,1} = Data{ii,jj};
+ end
+ end
+ end
+end
+
+
+% --- Executes on button press in pushbutton6_import.
+function pushbutton6_import_Callback(hObject, eventdata, handles)
+
+[filename, filepath] = uigetfile('*.txt', ...
+ 'Load Gird Locations', ...
+ 'MultiSelect', 'off');
+if isequal(filename,0)
+ disp('User selected Cancel');
+ return;
+end
+try
+ % DataInput = importdata([filepath,filename]);%%There are some errors
+ % when using importdata
+ DataInput = readcell([filepath,filename]);
+ CellNum=2;
catch
- for Numofrows = 1:size(changedoutput)
- changeStr{Numofrows} = char(changedoutput{Numofrows,1});
- end
-end
-
-if ~isempty(changeStr)
- columFormat = handles.uitable1_layout.ColumnFormat;
- columFormatOld = columFormat{1};
- GridinforDataOld = handles.uitable1_layout.Data;
- [Numrows,Numcolumns] = size(GridinforDataOld);
- for Numofrow = 1:Numrows
- for Numofcolumn = 1:Numcolumns
- SingleStr = char(GridinforDataOld{Numofrow,Numofcolumn});
- [C,IA] = ismember_bc2(SingleStr,columFormatOld);
- if C ==1
- if IA < length(columFormatOld)
- try
- GridinforDataOld{Numofrow,Numofcolumn} = char(changeStr{IA});
- catch
- GridinforDataOld{Numofrow,Numofcolumn} = char('');
+
+ DataInput = readcell([filepath,filename]);
+ handles.text7_message.String = sprintf(['Cannot import:',filepath,filename]);
+ return;
+ CellNum=2;
+end
+if isempty(DataInput)
+ handles.text7_message.String = sprintf(['The file is empty.']);
+ return;
+end
+
+DataOutput = f_gridlocation_transcell(DataInput,CellNum);
+
+AllabelArray = handles.AllabelArray;
+[Data,EmptyStr] = f_checktable_gridlocations_waviewer(DataOutput,AllabelArray);
+handles.GridinforData = Data;
+try
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
+catch
+ SingleCell = AllabelArray{1};
+end
+DataNew = f_add_bgcolor_cell(Data,SingleCell);
+
+handles.uitable1_layout.Data = DataNew;
+handles.edit1_columnsNum.String = num2str(size(Data,2));
+handles.text_rownum.String = num2str(size(Data,1));
+Numcolumns =size(Data,2);
+Numrows = size(Data,1);
+for Numofcolumns = 1:Numcolumns
+ columFormat{Numofcolumns} = 'char';
+ ColumnEditable(Numofcolumns) =1;
+ ColumnName{1,Numofcolumns} = char(['C',num2str(Numofcolumns)]);
+end
+
+for Numofrows = 1:Numrows
+ RowName{1,Numofrows} = char(['R',num2str(Numofrows)]);
+end
+handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
+handles.uitable1_layout.ColumnName = ColumnName;
+handles.uitable1_layout.RowName = RowName;
+handles.uitable1_layout.ColumnFormat = columFormat;
+if ~strcmp(EmptyStr,',') && ~strcmp(string(EmptyStr)," ") && ~isempty(EmptyStr)
+ handles.text7_message.String = sprintf([EmptyStr,32,'do(es)not match with items in the right panel.']);
+end
+DataNew=handles.GridinforData;
+usedIndex = handles.usedIndex;
+[LabelStr] = f_MarkLabels_gridlocations_ERP_Waveiwer(DataNew,usedIndex,AllabelArray);
+handles.listbox_Labels.String=LabelStr;
+
+
+
+
+
+
+function DataOutput = f_gridlocation_transcell(DataInput,CellNum)
+if CellNum~=1
+ if strcmpi(DataInput{1,size(DataInput,2)},'')
+ for ii = 1:size(DataInput,1)
+ for jj = 1:size(DataInput,2)-1
+ DataInputTras{ii,jj} = DataInput{ii,jj};
+ end
+ end
+ DataInput = DataInputTras;
+ end
+ if strcmpi(DataInput{size(DataInput,1),1},'')
+ for ii = 1:size(DataInput,1)-1
+ for jj = 1:size(DataInput,2)
+ DataInputTras1{ii,jj} = DataInput{ii,jj};
+ end
+ end
+ DataInput = DataInputTras1;
+ end
+end
+
+DataOutput = cell(size(DataInput,1),size(DataInput,2));
+if CellNum==1
+ if iscell(DataInput)
+ for ii =1:size(DataInput,1)
+ chanlabels=regexp(DataInput{ii,1},'.*?\s+', 'match');
+ DataNum(ii) = length(chanlabels);
+ end
+ for ii =1:size(DataInput,1)
+ for jj = 1:max(DataNum(:))
+ DataOutput{ii,jj} = char('');
+ end
+ end
+ for ii =1:size(DataInput,1)
+ chanlabels=regexp(DataInput{ii,1},'.*?\s+', 'match');
+ for jj = 1:length(chanlabels)
+ if ischar(chanlabels{jj})
+ DataOutput{ii,jj} = strtrim(char(chanlabels{jj}));
+ elseif isnumeric(chanlabels{jj})
+ DataOutput{ii,jj} = num2str(chanlabels{jj});
+ else
+ end
+ end
+ end
+ return;
+ end
+else
+ for ii = 1:size(DataInput,1)
+ for jj = 1:size(DataInput,2)
+ if ~ismissing(DataInput{ii,jj})
+ if ~isempty(DataInput{ii,jj})
+ if ischar(DataInput{ii,jj})
+ DataOutput{ii,jj} = char(DataInput{ii,jj});
+ elseif isnumeric(DataInput{ii,jj})
+ if isnan(DataInput{ii,jj})
+ DataOutput{ii,jj} = char('');
+ else
+ DataOutput{ii,jj} = char(num2str(DataInput{ii,jj}));
+ end
+ else
+ DataOutput{ii,jj} = char('');
end
- elseif IA == length(columFormatOld)
- GridinforDataOld{Numofrow,Numofcolumn} = char('None');
+ else
+ DataOutput{ii,jj} = char('');
end
else
- GridinforDataOld{Numofrow,Numofcolumn} = char('None');
+ DataOutput{ii,jj} = char('');
end
end
end
- handles.uitable1_layout.Data = GridinforDataOld;
- changeStr{length(changeStr)+1} = char('None');
- for Numofcolumns = 1:Numcolumns
- handles.uitable1_layout.ColumnFormat{Numofcolumns} = changeStr;
+ return;
+end
+
+if isnumeric(DataInput)
+ for ii = 1:size(DataInput,1)
+ for jj = 1:size(DataInput,2)
+ DataOutput{ii,jj} = num2str(DataInput(ii,jj));
+ end
end
- handles.plotArrayFormt = changeStr;
+ return;
end
-guidata(hObject, handles);
-% uiresume(handles.gui_chassis);
+
+
+
+
+
+
+% --- Executes on button press in pushbutton8_Export.
+function pushbutton8_Export_Callback(hObject, eventdata, handles)
+
+pathstr = pwd;
+namedef ='GridLocations';
+[erpfilename, erppathname, indxs] = uiputfile({'*.txt'}, ...
+ ['Save Grid Locations as'],...
+ fullfile(pathstr,namedef));
+if isequal(erpfilename,0)
+ disp('User selected Cancel')
+ return
+end
+
+[pathstr, erpfilename, ext] = fileparts(erpfilename) ;
+ext = '.txt';
+erpFilename = char(strcat(erppathname,erpfilename,ext));
+
+AllabelArray = handles.AllabelArray;
+fileID = fopen(erpFilename,'w');
+Data = handles.uitable1_layout.Data;
+Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+[nrows,ncols] = size(Data);
+Data = f_gridlocation_respace_addnan(Data);
+formatSpec ='';
+for jj = 1:ncols
+ formatSpec = strcat(formatSpec,'%s\t',32);
+end
+formatSpec = strcat(formatSpec,'\n');
+
+for row = 1:nrows
+ fprintf(fileID,formatSpec,Data{row,:});
+end
+fclose(fileID);
+
+
+function data = f_gridlocation_respace_addnan(data)
+[nrows,ncols] =size(data);
+for ii = 1:nrows
+ for jj = 1:ncols
+ labx = data{ii,jj};
+ labx= strrep(char(labx),' ','');
+ if ~isempty(labx)
+ labx = regexprep(labx,'\\|\/|\*|\#|\$|\@','_');
+ else
+ labx = 'NaN';
+ end
+ data{ii,jj} = labx;
+ end
+end
+
+
+
+
+
+function handles = Datacreate(plotBox,GridinforData,plotArrayFormt,AllabelArray,handles)
+Numrows = plotBox(1);
+Numcolumns = plotBox(2);
+FonsizeDefault = f_get_default_fontsize();
+
+usedIndex = zeros(length(AllabelArray),1);
+for jj = 1:length(AllabelArray)
+ for ii = 1:length(plotArrayFormt)
+ if strcmp(AllabelArray{jj},plotArrayFormt{ii})
+ usedIndex(jj) = 1;
+ end
+ end
+end
+handles.usedIndex = usedIndex;
+
+% tablePosition = handles.uitable1_layout.Position;
+for Numofcolumns = 1:Numcolumns
+ columFormat{Numofcolumns} = 'char';
+ ColumnEditable(Numofcolumns) =1;
+ ColumnName{1,Numofcolumns} = char(['C',num2str(Numofcolumns)]);
+end
+
+for Numofrows = 1:Numrows
+ RowName{1,Numofrows} = char(['R',num2str(Numofrows)]);
+end
+set(handles.uitable1_layout,'Data',GridinforData);
+handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
+handles.uitable1_layout.ColumnName = ColumnName;
+handles.uitable1_layout.RowName = RowName;
+handles.uitable1_layout.ColumnFormat = columFormat;
+handles.uitable1_layout.FontSize = FonsizeDefault;
+handles.uitable1_layout.CellEditCallback = {@MakerLabels,handles};
+
+[plotArrayFormt] = f_MarkLabels_gridlocations_ERP_Waveiwer(GridinforData,usedIndex,AllabelArray);
+handles.listbox_Labels.String = '';
+handles.listbox_Labels.String = plotArrayFormt;
+
+Data = handles.uitable1_layout.Data;
+
+Data = f_checktable_gridlocations_waviewer(Data,AllabelArray);
+try
+ SingleCell = AllabelArray{handles.listbox_Labels.Value};
+catch
+ SingleCell = AllabelArray{1};
+end
+Data = f_add_bgcolor_cell(Data,SingleCell);
+handles.uitable1_layout.Data=Data;
+handles.listbox_Labels.Min = 0;
+handles.listbox_Labels.Max =1;
+handles.listbox_Labels.Value = 1;
+%
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.fig b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.fig
deleted file mode 100755
index 6c819a93..00000000
Binary files a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.fig and /dev/null differ
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.m
deleted file mode 100755
index a10e0ea5..00000000
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/editlayoutstringGUI.m
+++ /dev/null
@@ -1,161 +0,0 @@
-function varargout = editlayoutstringGUI(varargin)
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 1;
-gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @editlayoutstringGUI_OpeningFcn, ...
- 'gui_OutputFcn', @editlayoutstringGUI_OutputFcn, ...
- 'gui_LayoutFcn', [] , ...
- 'gui_Callback', []);
-if nargin && ischar(varargin{1})
- gui_State.gui_Callback = str2func(varargin{1});
-end
-
-if nargout
- [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
- gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
-
-%-----------------------------------------------------------------------------------
-function editlayoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
-handles.output = [];
-
-try
- listname = varargin{1};
-catch
- for ii = 1:100
- listname{ii,1} = num2str(ii);
- end
-end
-
-try
- listnameOlder = varargin{2};
-catch
- listnameOlder = listname;
-end
-
-
-try
- PLOTORG = varargin{3};
-catch
- PLOTORG = [1 2 3];
-end
-
-try
- titlename = varargin{4};
-catch
- titlename = 'Edit labels for Plot Organization';
-end
-
-[Numrows,Numcolumns] = size(listname);
-
-
-for Numofrows = 1:Numrows
- for Numofcolumns = 1:2
- try
- if Numofcolumns==1
- GridinforData{Numofrows,Numofcolumns} = char(listname{Numofrows,1});
- else
- GridinforData{Numofrows,Numofcolumns} = char(listnameOlder{Numofrows});
- end
- catch
- GridinforData{Numofrows,Numofcolumns} = 'None';
- end
- end
-end
-
-
-
-ColumnEditable =[0,1];
-ColumnWidth = {300 300};
-ColumnName{1,1} = char(['Default Name']);
-ColumnName{1,2} = char(['Custom Name']);
-columFormat = {'char','char'};
-
-for Numofrow = 1:Numrows
- if PLOTORG(1)==1
- RowsName{Numofrow} = char(['Ch',num2str(Numofrow)]);
- elseif PLOTORG(1)==2
- RowsName{Numofrow} = char(['Bin',num2str(Numofrow)]);
- elseif PLOTORG(1)==3
- RowsName{Numofrow} = char(['Erp',num2str(Numofrow)]);
- else
- RowsName{Numofrow} = char(['Ch',num2str(Numofrow)]);
- end
-end
-
-%
-% Color GUI
-%
-% handles = painterplab(handles);
-[version reldate,ColorBdef,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
-set(handles.gui_chassis, 'Color', ColorBviewer_def);
-%
-% Set font size
-%
-% handles = setfonterplab(handles);
-
-% Update handles structure
-
-
-
-guidata(hObject, handles);
-set(handles.uitable1_layout,'Data',GridinforData);
-handles.uitable1_layout.ColumnEditable = logical(ColumnEditable);
-handles.uitable1_layout.ColumnWidth = ColumnWidth;
-handles.uitable1_layout.ColumnName = ColumnName;
-handles.uitable1_layout.RowName = RowsName;
-handles.uitable1_layout.ColumnFormat = columFormat;
-set(handles.gui_chassis, 'Name', titlename, 'WindowStyle','modal');
-
-% UIWAIT makes editlayoutstringGUI wait for user response (see UIRESUME)
-uiwait(handles.gui_chassis);
-
-
-%-----------------------------------------------------------------------------------
-function varargout = editlayoutstringGUI_OutputFcn(hObject, eventdata, handles)
-try
- varargout{1} = handles.output;
-catch
- varargout{1} = [];
-end
-% The figure can be deleted now
-delete(handles.gui_chassis);
-pause(0.1)
-
-%----------------------------------------------------------------------------------
-% function listbox_list_Callback(hObject, eventdata, handles)
-%
-% %----------------------------------------------------------------------------------
-% function listbox_list_CreateFcn(hObject, eventdata, handles)
-% if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-% set(hObject,'BackgroundColor','white');
-% end
-
-%----------------------------------------------------------------------------------
-function pushbutton_cancel_Callback(hObject, eventdata, handles)
-handles.output = [];
-% Update handles structure
-guidata(hObject, handles);
-uiresume(handles.gui_chassis);
-%----------------------------------------------------------------------------------
-function pushbutton_ok_Callback(hObject, eventdata, handles)
-
-Data = get(handles.uitable1_layout, 'Data');
-handles.output = Data;
-
-% Update handles structure
-guidata(hObject, handles);
-uiresume(handles.gui_chassis);
-
-%----------------------------------------------------------------------------------
-function gui_chassis_CloseRequestFcn(hObject, eventdata, handles)
-if isequal(get(handles.gui_chassis, 'waitstatus'), 'waiting')
- % The GUI is still in UIWAIT, us UIRESUME
- uiresume(handles.gui_chassis);
-else
- % The GUI is no longer waiting, just close it
- delete(handles.gui_chassis);
-end
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/erpAutoYLim.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/erpAutoYLim.m
index 87d03979..031f8a4e 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/erpAutoYLim.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/erpAutoYLim.m
@@ -133,10 +133,10 @@
if yylim(1)<1E-6 && yylim(2)<1E-6
if strcmpi(datatype, 'ERP')
yylim(1:2) = [-1 1];
- fprintf('WARNING: It seems like erpAutoYLim() found flatlined ERPs. So auto Y-limit was set to [-1 1].\n');
+% fprintf('WARNING: It seems like erpAutoYLim() found flatlined ERPs. So auto Y-limit was set to [-1 1].\n');
else
yylim(1:2) = [0 1];
- fprintf('WARNING: It seems like erpAutoYLim() found flatlined Spectrum. So auto Y-limit was set to [0 1].\n');
+% fprintf('WARNING: It seems like erpAutoYLim() found flatlined Spectrum. So auto Y-limit was set to [0 1].\n');
end
end
catch
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_Binchan_waviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_Binchan_waviewer_GUI.m
index 0f679dbb..f6861d3c 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_Binchan_waviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_Binchan_waviewer_GUI.m
@@ -17,10 +17,11 @@
global viewer_ERPDAT
global observe_ERPDAT;
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
addlistener(viewer_ERPDAT,'v_currentERP_change',@v_currentERP_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
+addlistener(viewer_ERPDAT,'ERPset_Chan_bin_label_change',@ERPset_Chan_bin_label_change);
addlistener(observe_ERPDAT,'ERP_chan_change',@ERP_chan_changed);
addlistener(observe_ERPDAT,'ERP_bin_change',@ERP_bin_changed);
addlistener(observe_ERPDAT,'Two_GUI_change',@Two_GUI_change);
@@ -59,7 +60,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_erpsetbinchan_viewer(FonsizeDefault);
@@ -67,6 +68,8 @@
varargout{1} = Chanbin_waveviewer_box;
% Draw the ui
function drawui_erpsetbinchan_viewer(FonsizeDefault)
+ MERPWaveViewer_chanbin= estudioworkingmemory('MERPWaveViewer_chanbin');%%call the memery for this panel
+
try
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
catch
@@ -86,13 +89,20 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
end
ERPwaveview_binchan.vBox = uiextras.VBox('Parent', Chanbin_waveviewer_box, 'Spacing', 5,'BackgroundColor',ColorBviewer_def); % VBox for everything
ERPtooltype = erpgettoolversion('tooltype');
+
if ~strcmpi(ERPtooltype,'EStudio') %&& ~strcmpi(ERPtooltype,'ERPLAB')
ERPwaviewer.erp_binchan_op = 0;
+ MERPWaveViewer_chanbin{1}=0;
end
try
- Enable_auto = ERPwaviewer.binchan_op;
+ Enable_auto = MERPWaveViewer_chanbin{1};
catch
Enable_auto = 1;
+ MERPWaveViewer_chanbin{1}=1;
+ end
+ if numel(Enable_auto)~=1 || (Enable_auto~=0 && Enable_auto~=1)
+ Enable_auto = 1;
+ MERPWaveViewer_chanbin{1}=1;
end
if Enable_auto ==1
Enable_label = 'off';
@@ -103,12 +113,15 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
ERPwaveview_binchan.opts_title = uiextras.HBox('Parent', ERPwaveview_binchan.vBox, 'Spacing', 5,'BackgroundColor',ColorBviewer_def);
ERPwaveview_binchan.auto = uicontrol('Style', 'radiobutton','Parent', ERPwaveview_binchan.opts_title,...
'String','Same as EStudio','callback',@Chanbin_auto,'Value',Enable_auto,'Enable','on','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
-
+ ERPwaveview_binchan.auto.KeyPressFcn = @setbinchan_presskey;
ERPwaveview_binchan.custom = uicontrol('Style', 'radiobutton','Parent', ERPwaveview_binchan.opts_title,...
'String','Custom','callback',@Chanbin_custom,'Value',~Enable_auto,'Enable','on','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
+ ERPwaveview_binchan.custom.KeyPressFcn = @setbinchan_presskey;
+
%
%%---------------------Display channel and bin labels-----------------------------------------------------
+
ERPwaveview_binchan.DataSelGrid = uiextras.HBox('Parent', ERPwaveview_binchan.vBox,'BackgroundColor',ColorBviewer_def);
[chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERP,SelectedIndex);
@@ -119,16 +132,30 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
end
% Channel information
Chanlist = chanStr;
- Chan_sel = ERPwaviewer.chan;
- if ~isempty(Chan_sel)
- if max(Chan_sel)> numel(Chanlist)
- Chan_sel= 1:length(Chanlist);
+ Chan_seldef = ERPwaviewer.chan;
+ if ~isempty(Chan_seldef)
+ if max(Chan_seldef)> numel(Chanlist)
+ Chan_seldef= 1:length(Chanlist);
end
else
- Chan_sel= 1:length(Chanlist);
+ Chan_seldef= 1:length(Chanlist);
end
+ try
+ Chan_sel = MERPWaveViewer_chanbin{2};
+ catch
+ MERPWaveViewer_chanbin{2} = Chan_seldef;
+ Chan_sel = Chan_seldef;
+ end
+ Chan_sel = unique(Chan_sel);
+ if isempty(Chan_sel) || max(Chan_sel(:))> length(Chanlist) || min(Chan_sel(:))> length(Chanlist) || min(Chan_sel(:))<=0
+ MERPWaveViewer_chanbin{2} = Chan_seldef;
+ Chan_sel = Chan_seldef;
+ end
+ ERPwaviewer.chan = Chan_sel;
ERPwaveview_binchan.ElecRange = uicontrol('Parent', ERPwaveview_binchan.DataSelGrid,'Style','listbox','min',1,'max',length(Chanlist_name),...
'String', Chanlist_name,'Callback',@ViewerElecRange,'FontSize',FonsizeDefault,'Enable',Enable_label); % 2B
+
+ ERPwaveview_binchan.ElecRange.KeyPressFcn = @setbinchan_presskey;
if numel(Chan_sel) == numel(Chanlist)
ERPwaveview_binchan.ElecRange.Value =1;
else
@@ -137,20 +164,32 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
%%Bin information
brange = cell(length(binStr)+1,1);
BinNum = length(binStr);
- Bin_sel = ERPwaviewer.bin;
- if ~isempty(Bin_sel)
- if max(Bin_sel)> BinNum
- Bin_sel= 1:BinNum;
+ Bin_seldef = ERPwaviewer.bin;
+ if ~isempty(Bin_seldef)
+ if max(Bin_seldef)> BinNum
+ Bin_seldef= 1:BinNum;
end
else
- Bin_sel= 1:BinNum;
+ Bin_seldef= 1:BinNum;
+ end
+ try
+ Bin_sel = MERPWaveViewer_chanbin{3};
+ catch
+ MERPWaveViewer_chanbin{3} = Bin_seldef;
+ Bin_sel = Bin_seldef;
+ end
+ if isempty(Bin_sel) || max(Bin_sel(:))> length(binStr) || min(Bin_sel(:))> length(binStr) || min(Bin_sel(:))<=0
+ MERPWaveViewer_chanbin{3} = Bin_seldef;
+ Bin_sel = Bin_seldef;
end
+ ERPwaviewer.bin=Bin_sel;
brange(1) = {'All'};
for Numofbin11 = 1:length(binStr)
brange(Numofbin11+1) = {char(strcat(num2str(Numofbin11),'.',32,char(binStr(Numofbin11))))};
end
ERPwaveview_binchan.BinRange = uicontrol('Parent', ERPwaveview_binchan.DataSelGrid,'Style','listbox','Min',1,'Max',BinNum+1,...
'String', brange,'callback',@ViewerBinRange,'FontSize',FonsizeDefault,'Enable',Enable_label); % 2C
+ ERPwaveview_binchan.BinRange.KeyPressFcn = @setbinchan_presskey;
if BinNum== numel(Bin_sel)
ERPwaveview_binchan.BinRange.Value =1;
else
@@ -160,9 +199,6 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
if strcmpi(ERPtooltype,'EStudio')
ERPwaveview_binchan.auto.String = 'Same as EStudio';
- % elseif strcmpi(ERPtooltype,'ERPLAB')
- % ERPwaveview_binchan.auto.String = 'Same as ERPLAB';
- % set(ERPwaveview_binchan.opts_title ,'Sizes',[130 90]);
else
ERPwaveview_binchan.auto.String = '';
ERPwaveview_binchan.auto.Enable = 'off';
@@ -183,9 +219,12 @@ function drawui_erpsetbinchan_viewer(FonsizeDefault)
uiextras.Empty('Parent',ERPwaveview_binchan.help_apply_title );
ERPwaveview_binchan.apply = uicontrol('Style','pushbutton','Parent',ERPwaveview_binchan.help_apply_title ,'String','Apply',...
'callback',@setbinchan_apply,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
+% ERPwaveview_binchan.custom.KeyPressFcn = @setbinchan_presskey;
uiextras.Empty('Parent',ERPwaveview_binchan.help_apply_title );
set(ERPwaveview_binchan.help_apply_title ,'Sizes',[40 70 20 70 20]);
set(ERPwaveview_binchan.vBox, 'Sizes', [20 190 25]);
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -201,11 +240,11 @@ function ViewerElecRange(Source,~)
ChanArray = Source.Value;
[x_flag,y_flag] = find(ChanArray==1);
if ~isempty(y_flag)
- Source.Value = 1;
+ Source.Value = 1;
else
- if length(Source.String)-1 == numel(ChanArray)
- Source.Value = 1;
- end
+ if length(Source.String)-1 == numel(ChanArray)
+ Source.Value = 1;
+ end
end
estudioworkingmemory('MyViewer_chanbin',1);
ERPwaveview_binchan.apply.BackgroundColor = [0.4940 0.1840 0.5560];
@@ -224,11 +263,11 @@ function ViewerBinRange(BinSource,~)
BinArray = BinSource.Value;
[x_flag,y_flag] = find(BinArray==1);
if ~isempty(y_flag)
- BinSource.Value = 1;
+ BinSource.Value = 1;
else
- if length(BinSource.String)-1 == numel(BinArray)
- BinSource.Value = 1;
- end
+ if length(BinSource.String)-1 == numel(BinArray)
+ BinSource.Value = 1;
+ end
end
estudioworkingmemory('MyViewer_chanbin',1);
@@ -243,7 +282,6 @@ function Chanbin_auto(source,~)
if ~isempty(messgStr) && viewerpanelIndex~=2
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
-
estudioworkingmemory('MyViewer_chanbin',1);
ERPwaveview_binchan.apply.BackgroundColor = [0.4940 0.1840 0.5560];
ERPwaveview_binchan.apply.ForegroundColor = [1 1 1];
@@ -389,11 +427,14 @@ function setbinchan_help(~,~)
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
+
changeFlag = estudioworkingmemory('MyViewer_chanbin');
if changeFlag~=1
return;
end
-
+ MessageViewer= char(strcat('Channels and Bins > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
@@ -436,6 +477,9 @@ function setbinchan_help(~,~)
ERPwaveview_binchan.apply.BackgroundColor = [1 1 1];
Chanbin_waveviewer_box.TitleColor= [0.5 0.5 0.9];
ERPwaveview_binchan.apply.ForegroundColor = [0 0 0];
+ MessageViewer= char(strcat('Channels and Bins > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
%%------------------------------Apply--------------------------------------
@@ -479,6 +523,12 @@ function setbinchan_apply(~,~)
Chanbin_waveviewer_box.TitleColor= [0.5 0.5 0.9];
ERPwaveview_binchan.apply.ForegroundColor = [0 0 0];
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ERPwaviewer_apply.binchan_op;
+ MERPWaveViewer_chanbin{2} =ERPwaviewer_apply.chan;
+ MERPWaveViewer_chanbin{3} =ERPwaviewer_apply.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
%%change the other panels based on the changed bins and channels
viewer_ERPDAT.Count_currentERP = viewer_ERPDAT.Count_currentERP+1;
%%plot waves
@@ -585,13 +635,19 @@ function v_currentERP_change(~,~)
end
ERPwaviewer_S.bin = BinArray;
assignin('base','ALLERPwaviewer',ERPwaviewer_S);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ERPwaviewer_S.binchan_op;
+ MERPWaveViewer_chanbin{2} =ERPwaviewer_S.chan;
+ MERPWaveViewer_chanbin{3} =ERPwaviewer_S.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
end
%%------------update this panel based on the imported parameters-----------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=2
return;
end
@@ -631,6 +687,7 @@ function count_loadproper_change(~,~)
else
Chan_sel= 1:length(Chanlist);
end
+ ERPwaviewer_S.chan = Chan_sel;
ERPwaveview_binchan.ElecRange.String = Chanlist_name;
try
if length(Chan_sel) == numel(chanStr)
@@ -665,6 +722,7 @@ function count_loadproper_change(~,~)
else
ERPwaveview_binchan.BinRange.Value = Bin_sel+1;
end
+ ERPwaviewer_S.bin = Bin_sel;
ERPtooltype = erpgettoolversion('tooltype');
if ~strcmpi(ERPtooltype,'EStudio') && ~strcmpi(ERPtooltype,'ERPLAB')
@@ -688,7 +746,11 @@ function count_loadproper_change(~,~)
if strcmpi(ERPtooltype,'EStudio')
ERPwaveview_binchan.auto.String = 'Same as EStudio';
elseif strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_binchan.auto.String = 'Same as ERPLAB';
+ ERPwaveview_binchan.auto.String = '';
+ ERPwaveview_binchan.BinRange.Enable = 'on';
+ ERPwaveview_binchan.ElecRange.Enable = 'on';
+ ERPwaveview_binchan.auto.Enable = 'off';
+ ERPwaveview_binchan.custom.Enable = 'off';
else
ERPwaveview_binchan.auto.String = '';
ERPwaveview_binchan.auto.Enable = 'off';
@@ -700,6 +762,13 @@ function count_loadproper_change(~,~)
ERPwaveview_binchan.BinRange.Enable = 'on';
end
+ assignin('base','ALLERPwaviewer',ERPwaviewer_S);
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ERPwaviewer_S.binchan_op;
+ MERPWaveViewer_chanbin{2} =ERPwaviewer_S.chan;
+ MERPWaveViewer_chanbin{3} =ERPwaviewer_S.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
+ viewer_ERPDAT.loadproper_count=3;
end
%%modify the channels based on the changes of main EStudio
@@ -746,6 +815,12 @@ function ERP_chan_changed(~,~)
assignin('base','ALLERPwaviewer',ALLERPwaviewer_apply);
%%change the other panels based on the changed bins and channels
viewer_ERPDAT.Count_currentERP = viewer_ERPDAT.Count_currentERP+1;
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ALLERPwaviewer_apply.binchan_op;
+ MERPWaveViewer_chanbin{2} =ALLERPwaviewer_apply.chan;
+ MERPWaveViewer_chanbin{3} =ALLERPwaviewer_apply.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
%%plot waves
f_redrawERP_viewer_test();
end
@@ -791,6 +866,13 @@ function ERP_bin_changed(~,~)
end
ALLERPwaviewer_apply.bin = BinArrayStudio;
assignin('base','ALLERPwaviewer',ALLERPwaviewer_apply);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ALLERPwaviewer_apply.binchan_op;
+ MERPWaveViewer_chanbin{2} =ALLERPwaviewer_apply.chan;
+ MERPWaveViewer_chanbin{3} =ALLERPwaviewer_apply.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
+
%%change the other panels based on the changed bins and channels
viewer_ERPDAT.Count_currentERP = viewer_ERPDAT.Count_currentERP+1;
%%plot waves
@@ -802,7 +884,7 @@ function ERP_bin_changed(~,~)
%%change channels and bins based on the main EStudio
function Two_GUI_change(~,~)
if observe_ERPDAT.Two_GUI~=2
- return;
+ return;
end
ERPtooltype = erpgettoolversion('tooltype');
@@ -881,7 +963,7 @@ function Two_GUI_change(~,~)
else
ERPwaveview_binchan.ElecRange.Value =ChanArrayStudio+1;
end
- ERPwaveview_binchan.ElecRange.Max = length( ERPwaveview_binchan.ElecRange.String)+2;
+ ERPwaveview_binchan.ElecRange.Max = length( ERPwaveview_binchan.ElecRange.String)+2;
catch
ERPwaveview_binchan.ElecRange.Value =1;
end
@@ -889,6 +971,14 @@ function Two_GUI_change(~,~)
end
ERPwaveview_binchan.ElecRange.Max = length(ERPwaveview_binchan.ElecRange.String)+2;
assignin('base','ALLERPwaviewer',ALLERPwaviewer_apply);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ALLERPwaviewer_apply.binchan_op;
+ MERPWaveViewer_chanbin{2} =ALLERPwaviewer_apply.chan;
+ MERPWaveViewer_chanbin{3} =ALLERPwaviewer_apply.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
+
+
%%change the other panels based on the changed bins and channels
viewer_ERPDAT.Count_currentERP = viewer_ERPDAT.Count_currentERP+1;
%%plot waves
@@ -993,8 +1083,8 @@ function Reset_Waviewer_panel_change(~,~)
ERPwaviewerIN.chan = Chan_sel;
ERPwaviewerIN.binchan_op = 1;
elseif strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_binchan.auto.Value = 1;
- ERPwaveview_binchan.custom.Value =0;
+ ERPwaveview_binchan.auto.Value = 0;
+ ERPwaveview_binchan.custom.Value =1;
ERPwaveview_binchan.auto.Enable = 'off';
ERPwaveview_binchan.custom.Enable = 'off';
ERPwaveview_binchan.ElecRange.Enable = 'on';
@@ -1021,9 +1111,16 @@ function Reset_Waviewer_panel_change(~,~)
end
ERPwaviewerIN.bin = [1:length(ERPwaveview_binchan.BinRange.String)-1];
ERPwaviewerIN.chan = [1:length(ERPwaveview_binchan.ElecRange.String)-1];
- ERPwaviewerIN.binchan_op = 1;
+ ERPwaviewerIN.binchan_op = 0;
end
assignin('base','ALLERPwaviewer',ERPwaviewerIN);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ERPwaviewerIN.binchan_op;
+ MERPWaveViewer_chanbin{2} =ERPwaviewerIN.chan;
+ MERPWaveViewer_chanbin{3} =ERPwaviewerIN.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
+
ERPwaveview_binchan.apply.BackgroundColor = [1 1 1];
Chanbin_waveviewer_box.TitleColor= [0.5 0.5 0.9];
ERPwaveview_binchan.apply.ForegroundColor = [0 0 0];
@@ -1031,4 +1128,56 @@ function Reset_Waviewer_panel_change(~,~)
end
end%%reset end
+%%Update the change of label indeces
+ function ERPset_Chan_bin_label_change(~,~)
+ if viewer_ERPDAT.ERPset_Chan_bin_label~=1
+ return;
+ end
+ try
+ ERPwaviewerIN = evalin('base','ALLERPwaviewer');
+ catch
+ beep;
+ disp('f_ERP_Binchan_waviewer_GUI error: Restart ERPwave Viewer');
+ return;
+ end
+
+ if ERPwaveview_binchan.auto.Value ==0
+ BinArray = ERPwaviewerIN.bin;
+ ChanArray = ERPwaviewerIN.chan;
+ ChaNum= length(ERPwaveview_binchan.ElecRange.String)-1;
+ if max(ChanArray(:)) <=ChaNum
+ if ChaNum== numel(ChanArray)
+ ERPwaveview_binchan.ElecRange.Value=1;
+ else
+ ERPwaveview_binchan.ElecRange.Value= ChanArray+1;
+ end
+ end
+ BiNum = length(ERPwaveview_binchan.BinRange.String)-1;
+ if max(BinArray(:)) <=BiNum
+ if numel(BinArray)==BiNum
+ ERPwaveview_binchan.BinRange.Value=1;
+ else
+ ERPwaveview_binchan.BinRange.Value=BinArray+1;
+ end
+ end
+
+ %%save the parameters to memory file
+ MERPWaveViewer_chanbin{1} = ERPwaviewerIN.binchan_op;
+ MERPWaveViewer_chanbin{2} =ERPwaviewerIN.chan;
+ MERPWaveViewer_chanbin{3} =ERPwaviewerIN.bin;
+ estudioworkingmemory('MERPWaveViewer_chanbin',MERPWaveViewer_chanbin);
+ end
+ end
+
+
+%%Execute the panel when press "Return" or "Enter"
+ function setbinchan_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ setbinchan_apply();
+ else
+ return;
+ end
+ end
+
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_labelset_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_labelset_waveviewer_GUI.m
index 51f0c94b..580d9db3 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_labelset_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_labelset_waveviewer_GUI.m
@@ -11,7 +11,7 @@
function varargout = f_ERP_labelset_waveviewer_GUI(varargin)
global viewer_ERPDAT;
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
% addlistener(viewer_ERPDAT,'Process_messg_change',@Process_messg_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
@@ -23,13 +23,13 @@
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
if nargin == 0
fig = figure(); % Parent figure
- box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', fig, 'Title', 'Chan/Bin/ERPset Labels', 'Padding', 5,...
+ box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', fig, 'Title', 'Chan/Bin/ERPset Label Properties', 'Padding', 5,...
'BackgroundColor',ColorBviewer_def,'TitleColor',[0.5 0.5 0.9],'ForegroundColor','w','FontSize',12); % Create boxpanel
elseif nargin == 1
- box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', varargin{1}, 'Title', 'Chan/Bin/ERPset Labels', 'Padding', 5,...
+ box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', varargin{1}, 'Title', 'Chan/Bin/ERPset Label Properties', 'Padding', 5,...
'BackgroundColor',ColorBviewer_def,'TitleColor',[0.5 0.5 0.9],'ForegroundColor','w','FontSize',12);
else
- box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', varargin{1}, 'Title', 'Chan/Bin/ERPset Labels', 'Padding', 5, ...
+ box_erplabelset_viewer_property = uiextras.BoxPanel('Parent', varargin{1}, 'Title', 'Chan/Bin/ERPset Label Properties', 'Padding', 5, ...
'FontSize', varargin{2},'BackgroundColor',ColorBviewer_def,'TitleColor',[0.5 0.5 0.9],'ForegroundColor','w');
end
%-----------------------------Draw the panel-------------------------------------
@@ -40,7 +40,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_plot_property(FonsizeDefault);
@@ -65,9 +65,20 @@ function drawui_plot_property(FonsizeDefault)
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',1,'FontWeight','bold'); %,'HorizontalAlignment','left'
%%-----------------Setting for Auto-------
- locationAuto = 1;
- locationno = 0;
- locationcustom = 0;%% the default value
+ %%get the parameters from memory file
+ MERPWaveViewer_label= estudioworkingmemory('MERPWaveViewer_label');
+ try
+ locationAuto = MERPWaveViewer_label{1};
+ locationno = MERPWaveViewer_label{2};
+ locationcustom = MERPWaveViewer_label{3};
+ catch
+ locationAuto = 1;
+ locationno = 0;
+ locationcustom = 0;%% the default value
+ MERPWaveViewer_label{1} = 1;
+ MERPWaveViewer_label{2} = 0;
+ MERPWaveViewer_label{3} = 0;
+ end
if locationAuto ==1
locationno =0;
locationcustom =0;
@@ -81,41 +92,63 @@ function drawui_plot_property(FonsizeDefault)
gui_labelset_waveviewer.parameters_title = uiextras.HBox('Parent', gui_labelset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_labelset_waveviewer.labelauto = uicontrol('Style','radiobutton','Parent', gui_labelset_waveviewer.parameters_title,'String','Auto',...
'callback',@labelauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',locationAuto); %
+ gui_labelset_waveviewer.labelauto.KeyPressFcn = @labels_presskey;
gui_labelset_waveviewer.nolabel = uicontrol('Style','radiobutton','Parent', gui_labelset_waveviewer.parameters_title,'String','No labels',...
'callback',@nolabel,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',locationno); %
+ gui_labelset_waveviewer.nolabel.KeyPressFcn = @labels_presskey;
gui_labelset_waveviewer.customlabel = uicontrol('Style','radiobutton','Parent', gui_labelset_waveviewer.parameters_title,'String','Custom',...
'callback',@customlabel,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',locationcustom); %
+ gui_labelset_waveviewer.customlabel.KeyPressFcn = @labels_presskey;
if gui_labelset_waveviewer.labelauto.Value
gui_labelset_waveviewer.nolabel.Value = ~gui_labelset_waveviewer.labelauto.Value;
gui_labelset_waveviewer.customlabel.Value = ~gui_labelset_waveviewer.labelauto.Value;
customdefEnable = 'off';
elseif gui_labelset_waveviewer.nolabel.Value
- gui_labelset_waveviewer.labelauto.Value.Value = ~gui_labelset_waveviewer.nolabel.Value;
+ gui_labelset_waveviewer.labelauto.Value = ~gui_labelset_waveviewer.nolabel.Value;
gui_labelset_waveviewer.customlabel.Value = ~gui_labelset_waveviewer.nolabel.Value;
customdefEnable = 'off';
elseif gui_labelset_waveviewer.customlabel.Value
- gui_labelset_waveviewer.labelauto.Value.Value = ~gui_labelset_waveviewer.nolabel.Value;
- gui_labelset_waveviewer.nolabel.Value = ~gui_labelset_waveviewer.nolabel.Value;
+ gui_labelset_waveviewer.labelauto.Value = ~gui_labelset_waveviewer.customlabel.Value;
+ gui_labelset_waveviewer.nolabel.Value = ~gui_labelset_waveviewer.customlabel.Value;
customdefEnable = 'on';
end
ERPwaviewer.chanbinsetlabel.location.auto = gui_labelset_waveviewer.labelauto.Value;
ERPwaviewer.chanbinsetlabel.location.no = gui_labelset_waveviewer.nolabel.Value;
ERPwaviewer.chanbinsetlabel.location.custom =gui_labelset_waveviewer.customlabel.Value;
-
- xperDef = '50';
- yperDef = '100';
- CenDef = 1;
+ if locationAuto ==1
+ xperDef = 50;
+ yperDef = 100;
+ else
+ try
+ xperDef= MERPWaveViewer_label{4};
+ yperDef= MERPWaveViewer_label{5};
+ catch
+ xperDef = 50;
+ yperDef = 100;
+ MERPWaveViewer_label{4} = xperDef;
+ MERPWaveViewer_label{5} = yperDef;
+ end
+ end
+ try
+ CenDef = MERPWaveViewer_label{6};
+ catch
+ CenDef = 1;
+ MERPWaveViewer_label{6} =1;
+ end
gui_labelset_waveviewer.labelloc_title = uiextras.HBox('Parent', gui_labelset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_labelset_waveviewer.xperctitle = uicontrol('Style','text','Parent', gui_labelset_waveviewer.labelloc_title,'String','X%',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~gui_labelset_waveviewer.labelauto.Value); %
- gui_labelset_waveviewer.xperc_edit = uicontrol('Style','edit','Parent', gui_labelset_waveviewer.labelloc_title,'String',xperDef,...
+ gui_labelset_waveviewer.xperc_edit = uicontrol('Style','edit','Parent', gui_labelset_waveviewer.labelloc_title,'String',num2str(xperDef),...
'callback',@label_xperc, 'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',customdefEnable); %
+ gui_labelset_waveviewer.xperc_edit.KeyPressFcn = @labels_presskey;
gui_labelset_waveviewer.yperctitle = uicontrol('Style','text','Parent', gui_labelset_waveviewer.labelloc_title,'String','Y%',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
- gui_labelset_waveviewer.yperc_edit = uicontrol('Style','edit','Parent', gui_labelset_waveviewer.labelloc_title,'String',yperDef,...
+ gui_labelset_waveviewer.yperc_edit = uicontrol('Style','edit','Parent', gui_labelset_waveviewer.labelloc_title,'String',num2str(yperDef),...
'callback',@label_yperc, 'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',customdefEnable); %
+ gui_labelset_waveviewer.yperc_edit.KeyPressFcn = @labels_presskey;
gui_labelset_waveviewer.center = uicontrol('Style','checkbox','Parent', gui_labelset_waveviewer.labelloc_title,'String','Centered',...
'callback',@label_center,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Enable',customdefEnable,'Value',CenDef); %
+ gui_labelset_waveviewer.center.KeyPressFcn = @labels_presskey;
set(gui_labelset_waveviewer.labelloc_title,'Sizes',[30 45 30 45 80]);
ERPwaviewer.chanbinsetlabel.location.xperc = str2num(char(gui_labelset_waveviewer.xperc_edit.String));
ERPwaviewer.chanbinsetlabel.location.yperc = str2num(char(gui_labelset_waveviewer.yperc_edit.String));
@@ -124,11 +157,25 @@ function drawui_plot_property(FonsizeDefault)
%
%%--------------------font and font size---------------------------
gui_labelset_waveviewer.font_title = uiextras.HBox('Parent', gui_labelset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- fontDef = 2;
+ try
+ fontDef=MERPWaveViewer_label{7};
+ catch
+ fontDef = 3;
+ MERPWaveViewer_label{7}=3;
+ end
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
labelfontsizeinum = str2num(char(fontsize));
- LabelfontsizeValue = 4;
+ try
+ LabelfontsizeValue = MERPWaveViewer_label{8};
+ catch
+ LabelfontsizeValue = 4;
+ MERPWaveViewer_label{8}=4;
+ end
+ if numel(LabelfontsizeValue)~=1 || LabelfontsizeValue<=0 || LabelfontsizeValue>20
+ LabelfontsizeValue = 4;
+ MERPWaveViewer_label{8}=4;
+ end
uicontrol('Style','text','Parent', gui_labelset_waveviewer.font_title,'String','Label Font & Fontsize & Color:',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'FontWeight','bold'); %,'HorizontalAlignment','left'
gui_labelset_waveviewer.font_custom_title = uiextras.HBox('Parent', gui_labelset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
@@ -137,24 +184,31 @@ function drawui_plot_property(FonsizeDefault)
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
gui_labelset_waveviewer.font_custom_type = uicontrol('Style','popupmenu','Parent', gui_labelset_waveviewer.font_custom_title ,'String',fonttype,...
'callback',@label_font,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',fontDef,'Enable',customdefEnable); %
-
+ gui_labelset_waveviewer.font_custom_type.KeyPressFcn = @labels_presskey;
uicontrol('Style','text','Parent', gui_labelset_waveviewer.font_custom_title ,'String','Size',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
gui_labelset_waveviewer.font_custom_size = uicontrol('Style','popupmenu','Parent', gui_labelset_waveviewer.font_custom_title ,'String',fontsize,...
'callback',@label_fontsize,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',LabelfontsizeValue,'Enable',customdefEnable); %
+ gui_labelset_waveviewer.font_custom_size.KeyPressFcn = @labels_presskey;
set(gui_labelset_waveviewer.font_custom_title,'Sizes',[30 110 30 70]);
ERPwaviewer.chanbinsetlabel.font = gui_labelset_waveviewer.font_custom_type.Value;
ERPwaviewer.chanbinsetlabel.fontsize = labelfontsizeinum(gui_labelset_waveviewer.font_custom_size.Value);
%%--------------Label text color-----------
- Labelfontcolor =1;
+ try
+ Labelfontcolor= MERPWaveViewer_label{9};
+ catch
+ Labelfontcolor =1;
+ MERPWaveViewer_label{9} =1;
+ end
gui_labelset_waveviewer.labelcolor_title = uiextras.HBox('Parent', gui_labelset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_labelset_waveviewer.labelcolor_title,'String','Color',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
textColor = {'Black','Red','Blue','Green','Orange','Cyan','Magenla'};
gui_labelset_waveviewer.labelcolor = uicontrol('Style','popupmenu','Parent',gui_labelset_waveviewer.labelcolor_title,'String',textColor,...
'callback',@label_color,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',customdefEnable,'Value',Labelfontcolor); %
+ gui_labelset_waveviewer.labelcolor.KeyPressFcn = @labels_presskey;
uiextras.Empty('Parent',gui_labelset_waveviewer.labelcolor_title);
uiextras.Empty('Parent',gui_labelset_waveviewer.labelcolor_title);
set(gui_labelset_waveviewer.labelcolor_title,'Sizes',[40 100 30 70]);
@@ -172,6 +226,7 @@ function drawui_plot_property(FonsizeDefault)
set(gui_labelset_waveviewer.help_apply_title ,'Sizes',[40 70 20 70 20]);
set(gui_labelset_waveviewer.DataSelBox ,'Sizes',[20 25 25 20 25 25 25]);
assignin('base','ALLERPwaviewer',ERPwaviewer);
+ estudioworkingmemory('MERPWaveViewer_label',MERPWaveViewer_label);
end
%%***********************************************************************%%
@@ -197,13 +252,13 @@ function labelauto(~,~)
gui_labelset_waveviewer.center.Enable = Enable;
gui_labelset_waveviewer.font_custom_type.Enable = Enable;
gui_labelset_waveviewer.font_custom_size.Enable = Enable;
- gui_labelset_waveviewer.font_custom_type.Value = 2;
+ gui_labelset_waveviewer.font_custom_type.Value = 3;
gui_labelset_waveviewer.font_custom_size.Value = 4;
gui_labelset_waveviewer.xperc_edit.String ='50' ;
gui_labelset_waveviewer.yperc_edit.String = '100';
gui_labelset_waveviewer.labelcolor.Enable = Enable;
gui_labelset_waveviewer.label_customtable.Enable = Enable;
- gui_labelset_waveviewer.labelcolor.Value = 1;
+ gui_labelset_waveviewer.labelcolor.Value = 1;
%%----------------Update the label-----------------
try
ALLERPwaviewer = evalin('base','ALLERPwaviewer');
@@ -311,8 +366,11 @@ function label_xperc(Source,~)
gui_labelset_waveviewer.Apply.BackgroundColor = [0.4940 0.1840 0.5560];
gui_labelset_waveviewer.Apply.ForegroundColor = [1 1 1];
box_erplabelset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
- if isempty(str2num(Source.String))
- gui_labelset_waveviewer.xperc_edit.String ='50' ;
+ if isempty(str2num(Source.String)) || numel(str2num(Source.String))~=1
+ viewer_ERPDAT.Process_messg =4;
+ messgStr = strcat('Chan/Bin/ERPset Label Properties > X% should a number and we therefore used 50');
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
+ gui_labelset_waveviewer.xperc_edit.String ='50' ;
end
end
@@ -326,8 +384,11 @@ function label_yperc(Source,~)
gui_labelset_waveviewer.Apply.BackgroundColor = [0.4940 0.1840 0.5560];
gui_labelset_waveviewer.Apply.ForegroundColor = [1 1 1];
box_erplabelset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
- if isempty(str2num(Source.String))
- gui_labelset_waveviewer.yperc_edit.String = '100';
+ if isempty(str2num(Source.String)) || numel(str2num(Source.String))~=1
+ viewer_ERPDAT.Process_messg =4;
+ messgStr = strcat('Chan/Bin/ERPset Label Properties > Y% should a number and we therefore used 100');
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
+ gui_labelset_waveviewer.yperc_edit.String = '100';
end
end
@@ -385,9 +446,14 @@ function label_help(~,~)
if ~isempty(messgStr) && viewerpanelIndex~=5
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
-
+ MessageViewer= char(strcat('Chan/Bin/ERPset Labels > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
changeFlag = estudioworkingmemory('MyViewer_labels');
if changeFlag~=1
+ MessageViewer= char(strcat('Chan/Bin/ERPset Labels > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
return;
end
@@ -440,6 +506,9 @@ function label_help(~,~)
gui_labelset_waveviewer.Apply.BackgroundColor = [1 1 1];
gui_labelset_waveviewer.Apply.ForegroundColor = [0 0 0];
box_erplabelset_viewer_property.TitleColor= [0.5 0.5 0.9];
+ MessageViewer= char(strcat('Chan/Bin/ERPset Labels > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
%%------------------------------Apply--------------------------------------
@@ -469,33 +538,45 @@ function label_apply(~,~)
ERPwaviewer_apply.chanbinsetlabel.location.custom =gui_labelset_waveviewer.customlabel.Value;
ERPwaviewer_apply.chanbinsetlabel.location.xperc = str2num(char(gui_labelset_waveviewer.xperc_edit.String));
ERPwaviewer_apply.chanbinsetlabel.location.yperc = str2num(char(gui_labelset_waveviewer.yperc_edit.String));
+ MERPWaveViewer_label{1} = ERPwaviewer_apply.chanbinsetlabel.location.auto;
+ MERPWaveViewer_label{2} = ERPwaviewer_apply.chanbinsetlabel.location.no;
+ MERPWaveViewer_label{3} =ERPwaviewer_apply.chanbinsetlabel.location.custom;
+ MERPWaveViewer_label{4} =ERPwaviewer_apply.chanbinsetlabel.location.xperc;
+ MERPWaveViewer_label{5} =ERPwaviewer_apply.chanbinsetlabel.location.yperc;
+
if ( ERPwaviewer_apply.chanbinsetlabel.location.no==1 || ERPwaviewer_apply.chanbinsetlabel.location.custom ==1) && (isempty(ERPwaviewer_apply.chanbinsetlabel.location.xperc) || isempty(ERPwaviewer_apply.chanbinsetlabel.location.yperc))
ERPwaviewer_apply.chanbinsetlabel.location.auto = 1;
ERPwaviewer_apply.chanbinsetlabel.location.no = 0;
ERPwaviewer_apply.chanbinsetlabel.location.custom =0;
end
ERPwaviewer_apply.chanbinsetlabel.location.center = gui_labelset_waveviewer.center.Value;
+ MERPWaveViewer_label{6} = ERPwaviewer_apply.chanbinsetlabel.location.center;
+
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
labelfontsizeinum = str2num(char(fontsize));
ERPwaviewer_apply.chanbinsetlabel.font = gui_labelset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_label{7} = ERPwaviewer_apply.chanbinsetlabel.font;
try
ERPwaviewer_apply.chanbinsetlabel.fontsize = labelfontsizeinum(gui_labelset_waveviewer.font_custom_size.Value);
catch
ERPwaviewer_apply.chanbinsetlabel.fontsize = 10;
end
ERPwaviewer_apply.chanbinsetlabel.textcolor = gui_labelset_waveviewer.labelcolor.Value;
+ MERPWaveViewer_label{8} = gui_labelset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_label{9} = ERPwaviewer_apply.chanbinsetlabel.textcolor;
ALLERPwaviewer=ERPwaviewer_apply;
assignin('base','ALLERPwaviewer',ALLERPwaviewer);
f_redrawERP_viewer_test();
viewer_ERPDAT.Process_messg =2;
+ estudioworkingmemory('MERPWaveViewer_label',MERPWaveViewer_label);
end
%%-------------change this panel based on the loaded parameters------------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=5
return;
end
try
@@ -569,6 +650,19 @@ function count_loadproper_change(~,~)
gui_labelset_waveviewer.font_custom_size.Value = xsize;
textColor = ERPwaviewer_apply.chanbinsetlabel.textcolor;
gui_labelset_waveviewer.labelcolor.Value = textColor;
+ viewer_ERPDAT.loadproper_count =6;
+
+ %%save the parameters to memory file
+ MERPWaveViewer_label{1} = ERPwaviewer_apply.chanbinsetlabel.location.auto;
+ MERPWaveViewer_label{2} = ERPwaviewer_apply.chanbinsetlabel.location.no;
+ MERPWaveViewer_label{3} =ERPwaviewer_apply.chanbinsetlabel.location.custom;
+ MERPWaveViewer_label{4} =ERPwaviewer_apply.chanbinsetlabel.location.xperc;
+ MERPWaveViewer_label{5} =ERPwaviewer_apply.chanbinsetlabel.location.yperc;
+ MERPWaveViewer_label{6} = ERPwaviewer_apply.chanbinsetlabel.location.center;
+ MERPWaveViewer_label{7} = ERPwaviewer_apply.chanbinsetlabel.font;
+ MERPWaveViewer_label{8} = gui_labelset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_label{9} = ERPwaviewer_apply.chanbinsetlabel.textcolor;
+ estudioworkingmemory('MERPWaveViewer_label',MERPWaveViewer_label);
end
@@ -616,11 +710,11 @@ function Reset_Waviewer_panel_change(~,~)
ERPwaviewerin.chanbinsetlabel.location.yperc = 100;
ERPwaviewerin.chanbinsetlabel.location.center =1;
%%label font, fontsize and color
- ERPwaviewerin.chanbinsetlabel.font =2;
+ ERPwaviewerin.chanbinsetlabel.font =3;
ERPwaviewerin.chanbinsetlabel.fontsize =10;
ERPwaviewerin.chanbinsetlabel.textcolor=1;
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
- gui_labelset_waveviewer.font_custom_type.Value=2;
+ gui_labelset_waveviewer.font_custom_type.Value=3;
gui_labelset_waveviewer.font_custom_type.String = fonttype;
gui_labelset_waveviewer.font_custom_type.Enable='off'; %
gui_labelset_waveviewer.font_custom_size.Value=4;
@@ -631,9 +725,35 @@ function Reset_Waviewer_panel_change(~,~)
gui_labelset_waveviewer.Apply.BackgroundColor = [1 1 1];
gui_labelset_waveviewer.Apply.ForegroundColor = [0 0 0];
box_erplabelset_viewer_property.TitleColor= [0.5 0.5 0.9];
+
+ %%save the default parameters to memory file
+ MERPWaveViewer_label{1} = ERPwaviewerin.chanbinsetlabel.location.auto;
+ MERPWaveViewer_label{2} = ERPwaviewerin.chanbinsetlabel.location.no;
+ MERPWaveViewer_label{3} =ERPwaviewerin.chanbinsetlabel.location.custom;
+ MERPWaveViewer_label{4} =ERPwaviewerin.chanbinsetlabel.location.xperc;
+ MERPWaveViewer_label{5} =ERPwaviewerin.chanbinsetlabel.location.yperc;
+ MERPWaveViewer_label{6} = ERPwaviewerin.chanbinsetlabel.location.center;
+ MERPWaveViewer_label{7} = ERPwaviewerin.chanbinsetlabel.font;
+ MERPWaveViewer_label{8} = gui_labelset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_label{9} = ERPwaviewerin.chanbinsetlabel.textcolor;
+ estudioworkingmemory('MERPWaveViewer_label',MERPWaveViewer_label);
+
viewer_ERPDAT.Reset_Waviewer_panel=6;
end
end
+%%using "Return" key to execute this panel
+ function labels_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ label_apply();
+ estudioworkingmemory('MyViewer_labels',0);
+ gui_labelset_waveviewer.Apply.BackgroundColor = [1 1 1];
+ gui_labelset_waveviewer.Apply.ForegroundColor = [0 0 0];
+ box_erplabelset_viewer_property.TitleColor= [0.5 0.5 0.9];
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_lineset_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_lineset_waveviewer_GUI.m
index 93f52b13..85a35e47 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_lineset_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_lineset_waveviewer_GUI.m
@@ -13,7 +13,7 @@
global viewer_ERPDAT;
addlistener(viewer_ERPDAT,'legend_change',@legend_change);
addlistener(viewer_ERPDAT,'page_xyaxis_change',@page_xyaxis_change);
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
addlistener(viewer_ERPDAT,'v_currentERP_change',@v_currentERP_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
@@ -43,7 +43,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_lineset_property(FonsizeDefault);
varargout{1} = box_erplineset_viewer_property;
@@ -51,17 +51,27 @@
function drawui_lineset_property(FonsizeDefault)
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer = ALLERPwaviewer;
+ ERPwaviewer = evalin('base','ALLERPwaviewer');
catch
beep;
disp('f_ERP_lineset_waveviewer_GUI() error: Please run the ERP wave viewer again.');
return;
end
+
%%--------------------channel and bin setting----------------------
gui_erplinset_waveviewer.DataSelBox = uiextras.VBox('Parent', box_erplineset_viewer_property,'BackgroundColor',ColorBviewer_def);
%%-----------------Setting for Auto-------
- linAutoValue = 1;
+ MERPWaveViewer_linelegend= estudioworkingmemory('MERPWaveViewer_linelegend');%%call the parameters for this panel
+ try
+ linAutoValue= MERPWaveViewer_linelegend{1};
+ catch
+ linAutoValue = 1;
+ MERPWaveViewer_linelegend{1}=1;
+ end
+ if isempty(linAutoValue) ||numel(linAutoValue)~=1 || (linAutoValue~=0 && linAutoValue~=1)
+ linAutoValue = 1;
+ MERPWaveViewer_linelegend{1}=1;
+ end
if linAutoValue ==1
DataEnable = 'off';
else
@@ -73,9 +83,10 @@ function drawui_lineset_property(FonsizeDefault)
gui_erplinset_waveviewer.linesauto = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.parameters_title,'String','Auto',...
'callback',@lines_auto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',linAutoValue); %
+ gui_erplinset_waveviewer.linesauto.KeyPressFcn = @line_presskey;
gui_erplinset_waveviewer.linescustom = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.parameters_title,'String','Custom',...
'callback',@lines_custom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~linAutoValue); %
-
+ gui_erplinset_waveviewer.linescustom.KeyPressFcn = @line_presskey;
set(gui_erplinset_waveviewer.parameters_title,'Sizes',[60 70 70]);
%%-----------Setting for line table-----------------------------
@@ -97,10 +108,16 @@ function drawui_lineset_property(FonsizeDefault)
[lineNameStr,linecolors,linetypes,linewidths,linecolors_str,linetypes_str,linewidths_str,linecolorsrgb] = f_get_lineset_ERPviewer();
if linAutoValue
lineset_str =table(lineNameStr,linecolors,linetypes,linewidths);
- lineset_str = table2cell(lineset_str);
+ lineset_strdef = table2cell(lineset_str);
else
lineset_str =table(lineNameStr,linecolorsrgb,linetypes,linewidths);
- lineset_str = table2cell(lineset_str);
+ lineset_strdef = table2cell(lineset_str);
+ end
+ try
+ lineset_str= MERPWaveViewer_linelegend{2};
+ catch
+ lineset_str = lineset_strdef;
+ MERPWaveViewer_linelegend{2}=lineset_str;
end
gui_erplinset_waveviewer.line_customtable = uitable(gui_erplinset_waveviewer.line_customtable_title);
gui_erplinset_waveviewer.line_customtable.ColumnFormat = {'char', 'char',...
@@ -115,6 +132,7 @@ function drawui_lineset_property(FonsizeDefault)
gui_erplinset_waveviewer.line_customtable.RowName = [];
gui_erplinset_waveviewer.line_customtable.ColumnWidth = {25 80 65 50};
gui_erplinset_waveviewer.line_customtable.CellEditCallback = @line_customtable;
+ gui_erplinset_waveviewer.line_customtable.KeyPressFcn = @line_presskey;
%%setting for uitable: https://undocumentedmatlab.com/artiALLERPwaviewercles/multi-line-uitable-column-headers
if gui_erplinset_waveviewer.linesauto.Value ==1
gui_erplinset_waveviewer.line_customtable.Enable = 'off';
@@ -124,20 +142,9 @@ function drawui_lineset_property(FonsizeDefault)
ERPwaviewer.Lines.auto =gui_erplinset_waveviewer.linesauto.Value;
ERPwaviewer.Lines.data =gui_erplinset_waveviewer.line_customtable.Data;
- %%------------------setting for legend---------------------------------------
- legendAuto = 1;
- gui_erplinset_waveviewer.legend_title = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- uicontrol('Style','text','Parent', gui_erplinset_waveviewer.legend_title,'String','Legend:',...
- 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left','FontWeight','bold'); %
- gui_erplinset_waveviewer.legendauto = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.legend_title,'String','Auto',...
- 'callback',@legend_auto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',legendAuto); %
- gui_erplinset_waveviewer.legendcustom = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.legend_title,'String','Custom',...
- 'callback',@legend_custom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~legendAuto); %
- set( gui_erplinset_waveviewer.legend_title,'Sizes',[60 70 70]);
-
%%-----------Setting for legend table -----------------------------
- gui_erplinset_waveviewer.legend_customtable_title = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+ % gui_erplinset_waveviewer.legend_customtable_title = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
for ii = 1:100
LegendName{ii,1} = '';
LegendNamenum(ii,1) =ii;
@@ -158,6 +165,7 @@ function drawui_lineset_property(FonsizeDefault)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ChanArray;
elseif plot_org.Overlay ==2
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -165,6 +173,7 @@ function drawui_lineset_property(FonsizeDefault)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
elseif plot_org.Overlay ==3
ALLERP = ERPwaviewer.ALLERP;
ERPsetArray = ERPwaviewer.SelectERPIdx;
@@ -173,6 +182,7 @@ function drawui_lineset_property(FonsizeDefault)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ERPsetArray;
else
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -180,70 +190,128 @@ function drawui_lineset_property(FonsizeDefault)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
end
catch
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
end
- gui_erplinset_waveviewer.legend_customtable = uitable(gui_erplinset_waveviewer.legend_customtable_title);
- gui_erplinset_waveviewer.legend_customtable.ColumnEditable = [false,true];
+ ERPwaviewer.Legend.data = legendset_str;
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
- gui_erplinset_waveviewer.legend_customtable.FontSize = FonsizeDefault;
- gui_erplinset_waveviewer.legend_customtable.ColumnName = {'#','Name'};
- gui_erplinset_waveviewer.legend_customtable.CellEditCallback = @legend_customtable;
- gui_erplinset_waveviewer.legend_customtable.BackgroundColor = [1 1 1;1 1 1];
- gui_erplinset_waveviewer.legend_customtable.RowName = [];
- gui_erplinset_waveviewer.legend_customtable.ColumnWidth = {20 200};
- % gui_erplinset_waveviewer.legend_customtable.CellEditCallback = {@legend_customtable,ERPwaviewer_num};
- %%setting for uitable: https://undocumentedmatlab.com/artiALLERPwaviewercles/multi-line-uitable-column-headers
- if gui_erplinset_waveviewer.legendauto.Value ==1
- gui_erplinset_waveviewer.legend_customtable.Enable = 'off';
+ %
+ %%--------------------legend font and font size---------------------------
+ gui_erplinset_waveviewer.fontcolor_title = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+ uicontrol('Style','text','Parent', gui_erplinset_waveviewer.fontcolor_title,'String','Legend:',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left','FontWeight','bold'); %
+ try
+ fontcolorAuto=MERPWaveViewer_linelegend{3};
+ catch
+ fontcolorAuto=1;
+ MERPWaveViewer_linelegend{3}=1;
+ end
+ if isempty(fontcolorAuto) || numel(fontcolorAuto)~=1 || (fontcolorAuto~=0 && fontcolorAuto~=1)
+ fontcolorAuto=1;
+ MERPWaveViewer_linelegend{3}=1;
+ end
+ gui_erplinset_waveviewer.font_colorauto = uicontrol('Style','radiobutton','Parent',gui_erplinset_waveviewer.fontcolor_title,'String','Auto',...
+ 'callback',@font_color_auto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',fontcolorAuto); %
+ gui_erplinset_waveviewer.font_colorauto.KeyPressFcn = @line_presskey;
+ gui_erplinset_waveviewer.font_colorcustom = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.fontcolor_title,'String','Custom',...
+ 'callback',@font_color_custom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~fontcolorAuto); %
+ gui_erplinset_waveviewer.font_colorcustom.KeyPressFcn = @line_presskey;
+ set(gui_erplinset_waveviewer.fontcolor_title,'Sizes',[60 70 70]);
+ ERPwaviewer.Legend.FontColorAuto = gui_erplinset_waveviewer.font_colorauto.Value;
+ if gui_erplinset_waveviewer.font_colorauto.Value==1
fontEnable = 'off';
else
- gui_erplinset_waveviewer.legend_customtable.Enable = 'on';
fontEnable = 'on';
end
- ERPwaviewer.Legend.auto = gui_erplinset_waveviewer.legendauto.Value;
- ERPwaviewer.Legend.data = gui_erplinset_waveviewer.legend_customtable.Data;
-
- %
- %%--------------------legend font and font size---------------------------
gui_erplinset_waveviewer.labelfont_title = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- fontDef = 2;
+
+ try
+ fontDef = MERPWaveViewer_linelegend{4};
+ catch
+ fontDef = 3;
+ MERPWaveViewer_linelegend{4}=3;
+ end
+ if isempty(fontDef) || numel(fontDef)~=1 || fontDef<1 || fontDef>5
+ fontDef = 3;
+ MERPWaveViewer_linelegend{4}=3;
+ end
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
labelfontsizeinum = str2num(char(fontsize));
- LabelfontsizeValue = 4;
+ try
+ LabelfontsizeValue = MERPWaveViewer_linelegend{5};
+ catch
+ LabelfontsizeValue = 4;
+ MERPWaveViewer_linelegend{5}=4;
+ end
+ if isempty(LabelfontsizeValue) || numel(LabelfontsizeValue)~=1 || LabelfontsizeValue<1 || LabelfontsizeValue>20
+ LabelfontsizeValue = 4;
+ MERPWaveViewer_linelegend{5}=4;
+ end
+
uicontrol('Style','text','Parent', gui_erplinset_waveviewer.labelfont_title ,'String','Font',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
gui_erplinset_waveviewer.font_custom_type = uicontrol('Style','popupmenu','Parent', gui_erplinset_waveviewer.labelfont_title ,'String',fonttype,...
'callback',@legendfont,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',fontDef,'Enable',fontEnable); %
+ gui_erplinset_waveviewer.font_custom_type.KeyPressFcn = @line_presskey;
uicontrol('Style','text','Parent', gui_erplinset_waveviewer.labelfont_title ,'String','Size',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
gui_erplinset_waveviewer.font_custom_size = uicontrol('Style','popupmenu','Parent', gui_erplinset_waveviewer.labelfont_title ,'String',fontsize,...
'callback',@legendfontsize,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',LabelfontsizeValue,'Enable',fontEnable); %
+ gui_erplinset_waveviewer.font_custom_size.KeyPressFcn = @line_presskey;
set(gui_erplinset_waveviewer.labelfont_title,'Sizes',[30 110 30 70]);
ERPwaviewer.Legend.font = gui_erplinset_waveviewer.font_custom_type.Value;
ERPwaviewer.Legend.fontsize = labelfontsizeinum(gui_erplinset_waveviewer.font_custom_size.Value);
%%----------------------------Legend textcolor---------------------
- legendtextcolorAuto =1;
+ try
+ legendtextcolorAuto= MERPWaveViewer_linelegend{6};
+ catch
+ legendtextcolorAuto =1;
+ MERPWaveViewer_linelegend{6} =1;
+ end
+ if isempty(legendtextcolorAuto) || numel(legendtextcolorAuto)~=1 || (legendtextcolorAuto~=0 && legendtextcolorAuto~=1)
+ legendtextcolorAuto =1;
+ MERPWaveViewer_linelegend{6} =1;
+ end
+ if isempty(legendtextcolorAuto) || numel(legendtextcolorAuto)~=1 || (legendtextcolorAuto~=0 && legendtextcolorAuto~=1)
+ legendtextcolorAuto =1;
+ MERPWaveViewer_linelegend{6} =1;
+ end
gui_erplinset_waveviewer.legend_textitle = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erplinset_waveviewer.legend_textitle,'String','Text color',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erplinset_waveviewer.legendtextauto = uicontrol('Style','radiobutton','Parent', gui_erplinset_waveviewer.legend_textitle,'String','Auto',...
'callback',@legendtextauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',legendtextcolorAuto,'Enable',fontEnable); %
+ gui_erplinset_waveviewer.legendtextauto.KeyPressFcn = @line_presskey;
gui_erplinset_waveviewer.legendtextcustom = uicontrol('Style','radiobutton','Parent',gui_erplinset_waveviewer.legend_textitle,'String','Same as lines',...
'callback',@legendtextcustom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~legendtextcolorAuto,'Enable',fontEnable,'HorizontalAlignment','left'); %
+ gui_erplinset_waveviewer.legendtextcustom.KeyPressFcn = @line_presskey;
set(gui_erplinset_waveviewer.legend_textitle,'Sizes',[70 60 150]);
ERPwaviewer.Legend.textcolor = gui_erplinset_waveviewer.legendtextauto.Value;
%%------------------------Legend columns---------------------------
- legendcolumns =1;
+ legendcolumnsdef = round(sqrt( length(LegendArray)));
+ try
+ legendcolumns= MERPWaveViewer_linelegend{7};
+ catch
+ legendcolumns =legendcolumnsdef;
+ MERPWaveViewer_linelegend{7}=legendcolumnsdef;
+ end
+ if isempty(legendcolumns) || numel(legendcolumns)~=1 ||legendcolumns<1 || legendcolumns>100
+ legendcolumns =legendcolumnsdef;
+ MERPWaveViewer_linelegend{7}=legendcolumnsdef;
+ end
+ if fontcolorAuto==1
+ legendcolumns =legendcolumnsdef;
+ MERPWaveViewer_linelegend{7}=legendcolumnsdef;
+ end
gui_erplinset_waveviewer.legend_columnstitle = uiextras.HBox('Parent', gui_erplinset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erplinset_waveviewer.legend_columnstitle,'String','Columns',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
@@ -252,6 +320,7 @@ function drawui_lineset_property(FonsizeDefault)
end
gui_erplinset_waveviewer.legendcolumns = uicontrol('Style','popupmenu','Parent', gui_erplinset_waveviewer.legend_columnstitle,'String',columnStr,...
'callback',@legendcolumns,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',legendcolumns,'Enable',fontEnable); %
+ gui_erplinset_waveviewer.legendcolumns.KeyPressFcn = @line_presskey;
uiextras.Empty('Parent', gui_erplinset_waveviewer.legend_columnstitle );
set(gui_erplinset_waveviewer.legend_columnstitle,'Sizes',[60 100 70]);
ERPwaviewer.Legend.columns = gui_erplinset_waveviewer.legendcolumns.Value;
@@ -268,9 +337,9 @@ function drawui_lineset_property(FonsizeDefault)
uiextras.Empty('Parent',gui_erplinset_waveviewer.help_apply_title );
set(gui_erplinset_waveviewer.help_apply_title ,'Sizes',[40 70 20 70 20]);
- set(gui_erplinset_waveviewer.DataSelBox ,'Sizes',[20 200 20 180 25 25 25 25]);
- ALLERPwaviewer=ERPwaviewer;
- assignin('base','ALLERPwaviewer',ALLERPwaviewer);
+ set(gui_erplinset_waveviewer.DataSelBox ,'Sizes',[20 200 20 25 25 25 25]);
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);
end
%%**************************************************************************%%
@@ -361,8 +430,9 @@ function line_customtable(~,~)
end
-%%--------------------legend auto-----------------------------------
- function legend_auto(~,~)
+
+%%Auto for font, fontsize, color, columns for legend
+ function font_color_auto(Source,~)
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();%%check if the changes were applied for the other panels
if ~isempty(messgStr) && viewerpanelIndex~=6
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
@@ -372,89 +442,48 @@ function legend_auto(~,~)
gui_erplinset_waveviewer.apply.ForegroundColor = [1 1 1];
box_erplineset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
- gui_erplinset_waveviewer.legendauto.Value = 1;
- gui_erplinset_waveviewer.legendcustom.Value = 0;
- gui_erplinset_waveviewer.legend_customtable.Enable = 'off';
+ try
+ ERPwaviewer = evalin('base','ALLERPwaviewer');
+ catch
+ beep;
+ disp(' Line & Legends> Legend Auto error: Please run the ERP wave viewer again.');
+ return;
+ end
+ ALLERPIN = ERPwaviewer.ALLERP;
+ ERPsetArray = ERPwaviewer.SelectERPIdx;
+ if max(ERPsetArray(:))> length(ALLERPIN)
+ ERPsetArray =length(ALLERPIN);
+ end
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ plot_org = ERPwaviewer.plot_org;
+ if plot_org.Overlay ==1
+ LegendArray = ERPwaviewer.chan;
+ elseif plot_org.Overlay ==2
+ LegendArray = ERPwaviewer.bin;
+ elseif plot_org.Overlay ==3
+ LegendArray = ERPwaviewer.SelectERPIdx;
+ else
+ LegendArray = ERPwaviewer.bin;
+ end
+
+ gui_erplinset_waveviewer.font_colorauto.Value=1; %
+ gui_erplinset_waveviewer.font_colorcustom.Value = 0;
gui_erplinset_waveviewer.font_custom_type.Enable = 'off'; %
gui_erplinset_waveviewer.font_custom_size.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Enable = 'off';
gui_erplinset_waveviewer.legendtextcustom.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Value = 1;
gui_erplinset_waveviewer.legendtextcustom.Value = 0;
- gui_erplinset_waveviewer.legendcolumns.Value =1;
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
gui_erplinset_waveviewer.legendcolumns.Enable = 'off';
- try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer = ALLERPwaviewer;
- catch
- beep;
- disp('f_ERP_lineset_waveviewer_GUI() error: Please run the ERP wave viewer again.');
- return;
- end
- for ii = 1:100
- LegendName{ii,1} = '';
- LegendNamenum(ii,1) =ii;
- end
- try
- plot_org = ERPwaviewer.plot_org;
- ERPIN = ERPwaviewer.ERP;
- if plot_org.Overlay ==1
- LegendName = [];
- ChanArray = ERPwaviewer.chan;
-
- for Numofchan = 1:numel(ChanArray)
- LegendName{Numofchan,1} = ERPIN.chanlocs(ChanArray(Numofchan)).labels;
- end
- for ii = length(LegendName)+1:100
- LegendName{ii,1} = '';
- end
- legendset_str = table(LegendNamenum,LegendName);
- legendset_str = table2cell(legendset_str);
- elseif plot_org.Overlay ==2
- binArray = ERPwaviewer.bin;
- for Numofbin = 1:numel(binArray)
- LegendName{Numofbin,1} = char(ERPIN.bindescr{binArray(Numofbin)});
- end
- for ii = length(LegendName)+1:100
- LegendName{ii,1} = '';
- end
- legendset_str = table(LegendNamenum,LegendName);
- legendset_str = table2cell(legendset_str);
- elseif plot_org.Overlay ==3
- ALLERP = ERPwaviewer.ALLERP;
- ERPsetArray = ERPwaviewer.SelectERPIdx;
- for Numoferpset = 1:numel(ERPsetArray)
- LegendName{Numoferpset,1} = char(ALLERP(ERPsetArray(Numoferpset)).erpname);
- end
- for ii = length(LegendName)+1:100
- LegendName{ii,1} = '';
- end
- legendset_str = table(LegendNamenum,LegendName);
- legendset_str = table2cell(legendset_str);
- else
- binArray = ERPwaviewer.bin;
- for Numofbin = 1:numel(binArray)
- LegendName{Numofbin,1} = char(ERPIN.bindescr{binArray(Numofbin)});
- end
- for ii = length(LegendName)+1:100
- LegendName{ii,1} = '';
- end
- legendset_str = table(LegendNamenum,LegendName);
- legendset_str = table2cell(legendset_str);
- end
- catch
- legendset_str = table(LegendNamenum,LegendName);
- legendset_str = table2cell(legendset_str);
- end
- gui_erplinset_waveviewer.legend_customtable.ColumnEditable = [false,true];
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
gui_erplinset_waveviewer.font_custom_size.Value = 4;
- gui_erplinset_waveviewer.font_custom_type.Value =1;
+ gui_erplinset_waveviewer.font_custom_type.Value =3;
+
end
-%%-------------------legend custom-----------------------------------------
- function legend_custom(~,~)
+%%Custom for font, fontsize, color, columns for legend
+ function font_color_custom(Source,~)
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();%%check if the changes were applied for the other panels
if ~isempty(messgStr) && viewerpanelIndex~=6
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
@@ -464,9 +493,8 @@ function legend_custom(~,~)
gui_erplinset_waveviewer.apply.ForegroundColor = [1 1 1];
box_erplineset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
- gui_erplinset_waveviewer.legendauto.Value = 0;
- gui_erplinset_waveviewer.legendcustom.Value = 1;
- gui_erplinset_waveviewer.legend_customtable.Enable = 'on';
+ gui_erplinset_waveviewer.font_colorauto.Value=0; %
+ gui_erplinset_waveviewer.font_colorcustom.Value = 1;
gui_erplinset_waveviewer.font_custom_type.Enable = 'on'; %
gui_erplinset_waveviewer.font_custom_size.Enable = 'on';
gui_erplinset_waveviewer.legendtextauto.Enable = 'on';
@@ -474,18 +502,6 @@ function legend_custom(~,~)
gui_erplinset_waveviewer.legendcolumns.Enable = 'on';
end
-%%---------------------------legend table----------------------------------
- function legend_customtable(~,~)
- [messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();%%check if the changes were applied for the other panels
- if ~isempty(messgStr) && viewerpanelIndex~=6
- viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
- end
- estudioworkingmemory('MyViewer_linelegend',1);
- gui_erplinset_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560]; %%mark the changes
- gui_erplinset_waveviewer.apply.ForegroundColor = [1 1 1];
- box_erplineset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
- end
-
%%----------------------font of legend text--------------------------------
function legendfont(Source,~)
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();%%check if the changes were applied for the other panels
@@ -517,7 +533,7 @@ function legendtextauto(~,~)
if ~isempty(messgStr) && viewerpanelIndex~=6
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
- estudioworkingmemory('MyViewer_linelegend',1);
+ estudioworkingmemory('MyViewelinelegend',1);
gui_erplinset_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560]; %%mark the changes
gui_erplinset_waveviewer.apply.ForegroundColor = [1 1 1];
box_erplineset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
@@ -552,7 +568,6 @@ function legendcolumns(~,~)
gui_erplinset_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560]; %%mark the changes
gui_erplinset_waveviewer.apply.ForegroundColor = [1 1 1];
box_erplineset_viewer_property.TitleColor= [0.4940 0.1840 0.5560];
-
end
@@ -562,9 +577,15 @@ function linelegend_help(~,~)
if ~isempty(messgStr) && viewerpanelIndex~=6
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
+ MessageViewer= char(strcat('Lines & Legends > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
changeFlag = estudioworkingmemory('MyViewer_linelegend');
if changeFlag~=1
+ MessageViewer= char(strcat('Lines & Legends > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
return;
end
@@ -585,10 +606,6 @@ function linelegend_help(~,~)
gui_erplinset_waveviewer.line_customtable.Enable = 'on';
end
- gui_erplinset_waveviewer.legendauto.Value= ERPwaviewer_apply.Legend.auto;
- gui_erplinset_waveviewer.legendcustom.Value= ~ERPwaviewer_apply.Legend.auto;
- gui_erplinset_waveviewer.legend_customtable.Data=ERPwaviewer_apply.Legend.data;
-
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
@@ -603,7 +620,15 @@ function linelegend_help(~,~)
gui_erplinset_waveviewer.legendtextauto.Value= ERPwaviewer_apply.Legend.textcolor;
gui_erplinset_waveviewer.legendtextcustom.Value= ~ERPwaviewer_apply.Legend.textcolor;
gui_erplinset_waveviewer.legendcolumns.Value=ERPwaviewer_apply.Legend.columns;
- if gui_erplinset_waveviewer.legendauto.Value==1
+ try
+ FontColorAuto= ERPwaviewer_apply.Legend.FontColorAuto;
+ catch
+ FontColorAuto=1;
+ end
+ gui_erplinset_waveviewer.font_colorauto.Value=FontColorAuto; %
+
+ gui_erplinset_waveviewer.font_colorcustom.Value=~FontColorAuto; %
+ if FontColorAuto==1
LegendEnable = 'off';
else
LegendEnable = 'on';
@@ -613,12 +638,15 @@ function linelegend_help(~,~)
gui_erplinset_waveviewer.legendtextauto.Enable = LegendEnable;
gui_erplinset_waveviewer.legendtextcustom.Enable = LegendEnable;
gui_erplinset_waveviewer.legendcolumns.Enable = LegendEnable;
- gui_erplinset_waveviewer.legend_customtable.Enable = LegendEnable;
+
estudioworkingmemory('MyViewer_linelegend',0);
gui_erplinset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_erplinset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erplineset_viewer_property.TitleColor= [0.5 0.5 0.9];
+ MessageViewer= char(strcat('Lines & Legends > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
@@ -647,8 +675,6 @@ function LineLegend_apply(~,~)
end
ERPwaviewer_apply.Lines.auto = gui_erplinset_waveviewer.linesauto.Value;
ERPwaviewer_apply.Lines.data = gui_erplinset_waveviewer.line_customtable.Data;
- ERPwaviewer_apply.Legend.auto = gui_erplinset_waveviewer.legendauto.Value;
- ERPwaviewer_apply.Legend.data = gui_erplinset_waveviewer.legend_customtable.Data;
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
labelfontsizeinum = str2num(char(fontsize));
@@ -656,7 +682,20 @@ function LineLegend_apply(~,~)
ERPwaviewer_apply.Legend.fontsize = labelfontsizeinum(gui_erplinset_waveviewer.font_custom_size.Value);
ERPwaviewer_apply.Legend.textcolor = gui_erplinset_waveviewer.legendtextauto.Value;
ERPwaviewer_apply.Legend.columns = gui_erplinset_waveviewer.legendcolumns.Value;
+ ERPwaviewer_apply.Legend.FontColorAuto = gui_erplinset_waveviewer.font_colorauto.Value;
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+
+
+ %%Save the parameters for this panel to memory file
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
+
f_redrawERP_viewer_test();
viewer_ERPDAT.Process_messg =2;
end
@@ -668,8 +707,7 @@ function legend_change(~,~)
return;
end
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer = ALLERPwaviewer;
+ ERPwaviewer = evalin('base','ALLERPwaviewer');
catch
beep;
disp('f_ERP_lineset_waveviewer_GUI() error: Please run the ERP wave viewer again.');
@@ -685,6 +723,7 @@ function legend_change(~,~)
ERPsetArray =length(ALLERPIN);
end
[chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ LegendArray = [1:4];
try
plot_org = ERPwaviewer.plot_org;
ERPIN = ERPwaviewer.ERP;
@@ -695,6 +734,7 @@ function legend_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ChanArray;
elseif plot_org.Overlay ==2
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -702,6 +742,7 @@ function legend_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
elseif plot_org.Overlay ==3
ALLERP = ERPwaviewer.ALLERP;
ERPsetArray = ERPwaviewer.SelectERPIdx;
@@ -710,6 +751,7 @@ function legend_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ERPsetArray;
else
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -717,18 +759,28 @@ function legend_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
end
catch
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
end
- if gui_erplinset_waveviewer.legendauto.Value ==1
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
- ERPwaviewer.Legend.auto = gui_erplinset_waveviewer.legendauto.Value;
- ERPwaviewer.Legend.data = gui_erplinset_waveviewer.legend_customtable.Data;
- ALLERPwaviewer=ERPwaviewer;
- assignin('base','ALLERPwaviewer',ALLERPwaviewer);
+ ERPwaviewer.Legend.data = legendset_str;
+ if gui_erplinset_waveviewer.font_colorauto.Value==1
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
+ ERPwaviewer.Legend.columns = round(sqrt(length(LegendArray)));
end
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+
+ %%Save parameters for this panel to memory file
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
end
%%--------changed the legend names based on the current page---------------
@@ -753,6 +805,7 @@ function page_xyaxis_change(~,~)
ERPsetArray =length(ALLERPIN);
end
[chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ LegendArray = [1:4];
try
plot_org = ERPwaviewer.plot_org;
ERPIN = ERPwaviewer.ERP;
@@ -763,6 +816,7 @@ function page_xyaxis_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ChanArray;
elseif plot_org.Overlay ==2
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -770,6 +824,7 @@ function page_xyaxis_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
elseif plot_org.Overlay ==3
ALLERP = ERPwaviewer.ALLERP;
ERPsetArray = ERPwaviewer.SelectERPIdx;
@@ -778,6 +833,7 @@ function page_xyaxis_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = ERPsetArray;
else
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -785,17 +841,28 @@ function page_xyaxis_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
end
catch
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
end
- if gui_erplinset_waveviewer.legendauto.Value ==1 && plot_org.Pages ==3
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
- ERPwaviewer.Legend.auto = gui_erplinset_waveviewer.legendauto.Value;
- ERPwaviewer.Legend.data = gui_erplinset_waveviewer.legend_customtable.Data;
- assignin('base','ALLERPwaviewer',ERPwaviewer);
+
+ ERPwaviewer.Legend.data = legendset_str;
+ if gui_erplinset_waveviewer.font_colorauto.Value==1
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
+ ERPwaviewer.Legend.columns = round(sqrt(length(LegendArray)));
end
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
end
@@ -815,15 +882,15 @@ function v_currentERP_change(~,~)
LegendName{ii,1} = '';
LegendNamenum(ii,1) =ii;
end
- ALLERPIN = ERPwaviewer.ALLERP;
+ ALLERP = ERPwaviewer.ALLERP;
ERPsetArray = ERPwaviewer.SelectERPIdx;
- if max(ERPsetArray(:))> length(ALLERPIN)
- ERPsetArray =length(ALLERPIN);
+ if max(ERPsetArray(:))> length(ALLERP)
+ ERPsetArray =length(ALLERP);
end
- [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERP,ERPsetArray);
+ LegendArray = [1:4];
try
plot_org = ERPwaviewer.plot_org;
- ERPIN = ERPwaviewer.ERP;
if plot_org.Overlay ==1
ChanArray = ERPwaviewer.chan;
for Numofchan = 1:numel(ChanArray)
@@ -831,6 +898,7 @@ function v_currentERP_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray =ChanArray ;
elseif plot_org.Overlay ==2
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -838,14 +906,14 @@ function v_currentERP_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray =binArray ;
elseif plot_org.Overlay ==3
- ALLERP = ERPwaviewer.ALLERP;
- ERPsetArray = ERPwaviewer.SelectERPIdx;
for Numoferpset = 1:numel(ERPsetArray)
LegendName{Numoferpset,1} = char(ALLERP(ERPsetArray(Numoferpset)).erpname);
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray =ERPsetArray ;
else
binArray = ERPwaviewer.bin;
for Numofbin = 1:numel(binArray)
@@ -853,24 +921,35 @@ function v_currentERP_change(~,~)
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray =binArray ;
end
catch
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
end
- if gui_erplinset_waveviewer.legendauto.Value ==1
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
- ERPwaviewer.Legend.auto = gui_erplinset_waveviewer.legendauto.Value;
- ERPwaviewer.Legend.data = gui_erplinset_waveviewer.legend_customtable.Data;
- assignin('base','ALLERPwaviewer',ERPwaviewer);
+ ERPwaviewer.Legend.data = legendset_str;
+ if gui_erplinset_waveviewer.font_colorauto.Value==1
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
+ ERPwaviewer.Legend.columns = round(sqrt(length(LegendArray)));
end
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
+
end
%%-------------change this panel based on the loaded parameters------------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=6
return;
end
try
@@ -880,7 +959,7 @@ function count_loadproper_change(~,~)
disp('f_ERP_lineset_waveviewer_GUI() error: Please run the ERP wave viewer again.');
return;
end
- %%Line settings
+ %%-----------------------Line settings-----------------------------
LineValue = ERPwaviewer.Lines.auto;
if numel(LineValue)~=1 || (LineValue~=1 && LineValue~=0)
LineValue = 1;
@@ -896,35 +975,98 @@ function count_loadproper_change(~,~)
gui_erplinset_waveviewer.line_customtable.Enable = 'on';
end
+
+ [lineNameStr,linecolors,linetypes,linewidths,linecolors_str,linetypes_str,linewidths_str,linecolorsrgb] = f_get_lineset_ERPviewer();
+ lineset_str =table(lineNameStr,linecolors,linetypes,linewidths);
+ lineset_str = table2cell(lineset_str);
+ gui_erplinset_waveviewer.line_customtable.ColumnFormat = {'char', 'char',...
+ {'solid','dash','dot','dashdot','plus','circle','asterisk'},...
+ {'0.25','0.5','1','1.5','2','2.5','3','3.5','4','4.5','5','5.5','6','6.5','7','7.5','8','8.5','9','9.5','10','10.5'}};
+
LineData = ERPwaviewer.Lines.data;
+ if LineValue==1
+ LineData= lineset_str;
+ ERPwaviewer.Lines.data = LineData;
+ end
gui_erplinset_waveviewer.line_customtable.Data = LineData;
+
%
- %%Legend setting
- LegendAuto = ERPwaviewer.Legend.auto;
- if LegendAuto==1
- gui_erplinset_waveviewer.legendauto.Value = 1;
- gui_erplinset_waveviewer.legendcustom.Value = 0;
- gui_erplinset_waveviewer.legend_customtable.Enable = 'off';
+ %%---------------------Legend setting------------------------------
+ for ii = 1:100
+ LegendName{ii,1} = '';
+ LegendNamenum(ii,1) =ii;
+ end
+ ALLERP = ERPwaviewer.ALLERP;
+ ERPsetArray = ERPwaviewer.SelectERPIdx;
+ if max(ERPsetArray(:))> length(ALLERP)
+ ERPsetArray =length(ALLERP);
+ end
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERP,ERPsetArray);
+ LegendArray = [1:4];
+ try
+ plot_org = ERPwaviewer.plot_org;
+ if plot_org.Overlay ==1
+ ChanArray = ERPwaviewer.chan;
+ for Numofchan = 1:numel(ChanArray)
+ LegendName{Numofchan,1} = char(chanStr(ChanArray(Numofchan)));
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray = ChanArray;
+ elseif plot_org.Overlay ==2
+ binArray = ERPwaviewer.bin;
+ for Numofbin = 1:numel(binArray)
+ LegendName{Numofbin,1} = char(binStr(binArray(Numofbin)));
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
+ elseif plot_org.Overlay ==3
+ for Numoferpset = 1:numel(ERPsetArray)
+ LegendName{Numoferpset,1} = char(ALLERP(ERPsetArray(Numoferpset)).erpname);
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray = ERPsetArray;
+ else
+ binArray = ERPwaviewer.bin;
+ for Numofbin = 1:numel(binArray)
+ LegendName{Numofbin,1} = char(binStr(binArray(Numofbin)));
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray = binArray;
+ end
+ catch
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ end
+ ERPwaviewer.Legend.data=legendset_str;
+
+ LegendfontColorAuto = gui_erplinset_waveviewer.font_colorauto.Value;
+ if LegendfontColorAuto==1
gui_erplinset_waveviewer.font_custom_type.Enable = 'off'; %
gui_erplinset_waveviewer.font_custom_size.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Enable = 'off';
gui_erplinset_waveviewer.legendtextcustom.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Value = 1;
gui_erplinset_waveviewer.legendtextcustom.Value = 0;
- gui_erplinset_waveviewer.legendcolumns.Value =1;
+ % gui_erplinset_waveviewer.legendcolumns.Value =1;
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
gui_erplinset_waveviewer.legendcolumns.Enable = 'off';
+ gui_erplinset_waveviewer.font_colorauto.Value=1;
+ gui_erplinset_waveviewer.font_colorcustom.Value = 0;
else
- gui_erplinset_waveviewer.legendauto.Value = 0;
- gui_erplinset_waveviewer.legendcustom.Value = 1;
- gui_erplinset_waveviewer.legend_customtable.Enable = 'on';
gui_erplinset_waveviewer.font_custom_type.Enable = 'on'; %
gui_erplinset_waveviewer.font_custom_size.Enable = 'on';
gui_erplinset_waveviewer.legendtextauto.Enable = 'on';
gui_erplinset_waveviewer.legendtextcustom.Enable = 'on';
gui_erplinset_waveviewer.legendcolumns.Enable = 'on';
+ gui_erplinset_waveviewer.font_colorauto.Value=0;
+ gui_erplinset_waveviewer.font_colorcustom.Value = 1;
end
- LegendData = ERPwaviewer.Legend.data;
- gui_erplinset_waveviewer.legend_customtable.Data = LegendData;
+
+
legendfont =ERPwaviewer.Legend.font;
gui_erplinset_waveviewer.font_custom_type.Value = legendfont;
legendfontsize = ERPwaviewer.Legend.fontsize;
@@ -949,6 +1091,19 @@ function count_loadproper_change(~,~)
columnStr{Numoflegend} = num2str(Numoflegend);
end
gui_erplinset_waveviewer.legendcolumns.String = columnStr;
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+
+ %%save the parameters to memory file
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
+
+ viewer_ERPDAT.loadproper_count =7;
end
%%-------------------------------------------------------------------------
@@ -978,7 +1133,7 @@ function Reset_Waviewer_panel_change(~,~)
disp('f_ERP_lineset_waveviewer_GUI error: Restart ERPwave Viewer');
return;
end
- %%Lines
+ %%-------------------------Lines-------------------------------
gui_erplinset_waveviewer.linesauto.Value =1;
gui_erplinset_waveviewer.linescustom.Value = 0;
gui_erplinset_waveviewer.line_customtable.Enable = 'off';
@@ -991,59 +1146,108 @@ function Reset_Waviewer_panel_change(~,~)
gui_erplinset_waveviewer.line_customtable.Data = lineset_str;
ERPwaviewerin.Lines.auto =1;
ERPwaviewerin.Lines.data = gui_erplinset_waveviewer.line_customtable.Data;
- %%Legends
- gui_erplinset_waveviewer.legendauto.Value = 1;
- gui_erplinset_waveviewer.legendcustom.Value = 0;
- gui_erplinset_waveviewer.legend_customtable.Enable = 'off';
+
+ %%-----------------------Legends-------------------------------
+ gui_erplinset_waveviewer.font_colorauto.Value =1;
+ gui_erplinset_waveviewer.font_colorcustom.Value =0;
+
gui_erplinset_waveviewer.font_custom_type.Enable = 'off'; %
gui_erplinset_waveviewer.font_custom_size.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Enable = 'off';
gui_erplinset_waveviewer.legendtextcustom.Enable = 'off';
gui_erplinset_waveviewer.legendtextauto.Value = 1;
gui_erplinset_waveviewer.legendtextcustom.Value = 0;
- gui_erplinset_waveviewer.legendcolumns.Value =1;
+ % gui_erplinset_waveviewer.legendcolumns.Value =1;
gui_erplinset_waveviewer.legendcolumns.Enable = 'off';
-
+ %
for ii = 1:100
LegendName{ii,1} = '';
LegendNamenum(ii,1) =ii;
end
- ALLERPIN = ERPwaviewerin.ALLERP;
+ ALLERP = ERPwaviewerin.ALLERP;
ERPsetArray = ERPwaviewerin.SelectERPIdx;
- if max(ERPsetArray(:))> length(ALLERPIN)
- ERPsetArray =length(ALLERPIN);
+ if max(ERPsetArray(:))> length(ALLERP)
+ ERPsetArray =length(ALLERP);
end
- [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERP,ERPsetArray);
+ LegendArray = [1:4];
try
plot_org = ERPwaviewerin.plot_org;
- ERPIN = ERPwaviewerin.ERP;
- if plot_org.Overlay ==2
+ if plot_org.Overlay ==1
+ ChanArray = ERPwaviewerin.chan;
+ for Numofchan = 1:numel(ChanArray)
+ LegendName{Numofchan,1} = char(chanStr(ChanArray(Numofchan)));
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray =ChanArray;
+ elseif plot_org.Overlay ==2
binArray = ERPwaviewerin.bin;
for Numofbin = 1:numel(binArray)
LegendName{Numofbin,1} = char(binStr(binArray(Numofbin)));
end
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
+ LegendArray =binArray;
+ elseif plot_org.Overlay ==3
+ for Numoferpset = 1:numel(ERPsetArray)
+ LegendName{Numoferpset,1} = char(ALLERP(ERPsetArray(Numoferpset)).erpname);
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray =ERPsetArray;
+ else
+ binArray = ERPwaviewerin.bin;
+ for Numofbin = 1:numel(binArray)
+ LegendName{Numofbin,1} = char(binStr(binArray(Numofbin)));
+ end
+ legendset_str = table(LegendNamenum,LegendName);
+ legendset_str = table2cell(legendset_str);
+ LegendArray =binArray;
end
catch
legendset_str = table(LegendNamenum,LegendName);
legendset_str = table2cell(legendset_str);
end
- gui_erplinset_waveviewer.legend_customtable.ColumnEditable = [false,true];
- gui_erplinset_waveviewer.legend_customtable.Data = legendset_str;
+
+ gui_erplinset_waveviewer.legendcolumns.Value =round(sqrt(length(LegendArray)));
gui_erplinset_waveviewer.font_custom_size.Value = 4;
- gui_erplinset_waveviewer.font_custom_type.Value =2;
- ERPwaviewerin.Legend.auto=1;
- ERPwaviewerin.Legend.data =gui_erplinset_waveviewer.legend_customtable.Data;
- ERPwaviewerin.Legend.font=1;
+ gui_erplinset_waveviewer.font_custom_type.Value =3;
+ ERPwaviewerin.Legend.data =legendset_str;
+ ERPwaviewerin.Legend.font=3;
ERPwaviewerin.Legend.fontsize=10;
ERPwaviewerin.Legend.textcolor=1;
ERPwaviewerin.Legend.columns=1;
+ ERPwaviewerin.Legend.FontColorAuto=1;
+
assignin('base','ALLERPwaviewer',ERPwaviewerin);
gui_erplinset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_erplinset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erplineset_viewer_property.TitleColor= [0.5 0.5 0.9];
+
+ MERPWaveViewer_linelegend{1}=gui_erplinset_waveviewer.linesauto.Value;
+ MERPWaveViewer_linelegend{2}= gui_erplinset_waveviewer.line_customtable.Data;
+ MERPWaveViewer_linelegend{3}=gui_erplinset_waveviewer.font_colorauto.Value;
+ MERPWaveViewer_linelegend{4}=gui_erplinset_waveviewer.font_custom_type.Value;
+ MERPWaveViewer_linelegend{5}=gui_erplinset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_linelegend{6}= gui_erplinset_waveviewer.legendtextauto.Value;
+ MERPWaveViewer_linelegend{7}=gui_erplinset_waveviewer.legendcolumns.Value;
+ estudioworkingmemory('MERPWaveViewer_linelegend',MERPWaveViewer_linelegend);%%save the parameters for this panel to memory file
+
viewer_ERPDAT.Reset_Waviewer_panel=7;
end
end
+
+ function line_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ LineLegend_apply();
+ estudioworkingmemory('MyViewer_linelegend',0);
+ gui_erplinset_waveviewer.apply.BackgroundColor = [1 1 1];
+ gui_erplinset_waveviewer.apply.ForegroundColor = [0 0 0];
+ box_erplineset_viewer_property.TitleColor= [0.5 0.5 0.9];
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_otherset_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_otherset_waveviewer_GUI.m
index 23fcd3a2..9bd5503b 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_otherset_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_otherset_waveviewer_GUI.m
@@ -5,13 +5,13 @@
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
-% 2022
+% 2022 && 2023
function varargout = f_ERP_otherset_waveviewer_GUI(varargin)
global viewer_ERPDAT;
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
% addlistener(viewer_ERPDAT,'Process_messg_change',@Process_messg_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
@@ -40,7 +40,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_otherset_waviewer(FonsizeDefault);
varargout{1} = box_erplabelset_viewer_otherset;
@@ -49,8 +49,7 @@ function drawui_otherset_waviewer(FonsizeDefault)
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer = ALLERPwaviewer;
+ ERPwaviewer = evalin('base','ALLERPwaviewer');
catch
beep;
disp('f_ERP_lineset_waveviewer_GUI() error: Please run the ERP wave viewer again.');
@@ -59,36 +58,67 @@ function drawui_otherset_waviewer(FonsizeDefault)
gui_otherset_waveviewer.DataSelBox = uiextras.VBox('Parent', box_erplabelset_viewer_otherset,'BackgroundColor',ColorBviewer_def);
%%----------Polarity Setting---------------------------------------
- Polaritylabel = 1;
+ MERPWaveViewer_others= estudioworkingmemory('MERPWaveViewer_others');%%call the parameters for this panel
+ try
+ Polaritylabel= MERPWaveViewer_others{1};
+ catch
+ Polaritylabel = 1;
+ MERPWaveViewer_others{1}=1;
+ end
+ if numel(Polaritylabel)~=1 || (Polaritylabel~=1 && Polaritylabel~=0)
+ MERPWaveViewer_others{1}=1;
+ Polaritylabel = 1;
+ end
+
gui_otherset_waveviewer.polarity_title = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_otherset_waveviewer.polarity_title,'String','Polarity',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %,'FontWeight','bold'
gui_otherset_waveviewer.polarity_up = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.polarity_title,'String','Positive up',...
'callback',@polarup,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',Polaritylabel); %,'FontWeight','bold'
+ gui_otherset_waveviewer.polarity_up.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.polarity_down = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.polarity_title,'String','Negative up',...
'callback',@polardown, 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~Polaritylabel); %,'FontWeight','bold'
+ gui_otherset_waveviewer.polarity_down.KeyPressFcn = @otherset_presskey;
set(gui_otherset_waveviewer.polarity_title,'Sizes',[50 90 90]);
ERPwaviewer.polarity=gui_otherset_waveviewer.polarity_up.Value;
%%----------------SEM of wave--------------------------------------
- SEMlabel = 0;
- SEMCustomValue = 0;
+ try
+ SEMlabel = MERPWaveViewer_others{2};
+ catch
+ MERPWaveViewer_others{2}=0;
+ SEMlabel = 0;
+ end
+ try
+ SEMCustomValue = MERPWaveViewer_others{3};
+ catch
+ MERPWaveViewer_others{3}=1;
+ SEMCustomValue = 1;
+ end
gui_otherset_waveviewer.SEM_title = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_otherset_waveviewer.show_SEM = uicontrol('Style','checkbox','Parent', gui_otherset_waveviewer.SEM_title ,'String','Show standard error',...
'callback',@showSEM,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',SEMlabel); %
+ gui_otherset_waveviewer.show_SEM.KeyPressFcn = @otherset_presskey;
SMEString = {'0','1','2','3','4','5','6','7','8','9','10'};
gui_otherset_waveviewer.SEM_custom = uicontrol('Style','popupmenu','Parent', gui_otherset_waveviewer.SEM_title ,'String',SMEString,...
'callback',@SEMerror,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',SEMCustomValue+1); %
+ gui_otherset_waveviewer.SEM_custom.KeyPressFcn = @otherset_presskey;
set(gui_otherset_waveviewer.SEM_title,'Sizes',[160 80]);
ERPwaviewer.SEM.active =gui_otherset_waveviewer.show_SEM.Value;
ERPwaviewer.SEM.error = gui_otherset_waveviewer.SEM_custom.Value-1;
- SEMtransValue = 0;
+ try
+ SEMtransValue= MERPWaveViewer_others{4};
+ catch
+ MERPWaveViewer_others{4}=0.2;
+ SEMtransValue = 0.2;
+ end
gui_otherset_waveviewer.SEMtrans_title = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_otherset_waveviewer.SEMtrans_title ,'String','transoarency',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','right'); %
SMEtransString = {'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7','0.8','0.9','1'};
gui_otherset_waveviewer.SEMtrans_custom = uicontrol('Style','popupmenu','Parent', gui_otherset_waveviewer.SEMtrans_title ,'String',SMEtransString,...
'callback',@SEMtrans,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',SEMtransValue*10 +1); %
+ gui_otherset_waveviewer.SEMtrans_custom.KeyPressFcn = @otherset_presskey;
set(gui_otherset_waveviewer.SEMtrans_title,'Sizes',[160 80]);
if SEMlabel
gui_otherset_waveviewer.SEM_custom.Enable = 'on';
@@ -100,12 +130,14 @@ function drawui_otherset_waviewer(FonsizeDefault)
ERPwaviewer.SEM.trans = (gui_otherset_waveviewer.SEMtrans_custom.Value-1)/10;
%%----------------baseline correction------------------------------
- blc_def = 'none';
try
- blc_def = ERPwaviewer.baselinecorr;
+ blc_def = MERPWaveViewer_others{5};
catch
blc_def = 'none';
+ MERPWaveViewer_others{5} = 'none';
end
+
+
if numel(blc_def) ==2
noneValue =0;
preValue =0;
@@ -139,7 +171,7 @@ function drawui_otherset_waviewer(FonsizeDefault)
customValue = 0;
customString = '';
customEnable = 'off';
- elseif strcmpi(blc_def,'whole')
+ elseif strcmpi(blc_def,'whole') || strcmpi(blc_def,'all')
noneValue =0;
preValue =0;
postValue = 0;
@@ -155,17 +187,23 @@ function drawui_otherset_waviewer(FonsizeDefault)
gui_otherset_waveviewer.bsl_title_1 = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_otherset_waveviewer.bsl_none = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.bsl_title_1 ,'String','None',...
'callback',@bsl_none,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',noneValue);
+ gui_otherset_waveviewer.bsl_none.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.bsl_pre = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.bsl_title_1 ,'String','Pre',...
'callback',@bsl_pre,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',preValue); %,'HorizontalAlignment','left','FontWeight','bold'
+ gui_otherset_waveviewer.bsl_pre.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.bsl_post = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.bsl_title_1 ,'String','Post',...
'callback',@bsl_post, 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',postValue); %,'HorizontalAlignment','left','FontWeight','bold'
+ gui_otherset_waveviewer.bsl_post.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.bsl_whole = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.bsl_title_1 ,'String','Whole',...
'callback',@bsl_whole, 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',wholeValue); %,'HorizontalAlignment','left','FontWeight','bold'
+ gui_otherset_waveviewer.bsl_whole.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.bsl_title_3 = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_otherset_waveviewer.bsl_custom = uicontrol('Style','radiobutton','Parent', gui_otherset_waveviewer.bsl_title_3 ,'String','Custom',...
'callback',@bsl_custom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',customValue); %,'HorizontalAlignment','left','FontWeight','bold'
+ gui_otherset_waveviewer.bsl_custom.KeyPressFcn = @otherset_presskey;
gui_otherset_waveviewer.bsl_customedit = uicontrol('Style','edit','Parent', gui_otherset_waveviewer.bsl_title_3 ,'String',customString,...
'callback',@bsl_customedit, 'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',customEnable); %,'HorizontalAlignment','left','FontWeight','bold'
+ gui_otherset_waveviewer.bsl_customedit.KeyPressFcn = @otherset_presskey;
set( gui_otherset_waveviewer.bsl_title_3,'Sizes',[80 155]);
if gui_otherset_waveviewer.bsl_none.Value ==1
@@ -177,18 +215,28 @@ function drawui_otherset_waviewer(FonsizeDefault)
elseif gui_otherset_waveviewer.bsl_whole.Value ==1
ERPwaviewer.baselinecorr = 'whole';
elseif gui_otherset_waveviewer.bsl_custom.Value ==1
- ERPwaviewer.baselinecorr = str2num(char(gui_otherset_waveviewer.bsl_customedit));
+ ERPwaviewer.baselinecorr = str2num(char(gui_otherset_waveviewer.bsl_customedit.String));
else
ERPwaviewer.baselinecorr = 'none';
end
%%Figure background color: the default is white
- bgColor = [1 1 1];
+ try
+ bgColor= MERPWaveViewer_others{6};
+ catch
+ bgColor = [1 1 1];
+ MERPWaveViewer_others{6} = [1 1 1];
+ end
+ if numel(bgColor)~=3 || max(bgColor(:))>1 || min(bgColor(:))<0
+ bgColor = [1 1 1];
+ MERPWaveViewer_others{6} = [1 1 1];
+ end
gui_otherset_waveviewer.figurebakcolor_title = uiextras.HBox('Parent', gui_otherset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_otherset_waveviewer.figurebakcolor_title,'String','Figure Background Color:',...
'FontSize',FonsizeDefault-1,'BackgroundColor',ColorBviewer_def,'FontWeight','bold'); %,'HorizontalAlignment','left'
gui_otherset_waveviewer.figurebakcolor = uicontrol('Style','edit','Parent', gui_otherset_waveviewer.figurebakcolor_title,'String',num2str(bgColor),...
'callback',@figbackcolor,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
+ gui_otherset_waveviewer.figurebakcolor.KeyPressFcn = @otherset_presskey;
set(gui_otherset_waveviewer.figurebakcolor_title,'Sizes',[150 85]);
ERPwaviewer.figbackgdcolor = str2num(gui_otherset_waveviewer.figurebakcolor.String);
@@ -205,8 +253,8 @@ function drawui_otherset_waviewer(FonsizeDefault)
set(gui_otherset_waveviewer.help_run_title,'Sizes',[40 70 20 70 20]);
set(gui_otherset_waveviewer.DataSelBox,'Sizes',[25 25 25 20 20 25 25 25]);
- ALLERPwaviewer=ERPwaviewer;
- assignin('base','ALLERPwaviewer',ALLERPwaviewer);
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+ estudioworkingmemory('MERPWaveViewer_others',MERPWaveViewer_others);
end
%%**************************************************************************%%
@@ -460,17 +508,17 @@ function figbackcolor(Str,~)
bgColor = str2num(Str.String);
if isempty(bgColor)
- msgboxText = strcat('Inputs are invalid and it should be,e.g., [1 1 1]');
- title = 'EStudio>ERP Wave Viewer>Other: Figure Background Color';
- errorfound(msgboxText, title);
+ viewer_ERPDAT.Process_messg =4;
+ msgboxText = strcat('Other > Figure Background Color: Inputs are invalid and it should be,e.g., [1 1 1]');
+ erpworkingmemory('ERPViewer_proces_messg',msgboxText);
Str.String = num2str([1 1 1]);
return;
end
if max(bgColor)>1 || min(bgColor) <0 || numel(bgColor)~=3
- msgboxText = strcat('Inputs are invalid and it should be,e.g., [1 1 1]');
- title = 'EStudio>ERP Wave Viewer>Other: Figure Background Color';
- errorfound(msgboxText, title);
+ viewer_ERPDAT.Process_messg =4;
+ msgboxText = strcat('Other > Figure Background Color: Inputs are invalid and it should be,e.g., [1 1 1]');
+ erpworkingmemory('ERPViewer_proces_messg',msgboxText);
Str.String = num2str([1 1 1]);
return;
end
@@ -482,9 +530,15 @@ function other_help(~,~)
if ~isempty(messgStr) && viewerpanelIndex~=7
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
+ MessageViewer= char(strcat('Other > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
changeFlag = estudioworkingmemory('MyViewer_other');
if changeFlag~=1
+ MessageViewer= char(strcat('Other > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
return;
end
@@ -535,7 +589,7 @@ function other_help(~,~)
gui_otherset_waveviewer.bsl_pre.Value=0;
gui_otherset_waveviewer.bsl_post.Value=1;
gui_otherset_waveviewer.bsl_whole.Value=0;
- elseif strcmpi(BslMethod,'whole')
+ elseif strcmpi(BslMethod,'whole') || strcmpi(BslMethod,'all')
gui_otherset_waveviewer.bsl_custom.Value =0;
gui_otherset_waveviewer.bsl_none.Value=0;
gui_otherset_waveviewer.bsl_pre.Value=0;
@@ -556,7 +610,9 @@ function other_help(~,~)
gui_otherset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_otherset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erplabelset_viewer_otherset.TitleColor= [0.5 0.5 0.9];
-
+ MessageViewer= char(strcat('Other > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
@@ -575,22 +631,26 @@ function other_apply(~,~)
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =1;
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer_apply = ALLERPwaviewer;
+ ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
viewer_ERPDAT.Process_messg =3;
fprintf(2,'\n Other > Apply-f_ERP_otherset_waveviewer_GUI() error: Cannot get parameters for whole panel.\n Please run My viewer again.\n\n');
return;
end
ERPwaviewer_apply.polarity = gui_otherset_waveviewer.polarity_up.Value;%% the polarity of wave
+ MERPWaveViewer_others{1} = ERPwaviewer_apply.polarity;
%%SME
ERPwaviewer_apply.SEM.active = gui_otherset_waveviewer.show_SEM.Value;
ERPwaviewer_apply.SEM.error = gui_otherset_waveviewer.SEM_custom.Value-1;
+ MERPWaveViewer_others{2} = ERPwaviewer_apply.SEM.active;
+ MERPWaveViewer_others{3} = ERPwaviewer_apply.SEM.error;
%%trans
ERPwaviewer_apply.SEM.trans = (gui_otherset_waveviewer.SEMtrans_custom.Value-1)/10;
- %%MGFP
- % ERPwaviewer_apply.MGFP = gui_otherset_waveviewer.MGFP_on.Value;
+ MERPWaveViewer_others{4} = ERPwaviewer_apply.SEM.trans;
+
+ %%baseline correction
ERPwaviewer_apply.figbackgdcolor = str2num(gui_otherset_waveviewer.figurebakcolor.String);
+ MERPWaveViewer_others{6} = ERPwaviewer_apply.figbackgdcolor;
%%baseline correction method
if gui_otherset_waveviewer.bsl_none.Value ==1
ERPwaviewer_apply.baselinecorr = 'none';
@@ -615,15 +675,17 @@ function other_apply(~,~)
else
ERPwaviewer_apply.baselinecorr = 'none';
end
- ALLERPwaviewer=ERPwaviewer_apply;
- assignin('base','ALLERPwaviewer',ALLERPwaviewer);
+ MERPWaveViewer_others{5} = ERPwaviewer_apply.baselinecorr;
+
+ assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
f_redrawERP_viewer_test();
viewer_ERPDAT.Process_messg =2;
+ estudioworkingmemory('MERPWaveViewer_others',MERPWaveViewer_others);
end
%%---------change this panel based on the loaded paras.--------------------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=7
return;
end
try
@@ -646,26 +708,34 @@ function count_loadproper_change(~,~)
%
%%SEM settings
SEMValue = ERPwaviewer_apply.SEM.active;
+ if isempty(SEMValue) || numel(SEMValue)~=1 || (SEMValue~=0 && SEMValue~=1)
+ SEMValue=0;
+ ERPwaviewer_apply.SEM.active=0;
+ end
if SEMValue==1
+ gui_otherset_waveviewer.show_SEM.Value =1;
gui_otherset_waveviewer.SEM_custom.Enable = 'on';
gui_otherset_waveviewer.SEMtrans_custom.Enable = 'on';
ERRORValue = ERPwaviewer_apply.SEM.error;
- if isempty(ERRORValue) || ERRORValue<0 || ERRORValue>10
- ERRORValue = 0;
- ERPwaviewer_apply.SEM.error = 0;
+ if isempty(ERRORValue) || ERRORValue<=0 || ERRORValue>10
+ ERRORValue = 1;
+ ERPwaviewer_apply.SEM.error = 1;
end
gui_otherset_waveviewer.SEM_custom.Value =ERRORValue+1;
SEMTrans = ERPwaviewer_apply.SEM.trans;
- if isempty(SEMTrans) || SEMTrans<0 || SEMTrans>1
- SEMTrans = 0;
- ERPwaviewer_apply.SEM.trans = 0;
+ if isempty(SEMTrans) || SEMTrans<=0 || SEMTrans>1
+ SEMTrans = 2;
+ ERPwaviewer_apply.SEM.trans = 0.2;
end
gui_otherset_waveviewer.SEMtrans_custom.Value = SEMTrans*10 +1;
else
+ gui_otherset_waveviewer.show_SEM.Value =0;
gui_otherset_waveviewer.SEM_custom.Enable = 'off';
gui_otherset_waveviewer.SEMtrans_custom.Enable = 'off';
gui_otherset_waveviewer.SEM_custom.Value =1;
gui_otherset_waveviewer.SEMtrans_custom.Value =1;
+ ERPwaviewer_apply.SEM.error = 0;
+ ERPwaviewer_apply.SEM.trans = 0;
end
%
@@ -705,7 +775,7 @@ function count_loadproper_change(~,~)
gui_otherset_waveviewer.bsl_whole.Value =0;
gui_otherset_waveviewer.bsl_custom.Value = 0;
gui_otherset_waveviewer.bsl_customedit.Enable = 'off';
- elseif strcmpi(BalineCorrection,'all')
+ elseif strcmpi(BalineCorrection,'all') || strcmpi(BalineCorrection,'whole')
gui_otherset_waveviewer.bsl_none.Value =0;
gui_otherset_waveviewer.bsl_pre.Value =0;
gui_otherset_waveviewer.bsl_post.Value =0;
@@ -736,6 +806,16 @@ function count_loadproper_change(~,~)
ERPwaviewer_apply.figbackgdcolor = BackgroundColor;
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ viewer_ERPDAT.loadproper_count =0;
+ %%save the reset parameters for this panel
+ MERPWaveViewer_others{1} = ERPwaviewer_apply.polarity;
+ MERPWaveViewer_others{2} = ERPwaviewer_apply.SEM.active;
+ MERPWaveViewer_others{3} = ERPwaviewer_apply.SEM.error;
+ MERPWaveViewer_others{4} = ERPwaviewer_apply.SEM.trans;
+ MERPWaveViewer_others{6} = ERPwaviewer_apply.figbackgdcolor;
+ MERPWaveViewer_others{5} = ERPwaviewer_apply.baselinecorr;
+ estudioworkingmemory('MERPWaveViewer_others',MERPWaveViewer_others);
+
end
@@ -775,12 +855,12 @@ function Reset_Waviewer_panel_change(~,~)
%%SME
gui_otherset_waveviewer.show_SEM.Value =0;
ERPwaviewerin.SEM.active = gui_otherset_waveviewer.show_SEM.Value;
- gui_otherset_waveviewer.SEM_custom.Value =1;
+ gui_otherset_waveviewer.SEM_custom.Value =2;
gui_otherset_waveviewer.SEM_custom.Enable = 'off';
ERPwaviewerin.SEM.error = gui_otherset_waveviewer.SEM_custom.Value-1;
%%trans
+ gui_otherset_waveviewer.SEMtrans_custom.Value =3;
ERPwaviewerin.SEM.trans = (gui_otherset_waveviewer.SEMtrans_custom.Value-1)/10;
- gui_otherset_waveviewer.SEMtrans_custom.Value =1;
gui_otherset_waveviewer.SEMtrans_custom.Enable = 'off';
gui_otherset_waveviewer.bsl_none.Value =1;
ERPwaviewerin.baselinecorr = 'none';
@@ -796,8 +876,29 @@ function Reset_Waviewer_panel_change(~,~)
gui_otherset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_otherset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erplabelset_viewer_otherset.TitleColor= [0.5 0.5 0.9];
- % viewer_ERPDAT.Reset_Waviewer_panel=3;
+
+ %%save the reset parameters for this panel
+ MERPWaveViewer_others{1} = ERPwaviewerin.polarity;
+ MERPWaveViewer_others{2} = ERPwaviewerin.SEM.active;
+ MERPWaveViewer_others{3} = ERPwaviewerin.SEM.error;
+ MERPWaveViewer_others{4} = ERPwaviewerin.SEM.trans;
+ MERPWaveViewer_others{6} = ERPwaviewerin.figbackgdcolor;
+ MERPWaveViewer_others{5} = ERPwaviewerin.baselinecorr;
+ estudioworkingmemory('MERPWaveViewer_others',MERPWaveViewer_others);
end
end
+
+ function otherset_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ other_apply();
+ estudioworkingmemory('MyViewer_other',0);
+ gui_otherset_waveviewer.apply.BackgroundColor = [1 1 1];
+ gui_otherset_waveviewer.apply.ForegroundColor = [0 0 0];
+ box_erplabelset_viewer_otherset.TitleColor= [0.5 0.5 0.9];
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_plotorg_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_plotorg_waveviewer_GUI.m
index e98e88e8..9abe70a5 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_plotorg_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_plotorg_waveviewer_GUI.m
@@ -13,7 +13,7 @@
global viewer_ERPDAT
addlistener(viewer_ERPDAT,'v_currentERP_change',@v_currentERP_change);
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
@@ -43,7 +43,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_plot_org(FonsizeDefault);
@@ -52,31 +52,74 @@
function drawui_plot_org(FonsizeDefault)
[version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewerin = ALLERPwaviewer;
+ ERPwaviewerin = evalin('base','ALLERPwaviewer');
+ ALLERP = ERPwaviewerin.ALLERP;
+ indexerp = ERPwaviewerin.SelectERPIdx;
catch
beep;
disp('f_ERP_plotorg_waveviewer_GUI() error: Please run the ERP wave viewer again.');
return;
end
+ for Numofselectederp = 1:numel(indexerp)
+ SrateNum_mp(Numofselectederp,1) = ALLERP(indexerp(Numofselectederp)).srate;
+ end
+
+ MERPWaveViewer_plotorg= estudioworkingmemory('MERPWaveViewer_plotorg');%%call the memery for this panel
+ try
+ plotorg_Index = MERPWaveViewer_plotorg{1};
+ catch
+ plotorg_Index=1;
+ MERPWaveViewer_plotorg{1}=1;
+ end
+ if isempty(plotorg_Index) || plotorg_Index<=0 || plotorg_Index>6
+ plotorg_Index=1;
+ MERPWaveViewer_plotorg{1}=1;
+ end
+
+ if numel(unique(SrateNum_mp))~=1 && (plotorg_Index~=1 && plotorg_Index~=3)
+ MessageViewer= char(strcat('Plot Organization - We will use "Channels,Bins, ERPsets" because Sampling rate varies across the selected ERPsets'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ plotorg_Index=1;
+ MERPWaveViewer_plotorg{1}=1;
+ end
+ if plotorg_Index==1
+ plotorg_Value = [1,0,0,0,0,0];
+ elseif plotorg_Index==2
+ plotorg_Value = [0,1,0,0,0,0];
+ elseif plotorg_Index==3
+ plotorg_Value = [0,0,1,0,0,0];
+ elseif plotorg_Index==4
+ plotorg_Value = [0,0,0,1,0,0];
+ elseif plotorg_Index==5
+ plotorg_Value = [0,0,0,0,1,0];
+ elseif plotorg_Index==6
+ plotorg_Value = [0,0,0,0,0,1];
+ end
gui_plotorg_waveviewer.DataSelBox = uiextras.VBox('Parent', box_erpwave_viewer_plotorg,'BackgroundColor',ColorBviewer_def);
%%--------------------grind overlay and pages----------------------
gui_plotorg_waveviewer.DataSelGrid = uiextras.Grid('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
% First column:
uiextras.Empty('Parent',gui_plotorg_waveviewer.DataSelGrid);
gui_plotorg_waveviewer.plotorg_c1 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c1,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',1); % 1B
+ 'callback',@plotorg_c1,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(1)); % 1B
+ gui_plotorg_waveviewer.plotorg_c1.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.plotorg_c2 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c2,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',0); % 1B
+ 'callback',@plotorg_c2,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(2)); % 1B
+ gui_plotorg_waveviewer.plotorg_c2.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.plotorg_c3 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c3,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',0); % 1B
+ 'callback',@plotorg_c3,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(3)); % 1B
+ gui_plotorg_waveviewer.plotorg_c3.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.plotorg_c4 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c4,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',0); % 1B
+ 'callback',@plotorg_c4,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(4)); % 1B
+ gui_plotorg_waveviewer.plotorg_c4.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.plotorg_c5 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c5,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',0); % 1B
+ 'callback',@plotorg_c5,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(5)); % 1B
+ gui_plotorg_waveviewer.plotorg_c5.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.plotorg_c6 = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','',...
- 'callback',@plotorg_c6,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',0); % 1B
+ 'callback',@plotorg_c6,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',plotorg_Value(6)); % 1B
+ gui_plotorg_waveviewer.plotorg_c6.KeyPressFcn = @plotorg_presskey;
% Second column:
uicontrol('Style','text','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','Grid',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'FontWeight','bold'); % 2A
@@ -124,24 +167,48 @@ function drawui_plot_org(FonsizeDefault)
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); % 3F
uicontrol('Style','text','Parent', gui_plotorg_waveviewer.DataSelGrid,'String','Channels',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); % 3G
-
set(gui_plotorg_waveviewer.DataSelGrid, 'ColumnSizes',[30 70 70 70],'RowSizes',[20 20 20 20 20 20 20]);
- ERPwaviewerin.plot_org.Grid = 1;
- ERPwaviewerin.plot_org.Overlay = 2;
- ERPwaviewerin.plot_org.Pages =3;
- gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
- %%----------------------Setting for grid layout--------------------
+ if gui_plotorg_waveviewer.plotorg_c1.Value ==1
+ GridValue=1; OverlayValue = 2; PageValue =3;
+ elseif gui_plotorg_waveviewer.plotorg_c2.Value ==1
+ GridValue=1; OverlayValue = 3; PageValue =2;
+ elseif gui_plotorg_waveviewer.plotorg_c3.Value ==1
+ GridValue=2; OverlayValue = 1; PageValue =3;
+ elseif gui_plotorg_waveviewer.plotorg_c4.Value ==1
+ GridValue=2; OverlayValue = 3; PageValue =1;
+ elseif gui_plotorg_waveviewer.plotorg_c5.Value ==1
+ GridValue=3; OverlayValue = 1; PageValue =2;
+ elseif gui_plotorg_waveviewer.plotorg_c6.Value ==1
+ GridValue=3; OverlayValue = 2; PageValue =1;
+ end
+ ERPwaviewerin.plot_org.Grid = GridValue;
+ ERPwaviewerin.plot_org.Overlay = OverlayValue;
+ ERPwaviewerin.plot_org.Pages =PageValue;
+ gui_plotorg_waveviewer.LayoutFlag = plotorg_Value;
+
+ %%----------------------Setting for grid layout-------------------
gui_plotorg_waveviewer.layout_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- gridlayoutValue = 1;
+ try
+ gridlayoutValue= MERPWaveViewer_plotorg{2};
+ catch
+ gridlayoutValue = 1;
+ MERPWaveViewer_plotorg{2}=1;
+ end
+ if isempty(gridlayoutValue) || numel(gridlayoutValue)~=1 || (gridlayoutValue~=0 &&gridlayoutValue~=1)
+ gridlayoutValue = 1;
+ MERPWaveViewer_plotorg{2}=1;
+ end
% First column:
- gui_plotorg_waveviewer.layout= uicontrol('Style','text','Parent', gui_plotorg_waveviewer.layout_title,'String','Grid Layout:',...
- 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
+ gui_plotorg_waveviewer.layout= uicontrol('Style','text','Parent', gui_plotorg_waveviewer.layout_title,'String','Grid Layout: ',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'FontWeight','bold'); %
set(gui_plotorg_waveviewer.layout,'HorizontalAlignment','left');
gui_plotorg_waveviewer.layout_auto = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.layout_title,'String','Auto',...
'callback',@layout_auto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',gridlayoutValue); %
+ gui_plotorg_waveviewer.layout_auto.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.layout_custom = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.layout_title,'String','Custom',...
'callback',@layout_custom,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',~gridlayoutValue); %
- set(gui_plotorg_waveviewer.layout_title, 'Sizes',[80 70 70]);
+ gui_plotorg_waveviewer.layout_custom.KeyPressFcn = @plotorg_presskey;
+ set(gui_plotorg_waveviewer.layout_title, 'Sizes',[90 60 70]);
ERPwaviewerin.plot_org.gridlayout.op = gui_plotorg_waveviewer.layout_auto.Value;
%%NUmber of rows and columns
@@ -153,17 +220,14 @@ function drawui_plot_org(FonsizeDefault)
ERPsetArray =length(ALLERPIN);
end
[chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
- GridValue = 1;
if GridValue ==1 %% if the selected Channel is "Grid"
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(chanArray)+1) = {'None'};
elseif GridValue == 2 %% if the selected Bin is "Grid"
plotArray = binArray;
plotArrayStr = binStr(binArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(binArray)+1) = {'None'};
elseif GridValue == 3%% if the selected ERPset is "Grid"
plotArray = ERPsetArray;
plotArrayStr = cell(numel(ERPsetArray),1);
@@ -171,20 +235,32 @@ function drawui_plot_org(FonsizeDefault)
plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
end
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(ERPsetArray)+1) = {'None'};
+
else
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(chanArray)+1) = {'None'};
end
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+
+
+ plotBoxdef = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ try
+ plotBox= MERPWaveViewer_plotorg{3};
+ catch
+ plotBox = plotBoxdef;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ end
+ if isempty(plotBox) || numel(plotBox)~=2 || min(plotBox(:))<1 || max(plotBox(:))>256
+ plotBox = plotBoxdef;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ end
try
Numrows = plotBox(1);
Numcolumns = plotBox(2);
catch
Numrows = 1;
Numcolumns = 1;
+ MERPWaveViewer_plotorg{3}=[1 1];
end
if gridlayoutValue==1
rowcolumnEnable = 'off';
@@ -200,10 +276,12 @@ function drawui_plot_org(FonsizeDefault)
'FontSize',FonsizeDefault-2,'BackgroundColor',ColorBviewer_def); % 1B
gui_plotorg_waveviewer.rownum = uicontrol('Style','popupmenu','Parent', gui_plotorg_waveviewer.row_column_title,'String',rowcolumnString,...
'callback',@plotorg_rownum,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',Numrows,'Enable',rowcolumnEnable); % 1B
+ gui_plotorg_waveviewer.rownum.KeyPressFcn = @plotorg_presskey;
uicontrol('Style','text','Parent', gui_plotorg_waveviewer.row_column_title,'String','Column(s)',...
'FontSize',FonsizeDefault-2,'BackgroundColor',ColorBviewer_def); % 1B
gui_plotorg_waveviewer.columnnum = uicontrol('Style','popupmenu','Parent', gui_plotorg_waveviewer.row_column_title,'String',rowcolumnString,...
'callback',@plotorg_columnnum,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',Numcolumns,'Enable',rowcolumnEnable); % 1B
+ gui_plotorg_waveviewer.columnnum.KeyPressFcn = @plotorg_presskey;
set(gui_plotorg_waveviewer.row_column_title, 'Sizes',[20 35 65 55 65]);
ERPwaviewerin.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
ERPwaviewerin.plot_org.gridlayout.columns =gui_plotorg_waveviewer.columnnum.Value;
@@ -214,7 +292,7 @@ function drawui_plot_org(FonsizeDefault)
for Numofcolumns = 1:Numcolumns
count = count +1;
if count> numel(plotArray)
- GridinforData{Numofrows,Numofcolumns} = char('None');
+ GridinforData{Numofrows,Numofcolumns} = '';
else
GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
@@ -223,18 +301,47 @@ function drawui_plot_org(FonsizeDefault)
ERPwaviewerin.plot_org.gridlayout.data =GridinforData;
columFormat = plotArrayFormt';
ERPwaviewerin.plot_org.gridlayout.columFormat = columFormat;
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig = columFormat;
-
+ % ERPwaviewerin.plot_org.gridlayout.columFormatOrig = columFormat;
%%---------------------Gap between rows----------------------------
- gui_plotorg_waveviewer.gridspace_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- uicontrol('Style','text','Parent', gui_plotorg_waveviewer.gridspace_title ,'String','Grid Spacing',...
- 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','center','FontWeight','bold'); %
- rowgapgtpValue = 1;
- RowGTPStr = '10';
- RowgapgtpEnable = 'off';
- if rowgapgtpValue==1 && ~gui_plotorg_waveviewer.layout_auto.Value
+ try
+ rowgapgtpValue= MERPWaveViewer_plotorg{4} ;
+ catch
+ rowgapgtpValue = 1;
+ MERPWaveViewer_plotorg{4}=1;
+ end
+ if isempty(rowgapgtpValue) || numel(rowgapgtpValue)~=1 || (rowgapgtpValue~=1 && rowgapgtpValue~=0)
+ MERPWaveViewer_plotorg{4}=1;
+ rowgapgtpValue = 1;
+ end
+ try
+ RowGTPStr= MERPWaveViewer_plotorg{5};
+ catch
+ RowGTPStr = 10;
+ MERPWaveViewer_plotorg{5}=10;
+ end
+ if rowgapgtpValue==1
RowgapgtpEnable = 'on';
+ RowgapOVERLAPEnable = 'off';
+ RowGTPStr = 10;
+ MERPWaveViewer_plotorg{5}=10;
+ else
+ RowgapgtpEnable = 'off';
+ RowgapOVERLAPEnable = 'on';
+ end
+ if gridlayoutValue==1
+ rowcolumnEnable = 'off';
+ RowGTPStr = 10;
+ MERPWaveViewer_plotorg{5}=10;
+ rowgapgtpValue = 1;
+ MERPWaveViewer_plotorg{4}=1;
+ RowgapgtpEnable = 'off';
+ else
+ rowcolumnEnable = 'on';
+ end
+ if isempty(RowGTPStr)|| numel(RowGTPStr)~=1 ||RowGTPStr<=0
+ RowGTPStr = 10;
+ MERPWaveViewer_plotorg{5}=10;
end
gui_plotorg_waveviewer.rowgap_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_plotorg_waveviewer.rowgap = uicontrol('Style','text','Parent', gui_plotorg_waveviewer.rowgap_title,'String','Row:',...
@@ -242,8 +349,10 @@ function drawui_plot_org(FonsizeDefault)
set(gui_plotorg_waveviewer.rowgap,'HorizontalAlignment','left');
gui_plotorg_waveviewer.rowgap_auto = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.rowgap_title,'String','Gap (%)',...
'callback',@rowgapgtpauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',rowgapgtpValue,'Enable',rowcolumnEnable); %
- gui_plotorg_waveviewer.rowgapGTPcustom = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.rowgap_title,'String',RowGTPStr,...
+ gui_plotorg_waveviewer.rowgap_auto.KeyPressFcn = @plotorg_presskey;
+ gui_plotorg_waveviewer.rowgapGTPcustom = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.rowgap_title,'String',num2str(RowGTPStr),...
'callback',@rowgapgtpcustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',RowgapgtpEnable); %
+ gui_plotorg_waveviewer.rowgapGTPcustom.KeyPressFcn = @plotorg_presskey;
if gui_plotorg_waveviewer.layout_auto.Value ==1
gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
end
@@ -251,80 +360,157 @@ function drawui_plot_org(FonsizeDefault)
ERPwaviewerin.plot_org.gridlayout.rowgap.GTPOP = gui_plotorg_waveviewer.rowgap_auto.Value;
ERPwaviewerin.plot_org.gridlayout.rowgap.GTPValue = str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
- RowgapOVERLAPEnable = 'off';
- if rowgapgtpValue==0 && ~gui_plotorg_waveviewer.layout_auto.Value
- RowgapOVERLAPEnable = 'on';
+ try
+ RowoverlayStr= MERPWaveViewer_plotorg{6};
+ catch
+ RowoverlayStr = 40;
+ MERPWaveViewer_plotorg{6}=40;
+ end
+ if isempty(RowoverlayStr) || numel(RowoverlayStr)~=1 || RowoverlayStr<=0 || RowoverlayStr>=100
+ MERPWaveViewer_plotorg{6}=40;
+ RowoverlayStr = 40;
+ end
+ if gridlayoutValue==1
+ RowgapOVERLAPEnable = 'off';
end
- RowoverlayStr = '40';
gui_plotorg_waveviewer.rowgapcustom_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uiextras.Empty('Parent',gui_plotorg_waveviewer.rowgapcustom_title);
gui_plotorg_waveviewer.rowoverlap = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.rowgapcustom_title,'String','Overlap (%)',...
'callback',@rowoverlap, 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Enable',rowcolumnEnable,'Value',~rowgapgtpValue); %
- gui_plotorg_waveviewer.rowgapoverlayedit = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.rowgapcustom_title,'String',RowoverlayStr,...
+ gui_plotorg_waveviewer.rowoverlap.KeyPressFcn = @plotorg_presskey;
+ gui_plotorg_waveviewer.rowgapoverlayedit = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.rowgapcustom_title,'String',num2str(RowoverlayStr),...
'callback',@rowoverlapcustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',RowgapOVERLAPEnable); %
+ gui_plotorg_waveviewer.rowgapoverlayedit.KeyPressFcn = @plotorg_presskey;
set(gui_plotorg_waveviewer.rowgapcustom_title, 'Sizes',[60 90 85]);
ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayOP = gui_plotorg_waveviewer.rowoverlap.Value;
ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayValue = str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
%%---------------------Gap between columns------------------------
- columngapgtpValue = 1;
- columnGTPStr = '';
- columngapgtpEnable = 'off';
+ try
+ columngapgtpValue= MERPWaveViewer_plotorg{7};
+ catch
+ columngapgtpValue = 1;
+ MERPWaveViewer_plotorg{7}=1;
+ end
+ if isempty(columngapgtpValue) || numel(columngapgtpValue)~=1 || (columngapgtpValue~=0 && columngapgtpValue~=1)
+ columngapgtpValue = 1;
+ MERPWaveViewer_plotorg{7}=1;
+ end
+ try
+ columnGTPStr = MERPWaveViewer_plotorg{8};
+ catch
+ columnGTPStr = 10;
+ MERPWaveViewer_plotorg{8} = 10;
+ end
+ if isempty(columnGTPStr) || numel(columnGTPStr)~=1 || columnGTPStr<0
+ columnGTPStr = 10;
+ MERPWaveViewer_plotorg{8} = 10;
+ end
+ if columngapgtpValue==1
+ columngapgtpEnable = 'on';
+ else
+ columngapgtpEnable = 'off';
+ end
+ if gridlayoutValue==1
+ columngapgtpEnable = 'off';
+ columnGTPStr = 10;
+ MERPWaveViewer_plotorg{8} = 10;
+ columngapgtpValue = 1;
+ MERPWaveViewer_plotorg{7}=1;
+ end
gui_plotorg_waveviewer.columngap_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_plotorg_waveviewer.columngap = uicontrol('Style','text','Parent', gui_plotorg_waveviewer.columngap_title,'String','Column:',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
set(gui_plotorg_waveviewer.columngap,'HorizontalAlignment','left');
gui_plotorg_waveviewer.columngapgtpop = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.columngap_title,'String','Gap (%)',...
- 'callback',@columngapgtpop,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',columngapgtpValue,'Enable',rowcolumnEnable); %
- gui_plotorg_waveviewer.columngapgtpcustom = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.columngap_title,'String',columnGTPStr,...
+ 'callback',@columngapgtpop,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',columngapgtpValue,...
+ 'Enable',rowcolumnEnable); %
+ gui_plotorg_waveviewer.columngapgtpop.KeyPressFcn = @plotorg_presskey;
+ gui_plotorg_waveviewer.columngapgtpcustom = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.columngap_title,'String',num2str(columnGTPStr),...
'callback',@columngapGTPcustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',columngapgtpEnable); %
+ gui_plotorg_waveviewer.columngapgtpcustom.KeyPressFcn = @plotorg_presskey;
if gui_plotorg_waveviewer.layout_auto.Value ==1
gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
end
set(gui_plotorg_waveviewer.columngap_title, 'Sizes',[60 90 85]);
ERPwaviewerin.plot_org.gridlayout.columngap.GTPOP = gui_plotorg_waveviewer.columngapgtpop.Value;
ERPwaviewerin.plot_org.gridlayout.columngap.GTPValue = str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
-
- columngapOVERLAPEnable = 'off';
- if columngapgtpValue==0 && ~gui_plotorg_waveviewer.layout_auto.Value
+ try
+ columnoverlayStr = MERPWaveViewer_plotorg{9};
+ catch
+ columnoverlayStr =40;
+ MERPWaveViewer_plotorg{9}=40;
+ end
+ if isempty(columnoverlayStr) || numel(columnoverlayStr)~=1 || columnoverlayStr<=0 || columnoverlayStr>=100
+ columnoverlayStr =40;
+ MERPWaveViewer_plotorg{9}=40;
+ end
+ if gridlayoutValue==1
+ columngapOVERLAPEnable = 'off';
+ else
columngapOVERLAPEnable = 'on';
end
- columnoverlayStr = '';
+
+ if gui_plotorg_waveviewer.layout_auto.Value
+ columngapOVERLAPEnable = 'off';
+ end
gui_plotorg_waveviewer.columngapcustom_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uiextras.Empty('Parent',gui_plotorg_waveviewer.columngapcustom_title);
gui_plotorg_waveviewer.columnoverlay = uicontrol('Style','radiobutton','Parent', gui_plotorg_waveviewer.columngapcustom_title,'String','Overlap (%)',...
'callback',@columnoverlap, 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Enable',rowcolumnEnable,'Value',~columngapgtpValue); %
- gui_plotorg_waveviewer.columngapoverlapedit = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.columngapcustom_title,'String',columnoverlayStr,...
+ gui_plotorg_waveviewer.columnoverlay.KeyPressFcn = @plotorg_presskey;
+
+ gui_plotorg_waveviewer.columngapoverlapedit = uicontrol('Style','edit','Parent', gui_plotorg_waveviewer.columngapcustom_title,'String',num2str(columnoverlayStr),...
'callback',@columnoverlaycustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',columngapOVERLAPEnable); %
+ gui_plotorg_waveviewer.columngapoverlapedit.KeyPressFcn = @plotorg_presskey;
set(gui_plotorg_waveviewer.columngapcustom_title, 'Sizes',[60 90 85]);
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayOP = gui_plotorg_waveviewer.columnoverlay.Value;
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayValue = str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
%%---------------help and apply the changed parameters-------------
- gui_plotorg_waveviewer.save_load_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- gui_plotorg_waveviewer.layout_custom_edit = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.save_load_title ,'String','Edit',...
- 'callback',@plotorg_edit,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',rowcolumnEnable); %,'HorizontalAlignment','left'
- % uiextras.Empty('Parent', gui_plotorg_waveviewer.save_load_title );
- gui_plotorg_waveviewer.layout_custom_load = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.save_load_title,'String','Load',...
+ try
+ layout_custom_editValue = MERPWaveViewer_plotorg{10};
+ catch
+ layout_custom_editValue=0;
+ end
+ if isempty(layout_custom_editValue) || numel(layout_custom_editValue)~=1 || (layout_custom_editValue~=1 && layout_custom_editValue~=0)
+ layout_custom_editValue=0;
+ end
+ layout_custom_editValue =0;
+ gui_plotorg_waveviewer.editgridlayout_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox = uicontrol('Style','checkbox','Parent', gui_plotorg_waveviewer.editgridlayout_title,'String','Custom Grid Locations',...
+ 'callback',@plotorg_edit_checkbox,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',layout_custom_editValue); %,'HorizontalAlignment','left'
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.KeyPressFcn = @plotorg_presskey;
+
+ gui_plotorg_waveviewer.layout_custom_edit = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.editgridlayout_title,'String','Edit',...
+ 'callback',@plotorg_edit,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
+ if gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value==1
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
+ else
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
+ set( gui_plotorg_waveviewer.editgridlayout_title,'Sizes',[150 60]);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ ERPwaviewerin.plot_org.gridlayout.GridLayoutAuto=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+
+ gui_plotorg_waveviewer.help_run_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+
+ gui_plotorg_waveviewer.layout_custom_load = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.help_run_title,'String','Load',...
'callback',@layout_custom_load,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
- % uiextras.Empty('Parent', gui_plotorg_waveviewer.save_load_title );
- gui_plotorg_waveviewer.layout_custom_save = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.save_load_title,'String','Save',...
+ gui_plotorg_waveviewer.layout_custom_save = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.help_run_title,'String','Save as',...
'callback',@layout_custom_save,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
- % uiextras.Empty('Parent', gui_plotorg_waveviewer.save_load_title );
- % set(gui_plotorg_waveviewer.save_load_title,'Sizes',[40 70 20 70 30]);
- gui_plotorg_waveviewer.help_run_title = uiextras.HBox('Parent', gui_plotorg_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
- uiextras.Empty('Parent', gui_plotorg_waveviewer.help_run_title );
gui_plotorg_waveviewer.cancel = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.help_run_title,'String','Cancel',...
'callback',@plotorg_cancel,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]);
- uiextras.Empty('Parent', gui_plotorg_waveviewer.help_run_title);
+ % gui_plotorg_waveviewer.apply.KeyPressFcn = @plotorg_presskey;
gui_plotorg_waveviewer.apply = uicontrol('Style','pushbutton','Parent', gui_plotorg_waveviewer.help_run_title,'String','Apply',...
'callback',@plotorg_apply,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
- uiextras.Empty('Parent', gui_plotorg_waveviewer.help_run_title);
- set(gui_plotorg_waveviewer.help_run_title,'Sizes',[40 70 20 70 30]);
- set(gui_plotorg_waveviewer.DataSelBox,'Sizes',[150 25 25 20 25 25 25 25 25 25]);
+ gui_plotorg_waveviewer.apply.KeyPressFcn = @plotorg_presskey;
+
+ set(gui_plotorg_waveviewer.DataSelBox,'Sizes',[150 25 25 25 25 25 25 25 25]);
gui_plotorg_waveviewer.columFormatStr = '';
assignin('base','ALLERPwaviewer',ERPwaviewerin);
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
end
@@ -352,12 +538,16 @@ function plotorg_c1(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -366,9 +556,8 @@ function plotorg_c1(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
gui_plotorg_waveviewer.plotorg_c1.Value = 1;
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -377,12 +566,32 @@ function plotorg_c1(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
-% if y_Flag==3
-% gui_plotorg_waveviewer.plotorg_c1.Value = 0;
-% end
-% return;
+
end
else
gui_plotorg_waveviewer.plotorg_c2.Enable = 'on';
@@ -403,10 +612,37 @@ function plotorg_c1(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ try
+ chanArray = ERPwaviewerin.chan;
+ plotArray = chanArray;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
- chanArray = ERPwaviewerin.chan;
- plotArray = chanArray;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -415,7 +651,6 @@ function plotorg_c1(source,~)
end
end
estudioworkingmemory('OverlayIndex',1);
-
end
%%-------------------------Setting for Overlay--------------------------------
@@ -438,12 +673,17 @@ function plotorg_c2(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
+
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -452,9 +692,8 @@ function plotorg_c2(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
gui_plotorg_waveviewer.plotorg_c1.Value = 1;
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -463,6 +702,30 @@ function plotorg_c2(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -475,7 +738,6 @@ function plotorg_c2(source,~)
gui_plotorg_waveviewer.plotorg_c6.Enable = 'on';
end
-
estudioworkingmemory('MyViewer_plotorg',1);
gui_plotorg_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560];
gui_plotorg_waveviewer.apply.ForegroundColor = [1 1 1];
@@ -488,10 +750,36 @@ function plotorg_c2(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [0,1,0,0,0,0];
-
chanArray = ERPwaviewerin.chan;
- plotArray = chanArray;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ try
+ plotArray = chanArray;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -499,6 +787,7 @@ function plotorg_c2(source,~)
catch
end
end
+
estudioworkingmemory('OverlayIndex',1);
end
@@ -522,12 +811,17 @@ function plotorg_c3(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
+
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -536,23 +830,42 @@ function plotorg_c3(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~=3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
- gui_plotorg_waveviewer.plotorg_c1.Value = 0;
- gui_plotorg_waveviewer.plotorg_c2.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c1.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c2.Value = 0;
gui_plotorg_waveviewer.plotorg_c3.Value = 0;
gui_plotorg_waveviewer.plotorg_c4.Value = 0;
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
-% if y_Flag==1
-% gui_plotorg_waveviewer.plotorg_c3.Value = 0;
-% end
-% return;
+
end
else
gui_plotorg_waveviewer.plotorg_c2.Enable = 'on';
@@ -573,9 +886,35 @@ function plotorg_c3(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,1,0,0,0];
-
- plotArray = ERPwaviewerin.bin;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ try
+ plotArray = ERPwaviewerin.bin;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
+ if GridValueOld~=2
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -583,6 +922,7 @@ function plotorg_c3(source,~)
catch
end
end
+
estudioworkingmemory('OverlayIndex',1);
end
@@ -608,12 +948,17 @@ function plotorg_c4(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -622,9 +967,8 @@ function plotorg_c4(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
gui_plotorg_waveviewer.plotorg_c1.Value = 1;
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -633,6 +977,29 @@ function plotorg_c4(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
gui_plotorg_waveviewer.plotorg_c4.Value = 0;
@@ -645,7 +1012,6 @@ function plotorg_c4(source,~)
gui_plotorg_waveviewer.plotorg_c6.Enable = 'on';
end
-
estudioworkingmemory('MyViewer_plotorg',1);
gui_plotorg_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560];
gui_plotorg_waveviewer.apply.ForegroundColor = [1 1 1];
@@ -658,9 +1024,36 @@ function plotorg_c4(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,1,0,0];
+ try
+ plotArray = ERPwaviewerin.bin;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
+ if GridValueOld~=2
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
- plotArray = ERPwaviewerin.bin;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -669,6 +1062,8 @@ function plotorg_c4(source,~)
end
end
estudioworkingmemory('OverlayIndex',1);
+
+
end
@@ -693,12 +1088,16 @@ function plotorg_c5(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -707,17 +1106,39 @@ function plotorg_c5(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
- gui_plotorg_waveviewer.plotorg_c1.Value = 0;
- gui_plotorg_waveviewer.plotorg_c2.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c1.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c2.Value = 0;
gui_plotorg_waveviewer.plotorg_c3.Value = 0;
gui_plotorg_waveviewer.plotorg_c4.Value = 0;
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
@@ -742,9 +1163,36 @@ function plotorg_c5(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 1;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,1,0];
-
- plotArray = indexerp;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ try
+ plotArray = indexerp;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
+ if GridValueOld~=3
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+
+ end
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -753,6 +1201,7 @@ function plotorg_c5(source,~)
end
end
estudioworkingmemory('OverlayIndex',1);
+
end
@@ -777,12 +1226,16 @@ function plotorg_c6(source,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
+ try
+ GridValueOld = ERPwaviewerin.plot_org.Grid;
+ catch
+ GridValueOld=1;
+ end
LayoutFlag = gui_plotorg_waveviewer.LayoutFlag;
[~,y_Flag] = find(LayoutFlag==1);
if length(unique(SrateNum_mp))~=1
@@ -791,17 +1244,41 @@ function plotorg_c6(source,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options (see Command Window)'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets. Please select the first or third options'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
- gui_plotorg_waveviewer.plotorg_c1.Value = 0;
- gui_plotorg_waveviewer.plotorg_c2.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c1.Value = 1;
+ gui_plotorg_waveviewer.plotorg_c2.Value = 0;
gui_plotorg_waveviewer.plotorg_c3.Value = 0;
gui_plotorg_waveviewer.plotorg_c4.Value = 0;
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ if GridValueOld~=1
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
return;
else
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
@@ -827,9 +1304,35 @@ function plotorg_c6(source,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 1;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,0,1];
-
- plotArray = indexerp;
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ if GridValueOld~=3
+ gui_plotorg_waveviewer.layout_auto.Value =1;
+ gui_plotorg_waveviewer.layout_custom.Value = 0;
+ gui_plotorg_waveviewer.rownum.Enable = 'off';
+ gui_plotorg_waveviewer.columnnum.Enable = 'off';
+
+ gui_plotorg_waveviewer.rowgap_auto.Value = 1;
+ gui_plotorg_waveviewer.rowgap_auto.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
+ gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'off';
+ gui_plotorg_waveviewer.rowoverlap.Value = 0;
+ gui_plotorg_waveviewer.rowoverlap.Enable = 'off';
+ gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpop.Value = 1;
+ gui_plotorg_waveviewer.columngapgtpop.Enable = 'off';
+ gui_plotorg_waveviewer.columngapgtpcustom.String = '10';
+ gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
+ gui_plotorg_waveviewer.columnoverlay.Value = 0;
+ gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
+ gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
+ try
+ plotArray = indexerp;
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ catch
+ plotBox = [1 1];
+ end
if gui_plotorg_waveviewer.layout_auto.Value==1
try
gui_plotorg_waveviewer.rownum.Value = plotBox(1);
@@ -854,7 +1357,6 @@ function layout_auto(~,~)
gui_plotorg_waveviewer.layout_auto.Value =1;
gui_plotorg_waveviewer.layout_custom.Value = 0;
- gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
gui_plotorg_waveviewer.rownum.Enable = 'off';
gui_plotorg_waveviewer.columnnum.Enable = 'off';
@@ -872,79 +1374,8 @@ function layout_auto(~,~)
gui_plotorg_waveviewer.columnoverlay.Value = 0;
gui_plotorg_waveviewer.columnoverlay.Enable = 'off';
gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'off';
- try
- ERPwaviewerin = evalin('base','ALLERPwaviewer');
- catch
- beep;
- disp('f_ERP_plotorg_waveviewer_GUI() error: Please run the ERP wave viewer again.');
- return;
- end
- binArray = ERPwaviewerin.bin;
- chanArray = ERPwaviewerin.chan;
- ERPsetArray = ERPwaviewerin.SelectERPIdx;
- ALLERPIN = ERPwaviewerin.ALLERP;
- if max(ERPsetArray) >length(ALLERPIN)
- ERPsetArray =length(ALLERPIN);
- end
- if gui_plotorg_waveviewer.plotorg_c3.Value ==1 || gui_plotorg_waveviewer.plotorg_c4.Value ==1
- GridValue=2;
- elseif gui_plotorg_waveviewer.plotorg_c5.Value==1 || gui_plotorg_waveviewer.plotorg_c6.Value ==1
- GridValue=3;
- else
- GridValue=1;
- end
- [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
- if GridValue ==1 %% if the selected Channel is "Grid"
- plotArray = chanArray;
- plotArrayStr = chanStr(chanArray);
- plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
- elseif GridValue == 2 %% if the selected Bin is "Grid"
- plotArray = binArray;
- plotArrayStr = binStr(binArray);
- plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
- elseif GridValue == 3%% if the selected ERPset is "Grid"
- plotArray = ERPsetArray;
- for Numoferpset = 1:numel(ERPsetArray)
- plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
- end
- plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
- else
- plotArray = chanArray;
- plotArrayStr = chanStr(chanArray);
- plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
- end
- plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
- Numrows = plotBox(1);
- Numcolumns=plotBox(2);
- try
- gui_plotorg_waveviewer.rownum.Value = plotBox(1);
- gui_plotorg_waveviewer.columnnum.Value = plotBox(2);
- catch
- return;
- end
- GridinforData = '';
- count = 0;
- for Numofrows = 1:Numrows
- for Numofcolumns = 1:Numcolumns
- count = count +1;
- if count> numel(plotArray)
- GridinforData{Numofrows,Numofcolumns} = char('None');
- else
- GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
- end
- end
- end
- ERPwaviewerin.plot_org.gridlayout.data =GridinforData;
- ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormt';
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig = plotArrayFormt';
- gui_plotorg_waveviewer.columFormatStr = '';
- % assignin('base','ALLERPwaviewer',ERPwaviewerin);
end
@@ -962,7 +1393,6 @@ function layout_custom(~,~)
gui_plotorg_waveviewer.layout_custom.Value = 1;
gui_plotorg_waveviewer.rownum.Enable = 'on';
gui_plotorg_waveviewer.columnnum.Enable = 'on';
- gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
gui_plotorg_waveviewer.rowgap_auto.Enable = 'on';
gui_plotorg_waveviewer.rowgapGTPcustom.Enable = 'on';
@@ -1062,6 +1492,9 @@ function rowgapgtpcustom(Source,~)
box_erpwave_viewer_plotorg.TitleColor= [0.4940 0.1840 0.5560];
rowgap = str2num(Source.String);
if isempty(rowgap) || numel(rowgap)~=1 || rowgap<=0
+ MessageViewer= char(strcat('Plot Organization > Row > Gap should be larger than 0'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
Source.String = '10';
return;
end
@@ -1096,6 +1529,10 @@ function rowoverlapcustom(Source,~)
box_erpwave_viewer_plotorg.TitleColor= [0.4940 0.1840 0.5560];
rowoverlay = str2num(Source.String);
if isempty(rowoverlay) || numel(rowoverlay)~=1 || rowoverlay<=0 || rowoverlay>=100
+ MessageViewer= char(strcat('Plot Organization > Column > Overlap should be larger than 0 and smaller than 100'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+
Source.String = '40';
return;
end
@@ -1130,6 +1567,9 @@ function columngapGTPcustom(Source,~)
box_erpwave_viewer_plotorg.TitleColor= [0.4940 0.1840 0.5560];
columngap = str2num(Source.String);
if isempty(columngap) || numel(columngap)~=1 || columngap<=0
+ MessageViewer= char(strcat('Plot Organization > Column > Gap should be larger than 0'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
Source.String = '10';
return;
end
@@ -1152,7 +1592,6 @@ function columnoverlap(Source,~)
gui_plotorg_waveviewer.columngapgtpcustom.Enable = 'off';
gui_plotorg_waveviewer.columnoverlay.Value=1;
gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'on';
- % Source.String = '40';
if isempty(colnOverlay)
gui_plotorg_waveviewer.columngapoverlapedit.String = '40';
end
@@ -1177,10 +1616,99 @@ function columnoverlaycustom(Source,~)
end
end
+
+
+%%
+ function plotorg_edit_checkbox(Source,~)
+ [messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
+ if ~isempty(messgStr) %% && viewerpanelIndex~=4
+ viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
+ end
+ estudioworkingmemory('MyViewer_plotorg',1);
+ gui_plotorg_waveviewer.apply.BackgroundColor = [0.4940 0.1840 0.5560];
+ gui_plotorg_waveviewer.apply.ForegroundColor = [1 1 1];
+ box_erpwave_viewer_plotorg.TitleColor= [0.4940 0.1840 0.5560];
+ if Source.Value==1
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
+ else
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ end
+
+
+ if Source.Value==0
+ try
+ ERPwaviewerin = evalin('base','ALLERPwaviewer');
+ catch
+ beep;
+ disp('f_ERP_plotorg_waveviewer_GUI() error: Please run the ERP wave viewer again.');
+ return;
+ end
+ binArray = ERPwaviewerin.bin;
+ chanArray = ERPwaviewerin.chan;
+ ERPsetArray = ERPwaviewerin.SelectERPIdx;
+ ALLERPIN = ERPwaviewerin.ALLERP;
+ if max(ERPsetArray) >length(ALLERPIN)
+ ERPsetArray =length(ALLERPIN);
+ end
+ if gui_plotorg_waveviewer.plotorg_c3.Value ==1 || gui_plotorg_waveviewer.plotorg_c4.Value ==1
+ GridValue=2;
+ elseif gui_plotorg_waveviewer.plotorg_c5.Value==1 || gui_plotorg_waveviewer.plotorg_c6.Value ==1
+ GridValue=3;
+ else
+ GridValue=1;
+ end
+
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ if GridValue ==1 %% if the selected Channel is "Grid"
+ plotArray = chanArray;
+ plotArrayStr = chanStr(chanArray);
+ elseif GridValue == 2 %% if the selected Bin is "Grid"
+ plotArray = binArray;
+ plotArrayStr = binStr(binArray);
+ elseif GridValue == 3%% if the selected ERPset is "Grid"
+ plotArray = ERPsetArray;
+ for Numoferpset = 1:numel(ERPsetArray)
+ plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
+ end
+ else
+ plotArray = chanArray;
+ plotArrayStr = chanStr(chanArray);
+ end
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ Numrows = plotBox(1);
+ Numcolumns=plotBox(2);
+ try
+ gui_plotorg_waveviewer.rownum.Value = plotBox(1);
+ gui_plotorg_waveviewer.columnnum.Value = plotBox(2);
+ catch
+ return;
+ end
+ GridinforData = '';
+ count = 0;
+ for Numofrows = 1:Numrows
+ for Numofcolumns = 1:Numcolumns
+ count = count +1;
+ if count> numel(plotArray)
+ GridinforData{Numofrows,Numofcolumns} = '';
+ else
+ GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
+ end
+ end
+ end
+ ERPwaviewerin.plot_org.gridlayout.data = GridinforData;
+ ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayStr';
+ ERPwaviewerin.plot_org.gridlayout.GridLayoutAuto = 0;
+ assignin('base','ALLERPwaviewer',ERPwaviewerin);
+ end
+ end
+
%%-----------------Edit the layout-----------------------------------------
- function plotorg_edit(~,~)
+ function plotorg_edit(Source,~)
+ if Source.Value==0
+ return;
+ end
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
- if ~isempty(messgStr) && viewerpanelIndex~=4
+ if ~isempty(messgStr) %% && viewerpanelIndex~=4
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
estudioworkingmemory('MyViewer_plotorg',1);
@@ -1188,7 +1716,7 @@ function plotorg_edit(~,~)
gui_plotorg_waveviewer.apply.ForegroundColor = [1 1 1];
box_erpwave_viewer_plotorg.TitleColor= [0.4940 0.1840 0.5560];
- MessageViewer= char(strcat('Plot Organization > Edit'));
+ MessageViewer= char(strcat('Plot Organization > Custom Grid Locations > Edit'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =1;
try
@@ -1198,32 +1726,9 @@ function plotorg_edit(~,~)
fprintf(2,'\n f_ERP_plotorg_waveviewer_GUI()> plotorg_edit() error: Cannot get parameters for whole panel.\n Please run My viewer again.\n\n');
return;
end
- ERPwaviewerin.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
- ERPwaviewerin.plot_org.gridlayout.columns = gui_plotorg_waveviewer.columnnum.Value;
- assignin('base','ALLERPwaviewer',ERPwaviewerin);
-
columFormat = ERPwaviewerin.plot_org.gridlayout.columFormat;
- if isempty(gui_plotorg_waveviewer.columFormatStr)
- for ii = 1:length(columFormat)-1
- columFormatin{ii,1} = columFormat{ii};
- end
- else
- columFormatStr = gui_plotorg_waveviewer.columFormatStr;
- for ii = 1:length(columFormat)-1
- if ii < length(columFormatStr)
- try
- columFormatin{ii,1} = columFormatStr{ii};
- catch
- columFormatin{ii,1} = columFormat{ii};
- end
- else
- columFormatin{ii,1} = columFormat{ii};
- end
- end
- end
- plotArrayFormtOlder = ERPwaviewerin.plot_org.gridlayout.columFormatOrig;
plotBox(1) = ERPwaviewerin.plot_org.gridlayout.rows;
plotBox(2) = ERPwaviewerin.plot_org.gridlayout.columns;
try
@@ -1231,99 +1736,88 @@ function plotorg_edit(~,~)
catch
GridinforData = [];
end
- def = ERP_layoutstringGUI(columFormatin,plotArrayFormtOlder,plotBox,GridinforData);
- if isempty(def)
- disp('User selected cancel');
- return;
- end
- TableDataDf = def{1};
- columFormat = def{2};
- [NumRows,NumColumns] = size(TableDataDf);
- GridposArray = zeros(NumRows,NumColumns);
- for Numofrows = 1:NumRows
- for Numofcolumns = 1:NumColumns
- SingleStr = char(TableDataDf{Numofrows,Numofcolumns});
- [C,IA] = ismember_bc2(SingleStr,columFormat);
- if C ==1
- if IA < length(columFormat)
- GridposArray(Numofrows,Numofcolumns) = IA;
- elseif IA == length(columFormat) %%%If the element is 'None'
- GridposArray(Numofrows,Numofcolumns) = 0;
- end
- else
- GridposArray(Numofrows,Numofcolumns) = 0;
- end
- end
- end
- GridposArrayMarker = cell(NumRows,NumColumns);
- for Numofrows = 1:NumRows
- for Numofcolumns = 1:NumColumns
- CellNum = GridposArray(Numofrows,Numofcolumns);
- [xRow,yColumn] = find(GridposArray==CellNum);
- if CellNum > 0 && ~isempty(xRow) && numel(yColumn)>1
- GridposArrayMarker{Numofrows,Numofcolumns} = [xRow,yColumn];
- end
- end
+
+
+ ERPsetArray = ERPwaviewerin.SelectERPIdx;
+ ALLERPIN = ERPwaviewerin.ALLERP;
+ if max(ERPsetArray) >length(ALLERPIN)
+ ERPsetArray =length(ALLERPIN);
end
- try %% try to display the reminder for the repeated items if they exist
- msgboxTextAll = '';
- for Numofrows = 1:NumRows
- for Numofcolumns = 1:NumColumns
- CellNum = GridposArray(Numofrows,Numofcolumns);
- SingleCellMarker = GridposArrayMarker{Numofrows,Numofcolumns};
- if ~isempty(SingleCellMarker)
- xRow = SingleCellMarker(:,1);
- yColumn = SingleCellMarker(:,2);
- msgboxText = [num2str(numel(yColumn)),32,'"',columFormat{CellNum},'"',32, 'are defined and they are at',32,];
- Location = char(strcat('(R',num2str(xRow(1)),',','C',num2str(yColumn(1)),')'));
- for Numofreapt = 2:numel(yColumn)
- if Numofreapt==numel(yColumn)
- Location = char(strcat(Location,', and',32,'(R',num2str(xRow(Numofreapt)),',','C',num2str(yColumn(Numofreapt)),').'));
- else
- Location = char(strcat(Location,',',32,'(R',num2str(xRow(Numofreapt)),',','C',num2str(yColumn(Numofreapt)),')'));
- end
- end
- for Numofmarker = 2:numel(xRow)
- GridposArrayMarker{xRow(Numofmarker),yColumn(Numofmarker)} = '';
- end
- if isempty(msgboxTextAll)
- msgboxTextAll = strcat('%s\n',msgboxText,32,Location);
- else
- msgboxTextAll = strcat(msgboxTextAll,'\n',msgboxText,32,Location);
- end
- end
- end
+ GridValue= ERPwaviewerin.plot_org.Grid;
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
+ if GridValue ==1 %% if the selected Channel is "Grid"
+ AllabelArray = chanStr;
+ elseif GridValue == 2 %% if the selected Bin is "Grid"
+ AllabelArray = binStr;
+ elseif GridValue == 3%% if the selected ERPset is "Grid"
+ for ii = 1:length(ALLERPIN)
+ AllabelArray(ii,1) ={char(ALLERPIN(ii).erpname)};
end
- catch
-
- end
-
- button = 'Apply';
- if ~isempty(msgboxTextAll)
- question = ['Do you want to use these repeated items?'];
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- title = 'EStudio Reminder: My Viewer > Plot organization > Edit';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf([msgboxTextAll],question), title,'No', 'Yes','Yes');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+ else
+ AllabelArray = chanStr;
end
- if isempty(button) || strcmpi(button,'No')
+ def = ERP_layoutstringGUI(columFormat,GridinforData,plotBox,AllabelArray);
+ if isempty(def)
+ estudioworkingmemory('MyViewer_plotorg',0);
+ gui_plotorg_waveviewer.apply.BackgroundColor = [1,1,1];
+ box_erpwave_viewer_plotorg.TitleColor= [0.5 0.5 0.9];
+ gui_plotorg_waveviewer.apply.ForegroundColor = [0 0 0];
+ disp('User selected cancel');
return;
end
+ TableDataDf = def{1};
+ ERPwaviewerin.plot_org.gridlayout.rows = size(TableDataDf,1);
+ ERPwaviewerin.plot_org.gridlayout.columns =size(TableDataDf,2);
+ gui_plotorg_waveviewer.rownum.Value =size(TableDataDf,1);
+ gui_plotorg_waveviewer.columnnum.Value =size(TableDataDf,2);
try
- ERPwaviewerin = evalin('base','ALLERPwaviewer');
+ columFormatout = def{2};
catch
- beep;
- disp('f_ERP_plotorglayout_waveviewer_GUI() error: Please run the ERP wave viewer again.');
- return;
+ columFormatout = columFormat;
end
- ERPwaviewerin.plot_org.gridlayout.columFormat = columFormat;
- gui_plotorg_waveviewer.columFormatStr = columFormat;
+ gui_plotorg_waveviewer.columFormatStr = columFormatout;
+ ERPwaviewerin.plot_org.gridlayout.columFormat = columFormatout;
ERPwaviewerin.plot_org.gridlayout.data =TableDataDf;
+ if ERPwaviewerin.plot_org.Grid==1
+ try
+ ERPwaviewerin.chan = def{3};
+ catch
+ end
+ MERPWaveViewer_plotorg{1}=1;
+ elseif ERPwaviewerin.plot_org.Grid==2
+ try
+ ERPwaviewerin.bin = def{3};
+ catch
+ end
+ MERPWaveViewer_plotorg{1}=2;
+ elseif ERPwaviewerin.plot_org.Grid==3
+ try
+ ERPwaviewerin.SelectERPIdx = def{3};
+ catch
+ end
+ if ERPwaviewerin.PageIndex> numel(ERPwaviewerin.SelectERPIdx)
+ ERPwaviewerin.PageIndex=1;
+ end
+ MERPWaveViewer_plotorg{1}=3;
+ end
assignin('base','ALLERPwaviewer',ERPwaviewerin);
+
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
+ viewer_ERPDAT.ERPset_Chan_bin_label=1;
+
f_redrawERP_viewer_test();
estudioworkingmemory('MyViewer_plotorg',0);
gui_plotorg_waveviewer.apply.BackgroundColor = [1,1,1];
@@ -1332,8 +1826,14 @@ function plotorg_edit(~,~)
end
+
+
%%-------load the saved parameters for plotting organization---------------
function layout_custom_load(~,~)
+ MessageViewer= char(strcat('Plot Organization > Load'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
if ~isempty(messgStr) && viewerpanelIndex~=4
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
@@ -1354,12 +1854,46 @@ function layout_custom_load(~,~)
return;
end
try
- ERPwaviewerin = evalin('base','ALLERPwaviewer');
+ ERPwaviewerin = evalin('base','ALLERPwaviewer');
+ catch
+ beep;
+ disp('f_ERP_plotorg_waveviewer_GUI() > layout_custom_load() error: Please run the ERP wave viewer again.');
+ return;
+ end
+
+ %%check current version
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
+ try
+ [version1 reldate] = geterplabstudioversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ else
+ try
+ [version1 reldate] = geterplabversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ end
+ erplabstudioverNum = str2num(erplabstudiover);
+ try
+ erplabstudioverNumOld = str2num(Plot_orgpar.version);
catch
- beep;
- disp('f_ERP_plotorg_waveviewer_GUI() > layout_custom_load() error: Please run the ERP wave viewer again.');
- return;
+ erplabstudioverNumOld = [];
end
+ if isempty(erplabstudioverNumOld) || erplabstudioverNumOld Load - This settings file was created using an older version of EStudio'));
+ elseif strcmpi(ERPtooltype,'ERPLAB')
+ MessageViewer= char(strcat('Plot Organization > Load - This settings file was created using an older version of ERPLAB'));
+ end
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+
try
GridValue = Plot_orgpar.Grid;
OverlayValue = Plot_orgpar.Overlay;
@@ -1385,9 +1919,8 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if PageValue~= 3
- MessageViewer= char(strcat('Warning: Sampling rate varies across ERPsets. We used the first option. (see Command Window)'));
+ MessageViewer= char(strcat('Plot Organization > Load - Sampling rate varies across ERPsets. We used the first option'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
GridValue = 1;OverlayValue = 2;PageValue=3;
end
@@ -1406,6 +1939,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =0;
gui_plotorg_waveviewer.plotorg_c6.Value =0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ MERPWaveViewer_plotorg{1}=1;
elseif GridValue==1 && OverlayValue == 3&& PageValue ==2
gui_plotorg_waveviewer.plotorg_c1.Value =0;
gui_plotorg_waveviewer.plotorg_c2.Value =1;
@@ -1414,6 +1948,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =0;
gui_plotorg_waveviewer.plotorg_c6.Value =0;
gui_plotorg_waveviewer.LayoutFlag = [0,1,0,0,0,0];
+ MERPWaveViewer_plotorg{1}=2;
elseif GridValue==2 && OverlayValue == 1 && PageValue ==3
gui_plotorg_waveviewer.plotorg_c1.Value =0;
gui_plotorg_waveviewer.plotorg_c2.Value =0;
@@ -1422,6 +1957,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =0;
gui_plotorg_waveviewer.plotorg_c6.Value =0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,1,0,0,0];
+ MERPWaveViewer_plotorg{1}=3;
elseif GridValue==2 && OverlayValue == 3 && PageValue ==1
gui_plotorg_waveviewer.plotorg_c1.Value =0;
gui_plotorg_waveviewer.plotorg_c2.Value =0;
@@ -1430,6 +1966,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =0;
gui_plotorg_waveviewer.plotorg_c6.Value =0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,1,0,0];
+ MERPWaveViewer_plotorg{1}=4;
elseif GridValue==3 && OverlayValue == 1 && PageValue ==2
gui_plotorg_waveviewer.plotorg_c1.Value =0;
gui_plotorg_waveviewer.plotorg_c2.Value =0;
@@ -1438,6 +1975,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =1;
gui_plotorg_waveviewer.plotorg_c6.Value =0;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,1,0];
+ MERPWaveViewer_plotorg{1}=5;
elseif GridValue==3 && OverlayValue == 2 && PageValue ==1
gui_plotorg_waveviewer.plotorg_c1.Value =0;
gui_plotorg_waveviewer.plotorg_c2.Value =0;
@@ -1446,6 +1984,7 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value =0;
gui_plotorg_waveviewer.plotorg_c6.Value =1;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,0,1];
+ MERPWaveViewer_plotorg{1}=6;
end
try
@@ -1465,29 +2004,25 @@ function layout_custom_load(~,~)
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormtdef = plotArrayStr;
- plotArrayFormtdef(numel(plotArray)+1) = {'None'};
elseif GridValue == 2 %% if the selected Bin is "Grid"
plotArray = binArray;
plotArrayStr = binStr(binArray);
plotArrayFormtdef = plotArrayStr;
- plotArrayFormtdef(numel(plotArray)+1) = {'None'};
+
elseif GridValue == 3%% if the selected ERPset is "Grid"
plotArray = ERPsetArray;
for Numoferpset = 1:numel(ERPsetArray)
plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
end
plotArrayFormtdef = plotArrayStr;
- plotArrayFormtdef(numel(plotArray)+1) = {'None'};
else
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormtdef = plotArrayStr;
- plotArrayFormtdef(numel(plotArray)+1) = {'None'};
end
plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
- gui_plotorg_waveviewer.rownum.Value=Plot_orgpar.gridlayout.rows;
- gui_plotorg_waveviewer.columnnum.Value=Plot_orgpar.gridlayout.columns;
+
try
RowNum = Plot_orgpar.gridlayout.rows;
catch
@@ -1500,73 +2035,18 @@ function layout_custom_load(~,~)
ColumNum = plotBox(2);
Plot_orgpar.gridlayout.columns= plotBox(2);
end
- plotArrayFormtimp = Plot_orgpar.gridlayout.columFormatOrig;
-
- plotArrayFormtimpChag = Plot_orgpar.gridlayout.columFormat;
- button='';
- if numel(plotArrayFormtimp) ~= numel(plotArrayFormtdef)
- button='OK';
- plotArrayFormtimp = plotArrayFormtdef;
- plotArrayFormtimpChag =plotArrayFormtdef;
- else
- code =0;
- for Numoflabel = 1:numel(plotArrayFormtimpChag)-1
- if ~strcmpi(plotArrayFormtimp{Numoflabel},plotArrayFormtdef{Numoflabel})
- code = code+1;
- end
- if code~=0
- plotArrayFormtimp = plotArrayFormtdef;
- plotArrayFormtimpChag =plotArrayFormtdef;
- button='OK';
- end
- end
- end
- GridinforData = Plot_orgpar.gridlayout.data;
- if ~isempty(button)
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- question = ['Warning: Bin/Channel/ERPset labels in saved parameter file donot match with the default ones.\n\n See Command Window for details'];
- title = 'Plot Organization > Load > layout_custom_load()';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf(question), title,'OK','OK');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor);
-
- fileCheck{1,1} = 'Default labels';
- fileCheck{1,2} = 'Imported labels';
- plotArrayFormtimp1 = Plot_orgpar.gridlayout.columFormatOrig;
- for Numoflist = 1:max([numel(plotArrayFormtimp1), numel(plotArrayFormtdef)])-1
- if Numoflist < numel(plotArrayFormtdef)
- fileCheck{Numoflist+1,1} = plotArrayFormtdef{Numoflist};
- else
- fileCheck{Numoflist+1,1} = 'none';
- end
-
- if Numoflist < numel(plotArrayFormtimp1)
- fileCheck{1+Numoflist,2} = plotArrayFormtimp1{Numoflist};
+ gui_plotorg_waveviewer.rownum.Value=Plot_orgpar.gridlayout.rows;
+ gui_plotorg_waveviewer.columnnum.Value=Plot_orgpar.gridlayout.columns;
+ NumrowsDef = plotBox(1);
+ NumcolumnsDef=plotBox(2);
+ count = 0;
+ for Numofrows = 1:NumrowsDef
+ for Numofcolumns = 1:NumcolumnsDef
+ count = count +1;
+ if count> numel(plotArray)
+ GridinforDatadef{Numofrows,Numofcolumns} = '';
else
- fileCheck{1+Numoflist,2} ='none';
- end
- end
-
- fprintf( [repmat('_',1,40) '\n']);
-
- for Numoflist = 1:size(fileCheck,1)
- hdr{1} = fileCheck{Numoflist,1};
- hdr{2} = fileCheck{Numoflist,2};
- fprintf( '\n%5s %24s %20s\n\n', hdr{:});
- end
- fprintf( ['\n',repmat('_',1,40) '\n']);
-
- GridinforData = '';
- count = 0;
- for Numofrows = 1:RowNum
- for Numofcolumns = 1:ColumNum
- count = count +1;
- if count> numel(plotArrayFormtimp)-1
- GridinforData{Numofrows,Numofcolumns} = char('None');
- else
- GridinforData{Numofrows,Numofcolumns} = char(plotArrayFormtimp(count));
- end
+ GridinforDatadef{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
end
end
@@ -1577,14 +2057,12 @@ function layout_custom_load(~,~)
LayOutauto = 'on';
end
try
- ERPwaviewerin.plot_org.gridlayout.data= GridinforData;
gui_plotorg_waveviewer.layoutinfor_table.Enable =LayOutauto;
gui_plotorg_waveviewer.rownum.Enable=LayOutauto;
gui_plotorg_waveviewer.columnnum.Enable=LayOutauto;
ERPwaviewerin.plot_org.gridlayout.rows = Plot_orgpar.gridlayout.rows;
ERPwaviewerin.plot_org.gridlayout.columns =Plot_orgpar.gridlayout.columns;
- ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormtimpChag;
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig = plotArrayFormtimp;
+ % ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormtimpChag;
catch
beep;
disp('The imported parameters didnot match with those of "Plot Organization".')
@@ -1598,7 +2076,6 @@ function layout_custom_load(~,~)
gui_plotorg_waveviewer.rowgapGTPcustom.String = num2str( Plot_orgpar.gridlayout.rowgap.GTPValue);
gui_plotorg_waveviewer.rowoverlap.Value = ~rowgapAutoValue;
gui_plotorg_waveviewer.rowgapoverlayedit.String = num2str(Plot_orgpar.gridlayout.rowgap.OverlayValue);
-
gui_plotorg_waveviewer.rowgap_auto.Enable = LayOutauto;
gui_plotorg_waveviewer.rowgapGTPcustom.Enable = LayOutauto;
gui_plotorg_waveviewer.rowoverlap.Enable = LayOutauto;
@@ -1642,12 +2119,91 @@ function layout_custom_load(~,~)
disp('The imported parameters for columns at "Grid Spacing" didnot match with those of "Plot Organization".')
return;
end
+
+ if Plot_orgpar.gridlayout.GridLayoutAuto==0
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value = 0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ ERPwaviewerin.plot_org.gridlayout.data= GridinforDatadef;
+ else
+ EmptyItemStr = '';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value = 1;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
+ ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormtdef;
+ plotArrayFormt= ERPwaviewerin.plot_org.gridlayout.columFormat';
+ GridinforDataOrg = Plot_orgpar.gridlayout.data;
+ % LabelUsedIndex = [];
+ % countlabel=0;
+ for ii = 1:size(GridinforDataOrg,1)
+ for jj = 1:size(GridinforDataOrg,2)
+ code = 0;
+ for kk = 1:length(plotArrayFormt)
+ if strcmp(GridinforDataOrg{ii,jj},char(plotArrayFormt(kk)))
+ code = 1;
+ end
+ end
+ if code==0
+ if ~isempty(GridinforDataOrg{ii,jj})
+ if isnumeric(GridinforDataOrg{ii,jj})
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ else
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ end
+ end
+ GridinforDataOrg{ii,jj} = '';
+ end
+ end
+ end
+ if ~isempty(EmptyItemStr)
+ MessageViewer= char(strcat('Plot Organization > Load - Undefined items in grid locations:',EmptyItemStr,32,'. Because they donot match with the selected labels'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+
+
+ ERPwaviewerin.plot_org.gridlayout.data =GridinforDataOrg;
+ gui_plotorg_waveviewer.rownum.Value = size(GridinforDataOrg,1);
+ gui_plotorg_waveviewer.columnnum.Value= size(GridinforDataOrg,2);
+ ERPwaviewerin.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
+ ERPwaviewerin.plot_org.gridlayout.columns =gui_plotorg_waveviewer.columnnum.Value;
+ end
+
+
+ ERPwaviewerin.plot_org.gridlayout.op =gui_plotorg_waveviewer.layout_auto.Value;
+ ERPwaviewerin.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
+ ERPwaviewerin.plot_org.gridlayout.columns = gui_plotorg_waveviewer.columnnum.Value;
+ ERPwaviewerin.plot_org.gridlayout.rowgap.GTPOP = gui_plotorg_waveviewer.rowgap_auto.Value;
+ ERPwaviewerin.plot_org.gridlayout.rowgap.GTPValue = str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayOP = gui_plotorg_waveviewer.rowoverlap.Value;
+ ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayValue = str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ ERPwaviewerin.plot_org.gridlayout.columngap.GTPOP = gui_plotorg_waveviewer.columngapgtpop.Value;
+ ERPwaviewerin.plot_org.gridlayout.columngap.GTPValue = str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ ERPwaviewerin.plot_org.gridlayout.columngap.OverlayOP = gui_plotorg_waveviewer.columnoverlay.Value;
+ ERPwaviewerin.plot_org.gridlayout.columngap.OverlayValue = str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ ERPwaviewerin.plot_org.gridlayout.GridLayoutAuto = gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+
+
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
+
assignin('base','ALLERPwaviewer',ERPwaviewerin);
viewer_ERPDAT.page_xyaxis = viewer_ERPDAT.page_xyaxis+1;
%%change the legend names based on the imported parameters
viewer_ERPDAT.count_legend = viewer_ERPDAT.count_legend+1;
f_redrawERP_viewer_test();
+ MessageViewer= char(strcat('Plot Organization > Load'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
@@ -1661,6 +2217,28 @@ function layout_custom_save(~,~)
return;
end
+ MessageViewer= char(strcat('Plot Organization > Save as'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
+ try
+ [version1 reldate] = geterplabstudioversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ else
+ try
+ [version1 reldate] = geterplabversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ end
+
+
try
ERPwaviewerin = evalin('base','ALLERPwaviewer');
catch
@@ -1682,7 +2260,7 @@ function layout_custom_save(~,~)
elseif gui_plotorg_waveviewer.plotorg_c6.Value ==1
GridValue=3; OverlayValue = 2; PageValue =1;
end
-
+ Plot_orgpar.version = erplabstudiover;
Plot_orgpar.Grid =GridValue;
Plot_orgpar.Overlay = OverlayValue;
Plot_orgpar.Pages = PageValue;
@@ -1691,7 +2269,6 @@ function layout_custom_save(~,~)
Plot_orgpar.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
Plot_orgpar.gridlayout.columns = gui_plotorg_waveviewer.columnnum.Value;
Plot_orgpar.gridlayout.columFormat = ERPwaviewerin.plot_org.gridlayout.columFormat;
- Plot_orgpar.gridlayout.columFormatOrig = ERPwaviewerin.plot_org.gridlayout.columFormatOrig;
Plot_orgpar.gridlayout.rowgap.GTPOP = ERPwaviewerin.plot_org.gridlayout.rowgap.GTPOP;
Plot_orgpar.gridlayout.rowgap.GTPValue = ERPwaviewerin.plot_org.gridlayout.rowgap.GTPValue;
Plot_orgpar.gridlayout.rowgap.OverlayOP = ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayOP;
@@ -1701,7 +2278,7 @@ function layout_custom_save(~,~)
Plot_orgpar.gridlayout.columngap.GTPValue = ERPwaviewerin.plot_org.gridlayout.columngap.GTPValue;
Plot_orgpar.gridlayout.columngap.OverlayOP = ERPwaviewerin.plot_org.gridlayout.columngap.OverlayOP;
Plot_orgpar.gridlayout.columngap.OverlayValue = ERPwaviewerin.plot_org.gridlayout.columngap.OverlayValue;
-
+ Plot_orgpar.gridlayout.GridLayoutAuto= ERPwaviewerin.plot_org.gridlayout.GridLayoutAuto;
pathstr = pwd;
namedef ='LayoutInfor';
[erpfilename, erppathname, indxs] = uiputfile({'*.mat'}, ...
@@ -1711,23 +2288,22 @@ function layout_custom_save(~,~)
disp('User selected Cancel')
return
end
- [pathx, filename, ext] = fileparts(erpfilename);
+ % [pathx, filename, ext] = fileparts(erpfilename);
[pathstr, erpfilename, ext] = fileparts(erpfilename) ;
- if indxs==1
- ext = '.mat';
- elseif indxs==2
- ext = '.mat';
- else
- ext = '.mat';
- end
+ ext = '.mat';
erpFilename = char(strcat(erpfilename,ext));
try
save([erppathname,erpFilename],'Plot_orgpar','-v7.3');
catch
- beep;
- disp('Cannot save the parameters for "Plot Organization", please try again');
+ MessageViewer = ['Plot Organization > Save as: Cannot save the parameters for "Plot Organization", please try again'];
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =3;
return;
end
+ MessageViewer= char(strcat('Plot Organization > Save as'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
+
end
@@ -1741,6 +2317,10 @@ function plotorg_cancel(~,~)
if changeFlag~=1
return;
end
+ MessageViewer= char(strcat('Plot Organization > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
@@ -1831,7 +2411,6 @@ function plotorg_cancel(~,~)
gui_plotorg_waveviewer.plotorg_c6.Value =1;
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,0,1];
end
-
gui_plotorg_waveviewer.layout_auto.Value = ERPwaviewer_apply.plot_org.gridlayout.op;
gui_plotorg_waveviewer.layout_custom.Value = ~ERPwaviewer_apply.plot_org.gridlayout.op;
gui_plotorg_waveviewer.layout_auto.Enable = 'on';
@@ -1886,11 +2465,23 @@ function plotorg_cancel(~,~)
gui_plotorg_waveviewer.columngapoverlapedit.Enable = 'on';
end
end
+
+ if ERPwaviewer_apply.plot_org.gridlayout.GridLayoutAuto ==0
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value = 0;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ else
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value = 1;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
+ end
+
gui_plotorg_waveviewer.columFormatStr = '';
estudioworkingmemory('MyViewer_plotorg',0);
gui_plotorg_waveviewer.apply.BackgroundColor = [1 1 1];
gui_plotorg_waveviewer.apply.ForegroundColor = [0 0 0];
box_erpwave_viewer_plotorg.TitleColor= [0.5 0.5 0.9];
+ MessageViewer= char(strcat('Plot Organization > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
@@ -1901,7 +2492,6 @@ function plotorg_apply(~,~)
if ~isempty(messgStr) && viewerpanelIndex~=4
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
-
estudioworkingmemory('MyViewer_plotorg',0);
gui_plotorg_waveviewer.apply.BackgroundColor = [1 1 1];
gui_plotorg_waveviewer.apply.ForegroundColor = [0 0 0];
@@ -1928,16 +2518,22 @@ function plotorg_apply(~,~)
if gui_plotorg_waveviewer.plotorg_c1.Value ==1
GridValue=1; OverlayValue = 2; PageValue =3;
+ MERPWaveViewer_plotorg{1}=1;
elseif gui_plotorg_waveviewer.plotorg_c2.Value ==1
GridValue=1; OverlayValue = 3; PageValue =2;
+ MERPWaveViewer_plotorg{1}=2;
elseif gui_plotorg_waveviewer.plotorg_c3.Value ==1
GridValue=2; OverlayValue = 1; PageValue =3;
+ MERPWaveViewer_plotorg{1}=3;
elseif gui_plotorg_waveviewer.plotorg_c4.Value ==1
GridValue=2; OverlayValue = 3; PageValue =1;
+ MERPWaveViewer_plotorg{1}=4;
elseif gui_plotorg_waveviewer.plotorg_c5.Value ==1
GridValue=3; OverlayValue = 1; PageValue =2;
+ MERPWaveViewer_plotorg{1}=5;
elseif gui_plotorg_waveviewer.plotorg_c6.Value ==1
GridValue=3; OverlayValue = 2; PageValue =1;
+ MERPWaveViewer_plotorg{1}=6;
end
[chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERPIN,ERPsetArray);
@@ -1945,24 +2541,21 @@ function plotorg_apply(~,~)
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
elseif GridValue == 2 %% if the selected Bin is "Grid"
plotArray = binArray;
plotArrayStr = binStr(binArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
elseif GridValue == 3%% if the selected ERPset is "Grid"
plotArray = ERPsetArray;
for Numoferpset = 1:numel(ERPsetArray)
plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
end
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
+
else
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(chanArray)+1) = {'None'};
end
plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
@@ -1973,79 +2566,71 @@ function plotorg_apply(~,~)
NumrowsDef = 1;
NumcolumnsDef = 1;
end
- % NumcolumnsChanged = gui_plotorg_waveviewer.rownum.Value;
- % NumrowsChanged = gui_plotorg_waveviewer.columnnum.Value;
- % allNum = NumcolumnsChanged*NumrowsChanged;
- % button = 'none';
- % if NumcolumnsChanged*NumrowsChanged< NumrowsDef* NumcolumnsDef
- % question = ['Are you sure to set row and column numbers to be',32,num2str(NumrowsChanged),32,'and',32,num2str(NumcolumnsChanged),'?\n\n',...
- % 'If so, only the first',32,num2str(allNum),32,'items will be plotted.\n',...
- % 'If not, the default numbers of rows and columns will be used.\n'];
- % BackERPLABcolor = [1 0.9 0.3]; % yellow
- % title = 'My Viewer > Plot Organization > Column(s)';
- % oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- % set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- % button = questdlg(sprintf(question), title,'Cancel','No', 'Yes','Yes');
- % set(0,'DefaultUicontrolBackgroundColor',oldcolor)
- % end
- % if isempty(button) || strcmpi(button,'Cancel')
- % return;
- % end
- % if strcmpi(button,'No')
- % count = 0;
- % for Numofrows = 1:NumrowsDef
- % for Numofcolumns = 1:NumcolumnsDef
- % count = count +1;
- % if count> numel(plotArray)
- % GridinforData{Numofrows,Numofcolumns} = char('None');
- % else
- % GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
- % end
- % end
- % end
- % ERPwaviewerin.plot_org.gridlayout.data =GridinforData;
- % gui_plotorg_waveviewer.rownum.Value=NumrowsDef;
- % gui_plotorg_waveviewer.columnnum.Value=NumcolumnsDef;
- % end
+
count = 0;
for Numofrows = 1:NumrowsDef
for Numofcolumns = 1:NumcolumnsDef
count = count +1;
if count> numel(plotArray)
- GridinforDatadef{Numofrows,Numofcolumns} = char('None');
+ GridinforDatadef{Numofrows,Numofcolumns} = '';
else
GridinforDatadef{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
end
end
-
- if gui_plotorg_waveviewer.layout_auto.Value==1
+ if gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value ==0
ERPwaviewerin.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
ERPwaviewerin.plot_org.gridlayout.columns =gui_plotorg_waveviewer.columnnum.Value;
ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormt';
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig = plotArrayFormt';
ERPwaviewerin.plot_org.gridlayout.data =GridinforDatadef;
else
- if ~isempty(gui_plotorg_waveviewer.columFormatStr)
- plotArrayFormtOld= gui_plotorg_waveviewer.columFormatStr;
- else
- plotArrayFormtOld = ERPwaviewerin.plot_org.gridlayout.columFormat;
- end
- for ii = 1:length(plotArrayFormt)-1
- if ii< length(plotArrayFormtOld)
- try
- plotArrayFormtNew{ii} = char(plotArrayFormtOld{ii});
- catch
- plotArrayFormtNew{ii} = char(plotArrayFormt{ii});
+ EmptyItemStr = '';
+ ERPwaviewerin.plot_org.gridlayout.columFormat=plotArrayFormt';
+ GridinforDataOrg = ERPwaviewerin.plot_org.gridlayout.data;
+ countEmp = 0;
+ for ii = 1:size(GridinforDataOrg,1)
+ for jj = 1:size(GridinforDataOrg,2)
+ code = 0;
+ for kk = 1:length(plotArrayFormt)
+ if strcmp(GridinforDataOrg{ii,jj},char(plotArrayFormt(kk)))
+ code = 1;
+ end
end
- else
- plotArrayFormtNew{ii} = char(plotArrayFormt{ii});
+ if code==0
+ if ~isempty(GridinforDataOrg{ii,jj})
+ if isnumeric(GridinforDataOrg{ii,jj})
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ else
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ end
+ else
+ countEmp = countEmp+1;
+ end
+ GridinforDataOrg{ii,jj} = '';
+ end
+ end
+ end
+ if ~isempty(EmptyItemStr)
+ MessageViewer= char(strcat('Plot Organization > Apply-Undefined item(s) in grid locations:',EmptyItemStr,32,'because they donot match with the selected labels'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+ if countEmp == size(GridinforDataOrg,1)*size(GridinforDataOrg,2) || isempty(EmptyItemStr)
+ EmptyItemStr = '';
+ for kk = 1:length(plotArrayFormt)
+ EmptyItemStr = strcat(EmptyItemStr,32,char(plotArrayFormt(kk)));
+ end
+ if ~isempty(EmptyItemStr)
+ MessageViewer= char(strcat('Plot Organization > Apply-Undefined item(s) in grid locations:',EmptyItemStr,32,'because they donot match with the selected labels'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
end
end
- plotArrayFormtNew{length(plotArrayFormt)} = {'None'};
- ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormtNew';
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig = plotArrayFormt';
+
+ ERPwaviewerin.plot_org.gridlayout.data =GridinforDataOrg;
+ gui_plotorg_waveviewer.rownum.Value = size(GridinforDataOrg,1);
+ gui_plotorg_waveviewer.columnnum.Value= size(GridinforDataOrg,2);
end
ERPwaviewerin.plot_org.Grid = GridValue;
@@ -2062,6 +2647,21 @@ function plotorg_apply(~,~)
ERPwaviewerin.plot_org.gridlayout.columngap.GTPValue = str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayOP = gui_plotorg_waveviewer.columnoverlay.Value;
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayValue = str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ ERPwaviewerin.plot_org.gridlayout.GridLayoutAuto = gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+
+
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
assignin('base','ALLERPwaviewer',ERPwaviewerin);
overlayIndex = estudioworkingmemory('OverlayIndex');
@@ -2086,17 +2686,6 @@ function v_currentERP_change(~,~)
end
%%Force Grid, Overlay, and Pages to be 1,2,3, respectively if "Same as ERPLAB"
- PlotOrg_ERPLAB= estudioworkingmemory('PlotOrg_ERPLAB');%% "Same as ERPLAB"? See "ERPsets" panel of ERP Wave Viewer
- if PlotOrg_ERPLAB==1
- gui_plotorg_waveviewer.plotorg_c1.Value = 1;
- gui_plotorg_waveviewer.plotorg_c2.Value = 0;
- gui_plotorg_waveviewer.plotorg_c3.Value = 0;
- gui_plotorg_waveviewer.plotorg_c4.Value = 0;
- gui_plotorg_waveviewer.plotorg_c5.Value = 0;
- gui_plotorg_waveviewer.plotorg_c6.Value = 0;
- end
- estudioworkingmemory('PlotOrg_ERPLAB',0);
-
indexerp = ERPwaviewer_apply.SelectERPIdx;
ALLERP = ERPwaviewer_apply.ALLERP;
for Numofselectederp = 1:numel(indexerp)
@@ -2110,9 +2699,8 @@ function v_currentERP_change(~,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Sampling rate varies across ERPsets.\n We used the first option (i.e., Channels, Bins, ERPsets).'));
+ MessageViewer= char(strcat('Sampling rate varies across ERPsets.\n We used the first option (i.e., Channels, Bins, ERPsets)'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
gui_plotorg_waveviewer.plotorg_c1.Value = 1;
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -2168,25 +2756,22 @@ function v_currentERP_change(~,~)
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
elseif GridValue == 2 %% if the selected Bin is "Grid"
plotArray = binArray;
plotArrayStr = binStr(binArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
elseif GridValue == 3%% if the selected ERPset is "Grid"
plotArray = ERPsetArray;
for Numoferpset = 1:numel(ERPsetArray)
plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
end
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
else
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(chanArray)+1) = {'None'};
end
+
plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
if gui_plotorg_waveviewer.layout_auto.Value
try
@@ -2204,44 +2789,89 @@ function v_currentERP_change(~,~)
for Numofcolumns = 1:Numcolumns
count = count +1;
if count> numel(plotArray)
- GridinforData{Numofrows,Numofcolumns} = char('None');
+ GridinforData{Numofrows,Numofcolumns} = '';
else
GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
end
end
- if gui_plotorg_waveviewer.layout_auto.Value
- ERPwaviewer_apply.plot_org.Grid = GridValue;
+ if gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value==0
ERPwaviewer_apply.plot_org.gridlayout.data =GridinforData;
- ERPwaviewer_apply.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
- ERPwaviewer_apply.plot_org.gridlayout.columns =gui_plotorg_waveviewer.columnnum.Value;
+ gui_plotorg_waveviewer.rownum.Value = size(GridinforData,1);
+ gui_plotorg_waveviewer.columnnum.Value= size(GridinforData,2);
ERPwaviewer_apply.plot_org.gridlayout.columFormat = plotArrayFormt';
- ERPwaviewer_apply.plot_org.gridlayout.columFormatOrig = plotArrayFormt';
else
- ERPwaviewer_apply.plot_org.gridlayout.columFormatOrig = plotArrayFormt;
- plotArrayFormtOld = ERPwaviewer_apply.plot_org.gridlayout.columFormat;
- for ii = 1:length(plotArrayFormt)-1
- if ii< length(plotArrayFormtOld)
- try
- plotArrayFormtNew{ii} = char(plotArrayFormtOld{ii});
- catch
- plotArrayFormtNew{ii} = char(plotArrayFormt{ii});
+ EmptyItemStr = '';
+ ERPwaviewer_apply.plot_org.gridlayout.columFormat=plotArrayFormt';
+ GridinforDataOrg = ERPwaviewer_apply.plot_org.gridlayout.data;
+ for ii = 1:size(GridinforDataOrg,1)
+ for jj = 1:size(GridinforDataOrg,2)
+ code = 0;
+ for kk = 1:length(plotArrayFormt)
+ if strcmp(GridinforDataOrg{ii,jj},char(plotArrayFormt(kk)))
+ code = 1;
+ end
+ end
+ if code==0
+ if ~isempty(GridinforDataOrg{ii,jj})
+ if isnumeric(GridinforDataOrg{ii,jj})
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ else
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(GridinforDataOrg{ii,jj}));
+ end
+ end
+ GridinforDataOrg{ii,jj} = '';
end
- else
- plotArrayFormtNew{ii} = char(plotArrayFormt{ii});
end
end
- plotArrayFormtNew{length(plotArrayFormt)} = {'None'};
- ERPwaviewer_apply.plot_org.gridlayout.columFormat = plotArrayFormtNew';
+
+ if ~isempty(EmptyItemStr)
+ MessageViewer= char(strcat('Plot Organization > v_currentERP_change() - Undefined items in grid locations:',EmptyItemStr,32,'. Because they donot match with the selected labels'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+
+ ERPwaviewer_apply.plot_org.gridlayout.data =GridinforDataOrg;
+ gui_plotorg_waveviewer.rownum.Value = size(GridinforDataOrg,1);
+ gui_plotorg_waveviewer.columnnum.Value= size(GridinforDataOrg,2);
end
+ ERPwaviewer_apply.plot_org.gridlayout.rows = gui_plotorg_waveviewer.rownum.Value;
+ ERPwaviewer_apply.plot_org.gridlayout.columns =gui_plotorg_waveviewer.columnnum.Value;
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ %%save the parameters for this panel to memory file
+ if gui_plotorg_waveviewer.plotorg_c1.Value ==1
+ MERPWaveViewer_plotorg{1}=1;
+ elseif gui_plotorg_waveviewer.plotorg_c2.Value ==1
+ MERPWaveViewer_plotorg{1}=2;
+ elseif gui_plotorg_waveviewer.plotorg_c3.Value ==1
+ MERPWaveViewer_plotorg{1}=3;
+ elseif gui_plotorg_waveviewer.plotorg_c4.Value ==1
+ MERPWaveViewer_plotorg{1}=4;
+ elseif gui_plotorg_waveviewer.plotorg_c5.Value ==1
+ MERPWaveViewer_plotorg{1}=5;
+ elseif gui_plotorg_waveviewer.plotorg_c6.Value ==1
+ MERPWaveViewer_plotorg{1}=6;
+ end
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
+
end
%%-------------modify this panel based on updated parameters---------------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=4
return;
end
try
@@ -2263,13 +2893,16 @@ function count_loadproper_change(~,~)
try
ALLERP = ERPwaviewer_apply.ALLERP;
indexerp = ERPwaviewer_apply.SelectERPIdx;
+ ERPsetArray = ERPwaviewer_apply.SelectERPIdx;
+ chanArray = ERPwaviewer_apply.chan;
+ binArray = ERPwaviewer_apply.bin;
catch
beep;
disp('f_ERP_plotorg_waveviewer_GUI() error: Please run the ERP wave viewer again.');
return;
end
for Numofselectederp = 1:numel(indexerp)
- SrateNum_mp{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).srate;
+ SrateNum_mp(Numofselectederp) = ALLERP(indexerp(Numofselectederp)).srate;
end
if length(unique(SrateNum_mp))~=1
gui_plotorg_waveviewer.plotorg_c2.Enable = 'off';
@@ -2277,17 +2910,13 @@ function count_loadproper_change(~,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if PageValue ~=3
- MessageViewer= char(strcat('Warning: Sampling rate varies across ERPsets. We used the first option. (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Sampling rate varies across ERPsets. We used the first option'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
GridValue=1; OverlayValue = 2; PageValue =3;
ERPwaviewer_apply.plot_org.Grid = 1;
ERPwaviewer_apply.plot_org.Overlay = 2;
ERPwaviewer_apply.plot_org.Pages = 3;
-
- chanArray = ERPwaviewer_apply.chan;
- ERPsetArray = ERPwaviewer_apply.SelectERPIdx;
ALLERPIN = ERPwaviewer_apply.ALLERP;
if max(ERPsetArray) >length(ALLERPIN)
ERPsetArray =length(ALLERPIN);
@@ -2297,7 +2926,6 @@ function count_loadproper_change(~,~)
plotArray = chanArray;
plotArrayStr = chanStr(chanArray);
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
plotBox = f_getrow_columnautowaveplot(plotArray);
try
Numrows = plotBox(1);
@@ -2311,7 +2939,7 @@ function count_loadproper_change(~,~)
for Numofcolumns = 1:Numcolumns
count = count +1;
if count> numel(plotArray)
- GridinforData{Numofrows,Numofcolumns} = char('None');
+ GridinforData{Numofrows,Numofcolumns} = '';
else
GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
@@ -2321,7 +2949,6 @@ function count_loadproper_change(~,~)
ERPwaviewer_apply.plot_org.gridlayout.rows = Numrows;
ERPwaviewer_apply.plot_org.gridlayout.columns =Numcolumns;
ERPwaviewer_apply.plot_org.gridlayout.columFormat = plotArrayFormt';
- ERPwaviewer_apply.plot_org.gridlayout.columFormatOrig = plotArrayFormt';
end
else
gui_plotorg_waveviewer.plotorg_c2.Enable = 'on';
@@ -2381,19 +3008,123 @@ function count_loadproper_change(~,~)
gui_plotorg_waveviewer.LayoutFlag = [0,0,0,0,0,1];
end
+
+ [chanStr,binStr,diff_mark] = f_geterpschanbin(ALLERP,ERPsetArray);
+ if GridValue ==1 %% if the selected Channel is "Grid"
+ plotArray = chanArray;
+ plotArrayStr = chanStr(chanArray);
+ plotArrayFormtdef = plotArrayStr;
+ elseif GridValue == 2 %% if the selected Bin is "Grid"
+ plotArray = binArray;
+ plotArrayStr = binStr(binArray);
+ plotArrayFormtdef = plotArrayStr;
+ elseif GridValue == 3%% if the selected ERPset is "Grid"
+ plotArray = ERPsetArray;
+ for Numoferpset = 1:numel(ERPsetArray)
+ plotArrayStr(Numoferpset,1) = {char(ALLERPIN(ERPsetArray(Numoferpset)).erpname)};
+ end
+ plotArrayFormtdef = plotArrayStr;
+ else
+ plotArray = chanArray;
+ plotArrayStr = chanStr(chanArray);
+ plotArrayFormtdef = plotArrayStr;
+ end
+
+ plotBox = f_getrow_columnautowaveplot(plotArray);%% the first element is number of rows and the second element is the number of columns
+ try
+ NumrowsDef = plotBox(1);
+ NumcolumnsDef = plotBox(2);
+ catch
+ NumrowsDef = 1;
+ NumcolumnsDef = 1;
+ end
+
+ count = 0;
+ for Numofrows = 1:NumrowsDef
+ for Numofcolumns = 1:NumcolumnsDef
+ count = count +1;
+ if count> numel(plotArray)
+ GridinforDatadef{Numofrows,Numofcolumns} = '';
+ else
+ GridinforDatadef{Numofrows,Numofcolumns} = char(plotArrayStr(count));
+ end
+ end
+ end
AutoValue = ERPwaviewer_apply.plot_org.gridlayout.op;
if AutoValue ==1
Enable = 'off';
gui_plotorg_waveviewer.layout_auto.Value =1;
gui_plotorg_waveviewer.layout_custom.Value = 0;
+ ERPwaviewer_apply.plot_org.gridlayout.rows =NumrowsDef;
+ ERPwaviewer_apply.plot_org.gridlayout.columns = NumcolumnsDef;
+ ERPwaviewer_apply.plot_org.gridlayout.rowgap.GTPOP=1;
+ ERPwaviewer_apply.plot_org.gridlayout.rowgap.GTPValue=10;
+ ERPwaviewer_apply.plot_org.gridlayout.rowgap.OverlayOP=0;
+ ERPwaviewer_apply.plot_org.gridlayout.rowgap.OverlayValue=40;
+ ERPwaviewer_apply.plot_org.gridlayout.columngap.GTPOP=1;
+ ERPwaviewer_apply.plot_org.gridlayout.columngap.GTPValue=10;
+ ERPwaviewer_apply.plot_org.gridlayout.columngap.OverlayOP=0;
+ ERPwaviewer_apply.plot_org.gridlayout.columngap.OverlayValue=40;
else
Enable = 'on';
gui_plotorg_waveviewer.layout_auto.Value =0;
gui_plotorg_waveviewer.layout_custom.Value = 1;
+
+
+ end
+ try
+ GridLayoutAuto = ERPwaviewer_apply.plot_org.gridlayout.GridLayoutAuto;
+ catch
+ GridLayoutAuto=0;
+ end
+ if GridLayoutAuto==0
+ ERPwaviewer_apply.plot_org.gridlayout.data = GridinforDatadef;
+ ERPwaviewer_apply.plot_org.gridlayout.columFormat=plotArrayFormtdef;
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'off';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value =0;
+ else
+ gui_plotorg_waveviewer.layout_custom_edit.Enable = 'on';
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value =1;
+ ERPwaviewer_apply.plot_org.gridlayout.columFormat=plotArrayFormtdef;
+ Datanew = ERPwaviewer_apply.plot_org.gridlayout.data;
+ ERPwaviewer_apply.plot_org.gridlayout.rows =size(Datanew,1);
+ ERPwaviewer_apply.plot_org.gridlayout.columns = size(Datanew,2);
+ LabelUsedIndex = [];
+ countlabel=0;
+ EmptyItemStr ='';
+ for ii = 1:size(Datanew,1)
+ for jj = 1:size(Datanew,2)
+ code1 = 0;
+ for kk = 1:length(plotArrayFormtdef)
+ if strcmp(Datanew{ii,jj},plotArrayFormtdef{kk})
+ code1=1;
+ end
+ end
+ if code1==0
+ if ~isempty(Datanew{ii,jj})
+ if isnumeric(Datanew{ii,jj})
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(Datanew{ii,jj}));
+ else
+ EmptyItemStr = strcat(EmptyItemStr,32,num2str(Datanew{ii,jj}));
+ end
+ end
+ Datanew{ii,jj} = '';
+ end
+ end
+ end
+ ERPwaviewer_apply.plot_org.gridlayout.data = Datanew;
+
+ if ~isempty(EmptyItemStr)
+ MessageViewer= char(strcat('Plot Organization > loadproper_change() - Undefined items in grid locations:',EmptyItemStr,32,'. Because they donot match with the selected labels'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+
+
end
+
gui_plotorg_waveviewer.layout_auto.Enable ='on';
gui_plotorg_waveviewer.layout_custom.Enable ='on';
- gui_plotorg_waveviewer.layout_custom_edit.Enable = Enable;
gui_plotorg_waveviewer.rownum.Enable = Enable;
gui_plotorg_waveviewer.columnnum.Enable = Enable;
gui_plotorg_waveviewer.rowgap_auto.Enable = Enable;
@@ -2404,7 +3135,6 @@ function count_loadproper_change(~,~)
gui_plotorg_waveviewer.columngapgtpcustom.Enable = Enable;
gui_plotorg_waveviewer.columnoverlay.Enable = Enable;
gui_plotorg_waveviewer.columngapoverlapedit.Enable = Enable;
-
RowNum = ERPwaviewer_apply.plot_org.gridlayout.rows;
columNum = ERPwaviewer_apply.plot_org.gridlayout.columns;
gui_plotorg_waveviewer.rownum.Value = RowNum;
@@ -2431,7 +3161,8 @@ function count_loadproper_change(~,~)
gui_plotorg_waveviewer.rowgapoverlayedit.Enable = 'on';
end
end
- %%column gap and oveerlay
+
+ %%column gap and overlay
columnGapValue = ERPwaviewer_apply.plot_org.gridlayout.columngap.GTPOP;
columnGapcustom = ERPwaviewer_apply.plot_org.gridlayout.columngap.GTPValue;
columnoverlayValue = ERPwaviewer_apply.plot_org.gridlayout.columngap.OverlayOP;
@@ -2453,6 +3184,35 @@ function count_loadproper_change(~,~)
end
end
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+
+ %%save the parameters for this panel to memory file
+ if gui_plotorg_waveviewer.plotorg_c1.Value ==1
+ MERPWaveViewer_plotorg{1}=1;
+ elseif gui_plotorg_waveviewer.plotorg_c2.Value ==1
+ MERPWaveViewer_plotorg{1}=2;
+ elseif gui_plotorg_waveviewer.plotorg_c3.Value ==1
+ MERPWaveViewer_plotorg{1}=3;
+ elseif gui_plotorg_waveviewer.plotorg_c4.Value ==1
+ MERPWaveViewer_plotorg{1}=4;
+ elseif gui_plotorg_waveviewer.plotorg_c5.Value ==1
+ MERPWaveViewer_plotorg{1}=5;
+ elseif gui_plotorg_waveviewer.plotorg_c6.Value ==1
+ MERPWaveViewer_plotorg{1}=6;
+ end
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
+
+ viewer_ERPDAT.loadproper_count =5;
end
@@ -2494,9 +3254,8 @@ function count_twopanels_change(~,~)
gui_plotorg_waveviewer.plotorg_c5.Enable = 'off';
gui_plotorg_waveviewer.plotorg_c6.Enable = 'off';
if y_Flag~=1 && y_Flag~= 3
- MessageViewer= char(strcat('Warning: Sampling rate varies across ERPsets. We used the first option. (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Sampling rate varies across ERPsets. We used the first option'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
gui_plotorg_waveviewer.plotorg_c1.Value = 1;
gui_plotorg_waveviewer.plotorg_c2.Value = 0;
@@ -2505,6 +3264,10 @@ function count_twopanels_change(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
+ ERPwaviewerin.plot_org.Grid = 1;
+ ERPwaviewerin.plot_org.Overlay = 2;
+ ERPwaviewerin.plot_org.Pages = 3;
+ assignin('base','ALLERPwaviewer',ERPwaviewerin);
end
else
gui_plotorg_waveviewer.plotorg_c2.Enable = 'on';
@@ -2537,7 +3300,6 @@ function Reset_Waviewer_panel_change(~,~)
gui_plotorg_waveviewer.plotorg_c5.Value = 0;
gui_plotorg_waveviewer.plotorg_c6.Value = 0;
gui_plotorg_waveviewer.LayoutFlag = [1,0,0,0,0,0];
-
ERPwaviewerin.plot_org.Grid = 1;
ERPwaviewerin.plot_org.Overlay = 2;
ERPwaviewerin.plot_org.Pages = 3;
@@ -2548,9 +3310,8 @@ function Reset_Waviewer_panel_change(~,~)
Datype{Numofselectederp} = ALLERP(indexerp(Numofselectederp)).datatype;
end
if length(unique(Datype))~=1 || (numel(indexerp)==1 && strcmpi(char(Datype),'ERP')~=1)
- MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset (see Command Window)'));
+ MessageViewer= char(strcat('Warning: Type of data varies across ERPsets. We only plot waves for ERPset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
viewer_ERPDAT.Process_messg =4;
return;
end
@@ -2578,6 +3339,7 @@ function Reset_Waviewer_panel_change(~,~)
gui_plotorg_waveviewer.columnnum.Value=NumcolumnsDef;
gui_plotorg_waveviewer.rownum.Enable='off';
gui_plotorg_waveviewer.columnnum.Enable='off';
+
ERPwaviewerin.plot_org.gridlayout.rows = NumrowsDef;
ERPwaviewerin.plot_org.gridlayout.columns=NumcolumnsDef;
ERPsetArray = ERPwaviewerin.SelectERPIdx;
@@ -2592,7 +3354,7 @@ function Reset_Waviewer_panel_change(~,~)
for Numofcolumns = 1:NumcolumnsDef
count = count +1;
if count> numel(plotArray)
- GridinforData{Numofrows,Numofcolumns} = char('None');
+ GridinforData{Numofrows,Numofcolumns} = '';
else
GridinforData{Numofrows,Numofcolumns} = char(plotArrayStr(count));
end
@@ -2600,9 +3362,7 @@ function Reset_Waviewer_panel_change(~,~)
end
ERPwaviewerin.plot_org.gridlayout.data =GridinforData;
plotArrayFormt = plotArrayStr;
- plotArrayFormt(numel(plotArray)+1) = {'None'};
ERPwaviewerin.plot_org.gridlayout.columFormat = plotArrayFormt';
- ERPwaviewerin.plot_org.gridlayout.columFormatOrig= plotArrayFormt';
%%Grid spacing
gui_plotorg_waveviewer.rowgap_auto.Value =1;
gui_plotorg_waveviewer.rowgapGTPcustom.String = '10';
@@ -2620,7 +3380,7 @@ function Reset_Waviewer_panel_change(~,~)
gui_plotorg_waveviewer.columngapgtpcustom.Enable ='off';
gui_plotorg_waveviewer.columnoverlay.Enable ='off';
gui_plotorg_waveviewer.columngapoverlapedit.Enable ='off';
- gui_plotorg_waveviewer.layout_custom_edit.Enable ='off';
+
ERPwaviewerin.plot_org.gridlayout.rowgap.GTPOP = gui_plotorg_waveviewer.rowgap_auto.Value;
ERPwaviewerin.plot_org.gridlayout.rowgap.GTPValue = str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
ERPwaviewerin.plot_org.gridlayout.rowgap.OverlayOP = gui_plotorg_waveviewer.rowoverlap.Value;
@@ -2630,13 +3390,47 @@ function Reset_Waviewer_panel_change(~,~)
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayOP = gui_plotorg_waveviewer.columnoverlay.Value;
ERPwaviewerin.plot_org.gridlayout.columngap.OverlayValue = str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value=0; %,'HorizontalAlignment','left'
+ gui_plotorg_waveviewer.layout_custom_edit.Enable='off';
+
+ assignin('base','ALLERPwaviewer',ERPwaviewerin);
+
+ %%Using the default background color for "apply" and title bar
gui_plotorg_waveviewer.apply.BackgroundColor = [1 1 1];
gui_plotorg_waveviewer.apply.ForegroundColor = [0 0 0];
box_erpwave_viewer_plotorg.TitleColor= [0.5 0.5 0.9];
- assignin('base','ALLERPwaviewer',ERPwaviewerin);
+ %%save the parameters for this panel to memory file
+ MERPWaveViewer_plotorg{1}=1;
+ MERPWaveViewer_plotorg{2}=gui_plotorg_waveviewer.layout_auto.Value;
+ plotBox(1) = gui_plotorg_waveviewer.rownum.Value;
+ plotBox(2) = gui_plotorg_waveviewer.columnnum.Value;
+ MERPWaveViewer_plotorg{3}=plotBox;
+ MERPWaveViewer_plotorg{4}= gui_plotorg_waveviewer.rowgap_auto.Value;
+ MERPWaveViewer_plotorg{5}=str2num(gui_plotorg_waveviewer.rowgapGTPcustom.String);
+ MERPWaveViewer_plotorg{6}=str2num(gui_plotorg_waveviewer.rowgapoverlayedit.String);
+ MERPWaveViewer_plotorg{7} = gui_plotorg_waveviewer.columngapgtpop.Value;
+ MERPWaveViewer_plotorg{8}=str2num(gui_plotorg_waveviewer.columngapgtpcustom.String);
+ MERPWaveViewer_plotorg{9}=str2num(gui_plotorg_waveviewer.columngapoverlapedit.String);
+ MERPWaveViewer_plotorg{10}=gui_plotorg_waveviewer.layout_custom_edit_checkbox.Value;
+ estudioworkingmemory('MERPWaveViewer_plotorg',MERPWaveViewer_plotorg);%%save parameters for this panel to memory file
+
+ %%execute next panel
viewer_ERPDAT.Reset_Waviewer_panel=5;
end
end%%end of reset
+
+ function plotorg_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress, 'enter')
+ plotorg_apply();
+ estudioworkingmemory('MyViewer_plotorg',0);
+ gui_plotorg_waveviewer.apply.BackgroundColor = [1 1 1];
+ gui_plotorg_waveviewer.apply.ForegroundColor = [0 0 0];
+ box_erpwave_viewer_plotorg.TitleColor= [0.5 0.5 0.9];
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_property_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_property_waveviewer_GUI.m
index 6c676b19..3dc6d2f2 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_property_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_property_waveviewer_GUI.m
@@ -12,7 +12,7 @@
global gui_erp_waviewer;
global viewer_ERPDAT;
% addlistener(viewer_ERPDAT,'v_currentERP_change',@Count_currentERPChanged);
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+% addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
gui_property_waveviewer = struct();
@@ -31,7 +31,7 @@
box_erpwave_viewer_property = uiextras.BoxPanel('Parent', varargin{1}, 'Title', 'Viewer Properties', 'Padding', 5,...
'FontSize', varargin{2},'BackgroundColor',ColorBviewer_def,'TitleColor',[0.5 0.5 0.9],'ForegroundColor','w');
end
-
+gui_erp_waviewer.Window.WindowButtonMotionFcn = {@ViewerPos};
%-----------------------------Draw the panel-------------------------------------
try
FonsizeDefault = varargin{2};
@@ -39,7 +39,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
drawui_plot_property(FonsizeDefault);
varargout{1} = box_erpwave_viewer_property;
@@ -74,7 +74,32 @@ function drawui_plot_property(FonsizeDefault)
gui_property_waveviewer.parameters_load = uicontrol('Style','edit','Parent',gui_property_waveviewer.viewer_TN_title,'String',ViewerName,...
'callback',@viewer_TN,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
set(gui_property_waveviewer.viewer_TN_title, 'Sizes',[70 165]);
- set(gui_property_waveviewer.DataSelBox ,'Sizes',[30 25])
+
+
+ gui_property_waveviewer.viewer_pos_title = uiextras.HBox('Parent', gui_property_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+ uicontrol('Style','text','Parent', gui_property_waveviewer.viewer_pos_title,'String','Position:',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %1A
+ New_pos = gui_erp_waviewer.screen_pos;
+ if isempty(New_pos)
+ New_pos = [0.01,0.01,75,75];
+ erpworkingmemory('ERPWaveScreenPos',New_pos);
+ end
+
+ New_pos1 = roundn(New_pos,-3);
+ New_poStr = char([num2str(New_pos1(1)),32,num2str(New_pos1(2)),32,num2str(New_pos1(3)),32,num2str(New_pos1(4))]);
+
+ gui_property_waveviewer.parameters_pos = uicontrol('Style','edit','Parent',gui_property_waveviewer.viewer_pos_title,'String',New_poStr,...
+ 'callback',@Viewerpos,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
+ set(gui_property_waveviewer.viewer_pos_title, 'Sizes',[70 165]);
+
+ gui_property_waveviewer.viewer_pos_title1 = uiextras.HBox('Parent', gui_property_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
+ uicontrol('Style','text','Parent', gui_property_waveviewer.viewer_pos_title1,'String','',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %1A
+ uicontrol('Style','text','Parent',gui_property_waveviewer.viewer_pos_title1,'String','(left bottom width height) in %',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
+ set(gui_property_waveviewer.viewer_pos_title1, 'Sizes',[68 165]);
+
+ set(gui_property_waveviewer.DataSelBox ,'Sizes',[30 25 25 25])
end
@@ -83,9 +108,13 @@ function drawui_plot_property(FonsizeDefault)
%%--------------------------Sub function------------------------------------%%
%%**************************************************************************%%
-
%%-------------------------Setting for load--------------------------------
function parameters_load(~,~)
+
+ MessageViewer= char(strcat('Viewer Properties > Load'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+
[filename, filepath,indxs] = uigetfile({'*.mat'}, ...
'Load parametrs for "My viewer"', ...
'MultiSelect', 'off');
@@ -103,49 +132,62 @@ function parameters_load(~,~)
ext = '.mat';
end
erpFilename = char(strcat(erpfilename,ext));
- MessageViewer= char(strcat('Viewer Properties > Load'));
- erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- viewer_ERPDAT.Process_messg =1;
try
ERPwaviewer = importdata([filepath,erpFilename]);
-
- if isempty(ERPwaviewer.ALLERP)
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- question = ['Do you want to use the default "ALLERP"? \n Because there is no "ALLERP" in the file'];
- title = 'My Viewer>Viewer Properties';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf(question), title,'Cancel','No', 'Yes','Yes');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor);
- if strcmpi(button,'Yes')
- ERPwaviewerdef = evalin('base','ALLERPwaviewer');
- ERPwaviewer.ALLERP= ERPwaviewerdef.ALLERP;
- ERPwaviewer.ERP = ERPwaviewerdef.ERP;
- else
- if strcmpi(button,'No')
- beep;
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Load: \n Cannot use the file because no ALLERP can be used.\n\n');
- else
- beep
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Load: \n User selected cancel.\n\n');
- end
- return;
- end
- end
-
+ ERPwaviewerdef = evalin('base','ALLERPwaviewer');
+ ERPwaviewer.ALLERP= ERPwaviewerdef.ALLERP;
+ ERPwaviewer.ERP = ERPwaviewerdef.ERP;
+ ERPwaviewer.CURRENTERP = ERPwaviewerdef.CURRENTERP;
+ ERPwaviewer.SelectERPIdx = ERPwaviewerdef.SelectERPIdx;
+ ERPwaviewer.PageIndex = ERPwaviewerdef.PageIndex;
assignin('base','ALLERPwaviewer',ERPwaviewer);
catch
beep;
+ MessageViewer=['\n\n My viewer > Viewer Propoerties > Load: Cannot load the saved parameters of My viewer '];
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Load: \n Cannot load the saved parameters of My viewer.\n\n');
return;
end
- viewer_ERPDAT.count_loadproper = viewer_ERPDAT.count_loadproper+1;
- % estudioworkingmemory('zoomSpace',1.5);
+
+ %%check current version
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
+ try
+ [version1 reldate] = geterplabstudioversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ else
+ try
+ [version1 reldate] = geterplabversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ end
+ erplabstudioverNum = str2num(erplabstudiover);
+ try
+ erplabstudioverNumOld = str2num(ERPwaviewer.version);
+ catch
+ erplabstudioverNumOld = [];
+ end
+ if isempty(erplabstudioverNumOld) || erplabstudioverNumOld Load - This settings file was created using an older version of EStudio'));
+ elseif strcmpi(ERPtooltype,'ERPLAB')
+ MessageViewer= char(strcat('Viewer Properties > Load - This settings file was created using an older version of ERPLAB'));
+ end
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ end
+
+ viewer_ERPDAT.loadproper_count = 1;
f_redrawERP_viewer_test();
+
+ MessageViewer= char(strcat('Viewer Properties > Load'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =2;
end
@@ -166,35 +208,42 @@ function parameters_save(~,~)
namedef ='Viewer';
erpFilename = char(strcat(namedef,'.mat'));
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- question = ['Do you want to include "ALLERP"?'];
- title = 'My Viewer>Viewer Properties';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf(question), title,'Cancel','No', 'Yes','Yes');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor);
-
- if strcmpi(button,'No') || strcmpi(button,'Yes')
- if strcmpi(button,'No')
- ERPwaviewer.ALLERP = [];
- ERPwaviewer.ERP = [];
- end
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
try
- save([pathstr,filesep,erpFilename],'ERPwaviewer','-v7.3');
- viewer_ERPDAT.Process_messg =2;
+ [version1 reldate] = geterplabstudioversion;
+ erplabstudiover = version1;
catch
- beep;
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Save as: \n Cannot save the parameters of My viewer.\n\n');
- return;
+ erplabstudiover = '';
end
else
+ try
+ [version1 reldate] = geterplabversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ end
+ ERPwaviewer.version = erplabstudiover;
+
+
+ ERPwaviewer.ALLERP = [];
+ ERPwaviewer.ERP = [];
+ ERPwaviewer.CURRENTERP = [];
+ ERPwaviewer.SelectERPIdx = [];
+ ERPwaviewer.PageIndex = [];
+ try
+ save([pathstr,filesep,erpFilename],'ERPwaviewer','-v7.3');
+ catch
beep;
+ MessageViewer= char(strcat('Viewer Propoerties > Save: \n Cannot save the parameters of My viewer'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Save as: \n User selected cancel.\n\n');
return;
end
-
+ MessageViewer= char(strcat('Viewer Properties > Save'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
%%-------------------------Setting for Save as--------------------------------
function parameters_saveas(~,~)
@@ -235,39 +284,43 @@ function parameters_saveas(~,~)
end
erpFilename = char(strcat(erpfilename,ext));
-
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- question = ['Do you want to include "ALLERP"?'];
- title = 'My Viewer>Viewer Properties';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf(question), title,'Cancel','No', 'Yes','Yes');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor);
-
- if strcmpi(button,'No') || strcmpi(button,'Yes')
- if strcmpi(button,'No')
- ERPwaviewer.ALLERP = [];
- ERPwaviewer.ERP = [];
- end
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
try
- save([erppathname,erpFilename],'ERPwaviewer','-v7.3');
- viewer_ERPDAT.Process_messg =2;
+ [version1 reldate] = geterplabstudioversion;
+ erplabstudiover = version1;
catch
- beep;
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Save as: \n Cannot save the parameters of My viewer.\n\n');
- return;
+ erplabstudiover = '';
end
else
+ try
+ [version1 reldate] = geterplabversion;
+ erplabstudiover = version1;
+ catch
+ erplabstudiover = '';
+ end
+ end
+ ERPwaviewer.version = erplabstudiover;
+ ERPwaviewer.ALLERP = [];
+ ERPwaviewer.ERP = [];
+ ERPwaviewer.CURRENTERP = [];
+ ERPwaviewer.SelectERPIdx = [];
+ ERPwaviewer.PageIndex = [];
+ try
+ save([erppathname,erpFilename],'ERPwaviewer','-v7.3');
+ catch
beep;
viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n\n My viewer > Viewer Propoerties > Save as: \n User selected cancel.\n\n');
+ fprintf(2,'\n\n My viewer > Viewer Propoerties > Save as: \n Cannot save the parameters of My viewer.\n\n');
return;
end
+ MessageViewer= char(strcat('Viewer Properties > Save as'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
-%%----------------Setting for location path-----------------------------
+%%------------------Title name for Wave Viewer-----------------------------
function viewer_TN(source_locationname,~)
MessageViewer= char(strcat('Viewer Properties > Title'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
@@ -297,4 +350,132 @@ function viewer_TN(source_locationname,~)
gui_erp_waviewer.Window.Name = currvers;
viewer_ERPDAT.Process_messg =2;
end
+
+
+ function Viewerpos(Str,~)
+ New_pos = str2num(Str.String);
+ MessageViewer= char(strcat('Viewer Properties > Position'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+ try
+ ScreenPos = get( groot, 'Screensize' );
+ catch
+ ScreenPos = get( 0, 'Screensize' );
+ end
+ if isempty(New_pos) || numel(New_pos)~=4
+ MessageViewer= char(strcat('Viewer Properties > Position- 4 numbers are needed for Viewer position (e.g., [1 1 1200 700])'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ % fprintf(2,['\n Warning: ',MessageViewer,'.\n']);
+ viewer_ERPDAT.Process_messg =4;
+ new_pos = gui_erp_waviewer.Window.Position;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+ gui_property_waveviewer.parameters_pos.String = num2str(new_pos);
+ return;
+ end
+
+ xyValue = New_pos(1:2);
+ WHpos = New_pos(3:4);
+ if min(xyValue(:))<-100 || max(xyValue(:)) >100
+ MessageViewer= char(strcat('Viewer Properties > X and Y values should be between [-100 100]'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ new_pos = gui_erp_waviewer.Window.Position;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+ gui_property_waveviewer.parameters_pos.String = num2str(new_pos);
+ return;
+ end
+ if min(WHpos(:))<0 || max(WHpos(:))>100
+ MessageViewer= char(strcat('Viewer Properties > width and height values should be between [0 100]'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ new_pos = gui_erp_waviewer.Window.Position;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+ gui_property_waveviewer.parameters_pos.String = num2str(new_pos);
+ return;
+ end
+
+ if New_pos(1)>90 || New_pos(1)< -90
+ MessageViewer= char(strcat('Viewer Properties > Position: Left is better within [-90 90], otherwise, the main GUI will disappear.'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ new_pos = gui_erp_waviewer.Window.Position;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+ gui_property_waveviewer.parameters_pos.String = num2str(new_pos);
+ return;
+ end
+
+ if New_pos(2)< -90
+ MessageViewer= char(strcat('Viewer Properties > Position: Bottom should be larger than -90, otherwise, the main GUI will disappear.'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =4;
+ new_pos = gui_erp_waviewer.Window.Position;
+ new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+ gui_property_waveviewer.parameters_pos.String = num2str(new_pos);
+ return;
+ end
+
+ erpworkingmemory('ERPWaveScreenPos',New_pos);
+ gui_erp_waviewer.screen_pos = New_pos;
+ New_pos1 = roundn(New_pos,-3);
+ New_poStr = char([num2str(New_pos1(1)),32,num2str(New_pos1(2)),32,num2str(New_pos1(3)),32,num2str(New_pos1(4))]);
+ gui_property_waveviewer.parameters_pos.String = New_poStr;
+
+
+ New_pos =[ScreenPos(3)*New_pos(1)/100,ScreenPos(4)*New_pos(2)/100,ScreenPos(3)*New_pos(3)/100,ScreenPos(4)*New_pos(4)/100];
+ gui_erp_waviewer.Window.Position= New_pos;
+ viewer_ERPDAT.Process_messg =2;
+ f_redrawERP_viewer_test();
+ end
+
+%%Update the Viewer position automatically
+ function ViewerPos(~,~)
+
+ ERPLAB_ERPWaviewer= erpworkingmemory('ERPLAB_ERPWaviewer');
+ if ERPLAB_ERPWaviewer==1
+ viewer_ERPDAT.ERPset_Chan_bin_label=2;
+ end
+
+ try
+ ScreenPos = get( groot, 'Screensize' );
+ catch
+ ScreenPos = get( 0, 'Screensize' );
+ end
+ try
+ New_pos = gui_erp_waviewer.Window.Position;
+ catch
+ return;
+ end
+ New_pos1 = [100*New_pos(1)/ScreenPos(3),100*New_pos(2)/ScreenPos(4),100*New_pos(3)/ScreenPos(3),100*New_pos(4)/ScreenPos(4)];
+ try
+ Old_pos = gui_erp_waviewer.screen_pos;
+ New_pos = [100*New_pos(1)/ScreenPos(3),100*New_pos(2)/ScreenPos(4),Old_pos(3),Old_pos(4)];
+ catch
+ New_pos = [100*New_pos(1)/ScreenPos(3),100*New_pos(2)/ScreenPos(4),100*New_pos(3)/ScreenPos(3),100*New_pos(4)/ScreenPos(4)];
+ end
+
+ if New_pos1(1)>90 || New_pos1(1)< -90 || New_pos(2)< -90 || min(New_pos1(3:4))<-100 || max(New_pos1(3:4)) >100 %% from different size of monitor
+ New_pos = [0.01,0.01,75,75];
+ new_pos =[ScreenPos(3)*New_pos(1)/100,ScreenPos(4)*New_pos(2)/100,ScreenPos(3)*New_pos(3)/100,ScreenPos(4)*New_pos(4)/100];
+ set(gui_erp_waviewer.Window, 'Position', new_pos);
+
+ zoomSpace = 100*((gui_erp_waviewer.ViewAxes.Widths+240)-gui_erp_waviewer.Window.Position(3))/gui_erp_waviewer.Window.Position(3);
+ if isempty(zoomSpace) || zoomSpace<0
+ zoomSpace = 0;
+ end
+ if zoomSpace ==0
+ gui_erp_waviewer.ScrollVerticalOffsets=0;
+ gui_erp_waviewer.ScrollHorizontalOffsets=0;
+ end
+ estudioworkingmemory('zoomSpace',zoomSpace);
+ gui_erp_waviewer.zoom_edit.String = num2str(roundn(zoomSpace,-1));
+
+ end
+
+ New_pos = roundn(New_pos,-3);
+ New_poStr = char([num2str(New_pos(1)),32,num2str(New_pos(2)),32,num2str(New_pos(3)),32,num2str(New_pos(4))]);
+
+ gui_property_waveviewer.parameters_pos.String = New_poStr;
+ % erpworkingmemory('ERPWaveScreenPos',New_pos);
+ gui_erp_waviewer.screen_pos = New_pos;
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_timeampscal_waveviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_timeampscal_waveviewer_GUI.m
index 0174656e..96299bff 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_timeampscal_waveviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERP_timeampscal_waveviewer_GUI.m
@@ -13,7 +13,7 @@
addlistener(viewer_ERPDAT,'v_currentERP_change',@v_currentERP_change);
addlistener(viewer_ERPDAT,'page_xyaxis_change',@page_xyaxis_change);
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
@@ -41,7 +41,7 @@
FonsizeDefault = [];
end
if isempty(FonsizeDefault)
- FonsizeDefault = f_get_default_fontsize();
+ FonsizeDefault = f_get_default_fontsize();
end
@@ -50,24 +50,43 @@
function drawui_plot_xyaxis_viewer(FonsizeDefault)
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
+ MERPWaveViewer_xaxis= estudioworkingmemory('MERPWaveViewer_xaxis');%%call the memery for this panel
+ MERPWaveViewer_yaxis= estudioworkingmemory('MERPWaveViewer_yaxis');
try
- ALLERPwaviewer = evalin('base','ALLERPwaviewer');
- ERPwaviewer = ALLERPwaviewer;
+ ERPwaviewer = evalin('base','ALLERPwaviewer');
catch
beep;
disp('f_ERP_timeampscal_waveviewer_GUI() error: Please run the ERP wave viewer again.');
return;
end
+
+ %%Set for x units: 1 is in Second; 0 is in millisecond
try
- timeArray(1) = ERPwaviewer.ERP.times(1);
- timeArray(2) = ERPwaviewer.ERP.times(end);
+ xdispysecondValue= MERPWaveViewer_xaxis{1};
catch
- timeArray = [];
+ xdispysecondValue = 1;
+ MERPWaveViewer_xaxis{1} = xdispysecondValue;
+ end
+ if numel(xdispysecondValue)~=1 || (xdispysecondValue~=1 && xdispysecondValue~=0 )
+ xdispysecondValue = 1;
+ MERPWaveViewer_xaxis{1} = xdispysecondValue;
end
+
+ %%x scale
try
- timerangeAuto = ERPwaviewer.xaxis.trangeauto;
+ timerangeAutodef = ERPwaviewer.xaxis.trangeauto;
catch
- timerangeAuto =1;
+ timerangeAutodef =1;
+ end
+ try
+ timerangeAuto= MERPWaveViewer_xaxis{2};
+ catch
+ timerangeAuto = timerangeAutodef;
+ MERPWaveViewer_xaxis{2} = timerangeAutodef;
+ end
+ if isempty(timerangeAuto) || numel(timerangeAuto)~=1 || (timerangeAuto~=1 && timerangeAuto~=0)
+ timerangeAuto = timerangeAutodef;
+ MERPWaveViewer_xaxis{2} = timerangeAutodef;
end
gui_erpxyaxeset_waveviewer.DataSelBox = uiextras.VBox('Parent', box_erpxtaxes_viewer_property,'BackgroundColor',ColorBviewer_def);
@@ -77,16 +96,33 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try
ERPIN = ERPwaviewer.ERP;
- timeArray(1) = ERPwaviewer.ERP.times(1);
- timeArray(2) = ERPwaviewer.ERP.times(end);
- [timeticks stepX]= default_time_ticks_studio(ERPIN, [timeArray(1),timeArray(2)]);
+ timeArraydef(1) = ERPwaviewer.ERP.times(1);
+ timeArraydef(2) = ERPwaviewer.ERP.times(end);
+ [timeticksdef stepX]= default_time_ticks_studio(ERPIN, [timeArraydef(1),timeArraydef(2)]);
if ~isempty(stepX) && numel(stepX) ==1
stepX = floor(stepX/2);
end
catch
- timeticks = [];
+ timeticksdef = '';
timeArray =[];
end
+ try
+ timeArray= MERPWaveViewer_xaxis{3};
+ catch
+ timeArray = timeArraydef;
+ MERPWaveViewer_xaxis{3} = timeArray;
+ end
+ if numel(timeArray)~=2 || isempty(timeArray)
+ timeArray = timeArraydef;
+ MERPWaveViewer_xaxis{3} = timeArray;
+ end
+ if timerangeAuto==1
+ timeArray = timeArraydef;
+ MERPWaveViewer_xaxis{3} = timeArray;
+ end
+ if xdispysecondValue==0
+ timeArray = timeArray/1000;
+ end
%%-----------------Setting for time range-------
gui_erpxyaxeset_waveviewer.xaxis_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xaxis_title,'String','X Axis:',...
@@ -96,24 +132,35 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
gui_erpxyaxeset_waveviewer.display_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.display_title,...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Display in','HorizontalAlignment','left'); %
- xdispysecondValue = 1;
gui_erpxyaxeset_waveviewer.xmillisecond = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.display_title,...
'callback',@xmilsecond,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Millisecond','Value',xdispysecondValue); %
+ gui_erpxyaxeset_waveviewer.xmillisecond.KeyPressFcn = @xyaxis_presskey;
+ ERPwaviewer.xaxis.tdis = gui_erpxyaxeset_waveviewer.xmillisecond.Value;
gui_erpxyaxeset_waveviewer.xsecond = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.display_title,...
'callback',@xsecond,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Second','Value',~xdispysecondValue); %
+ gui_erpxyaxeset_waveviewer.xsecond.KeyPressFcn = @xyaxis_presskey;
set(gui_erpxyaxeset_waveviewer.display_title,'Sizes',[75 90 75]);
- ERPwaviewer.xaxis.tdis = 1;
- erpworkingmemory('MyViewer_xaxis_second',0);
- erpworkingmemory('MyViewer_xaxis_msecond',1);
+ if timerangeAutodef==1
+ % ERPwaviewer.xaxis.tdis = 1;
+ erpworkingmemory('MyViewer_xaxis_second',0);
+ erpworkingmemory('MyViewer_xaxis_msecond',1);
+ else
+ % ERPwaviewer.xaxis.tdis = 0;
+ erpworkingmemory('MyViewer_xaxis_second',1);
+ erpworkingmemory('MyViewer_xaxis_msecond',0);
+ end
%%------time range------
gui_erpxyaxeset_waveviewer.xtimerange_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_erpxyaxeset_waveviewer.timerange_label = uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimerange_title,...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Time Range','Max',10,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.timerange_edit = uicontrol('Style','edit','Parent', gui_erpxyaxeset_waveviewer.xtimerange_title,'String',num2str(timeArray),...
'callback',@timerangecustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
+ gui_erpxyaxeset_waveviewer.timerange_edit.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.xtimerangeauto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.xtimerange_title,'String','Auto',...
'callback',@xtimerangeauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',timerangeAuto); %
+ gui_erpxyaxeset_waveviewer.xtimerangeauto.KeyPressFcn = @xyaxis_presskey;
+
if gui_erpxyaxeset_waveviewer.xtimerangeauto.Value ==1
enableName = 'off';
else
@@ -121,61 +168,127 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
end
gui_erpxyaxeset_waveviewer.timerange_edit.Enable = enableName;
set(gui_erpxyaxeset_waveviewer.xtimerange_title,'Sizes',[80 100 60]);
- ERPwaviewer.xaxis.timerange = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ if xdispysecondValue==1
+ ERPwaviewer.xaxis.timerange = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ else
+ ERPwaviewer.xaxis.timerange = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String))*1000;
+ end
ERPwaviewer.xaxis.trangeauto = gui_erpxyaxeset_waveviewer.xtimerangeauto.Value;
%%----------------------time ticks---------------------------------
stepX = [];
- timeticksAuto = 1;
- xtick_precision =0;
+ try
+ timeticksAuto= MERPWaveViewer_xaxis{4};
+ catch
+ timeticksAuto = 1;
+ MERPWaveViewer_xaxis{4}=1;
+ end
+ if isempty(timeticksAuto)|| numel(timeticksAuto)~=1 || (timeticksAuto~=1 && timeticksAuto~=0)
+ timeticksAuto = 1;
+ MERPWaveViewer_xaxis{4}=1;
+ end
+ timeticksdef = str2num(char(timeticksdef));
+ try
+ timeticks = MERPWaveViewer_xaxis{5};
+ catch
+ timeticks = timeticksdef;
+ MERPWaveViewer_xaxis{5} =timeticks;
+ end
+ if timeticksAuto==1
+ timeticks = timeticksdef;
+ MERPWaveViewer_xaxis{5} =timeticks;
+ end
+ if xdispysecondValue==0
+ timeticks = timeticks/1000;
+ end
+
+ %%Precision for xtick labels
+ try
+ xtick_precision= MERPWaveViewer_xaxis{6};
+ catch
+ if xdispysecondValue==1
+ xtick_precision =0;
+ else
+ xtick_precision =1;
+ end
+ MERPWaveViewer_xaxis{6} = xtick_precision;
+ end
+ if xdispysecondValue==1
+ xprecisoonName = {'0','1','2','3','4','5','6'};
+ if xtick_precision<0 || xtick_precision>6
+ MERPWaveViewer_xaxis{6} = 0;
+ xtick_precision =0;
+ end
+ else
+ xprecisoonName = {'1','2','3','4','5','6'};
+ if xtick_precision<1 || xtick_precision>6
+ MERPWaveViewer_xaxis{6} = 1;
+ xtick_precision =1;
+ MERPWaveViewer_xaxis{6} = xtick_precision;
+ end
+ end
+ timeticks= f_decimal(timeticks,xtick_precision);
gui_erpxyaxeset_waveviewer.xtimetick_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_erpxyaxeset_waveviewer.timeticks_label = uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimetick_title ,...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Time Ticks','HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.timeticks_edit = uicontrol('Style','edit','Parent', gui_erpxyaxeset_waveviewer.xtimetick_title ,'String',timeticks,...
'callback',@timetickscustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
+ gui_erpxyaxeset_waveviewer.timeticks_edit.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.xtimetickauto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.xtimetick_title ,'String','Auto',...
'callback',@xtimetickauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',timeticksAuto); %
+ gui_erpxyaxeset_waveviewer.xtimetickauto.KeyPressFcn = @xyaxis_presskey;
if gui_erpxyaxeset_waveviewer.xtimetickauto.Value ==1
enableName_tick = 'off';
else
enableName_tick = 'on';
end
- % gui_erpxyaxeset_waveviewer.timeticks_label.Enable = enableName_tick;
gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = enableName_tick;
set(gui_erpxyaxeset_waveviewer.xtimetick_title,'Sizes',[80 100 60]);
- ERPwaviewer.xaxis.timeticks = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ if xdispysecondValue==1
+ ERPwaviewer.xaxis.timeticks = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ else
+ ERPwaviewer.xaxis.timeticks = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String))*1000;
+ end
ERPwaviewer.xaxis.ticksauto = gui_erpxyaxeset_waveviewer.xtimetickauto.Value;
-
%%--------x tick precision with decimals---------------------------
gui_erpxyaxeset_waveviewer.xtickprecision_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.xtickprecision_title);
uicontrol('Style','text','Parent',gui_erpxyaxeset_waveviewer.xtickprecision_title ,...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Precision','HorizontalAlignment','left'); %
- xprecisoonName = {'0','1','2','3','4','5','6'};
+ if xdispysecondValue==1
+ xtick_precision =xtick_precision+1;
+ end
gui_erpxyaxeset_waveviewer.xticks_precision = uicontrol('Style','popupmenu','Parent',gui_erpxyaxeset_waveviewer.xtickprecision_title,'String',xprecisoonName,...
- 'callback',@xticksprecison,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',xtick_precision+1); %
+ 'callback',@xticksprecison,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',xtick_precision); %
+ gui_erpxyaxeset_waveviewer.xticks_precision.KeyPressFcn = @xyaxis_presskey;
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtickprecision_title,'String','# decimals',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
set(gui_erpxyaxeset_waveviewer.xtickprecision_title,'Sizes',[30 65 60 80]);
- ERPwaviewer.xaxis.tickdecimals = gui_erpxyaxeset_waveviewer.xticks_precision.Value-1;
-
-
+ if xdispysecondValue==1
+ ERPwaviewer.xaxis.tickdecimals = gui_erpxyaxeset_waveviewer.xticks_precision.Value-1;
+ else
+ ERPwaviewer.xaxis.tickdecimals = gui_erpxyaxeset_waveviewer.xticks_precision.Value;
+ end
%%-----time minor ticks--------------------------------------------
- xticksStr = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
- stepX = [];
+ if xdispysecondValue==1
+ xticksStr = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ else
+ xticksStr = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String))*1000;
+ end
+ stepXdef = [];
if ~isempty(xticksStr) && numel(xticksStr)>1
if numel(xticksStr)>=2
for Numofxticks = 1:numel(xticksStr)-1
- stepX(1,Numofxticks) = xticksStr(Numofxticks)+(xticksStr(Numofxticks+1)-xticksStr(Numofxticks))/2;
+ stepXdef(1,Numofxticks) = xticksStr(Numofxticks)+(xticksStr(Numofxticks+1)-xticksStr(Numofxticks))/2;
end
%%adjust the left edge
stexleft = (xticksStr(2)-xticksStr(1))/2;
for ii = 1:1000
if (xticksStr(1)- stexleft*ii)>=timeArray(1)
- stepX = [(xticksStr(1)- stexleft*ii),stepX];
+ stepXdef = [(xticksStr(1)- stexleft*ii),stepXdef];
else
break;
end
@@ -184,46 +297,100 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
stexright = (xticksStr(end)-xticksStr(end-1))/2;
for ii = 1:1000
if (xticksStr(end)+ stexright*ii)<=timeArray(end)
- stepX = [stepX,(xticksStr(end)+ stexright*ii)];
+ stepXdef = [stepXdef,(xticksStr(end)+ stexright*ii)];
else
break;
end
end
end
end
- timeminorLabel = 0;
+ try
+ timeminorLabel= MERPWaveViewer_xaxis{7};
+ catch
+ timeminorLabel = 0;
+ MERPWaveViewer_xaxis{7} = 0;
+ end
+ if isempty(timeminorLabel) || numel(timeminorLabel)~=1 || (timeminorLabel~=1 && timeminorLabel~=0)
+ timeminorLabel = 0;
+ MERPWaveViewer_xaxis{7} = 0;
+ end
if timeminorLabel==1
xminorEnable_auto = 'on';
else
xminorEnable_auto = 'off';
end
- timeminorstep = 1;
+ try
+ stepX = MERPWaveViewer_xaxis{8};
+ if isempty(stepX)
+ MERPWaveViewer_xaxis{8} = stepXdef;
+ stepX = stepXdef;
+ end
+ catch
+ MERPWaveViewer_xaxis{8} = stepXdef;
+ stepX = stepXdef;
+ end
+
+ try
+ timeminorstep = MERPWaveViewer_xaxis{9};
+ catch
+ MERPWaveViewer_xaxis{9} =1;
+ timeminorstep = 1;
+ end
+ if isempty(timeminorstep)|| numel(timeminorstep)~=1 || (timeminorstep~=1 && timeminorstep~=0)
+ MERPWaveViewer_xaxis{9} =1;
+ timeminorstep = 1;
+ end
+
if timeminorstep ==1
xminorEnable_custom = 'off';
+ MERPWaveViewer_xaxis{8} = stepXdef;
+ stepX = stepXdef;
else
xminorEnable_custom = 'on';
end
+ if xdispysecondValue==0
+ stepX = stepX/1000;
+ end
gui_erpxyaxeset_waveviewer.xtimeminnortick_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_erpxyaxeset_waveviewer.xtimeminorauto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.xtimeminnortick_title ,...
'callback',@timeminortickslabel,'String','Minor ticks','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left','Value',timeminorLabel); %
+ gui_erpxyaxeset_waveviewer.xtimeminorauto.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.timeminorticks_custom = uicontrol('Style','edit','Parent', gui_erpxyaxeset_waveviewer.xtimeminnortick_title ,...
'callback',@timeminorticks_custom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'String',num2str(stepX),'Enable',xminorEnable_custom); %
+ gui_erpxyaxeset_waveviewer.timeminorticks_custom.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.timeminorticks_auto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.xtimeminnortick_title,...
'callback',@timeminortickscustom_auto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Auto','Value',timeminorstep, 'Enable',xminorEnable_auto); %
+ gui_erpxyaxeset_waveviewer.timeminorticks_auto.KeyPressFcn = @xyaxis_presskey;
set(gui_erpxyaxeset_waveviewer.xtimeminnortick_title,'Sizes',[90 90 50]);
ERPwaviewer.xaxis.tminor.disp = gui_erpxyaxeset_waveviewer.xtimeminorauto.Value;
- ERPwaviewer.xaxis.tminor.step = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ if xdispysecondValue==1
+ ERPwaviewer.xaxis.tminor.step = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ else
+ ERPwaviewer.xaxis.tminor.step = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String))*1000;
+ end
+
ERPwaviewer.xaxis.tminor.auto = gui_erpxyaxeset_waveviewer.timeminorticks_auto.Value;
%%-----time ticks label--------------------------------------------
- timetickLabel = 1;
+ try
+ timetickLabel= MERPWaveViewer_xaxis{10};
+ catch
+ MERPWaveViewer_xaxis{10}=1;
+ timetickLabel = 1;
+ end
+ if isempty(timetickLabel) || numel(timetickLabel)~=1 || (timetickLabel~=1 && timetickLabel~=0)
+ MERPWaveViewer_xaxis{10}=1;
+ timetickLabel = 1;
+ end
gui_erpxyaxeset_waveviewer.xtimelabel_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimelabel_title ,'String','Labels',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.xtimelabel_on = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.xtimelabel_title,...
'callback',@xtimelabelon,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','On','Value',timetickLabel); %
+ gui_erpxyaxeset_waveviewer.xtimelabel_on.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.xtimelabel_off = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.xtimelabel_title,...
'callback',@xtimelabeloff,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Off','Value',~timetickLabel); %
+ gui_erpxyaxeset_waveviewer.xtimelabel_off.KeyPressFcn = @xyaxis_presskey;
uiextras.Empty('Parent',gui_erpxyaxeset_waveviewer.xtimelabel_title);
set(gui_erpxyaxeset_waveviewer.xtimelabel_title,'Sizes',[50 50 50 80]);
if gui_erpxyaxeset_waveviewer.xtimelabel_on.Value ==1
@@ -235,22 +402,51 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
%%-----font, font size, and text color for time ticks--------------
- ttickLabelfont = 2;
+ try
+ ttickLabelfont = MERPWaveViewer_xaxis{11};
+ catch
+ ttickLabelfont = 3;
+ MERPWaveViewer_xaxis{11}=3;
+ end
+ if isempty(ttickLabelfont) || numel(ttickLabelfont)~=1 || ttickLabelfont<1 || ttickLabelfont>20
+ ttickLabelfont = 3;
+ MERPWaveViewer_xaxis{11}=3;
+ end
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
xfontsizeinum = str2num(char(fontsize));
- ttickLabelfontsizeV = 4;
- ttickLabelfontcolor = 1;
+ try
+ ttickLabelfontsizeV = MERPWaveViewer_xaxis{12};
+ catch
+ ttickLabelfontsizeV = 4;
+ MERPWaveViewer_xaxis{12}=4;
+ end
+ if isempty(ttickLabelfontsizeV) || numel(ttickLabelfontsizeV)~=1 || ttickLabelfontsizeV<1 || ttickLabelfontsizeV>20
+ ttickLabelfontsizeV = 4;
+ MERPWaveViewer_xaxis{12}=4;
+ end
+ try
+ ttickLabelfontcolor= MERPWaveViewer_xaxis{13};
+ catch
+ ttickLabelfontcolor = 1;
+ MERPWaveViewer_xaxis{13} =1;
+ end
+ if isempty(ttickLabelfontcolor) || numel(ttickLabelfontcolor)~=1 || ttickLabelfontcolor<1 || ttickLabelfontcolor>7
+ ttickLabelfontcolor = 1;
+ MERPWaveViewer_xaxis{13} =1;
+ end
gui_erpxyaxeset_waveviewer.xtimefont_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimefont_title,'String','Font',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
gui_erpxyaxeset_waveviewer.xtimefont_custom = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.xtimefont_title ,'String',fonttype,...
'callback',@xtimefont,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',fontenable,'Value',ttickLabelfont); %
+ gui_erpxyaxeset_waveviewer.xtimefont_custom.KeyPressFcn = @xyaxis_presskey;
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimefont_title ,'String','Size',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.font_custom_size = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.xtimefont_title ,'String',fontsize,...
'callback',@xtimefontsize,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',fontenable,'Value',ttickLabelfontsizeV); %
+ gui_erpxyaxeset_waveviewer.font_custom_size.KeyPressFcn = @xyaxis_presskey;
set(gui_erpxyaxeset_waveviewer.xtimefont_title,'Sizes',[30 100 30 80]);
ERPwaviewer.xaxis.font = gui_erpxyaxeset_waveviewer.xtimefont_custom.Value;
ERPwaviewer.xaxis.fontsize = xfontsizeinum(gui_erpxyaxeset_waveviewer.font_custom_size.Value);
@@ -262,20 +458,32 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
textColor = {'Black','Red','Blue','Green','Orange','Cyan','Magenla'};
gui_erpxyaxeset_waveviewer.xtimetextcolor = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.xtimelabelcolor_title ,'String',textColor,...
'callback',@xtimecolor,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',fontenable,'Value',ttickLabelfontcolor); %
+ gui_erpxyaxeset_waveviewer.xtimetextcolor.KeyPressFcn = @xyaxis_presskey;
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.xtimelabelcolor_title);
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.xtimelabelcolor_title);
set(gui_erpxyaxeset_waveviewer.xtimelabelcolor_title,'Sizes',[40 100 30 70]);
ERPwaviewer.xaxis.fontcolor = gui_erpxyaxeset_waveviewer.xtimetextcolor.Value;
%%%----Setting for the xunits display--------------------------
- timeunits = 1;
+ try
+ timeunits= MERPWaveViewer_xaxis{14};
+ catch
+ timeunits = 1;
+ MERPWaveViewer_xaxis{14}=1;
+ end
+ if isempty(timeunits) || numel(timeunits)~=1 || (timeunits~=1 && timeunits~=0)
+ timeunits = 1;
+ MERPWaveViewer_xaxis{14}=1;
+ end
gui_erpxyaxeset_waveviewer.xtimeunits_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.xtimeunits_title ,'String','Units',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.xtimeunits_on = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.xtimeunits_title,...
'callback',@xtimeunitson,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','On','Value',timeunits); %
+ gui_erpxyaxeset_waveviewer.xtimeunits_on.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.xtimeunits_off = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.xtimeunits_title,...
'callback',@xtimeunitsoff,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Off','Value',~timeunits); %
+ gui_erpxyaxeset_waveviewer.xtimeunits_off.KeyPressFcn = @xyaxis_presskey;
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.xtimeunits_title);
set(gui_erpxyaxeset_waveviewer.xtimeunits_title,'Sizes',[50 50 50 80]);
ERPwaviewer.xaxis.units = gui_erpxyaxeset_waveviewer.xtimeunits_on.Value;
@@ -315,17 +523,44 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
else
yRangeLabel = num2str(yylim_out(yscales_v,:));
end
- yRangeauto = 1;
+ yRangeLabeldef = num2str(yRangeLabel);
+ try
+ yRangeauto= MERPWaveViewer_yaxis{1};
+ catch
+ yRangeauto = 1;
+ MERPWaveViewer_yaxis{1}=1;
+ end
+ if isempty(yRangeauto) || numel(yRangeauto)~=1 || (yRangeauto~=0 && yRangeauto~=1)
+ yRangeauto = 1;
+ MERPWaveViewer_yaxis{1}=1;
+ end
+
+ try
+ yRangeLabel = MERPWaveViewer_yaxis{2};
+ catch
+ yRangeLabel = yRangeLabeldef;
+ MERPWaveViewer_yaxis{2} = yRangeLabel;
+ end
+ if isempty(yRangeLabel) || numel(yRangeLabel)~=2
+ yRangeLabel = yRangeLabeldef;
+ MERPWaveViewer_yaxis{2} = yRangeLabel;
+ end
+ if yRangeauto==1
+ yRangeLabel = yRangeLabeldef;
+ MERPWaveViewer_yaxis{2} = yRangeLabel;
+ end
gui_erpxyaxeset_waveviewer.yaxis_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.yaxis_title,'String','Y Axis:',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',1,'HorizontalAlignment','center','FontWeight','bold'); %
gui_erpxyaxeset_waveviewer.yrange_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_erpxyaxeset_waveviewer.yrange_label = uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.yrange_title,...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Y Scale','Max',10,'HorizontalAlignment','left'); %
- gui_erpxyaxeset_waveviewer.yrange_edit = uicontrol('Style','edit','Parent', gui_erpxyaxeset_waveviewer.yrange_title,'String',yRangeLabel,...
+ gui_erpxyaxeset_waveviewer.yrange_edit = uicontrol('Style','edit','Parent', gui_erpxyaxeset_waveviewer.yrange_title,'String',num2str(yRangeLabel),...
'callback',@yrangecustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
+ gui_erpxyaxeset_waveviewer.yrange_edit.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.yrangeauto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.yrange_title,'String','Auto',...
'callback',@yrangeauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',yRangeauto); %
+ gui_erpxyaxeset_waveviewer.yrangeauto.KeyPressFcn = @xyaxis_presskey;
if gui_erpxyaxeset_waveviewer.yrangeauto.Value ==1
yenableName = 'off';
else
@@ -337,12 +572,46 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
ERPwaviewer.yaxis.scalesauto = gui_erpxyaxeset_waveviewer.yrangeauto.Value;
%%--------Y ticks--------------------------------------------------
- ytick_precision = 1;
+ try %%Auto for y ticks
+ yTickauto= MERPWaveViewer_yaxis{3};
+ catch
+ yTickauto = 1;
+ MERPWaveViewer_yaxis{3} = 1;
+ end
+ if isempty(yTickauto) || numel(yTickauto)~=1 || (yTickauto~=1 && yTickauto~=0)
+ yTickauto = 1;
+ MERPWaveViewer_yaxis{3} = 1;
+ end
+ try
+ ytick_precision= MERPWaveViewer_yaxis{5};
+ catch
+ ytick_precision = 1;
+ MERPWaveViewer_yaxis{5}=1;
+ end
+ if isempty(ytick_precision) ||numel(ytick_precision)~=1 || ytick_precision<0 || ytick_precision>6
+ ytick_precision = 1;
+ MERPWaveViewer_yaxis{5}=1;
+ end
+ yRangeLabel = gui_erpxyaxeset_waveviewer.yrange_edit.String;
yticksLabel = '';
if ~isempty(str2num(yRangeLabel))
yticksLabel = default_amp_ticks_viewer(str2num(yRangeLabel));
end
- yTickauto = 1;
+ if yTickauto==0
+ yticksLabelin = [];
+ try
+ yticksLabelin= MERPWaveViewer_yaxis{4};
+ catch
+ yticksLabelin = str2num(yRangeLabel);
+ MERPWaveViewer_yaxis{4} = yticksLabelin;
+ end
+ if isempty(yticksLabelin)
+ yticksLabelin = str2num(yRangeLabel);
+ MERPWaveViewer_yaxis{4} = yticksLabelin;
+ end
+ yticksLabel = num2str(yticksLabelin);
+ end
+
if isempty(str2num(yticksLabel))
yticksLabel = '';
else
@@ -362,8 +631,10 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Y Ticks','HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.yticks_edit = uicontrol('Style','edit','Parent',gui_erpxyaxeset_waveviewer.ytick_title,'String',yticksLabel,...
'callback',@ytickscustom,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %
+ gui_erpxyaxeset_waveviewer.yticks_edit.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.ytickauto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.ytick_title ,'String','Auto',...
'callback',@ytickauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'Value',yTickauto); %
+ gui_erpxyaxeset_waveviewer.ytickauto.KeyPressFcn = @xyaxis_presskey;
if gui_erpxyaxeset_waveviewer.ytickauto.Value ==1
yenableName_tick = 'off';
else
@@ -382,28 +653,59 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
yprecisoonName = {'0','1','2','3','4','5','6'};
gui_erpxyaxeset_waveviewer.yticks_precision = uicontrol('Style','popupmenu','Parent',gui_erpxyaxeset_waveviewer.ytickprecision_title,'String',yprecisoonName,...
'callback',@yticksprecison,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Value',ytick_precision+1); %
+ gui_erpxyaxeset_waveviewer.yticks_precision.KeyPressFcn = @xyaxis_presskey;
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.ytickprecision_title,'String','# decimals',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
set(gui_erpxyaxeset_waveviewer.ytickprecision_title,'Sizes',[30 65 60 80]);
ERPwaviewer.yaxis.tickdecimals = gui_erpxyaxeset_waveviewer.yticks_precision.Value-1;
%%-----y minor ticks-----------------------------------------------
- yminorLabel = 0;
+ try
+ yminorLabel= MERPWaveViewer_yaxis{6};
+ catch
+ yminorLabel= 0;
+ MERPWaveViewer_yaxis{6}=0;
+ end
+ if isempty(yminorLabel) || numel(yminorLabel)~=1 || (yminorLabel~=0&& yminorLabel~=1)
+ yminorLabel= 0;
+ MERPWaveViewer_yaxis{6}=0;
+ end
if yminorLabel ==1
yminorautoLabel = 'on';
else
yminorautoLabel ='off';
end
- yminorautoValue = 1;
+ try
+ yminorautoValue = MERPWaveViewer_yaxis{7};
+ catch
+ yminorautoValue = 1;
+ MERPWaveViewer_yaxis{7}=1;
+ end
+ if isempty(yminorautoValue) || numel(yminorautoValue)~=1 || (yminorautoValue~=1 && yminorautoValue~=0)
+ yminorautoValue = 1;
+ MERPWaveViewer_yaxis{7}=1;
+ end
if yminorautoValue ==1
yminoreditEnable = 'off';
else
yminoreditEnable = 'on';
end
- yticksStr = str2num(char(gui_erpxyaxeset_waveviewer.yticks_edit.String));
+ yticksStrdef = str2num(char(gui_erpxyaxeset_waveviewer.yticks_edit.String));
+ if yminorautoValue==1
+ yticksStr = yticksStrdef;
+ MERPWaveViewer_yaxis{8} = yticksStrdef;
+ else
+ try
+ yticksStr = MERPWaveViewer_yaxis{8};
+ catch
+ yticksStr = yticksStrdef;
+ MERPWaveViewer_yaxis{8} = yticksStrdef;
+ end
+ end
+
stepY = [];
- yscaleRange = (str2num(yRangeLabel));
+ yscaleRange = str2num(gui_erpxyaxeset_waveviewer.yrange_edit.String);
if ~isempty(yticksStr) && numel(yticksStr)>1
if numel(yticksStr)>=2
for Numofxticks = 1:numel(yticksStr)-1
@@ -432,24 +734,38 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
gui_erpxyaxeset_waveviewer.yminnortick_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
gui_erpxyaxeset_waveviewer.yminortick = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.yminnortick_title ,'String','Minor Ticks',...
'callback',@yminordisp,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left','Value',yminorLabel); %
+ gui_erpxyaxeset_waveviewer.yminortick.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.yminorstepedit = uicontrol('Style','edit','Parent',gui_erpxyaxeset_waveviewer.yminnortick_title ,...
'callback',@yminorstepedit,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'String',char(num2str(stepY)),'Enable',yminoreditEnable); %
+ gui_erpxyaxeset_waveviewer.yminorstepedit.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.yminorstep_auto = uicontrol('Style','checkbox','Parent', gui_erpxyaxeset_waveviewer.yminnortick_title,...
'callback',@yminorstepauto,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Auto','Value',yminorautoValue,'Enable',yminorautoLabel); %
+ gui_erpxyaxeset_waveviewer.yminorstep_auto.KeyPressFcn = @xyaxis_presskey;
ERPwaviewer.yaxis.yminor.disp = gui_erpxyaxeset_waveviewer.yminortick.Value;
ERPwaviewer.yaxis.yminor.step = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
ERPwaviewer.yaxis.yminor.auto = gui_erpxyaxeset_waveviewer.yminorstep_auto.Value;
set(gui_erpxyaxeset_waveviewer.yminnortick_title,'Sizes',[90 90 50]);
%%-----y ticks label-----------------------------------------------
- ytickLabel = 1;
+ try
+ ytickLabel = MERPWaveViewer_yaxis{9};
+ catch
+ ytickLabel = 1;
+ MERPWaveViewer_yaxis{9}=1;
+ end
+ if isempty(ytickLabel) || numel(ytickLabel)~=1 || (ytickLabel~=1 && ytickLabel~=0)
+ ytickLabel = 1;
+ MERPWaveViewer_yaxis{9}=1;
+ end
gui_erpxyaxeset_waveviewer.ylabel_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.ylabel_title,'String','Labels',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.ylabel_on = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.ylabel_title,...
'callback',@ylabelon,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','On','Value',ytickLabel); %
+ gui_erpxyaxeset_waveviewer.ylabel_on.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.ylabel_off = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.ylabel_title,...
'callback',@ylabeloff,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Off','Value',~ytickLabel); %
+ gui_erpxyaxeset_waveviewer.ylabel_off.KeyPressFcn = @xyaxis_presskey;
if gui_erpxyaxeset_waveviewer.ylabel_on.Value ==1
yfontenable = 'on';
else
@@ -460,21 +776,51 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
ERPwaviewer.yaxis.label = gui_erpxyaxeset_waveviewer.ylabel_on.Value;
%%-----y ticklabel:font, font size, and text color for time ticks
- ytickLabelfont = 2;
- ytickLabelfontsize = 4;
- ytickLabelfontcolor = 1;
+ try
+ ytickLabelfont= MERPWaveViewer_yaxis{10};
+ catch
+ ytickLabelfont = 3;
+ MERPWaveViewer_yaxis{10} =3;
+ end
+ if isempty(ytickLabelfont) || numel(ytickLabelfont)~=1 || ytickLabelfont<1 || ytickLabelfont>5
+ ytickLabelfont = 3;
+ MERPWaveViewer_yaxis{10} =3;
+ end
+
+ try
+ ytickLabelfontsize =MERPWaveViewer_yaxis{11};
+ catch
+ ytickLabelfontsize = 4;
+ MERPWaveViewer_yaxis{11}=4;
+ end
+ if isempty(ytickLabelfontsize) || ytickLabelfontsize<0 || ytickLabelfontsize>20
+ ytickLabelfontsize = 4;
+ MERPWaveViewer_yaxis{11}=4;
+ end
+ try
+ ytickLabelfontcolor = MERPWaveViewer_yaxis{12};
+ catch
+ ytickLabelfontcolor = 1;
+ MERPWaveViewer_yaxis{12}=1;
+ end
+ if isempty(ytickLabelfontcolor) || numel(ytickLabelfontcolor)~=1 || ytickLabelfontcolor<0 || ytickLabelfontcolor>5
+ ytickLabelfontcolor = 1;
+ MERPWaveViewer_yaxis{12}=1;
+ end
gui_erpxyaxeset_waveviewer.yfont_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.yfont_title,'String','Font',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
gui_erpxyaxeset_waveviewer.yfont_custom = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.yfont_title,'String',fonttype,...
'callback',@yaxisfont, 'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',yfontenable,'Value',ytickLabelfont); %
+ gui_erpxyaxeset_waveviewer.yfont_custom.KeyPressFcn = @xyaxis_presskey;
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.yfont_title ,'String','Size',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def); %
yfontsize={'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
gui_erpxyaxeset_waveviewer.yfont_custom_size = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.yfont_title ,'String',yfontsize,...
'callback',@yaxisfontsize,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',yfontenable,'Value',ytickLabelfontsize); %
+ gui_erpxyaxeset_waveviewer.yfont_custom_size.KeyPressFcn = @xyaxis_presskey;
set(gui_erpxyaxeset_waveviewer.yfont_title,'Sizes',[30 100 30 80]);
ERPwaviewer.yaxis.font = gui_erpxyaxeset_waveviewer.yfont_custom.Value;
ERPwaviewer.yaxis.fontsize = xfontsizeinum(gui_erpxyaxeset_waveviewer.yfont_custom_size.Value);
@@ -486,20 +832,32 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
ytextColor = {'Black','Red','Blue','Green','Orange','Cyan','Magenla'};
gui_erpxyaxeset_waveviewer.ytextcolor = uicontrol('Style','popupmenu','Parent', gui_erpxyaxeset_waveviewer.ylabelcolor_title ,'String',ytextColor,...
'callback',@yaxisfontcolor,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Enable',yfontenable,'Value',ytickLabelfontcolor); %
+ gui_erpxyaxeset_waveviewer.ytextcolor.KeyPressFcn = @xyaxis_presskey;
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.ylabelcolor_title);
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.ylabelcolor_title);
set(gui_erpxyaxeset_waveviewer.ylabelcolor_title,'Sizes',[40 100 30 70]);
ERPwaviewer.yaxis.fontcolor = gui_erpxyaxeset_waveviewer.ytextcolor.Value;
%%%-----------Setting for the units display of y axis---------------
- yunits = 1;
+ try
+ yunits = MERPWaveViewer_yaxis{13};
+ catch
+ MERPWaveViewer_yaxis{13}=1;
+ yunits = 1;
+ end
+ if isempty(yunits) || numel(yunits)~=1 || (yunits~=1 && yunits~=0)
+ MERPWaveViewer_yaxis{13}=1;
+ yunits = 1;
+ end
gui_erpxyaxeset_waveviewer.yunits_title = uiextras.HBox('Parent', gui_erpxyaxeset_waveviewer.DataSelBox,'BackgroundColor',ColorBviewer_def);
uicontrol('Style','text','Parent', gui_erpxyaxeset_waveviewer.yunits_title ,'String','Units',...
'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'HorizontalAlignment','left'); %
gui_erpxyaxeset_waveviewer.yunits_on = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.yunits_title,...
'callback',@yunitson,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','On','Value',yunits); %
+ gui_erpxyaxeset_waveviewer.yunits_on.KeyPressFcn = @xyaxis_presskey;
gui_erpxyaxeset_waveviewer.yunits_off = uicontrol('Style','radiobutton','Parent', gui_erpxyaxeset_waveviewer.yunits_title,...
'callback',@yunitsoff,'FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def,'String','Off','Value',~yunits); %
+ gui_erpxyaxeset_waveviewer.yunits_off.KeyPressFcn = @xyaxis_presskey;
uiextras.Empty('Parent', gui_erpxyaxeset_waveviewer.yunits_title);
set(gui_erpxyaxeset_waveviewer.yunits_title,'Sizes',[50 50 50 80]);
ERPwaviewer.yaxis.units = gui_erpxyaxeset_waveviewer.yunits_on.Value;
@@ -516,8 +874,9 @@ function drawui_plot_xyaxis_viewer(FonsizeDefault)
set(gui_erpxyaxeset_waveviewer.help_run_title,'Sizes',[40 70 20 70 30]);
%%save the parameters
- ALLERPwaviewer=ERPwaviewer;
- assignin('base','ALLERPwaviewer',ALLERPwaviewer);
+ assignin('base','ALLERPwaviewer',ERPwaviewer);
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%% save parameters for x axis to memory file
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%% save parameters for y axis to memory file
end
%%*********************************************************************************************************************************%%
@@ -880,10 +1239,10 @@ function timerangecustom(Strtimcustom,~)
if xdisSecondValue==0
timeArray = timeArray/1000;
end
- if numel(timcustom)==1 || isempty(timcustom)
+ if isempty(timcustom) || numel(timcustom)~=2
messgStr = strcat('Time range in "Time and Amplitude Scales" - Inputs must be two numbers!');
erpworkingmemory('ERPViewer_proces_messg',messgStr);
- fprintf(2,['\n Warning: ',messgStr,'.\n']);
+ % fprintf(2,['\n Warning: ',messgStr,'.\n']);
Strtimcustom.String = num2str(timeArray);
viewer_ERPDAT.Process_messg =4;
return;
@@ -1139,7 +1498,7 @@ function timeminortickscustom_auto(Str,~)
stepX = [];
if ~isempty(xticks) && numel(xticks)>1
timeArray = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
- xticksStr = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ xticksStr = xticks;
stepX = [];
if ~isempty(xticksStr) && numel(xticksStr)>1 && numel(timeArray) ==2 && (timeArray(1)< timeArray(2))
if numel(xticksStr)>=2
@@ -1295,10 +1654,11 @@ function yrangecustom(yscalStr,~)
yscalecustom = str2num(char(yscalStr.String));
%%checking the inputs
- if isempty(yscalecustom)|| numel(yscalecustom)==1
+ if isempty(yscalecustom)|| numel(yscalecustom)~=2
messgStr = strcat('Y scale for "Y Axs" in "Time and Amplitude Scales" - Inputs must be two numbers ');
erpworkingmemory('ERPViewer_proces_messg',messgStr);
fprintf(2,['\n Warning: ',messgStr,'.\n']);
+ % yscalStr.String = '';
viewer_ERPDAT.Process_messg =4;
return;
end
@@ -1497,7 +1857,6 @@ function ytickauto(Str,~)
if ytick_precision<0
ytick_precision=1;
end
-
if isempty(str2num(yticksLabel))
yticksLabel = '';
else
@@ -1795,6 +2154,11 @@ function xyaxis_help(~,~)
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
+
+ MessageViewer= char(strcat('Time and Amplitude Scales > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
+
changeFlag = estudioworkingmemory('MyViewer_xyaxis');
if changeFlag~=1%% Donot reset this panel if there is no change
return;
@@ -1818,6 +2182,7 @@ function xyaxis_help(~,~)
xprecisoonName = {'1','2','3','4','5','6'};
gui_erpxyaxeset_waveviewer.xticks_precision.String = xprecisoonName;
end
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%-------------------------time range------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1988,10 +2353,13 @@ function xyaxis_help(~,~)
gui_erpxyaxeset_waveviewer.yunits_on.Value = ERPwaviewer_apply.yaxis.units;
gui_erpxyaxeset_waveviewer.yunits_off.Value = ~ERPwaviewer_apply.yaxis.units;
- estudioworkingmemory('MyViewer_xyaxis',0);
gui_erpxyaxeset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_erpxyaxeset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erpxtaxes_viewer_property.TitleColor= [0.5 0.5 0.9];
+ estudioworkingmemory('MyViewer_xyaxis',0);
+ MessageViewer= char(strcat('Time and Amplitude Scales > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
%%-----------------------------Apply---------------------------------------
@@ -2023,24 +2391,28 @@ function xyaxis_apply(~,~)
else
timeRange = str2num(gui_erpxyaxeset_waveviewer.timerange_edit.String)*1000;
end
+ MERPWaveViewer_xaxis{1} = xdispsecondValue;
- if numel(timeRange)==1 || isempty(timeRange)
+
+ if isempty(timeRange) || numel(timeRange)~=2
timeRange(1) = ERPwaviewer_apply.ERP.times(1);
timeRange(2) = ERPwaviewer_apply.ERP.times(end);
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n Time and Amplitude Scales > Apply-Time range() error.\n Inputs must be two numbers! Please change it, otherwise, the default values will be used.\n\n');
- % return;
+ messgStr = strcat('The default time range will be used because the inputs are not two numbers');
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
+ fprintf(2,['\n Warning: ',messgStr,'.\n']);
+ viewer_ERPDAT.Process_messg =4;
end
if timeRange(1) >= timeRange(2)
timeRange(1) = ERPwaviewer_apply.ERP.times(1);
timeRange(2) = ERPwaviewer_apply.ERP.times(end);
viewer_ERPDAT.Process_messg =3;
fprintf(2,'\n Time and Amplitude Scales > Apply-Time range() error.\n The left edge should not be smaller than the right one!\n Please change current values, otherwise, the default ones will be used!\n\n');
- % return;
end
ERPwaviewer_apply.xaxis.timerange = timeRange;
ERPwaviewer_apply.xaxis.trangeauto = gui_erpxyaxeset_waveviewer.xtimerangeauto.Value;
ERPwaviewer_apply.xaxis.tdis = xdispsecondValue;
+ MERPWaveViewer_xaxis{3} = timeRange;
+ MERPWaveViewer_xaxis{2} = gui_erpxyaxeset_waveviewer.xtimerangeauto.Value;
%%getting xticks
if xdispsecondValue==1
xticksArray = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
@@ -2060,12 +2432,14 @@ function xyaxis_apply(~,~)
end
ERPwaviewer_apply.xaxis.timeticks = xticksArray;
ERPwaviewer_apply.xaxis.ticksauto = gui_erpxyaxeset_waveviewer.xtimetickauto.Value;
+ MERPWaveViewer_xaxis{4} = ERPwaviewer_apply.xaxis.ticksauto;
+ MERPWaveViewer_xaxis{5} = xticksArray;
if gui_erpxyaxeset_waveviewer.xmillisecond.Value==1
ERPwaviewer_apply.xaxis.tickdecimals = gui_erpxyaxeset_waveviewer.xticks_precision.Value-1;
else
ERPwaviewer_apply.xaxis.tickdecimals = gui_erpxyaxeset_waveviewer.xticks_precision.Value;
end
-
+ MERPWaveViewer_xaxis{6} = ERPwaviewer_apply.xaxis.tickdecimals;
%%minor for xticks
ERPwaviewer_apply.xaxis.tminor.disp = gui_erpxyaxeset_waveviewer.xtimeminorauto.Value;
xticckMinorstep = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
@@ -2075,6 +2449,9 @@ function xyaxis_apply(~,~)
ERPwaviewer_apply.xaxis.tminor.step = xticckMinorstep*1000;
end
ERPwaviewer_apply.xaxis.tminor.auto = gui_erpxyaxeset_waveviewer.timeminorticks_auto.Value;
+ MERPWaveViewer_xaxis{7} = gui_erpxyaxeset_waveviewer.xtimeminorauto.Value;
+ MERPWaveViewer_xaxis{8} = ERPwaviewer_apply.xaxis.tminor.step;
+ MERPWaveViewer_xaxis{9} =gui_erpxyaxeset_waveviewer.timeminorticks_auto.Value;
%%xtick label on/off
ERPwaviewer_apply.xaxis.label = gui_erpxyaxeset_waveviewer.xtimelabel_on.Value;
fontsize = {'4','6','8','10','12','14','16','18','20','24','28','32','36',...
@@ -2084,9 +2461,19 @@ function xyaxis_apply(~,~)
ERPwaviewer_apply.xaxis.fontsize = xfontsizeinum(gui_erpxyaxeset_waveviewer.font_custom_size.Value);
ERPwaviewer_apply.xaxis.fontcolor = gui_erpxyaxeset_waveviewer.xtimetextcolor.Value;
ERPwaviewer_apply.xaxis.units = gui_erpxyaxeset_waveviewer.xtimeunits_on.Value;
+ MERPWaveViewer_xaxis{10}=gui_erpxyaxeset_waveviewer.xtimelabel_on.Value;
+ MERPWaveViewer_xaxis{11} = gui_erpxyaxeset_waveviewer.xtimefont_custom.Value;
+ MERPWaveViewer_xaxis{12} = gui_erpxyaxeset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_xaxis{13}= gui_erpxyaxeset_waveviewer.xtimetextcolor.Value;
+ MERPWaveViewer_xaxis{14}= gui_erpxyaxeset_waveviewer.xtimeunits_on.Value;
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%%save the parameters for x axis to memory file
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%Setting for Y axis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%y scales
YScales = str2num(char(gui_erpxyaxeset_waveviewer.yrange_edit.String));
- if isempty(YScales)
+ if isempty(YScales) || numel(YScales)~=2
ALLERPIN = ERPwaviewer_apply.ALLERP;
ERPArrayin = ERPwaviewer_apply.SelectERPIdx;
BinArrayIN = [];
@@ -2117,9 +2504,20 @@ function xyaxis_apply(~,~)
catch
YScales = yylim_out(1,:);
end
+
+ if isempty(YScales)
+ messgStr = strcat('The default Y scales will be used because the inputs are empty');
+ elseif numel(YScales)~=2
+ messgStr = strcat('The default Y scales will be used because the number of inputs is not 2');
+ end
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
+ fprintf(2,['\n Warning: ',messgStr,'.\n']);
+ viewer_ERPDAT.Process_messg =4;
end
ERPwaviewer_apply.yaxis.scales =YScales ;
ERPwaviewer_apply.yaxis.scalesauto = gui_erpxyaxeset_waveviewer.yrangeauto.Value;
+ MERPWaveViewer_yaxis{1} = ERPwaviewer_apply.yaxis.scalesauto;
+ MERPWaveViewer_yaxis{2} = YScales;
%%yticks
YTicks = str2num(char(gui_erpxyaxeset_waveviewer.yticks_edit.String));
count_xtks = 0;
@@ -2136,20 +2534,34 @@ function xyaxis_apply(~,~)
ERPwaviewer_apply.yaxis.tickdecimals = gui_erpxyaxeset_waveviewer.yticks_precision.Value-1;
ERPwaviewer_apply.yaxis.ticks = YTicks;
ERPwaviewer_apply.yaxis.tickauto = gui_erpxyaxeset_waveviewer.ytickauto.Value;
+ MERPWaveViewer_yaxis{3} = gui_erpxyaxeset_waveviewer.ytickauto.Value;
+ MERPWaveViewer_yaxis{4} = YTicks;
+ MERPWaveViewer_yaxis{5} = ERPwaviewer_apply.yaxis.tickdecimals;
%%minor yticks
ERPwaviewer_apply.yaxis.yminor.disp = gui_erpxyaxeset_waveviewer.yminortick.Value;
ERPwaviewer_apply.yaxis.yminor.step = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
ERPwaviewer_apply.yaxis.yminor.auto = gui_erpxyaxeset_waveviewer.yminorstep_auto.Value;
+ MERPWaveViewer_yaxis{6} = ERPwaviewer_apply.yaxis.yminor.disp ;
+ MERPWaveViewer_yaxis{7} = ERPwaviewer_apply.yaxis.yminor.auto;
+ MERPWaveViewer_yaxis{8} = ERPwaviewer_apply.yaxis.yminor.step;
+
%%y labels: on/off
ERPwaviewer_apply.yaxis.label = gui_erpxyaxeset_waveviewer.ylabel_on.Value;
+ MERPWaveViewer_yaxis{9} = gui_erpxyaxeset_waveviewer.ylabel_on.Value;
%%yticks: font and font size
ERPwaviewer_apply.yaxis.font = gui_erpxyaxeset_waveviewer.yfont_custom.Value;
yfontsizeinum = str2num(char(fontsize));
ERPwaviewer_apply.yaxis.fontsize = yfontsizeinum(gui_erpxyaxeset_waveviewer.yfont_custom_size.Value);
+ MERPWaveViewer_yaxis{10} =ERPwaviewer_apply.yaxis.font;
+ MERPWaveViewer_yaxis{11}=gui_erpxyaxeset_waveviewer.yfont_custom_size.Value;
%%yticks color
ERPwaviewer_apply.yaxis.fontcolor = gui_erpxyaxeset_waveviewer.ytextcolor.Value;
+ MERPWaveViewer_yaxis{12}=gui_erpxyaxeset_waveviewer.ytextcolor.Value;
%%y units
ERPwaviewer_apply.yaxis.units = gui_erpxyaxeset_waveviewer.yunits_on.Value;
+ MERPWaveViewer_yaxis{13}= gui_erpxyaxeset_waveviewer.yunits_on.Value;
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%%save the parameters for y axis to momery file
+
%%save the parameters
ALLERPwaviewer=ERPwaviewer_apply;
assignin('base','ALLERPwaviewer',ALLERPwaviewer);
@@ -2163,6 +2575,13 @@ function v_currentERP_change(~,~)
if viewer_ERPDAT.Count_currentERP == 0
return;
end
+ [messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
+ if ~isempty(messgStr) && viewerpanelIndex==3
+ xyaxis_apply();
+ estudioworkingmemory('MyViewer_xyaxis',0);
+ end
+
+
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
@@ -2188,23 +2607,23 @@ function v_currentERP_change(~,~)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xSecondflag = erpworkingmemory('MyViewer_xaxis_second');
xmSecondflag = erpworkingmemory('MyViewer_xaxis_msecond');
- if isempty(xSecondflag) && isempty(xmSecondflag)
- xdispysecondValue = gui_erpxyaxeset_waveviewer.xmillisecond.Value;%%millisecond
- end
- if xSecondflag ==0 && xmSecondflag==1
- xdispysecondValue =1;
- if gui_erpxyaxeset_waveviewer.xtimerangeauto.Value==1
- if xdispysecondValue==1
- gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeArray);
- gui_erpxyaxeset_waveviewer.xticks_precision.String = {'0','1','2','3','4','5','6'};
- else
- gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeArray/1000);
- gui_erpxyaxeset_waveviewer.xticks_precision.String = {'1','2','3','4','5','6'};
- end
+ % if isempty(xSecondflag) && isempty(xmSecondflag)
+ xdispysecondValue = gui_erpxyaxeset_waveviewer.xmillisecond.Value;%%millisecond
+ % end
+ % if xSecondflag ==0 && xmSecondflag==1
+ % xdispysecondValue =1;
+ if gui_erpxyaxeset_waveviewer.xtimerangeauto.Value==1
+ if xdispysecondValue==1
+ gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeArray);
+ gui_erpxyaxeset_waveviewer.xticks_precision.String = {'0','1','2','3','4','5','6'};
+ else
+ gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeArray/1000);
+ gui_erpxyaxeset_waveviewer.xticks_precision.String = {'1','2','3','4','5','6'};
end
- else
- xdispysecondValue =0;
end
+ % else
+ % xdispysecondValue =0;
+ % end
if xdispysecondValue==1
xtick_precision =gui_erpxyaxeset_waveviewer.xticks_precision.Value-1;
if xtick_precision<0
@@ -2273,6 +2692,20 @@ function v_currentERP_change(~,~)
gui_erpxyaxeset_waveviewer.timeminorticks_custom.String = num2str(stepX);
end
+ MERPWaveViewer_xaxis = estudioworkingmemory('MERPWaveViewer_xaxis');
+ if xdispysecondValue==1
+ MERPWaveViewer_xaxis{1}=1;
+ MERPWaveViewer_xaxis{3} = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ MERPWaveViewer_xaxis{5} = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ MERPWaveViewer_xaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ else
+ MERPWaveViewer_xaxis{1}=0;
+ MERPWaveViewer_xaxis{3} = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ MERPWaveViewer_xaxis{5} = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ MERPWaveViewer_xaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ end
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%%save the changed parameters for x axis to memory file.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%----------------------------Setting for Y axis-------------------
@@ -2417,6 +2850,13 @@ function v_currentERP_change(~,~)
ERPwaviewer_apply.yaxis.yminor.step = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
%%save the parameters
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ MERPWaveViewer_yaxis = estudioworkingmemory('MERPWaveViewer_yaxis');
+ MERPWaveViewer_yaxis{1} = gui_erpxyaxeset_waveviewer.yrangeauto.Value;
+ MERPWaveViewer_yaxis{2}=str2num(char(gui_erpxyaxeset_waveviewer.yrange_edit.String));
+ MERPWaveViewer_yaxis{4} = str2num(char(gui_erpxyaxeset_waveviewer.yticks_edit.String));
+ MERPWaveViewer_yaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%%save the changed parameters for y axis to memory file.
+
end
@@ -2427,6 +2867,13 @@ function page_xyaxis_change(~,~)
if viewer_ERPDAT.page_xyaxis==0
return;
end
+ %%execute any changes in this panel
+ [messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
+ if ~isempty(messgStr) && viewerpanelIndex==3
+ xyaxis_apply();
+ estudioworkingmemory('MyViewer_xyaxis',0);
+ end
+
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
@@ -2447,6 +2894,7 @@ function page_xyaxis_change(~,~)
timeticks = '';
timeArray = [];
end
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%----------------------------Setting for X axis-------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2535,6 +2983,20 @@ function page_xyaxis_change(~,~)
gui_erpxyaxeset_waveviewer.timeminorticks_custom.String = num2str(stepX);
end
+ MERPWaveViewer_xaxis = estudioworkingmemory('MERPWaveViewer_xaxis');
+ if xdispysecondValue==1
+ MERPWaveViewer_xaxis{1}=1;
+ MERPWaveViewer_xaxis{3} = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ MERPWaveViewer_xaxis{5} = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ MERPWaveViewer_xaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ else
+ MERPWaveViewer_xaxis{1}=0;
+ MERPWaveViewer_xaxis{3} = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ MERPWaveViewer_xaxis{5} = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ MERPWaveViewer_xaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.timeminorticks_custom.String));
+ end
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%%save the changed parameters for x axis to memory file.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%----------------------------Setting for Y axis-------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2679,20 +3141,28 @@ function page_xyaxis_change(~,~)
end
ERPwaviewer_apply.yaxis.ticks = YTicks;
ERPwaviewer_apply.yaxis.yminor.step = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
+
+ MERPWaveViewer_yaxis = estudioworkingmemory('MERPWaveViewer_yaxis');
+ MERPWaveViewer_yaxis{1} = gui_erpxyaxeset_waveviewer.yrangeauto.Value;
+ MERPWaveViewer_yaxis{2}=str2num(char(gui_erpxyaxeset_waveviewer.yrange_edit.String));
+ MERPWaveViewer_yaxis{4} = str2num(char(gui_erpxyaxeset_waveviewer.yticks_edit.String));
+ MERPWaveViewer_yaxis{8} = str2num(char(gui_erpxyaxeset_waveviewer.yminorstepedit.String));
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%%save the changed parameters for y axis to memory file.
+
%%save the parameters
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
end
%%-------------modify this panel based on the updated parameters-----------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=3
return;
end
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
catch
beep;
- disp('f_ERP_timeampscal_waveviewer_GUI()> count_loadproper_change() error: Please run the ERP wave viewer again.');
+ disp('f_ERP_timeampscal_waveviewer_GUI()> loadproper_change() error: Please run the ERP wave viewer again.');
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2704,17 +3174,39 @@ function count_loadproper_change(~,~)
gui_erpxyaxeset_waveviewer.xmillisecond.Value = xdispysecondValue;
gui_erpxyaxeset_waveviewer.xsecond.Value = ~xdispysecondValue;
+ try
+ ERPIN = ERPwaviewer_apply.ERP;
+ timeArraydef(1) = ERPIN.times(1);
+ timeArraydef(2) = ERPIN.times(end);
+ [timeticksdef stepX]= default_time_ticks_studio(ERPIN, [timeArraydef(1),timeArraydef(2)]);
+ timeticksdef = str2num(char(timeticksdef));
+ if ~isempty(stepX) && numel(stepX) ==1
+ stepX = floor(stepX/2);
+ end
+ catch
+ timeticksdef = [];
+ timeArraydef =[];
+ end
+ MERPWaveViewer_xaxis{1} =1;
+
+
%%x range
timeRange = ERPwaviewer_apply.xaxis.timerange;
timeRangeAuto = ERPwaviewer_apply.xaxis.trangeauto;
if timeRangeAuto~=0 && timeRangeAuto~=1
timeRangeAuto =1;
end
+ if timeRangeAuto==1
+ timeRange = timeArraydef;
+ ERPwaviewer_apply.xaxis.timerange= timeArraydef;
+ end
if xdispysecondValue ==1
gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeRange);
else
gui_erpxyaxeset_waveviewer.timerange_edit.String = num2str(timeRange/1000);
end
+ MERPWaveViewer_xaxis{2} = timeRangeAuto;
+ MERPWaveViewer_xaxis{3} = timeRange;
gui_erpxyaxeset_waveviewer.xtimerangeauto.Value = timeRangeAuto;
if timeRangeAuto==1
@@ -2724,7 +3216,15 @@ function count_loadproper_change(~,~)
end
timeTick = ERPwaviewer_apply.xaxis.timeticks;
timetickAuto = ERPwaviewer_apply.xaxis.ticksauto;
-
+ if timetickAuto==1
+ gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = 'off';
+ timeTick = timeticksdef;
+ ERPwaviewer_apply.xaxis.timeticks = timeTick;
+ else
+ gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = 'on';
+ end
+ MERPWaveViewer_xaxis{4} = timetickAuto;
+ MERPWaveViewer_xaxis{5} = timeTick;
if xdispysecondValue ==0%% in second
timeTick = timeTick/1000;
end
@@ -2742,23 +3242,57 @@ function count_loadproper_change(~,~)
gui_erpxyaxeset_waveviewer.xticks_precision.Value = xtick_precision;
gui_erpxyaxeset_waveviewer.xticks_precision.String = {'1','2','3','4','5','6'};
end
+ MERPWaveViewer_xaxis{6} = xtick_precision;
timeTick= f_decimal(char(num2str(timeTick)),xtick_precision);
gui_erpxyaxeset_waveviewer.timeticks_edit.String = timeTick;
gui_erpxyaxeset_waveviewer.xtimetickauto.Value = timetickAuto;
- if timetickAuto==1
- gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = 'off';
- else
- gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = 'on';
- end
-
timetixkMinordip = ERPwaviewer_apply.xaxis.tminor.disp;
timetixkMinorstep = ERPwaviewer_apply.xaxis.tminor.step;
timetixkMinorauto = ERPwaviewer_apply.xaxis.tminor.auto;
gui_erpxyaxeset_waveviewer.xtimeminorauto.Value = timetixkMinordip;
+ xticks = str2num(char(gui_erpxyaxeset_waveviewer.timeticks_edit.String));
+ stepX = [];
+ if ~isempty(xticks) && numel(xticks)>1
+ timeArray = str2num(char(gui_erpxyaxeset_waveviewer.timerange_edit.String));
+ xticksStr = xticks;
+ stepX = [];
+ if ~isempty(xticksStr) && numel(xticksStr)>1 && numel(timeArray) ==2 && (timeArray(1)< timeArray(2))
+ if numel(xticksStr)>=2
+ for Numofxticks = 1:numel(xticksStr)-1
+ stepX(1,Numofxticks) = xticksStr(Numofxticks)+(xticksStr(Numofxticks+1)-xticksStr(Numofxticks))/2;
+ end
+ %%adjust the left edge
+ stexleft = (xticksStr(2)-xticksStr(1))/2;
+ for ii = 1:1000
+ if (xticksStr(1)- stexleft*ii)>=timeArray(1)
+ stepX = [(xticksStr(1)- stexleft*ii),stepX];
+ else
+ break;
+ end
+ end
+ %%adjust the right edge
+ stexright = (xticksStr(end)-xticksStr(end-1))/2;
+ for ii = 1:1000
+ if (xticksStr(end)+ stexright*ii)<=timeArray(end)
+ stepX = [stepX,(xticksStr(end)+ stexright*ii)];
+ else
+ break;
+ end
+ end
+ end
+ end
+ end
+ MERPWaveViewer_xaxis{7} = timetixkMinordip;
+ MERPWaveViewer_xaxis{8}=timetixkMinorstep;
+ MERPWaveViewer_xaxis{9} = timetixkMinorauto;
if xdispysecondValue ==0%% in second
timetixkMinorstep = timetixkMinorstep/1000;
end
+ if timetixkMinorauto==1
+ timetixkMinorstep = stepX;
+ ERPwaviewer_apply.xaxis.tminor.step= timetixkMinorstep;
+ end
timetixkMinorstep= f_decimal(char(num2str(timetixkMinorstep)),xtick_precision);
gui_erpxyaxeset_waveviewer.timeminorticks_custom.String = char(timetixkMinorstep);
gui_erpxyaxeset_waveviewer.timeminorticks_auto.Value = timetixkMinorauto;
@@ -2798,43 +3332,144 @@ function count_loadproper_change(~,~)
gui_erpxyaxeset_waveviewer.xtimefont_custom.Enable = XticklabelEnable;
gui_erpxyaxeset_waveviewer.font_custom_size.Enable = XticklabelEnable;
gui_erpxyaxeset_waveviewer.xtimetextcolor.Enable = XticklabelEnable;
+ MERPWaveViewer_xaxis{10} = xticklabelValue;
+ MERPWaveViewer_xaxis{11} = xticklabelfont;
+ MERPWaveViewer_xaxis{12} = gui_erpxyaxeset_waveviewer.font_custom_size.Value;
+ MERPWaveViewer_xaxis{13} = xticklabelcolor;
+ MERPWaveViewer_xaxis{14} =gui_erpxyaxeset_waveviewer.xtimeunits_on.Value ;
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%% save the parameters for x axis to memory file
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%------------------------------Y axis---------------------------%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ ALLERPIN = ERPwaviewer_apply.ALLERP;
+ ERPArrayin = ERPwaviewer_apply.SelectERPIdx;
+ BinArrayIN = [];
+ ChanArrayIn = [];
+ plotOrg = [1 2 3];
+ try
+ plotOrg(1) = ERPwaviewer_apply.plot_org.Grid;
+ plotOrg(2) = ERPwaviewer_apply.plot_org.Overlay;
+ plotOrg(3) = ERPwaviewer_apply.plot_org.Pages;
+ catch
+ plotOrg = [1 2 3];
+ end
+ try
+ ChanArrayIn = ERPwaviewer_apply.chan;
+ catch
+ ChanArrayIn = [];
+ end
+ try
+ BinArrayIN = ERPwaviewer_apply.bin;
+ catch
+ BinArrayIN = [];
+ end
+ PageCurrent = ERPwaviewer_apply.PageIndex;
+ yylim_out = f_erpAutoYLim(ALLERPIN, ERPArrayin,plotOrg,BinArrayIN, ChanArrayIn);
+ try
+ yRangeLabel = yylim_out(PageCurrent,:);
+ catch
+ yRangeLabel = yylim_out(1,:);
+ end
+
YScales = ERPwaviewer_apply.yaxis.scales;
YScalesAuto = ERPwaviewer_apply.yaxis.scalesauto;
- gui_erpxyaxeset_waveviewer.yrange_edit.String = num2str(YScales);
- gui_erpxyaxeset_waveviewer.yrangeauto.Value = YScalesAuto;
if YScalesAuto==1
gui_erpxyaxeset_waveviewer.yrange_edit.Enable = 'off';
+ YScales =yRangeLabel;
+ ERPwaviewer_apply.yaxis.scales= YScales;
else
gui_erpxyaxeset_waveviewer.yrange_edit.Enable = 'on';
end
+ gui_erpxyaxeset_waveviewer.yrange_edit.String = num2str(YScales);
+ gui_erpxyaxeset_waveviewer.yrangeauto.Value = YScalesAuto;
%%y ticks
try
gui_erpxyaxeset_waveviewer.yticks_precision.Value =ERPwaviewer_apply.yaxis.tickdecimals;
catch
gui_erpxyaxeset_waveviewer.yticks_precision.Value =1;
end
-
yticks = ERPwaviewer_apply.yaxis.ticks;
yticksauto = ERPwaviewer_apply.yaxis.tickauto;
ytick_precision = ERPwaviewer_apply.yaxis.tickdecimals;
gui_erpxyaxeset_waveviewer.yticks_precision.Value = ytick_precision+1;
+ yRangeLabel = str2num(char(gui_erpxyaxeset_waveviewer.yrange_edit.String));
+ if ~isempty(yRangeLabel) && numel(yRangeLabel) ==2 && (yRangeLabel(1)1
+ if numel(yticksStr)>=2
+ for Numofxticks = 1:numel(yticksStr)-1
+ stepY(1,Numofxticks) = yticksStr(Numofxticks)+(yticksStr(Numofxticks+1)-yticksStr(Numofxticks))/2;
+ end
+ %%adjust the left edge
+ steyleft = (yticksStr(2)-yticksStr(1))/2;
+ for ii = 1:1000
+ if (yticksStr(1)- steyleft*ii)>=yscaleRange(1)
+ stepY = [(yticksStr(1)- steyleft*ii),stepY];
+ else
+ break;
+ end
+ end
+ %%adjust the right edge
+ steyright = (yticksStr(end)-yticksStr(end-1))/2;
+ for ii = 1:1000
+ if (yticksStr(end)+ steyright*ii)<=yscaleRange(end)
+ stepY = [stepY,(yticksStr(end)+ steyright*ii)];
+ else
+ break;
+ end
+ end
+ end
+ end
ytickminordisp = ERPwaviewer_apply.yaxis.yminor.disp;
ytickminorstep = ERPwaviewer_apply.yaxis.yminor.step;
ytickminorauto = ERPwaviewer_apply.yaxis.yminor.auto;
+
gui_erpxyaxeset_waveviewer.yminortick.Value = ytickminordisp;
+ if ytickminorauto==1
+ ytickminorstep = stepY;
+ ERPwaviewer_apply.yaxis.yminor.step= stepY;
+ end
gui_erpxyaxeset_waveviewer.yminorstepedit.String = num2str(ytickminorstep);
gui_erpxyaxeset_waveviewer.yminorstep_auto.Value = ytickminorauto;
if ytickminordisp==0
@@ -2848,6 +3483,10 @@ function count_loadproper_change(~,~)
gui_erpxyaxeset_waveviewer.yminorstepedit.Enable = 'on';
end
end
+ MERPWaveViewer_yaxis{6} = ERPwaviewer_apply.yaxis.yminor.disp;
+ MERPWaveViewer_yaxis{7} = ytickminorauto;
+ MERPWaveViewer_yaxis{8} = ytickminorstep;
+
yticklabel = ERPwaviewer_apply.yaxis.label;
gui_erpxyaxeset_waveviewer.ylabel_on.Value = yticklabel;
gui_erpxyaxeset_waveviewer.ylabel_off.Value = ~yticklabel;
@@ -2869,6 +3508,15 @@ function count_loadproper_change(~,~)
yunits = ERPwaviewer_apply.yaxis.units;
gui_erpxyaxeset_waveviewer.yunits_on.Value = yunits;
gui_erpxyaxeset_waveviewer.yunits_off.Value = ~yunits;
+ MERPWaveViewer_yaxis{9} = yticklabel;
+ MERPWaveViewer_yaxis{10} = yticklabelfont;
+ MERPWaveViewer_yaxis{11} = ysize;
+ MERPWaveViewer_yaxis{12} = yticklabelcolor;
+ MERPWaveViewer_yaxis{13} = yunits;
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%%save the parameters for y axis to memory file
+
+ assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ viewer_ERPDAT.loadproper_count=4;%%update the next panel
end
%%-------------------------------------------------------------------------
@@ -2893,7 +3541,6 @@ function Reset_Waviewer_panel_change(~,~)
if viewer_ERPDAT.Reset_Waviewer_panel==3
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
-
catch
beep;
disp('f_ERP_Binchan_waviewer_GUI error: Restart ERPwave Viewer');
@@ -2917,6 +3564,7 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.xsecond.Value =0;
ERPwaviewer_apply.xaxis.tdis =1;
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%----------------------------Setting for X axis---------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2926,16 +3574,24 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.timerange_edit.Enable = 'off';
gui_erpxyaxeset_waveviewer.xtimerangeauto.Value = 1;
ERPwaviewer_apply.xaxis.trangeauto =1;
+
+ MERPWaveViewer_xaxis{1} =1;
+ MERPWaveViewer_xaxis{2} = 1;
+ MERPWaveViewer_xaxis{3} = timeArray;
+
%%x ticklable
gui_erpxyaxeset_waveviewer.timeticks_edit.String = char(timeticks);%% xtick label
ERPwaviewer_apply.xaxis.timeticks = str2num(char(timeticks));
gui_erpxyaxeset_waveviewer.timeticks_edit.Enable = 'off';
gui_erpxyaxeset_waveviewer.xtimetickauto.Value=1;
ERPwaviewer_apply.xaxis.ticksauto = 1;
+ MERPWaveViewer_xaxis{4}=1;
+ MERPWaveViewer_xaxis{5} =str2num(char(timeticks));
%%x precision for x ticklabel
gui_erpxyaxeset_waveviewer.xticks_precision.String = {'0','1','2','3','4','5','6'};
gui_erpxyaxeset_waveviewer.xticks_precision.Value = 1;
ERPwaviewer_apply.xaxis.tickdecimals = 0;
+ MERPWaveViewer_xaxis{6} = 0;
%%x minor ticks
gui_erpxyaxeset_waveviewer.xtimeminorauto.Value =0;
ERPwaviewer_apply.xaxis.tminor.disp = 0;
@@ -2948,14 +3604,17 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.timeminorticks_auto.Enable = 'off';
ERPwaviewer_apply.xaxis.tminor.step =[];
ERPwaviewer_apply.xaxis.tminor.auto = 1;
+ MERPWaveViewer_xaxis{7} = 0;
+ MERPWaveViewer_xaxis{8} = xticksStr;
+ MERPWaveViewer_xaxis{9} =1;
%%x label on/off
gui_erpxyaxeset_waveviewer.xtimelabel_on.Value=1; %
gui_erpxyaxeset_waveviewer.xtimelabel_off.Value=0;
ERPwaviewer_apply.xaxis.label =1;
-
+ MERPWaveViewer_xaxis{10}=1;
%%font and font size
- ERPwaviewer_apply.xaxis.font =2;
- gui_erpxyaxeset_waveviewer.xtimefont_custom.Value=2;
+ ERPwaviewer_apply.xaxis.font =3;
+ gui_erpxyaxeset_waveviewer.xtimefont_custom.Value=3;
ERPwaviewer_apply.xaxis.fontsize =10;
gui_erpxyaxeset_waveviewer.font_custom_size.Value=4;
fonttype = {'Courier','Geneva','Helvetica','Monaco','Times'};
@@ -2963,6 +3622,10 @@ function Reset_Waviewer_panel_change(~,~)
yfontsize={'4','6','8','10','12','14','16','18','20','24','28','32','36',...
'40','50','60','70','80','90','100'};
gui_erpxyaxeset_waveviewer.font_custom_size.String = yfontsize;
+ MERPWaveViewer_xaxis{11}=3;
+ MERPWaveViewer_xaxis{12}=4;
+ MERPWaveViewer_xaxis{13} =1;
+
%%color for x ticklabel
xtextColor = {'Black','Red','Blue','Green','Orange','Cyan','Magenla'};
@@ -2972,6 +3635,7 @@ function Reset_Waviewer_panel_change(~,~)
ERPwaviewer_apply.xaxis.units =1;
gui_erpxyaxeset_waveviewer.xtimeunits_on.Value=1; %
gui_erpxyaxeset_waveviewer.xtimeunits_off.Value=0; %
+ MERPWaveViewer_xaxis{14}=1;
erpworkingmemory('MyViewer_xaxis_second',0);
erpworkingmemory('MyViewer_xaxis_msecond',1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -3007,6 +3671,8 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.yrangeauto.Value =1;
ERPwaviewer_apply.yaxis.scales = str2num(yRangeLabel);
ERPwaviewer_apply.yaxis.scalesauto = 1;
+ MERPWaveViewer_yaxis{1}=1;
+ MERPWaveViewer_yaxis{2} = yRangeLabel;
%%Y tick label
%%y ticks
ytick_precision=1;
@@ -3022,6 +3688,9 @@ function Reset_Waviewer_panel_change(~,~)
ERPwaviewer_apply.yaxis.tickauto = 1;
gui_erpxyaxeset_waveviewer.yticks_precision.Value=2;
ERPwaviewer_apply.yaxis.tickdecimals=1;
+ MERPWaveViewer_yaxis{3}=1;
+ MERPWaveViewer_yaxis{5}=1;
+ MERPWaveViewer_yaxis{4} = str2num(yticksLabel);
%%Y minor
ERPwaviewer_apply.yaxis.yminor.disp =0;
ERPwaviewer_apply.yaxis.yminor.auto =1;
@@ -3031,14 +3700,17 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.yminorstepedit.Enable = 'off'; %
gui_erpxyaxeset_waveviewer.yminorstep_auto.Value=1;
gui_erpxyaxeset_waveviewer.yminorstep_auto.Enable ='off'; %
+ MERPWaveViewer_yaxis{6}=0;
+ MERPWaveViewer_yaxis{7}=1;
+ MERPWaveViewer_yaxis{8}=[];
%%Y ticklabel on/off
ERPwaviewer_apply.yaxis.label = 1;
gui_erpxyaxeset_waveviewer.ylabel_on.Value=1; %
gui_erpxyaxeset_waveviewer.ylabel_off.Value=0;
%%font and fontsize
- ERPwaviewer_apply.yaxis.font=2;
+ ERPwaviewer_apply.yaxis.font=3;
ERPwaviewer_apply.yaxis.fontsize=10;
- gui_erpxyaxeset_waveviewer.yfont_custom.Value=2;
+ gui_erpxyaxeset_waveviewer.yfont_custom.Value=3;
gui_erpxyaxeset_waveviewer.yfont_custom_size.Value=4;
%%color for y ticklabels
ytextColor = {'Black','Red','Blue','Green','Orange','Cyan','Magenla'};
@@ -3050,6 +3722,13 @@ function Reset_Waviewer_panel_change(~,~)
gui_erpxyaxeset_waveviewer.yunits_off.Value=0; %
ERPwaviewer_apply.yaxis.units=1;
assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ MERPWaveViewer_yaxis{9}=1;
+ MERPWaveViewer_yaxis{10} =3;
+ MERPWaveViewer_yaxis{11}=4;
+ MERPWaveViewer_yaxis{12}=1;
+ MERPWaveViewer_yaxis{13}= 1;
+ estudioworkingmemory('MERPWaveViewer_xaxis',MERPWaveViewer_xaxis);%%save the parameters for x axis to memory file
+ estudioworkingmemory('MERPWaveViewer_yaxis',MERPWaveViewer_yaxis);%%save the parameters for y axis to memory file
gui_erpxyaxeset_waveviewer.apply.BackgroundColor = [1 1 1];
gui_erpxyaxeset_waveviewer.apply.ForegroundColor = [0 0 0];
box_erpxtaxes_viewer_property.TitleColor= [0.5 0.5 0.9];
@@ -3057,4 +3736,19 @@ function Reset_Waviewer_panel_change(~,~)
end
end%% end of reset for the current panel
+
+
+%%Press Return key to execute the function
+ function xyaxis_presskey(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ xyaxis_apply();
+ estudioworkingmemory('MyViewer_xyaxis',0);
+ gui_erpxyaxeset_waveviewer.apply.BackgroundColor = [1 1 1];
+ gui_erpxyaxeset_waveviewer.apply.ForegroundColor = [0 0 0];
+ box_erpxtaxes_viewer_property.TitleColor= [0.5 0.5 0.9];
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERPsets_waviewer_GUI.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERPsets_waviewer_GUI.m
index 9f5e5cc7..d7502d17 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERPsets_waviewer_GUI.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ERPsets_waviewer_GUI.m
@@ -17,13 +17,14 @@
global viewer_ERPDAT
global observe_ERPDAT;
global gui_erp_waviewer;
-addlistener(viewer_ERPDAT,'count_loadproper_change',@count_loadproper_change);
+addlistener(viewer_ERPDAT,'loadproper_change',@loadproper_change);
addlistener(viewer_ERPDAT,'count_twopanels_change',@count_twopanels_change);
addlistener(viewer_ERPDAT,'Reset_Waviewer_panel_change',@Reset_Waviewer_panel_change);
+addlistener(viewer_ERPDAT,'ERPset_Chan_bin_label_change',@ERPset_Chan_bin_label_change);
addlistener(observe_ERPDAT,'Two_GUI_change',@Two_GUI_change);
ERPwaveview_erpsetops = struct();
%---------Setting the parameter which will be used in the other panels-----------
-
+% gui_erp_waviewer.Window.WindowButtonMotionFcn = {@erpselect_refresh};
try
[version reldate,ColorBviewer_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
catch
@@ -99,44 +100,6 @@ function drawui_erpsetbinchan_viewer(ERPdatasets,ERPwaviewer,FonsizeDefault)
% Sort the ERPdatasets!!!
ERPdatasets = sortdata(ERPdatasets);
ERPwaveview_erpsetops.vBox = uiextras.VBox('Parent', ERPsets_waveviewer_box, 'Spacing', 5,'BackgroundColor',ColorBviewer_def); % VBox for everything
- ERPtooltype = erpgettoolversion('tooltype');
- if ~strcmpi(ERPtooltype,'EStudio') && ~strcmpi(ERPtooltype,'ERPLAB')
- ERPwaviewer.erp_binchan_op = 0;
- end
-
- try
- Enable_auto = ERPwaviewer.erp_binchan_op;
- catch
- Enable_auto = 1;
- end
-
- if Enable_auto ==1
- Enable_label = 'off';
- elseif Enable_auto ==0
- Enable_label = 'on';
- end
-
-
- %%---------------------Options for selecting ERPsets-----------------------------------------------------
- ERPwaveview_erpsetops.opts_title = uiextras.HBox('Parent', ERPwaveview_erpsetops.vBox, 'Spacing', 5,'BackgroundColor',ColorBviewer_def);
- ERPwaveview_erpsetops.auto = uicontrol('Style', 'radiobutton','Parent', ERPwaveview_erpsetops.opts_title,...
- 'String',' ','callback',@erpselect_auto,'Value',Enable_auto,'Enable','on','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
-
- ERPwaveview_erpsetops.custom = uicontrol('Style', 'radiobutton','Parent', ERPwaveview_erpsetops.opts_title,...
- 'String','Custom','callback',@erpselect_custom,'Value',~Enable_auto,'Enable','on','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
-
- if strcmpi(ERPtooltype,'EStudio')
- ERPwaveview_erpsetops.auto.String = 'Same as EStudio';
- elseif strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_erpsetops.auto.String = 'Same as ERPLAB';
- set(ERPwaveview_erpsetops.opts_title,'Sizes',[130 90]);
- else
- ERPwaveview_erpsetops.auto.String = '';
- ERPwaveview_erpsetops.auto.Enable = 'off';
- ERPwaveview_erpsetops.custom.String = '';
- ERPwaveview_erpsetops.custom.Enable = 'off';
- end
-
%%-----------------------Display tthe selected ERPsets---------------------------------------
panelshbox = uiextras.HBox('Parent', ERPwaveview_erpsetops.vBox, 'Spacing', 5,'BackgroundColor',ColorBviewer_def);
@@ -154,18 +117,22 @@ function drawui_erpsetbinchan_viewer(ERPdatasets,ERPwaviewer,FonsizeDefault)
end
ds_length = length(ERPdatasets);
ERPwaveview_erpsetops.butttons_datasets = uicontrol('Parent', panelshbox, 'Style', 'listbox', 'min', 1,'max',...
- ds_length,'String', dsnames,'Value', SelectedIndex,'Callback',@selectdata,'FontSize',FonsizeDefault,'Enable',Enable_label);
+ ds_length,'String', dsnames,'Value', SelectedIndex,'Callback',@selectdata,'FontSize',FonsizeDefault,'Enable','on');
+ ERPwaveview_erpsetops.butttons_datasets.KeyPressFcn = @ERPset_keypress;
%%Help and apply
ERPwaveview_erpsetops.help_apply_title = uiextras.HBox('Parent', ERPwaveview_erpsetops.vBox,'BackgroundColor',ColorBviewer_def);
+ ERPwaveview_erpsetops.auto = uicontrol('Style', 'pushbutton','Parent', ERPwaveview_erpsetops.help_apply_title,...
+ 'String',' Refresh','callback',@erpselect_refresh,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]);
+
uiextras.Empty('Parent',ERPwaveview_erpsetops.help_apply_title );
uicontrol('Style','pushbutton','Parent', ERPwaveview_erpsetops.help_apply_title ,'String','Cancel',...
'callback',@erpset_help,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
uiextras.Empty('Parent',ERPwaveview_erpsetops.help_apply_title );
ERPwaveview_erpsetops.erpset_apply = uicontrol('Style','pushbutton','Parent',ERPwaveview_erpsetops.help_apply_title ,'String','Apply',...
'callback',@ERPset_apply,'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1]); %,'HorizontalAlignment','left'
- uiextras.Empty('Parent',ERPwaveview_erpsetops.help_apply_title );
- set(ERPwaveview_erpsetops.help_apply_title ,'Sizes',[40 70 20 70 20]);
- set(ERPwaveview_erpsetops.vBox, 'Sizes', [20 190 25]);
+ % uiextras.Empty('Parent',ERPwaveview_erpsetops.help_apply_title );
+ set(ERPwaveview_erpsetops.help_apply_title ,'Sizes',[70 14 70 14 70]);
+ set(ERPwaveview_erpsetops.vBox, 'Sizes', [190 25]);
ERPwaveview_erpsetops.ERPLABFlag = 0;
end
@@ -174,7 +141,7 @@ function drawui_erpsetbinchan_viewer(ERPdatasets,ERPwaviewer,FonsizeDefault)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------------select the ERPset of interest--------------------------
- function selectdata(source,EventData)
+ function selectdata(~,EventData)
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
if ~isempty(messgStr) && viewerpanelIndex~=1
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
@@ -187,63 +154,69 @@ function selectdata(source,EventData)
%%---------------Setting for auto option-----------------------------------
- function erpselect_auto(source,~)
-
+ function erpselect_refresh(~,~)
+ % Value = Source.Value;
[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
if ~isempty(messgStr) && viewerpanelIndex~=1
viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
end
ERPtooltype = erpgettoolversion('tooltype');
- estudioworkingmemory('MyViewer_ERPsetpanel',1);
- ERPwaveview_erpsetops.erpset_apply.BackgroundColor = [0.4940 0.1840 0.5560];
- ERPwaveview_erpsetops.erpset_apply.ForegroundColor = [1 1 1];
- ERPsets_waveviewer_box.TitleColor= [0.4940 0.1840 0.5560];
- BackERPLABcolor1 = [1 0.9 0.3]; % yellow
- question1 = ['Are you sure to use the same ERPsets as',32, ERPtooltype,'?\n If so, the current ERPsets will be overwritten.'];
- title1 = 'ERP Wave Viewer>ERPsets';
- oldcolor1 = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor1)
- button1 = questdlg(sprintf(question1), title1,'Cancel','No', 'Yes','Yes');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor1);
+ %%load the parameters from workspace
+ try
+ ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
+ catch
+ viewer_ERPDAT.Process_messg =3;
+ fprintf(2,'\n ERPsets > Refresh-f_ERPsets_waviewer_GUI() error: Cannot get parameters for whole panel.\n Please run My viewer again.\n\n');
+ return;
+ end
- MessageViewer= char(strcat('ERPsets>" Same as',32,ERPtooltype,32,'"'));
+ MessageViewer= char(strcat('ERPsets>" Refresh'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
viewer_ERPDAT.Process_messg =1;
- if strcmpi(ERPtooltype,'EStudio') || strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_erpsetops.auto.Value = 1;
- ERPwaveview_erpsetops.custom.Value =0;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'off';
- else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- ERPwaveview_erpsetops.auto.Enable = 'off';
- ERPwaveview_erpsetops.custom.Enable = 'off';
- end
- if strcmpi(button1,'Yes')
- if strcmpi(ERPtooltype,'EStudio') || strcmpi(ERPtooltype,'ERPLAB')
- if strcmpi(ERPtooltype,'ERPLAB')
+
+ if strcmpi(ERPtooltype,'EStudio') || strcmpi(ERPtooltype,'ERPLAB')
+ if strcmpi(ERPtooltype,'ERPLAB')
+ try
+ Selected_erpset = ERPwaveview_erpsetops.butttons_datasets.Value;
try
- Selected_erpset = evalin('base','CURRENTERP');
- CURRENTERPStudio = Selected_erpset;
+ CURRENTERPStudio = Selected_erpset(ERPwaviewer_apply.PageIndex);
catch
- viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n ERPsets error: Cannot get CURRENTERP from Workspace.\n');
- return;
+ CURRENTERPStudio = Selected_erpset(1);
+ ERPwaviewer_apply.PageIndex=1;
end
- estudioworkingmemory('PlotOrg_ERPLAB',1);
- end
- try
- ALLERPin = evalin('base','ALLERP');
catch
+ messgStr = strcat('Cannot get CURRENTERP from Workspace');
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
viewer_ERPDAT.Process_messg =3;
- fprintf(2,'\n ERPsets error: Cannot get ALLERP from Workspace.\n');
return;
end
- if isempty(ALLERPin)
- viewer_ERPDAT.Process_messg =3;
+ % estudioworkingmemory('PlotOrg_ERPLAB',1);
+ end
+ try
+ ALLERPin = evalin('base','ALLERP');
+ catch
+ messgStr = strcat('Cannot get ALLERP from Workspace');
+ erpworkingmemory('ERPViewer_proces_messg',messgStr);
+ viewer_ERPDAT.Process_messg =3;
+ return;
+ end
+ if isempty(ALLERPin)
+ viewer_ERPDAT.Process_messg =3;
+ try
+ cprintf('red',['\n ERP Wave viewer will be closed because ALLERP is empty.\n\n']);
+ close(gui_erp_waviewer.Window);
+ catch
+ end
+ assignin('base','ALLERPwaviewer',[]);
+ return;
+ end
+
+ if strcmpi(ERPtooltype,'EStudio')
+ Selected_erpset= estudioworkingmemory('selectederpstudio');
+ CURRENTERPStudio = observe_ERPDAT.CURRENTERP;
+ if length(ALLERPin)==1 && strcmpi(ALLERPin(1).erpname,'No ERPset loaded')
try
cprintf('red',['\n ERP Wave viewer will be closed because ALLERP is empty.\n\n']);
close(gui_erp_waviewer.Window);
@@ -252,109 +225,64 @@ function erpselect_auto(source,~)
assignin('base','ALLERPwaviewer',[]);
return;
end
-
- if strcmpi(ERPtooltype,'EStudio')
- Selected_erpset= estudioworkingmemory('selectederpstudio');
- CURRENTERPStudio = observe_ERPDAT.CURRENTERP;
- if length(ALLERPin)==1 && strcmpi(ALLERPin(1).erpname,'No ERPset loaded')
- try
- cprintf('red',['\n ERP Wave viewer will be closed because ALLERP is empty.\n\n']);
- close(gui_erp_waviewer.Window);
- catch
- end
- assignin('base','ALLERPwaviewer',[]);
- return;
- end
- end
-
- if isempty(Selected_erpset) || Selected_erpset> length(ALLERPin)
- Selected_erpset = length(ALLERPin);
- end
- if isempty(CURRENTERPStudio) || CURRENTERPStudio> length(ALLERPin)
- CURRENTERPStudio = length(ALLERPin);
- end
-
- [x_index,y_index] = find(Selected_erpset==CURRENTERPStudio);
- if isempty(y_index)
- y_index = numel(Selected_erpset);
- end
-
- ERPwaveview_erpsetops.ALLERP = ALLERPin;
- ERPwaveview_erpsetops.ERP = ALLERPin(CURRENTERPStudio);
- ERPwaveview_erpsetops.CURRENTERP = CURRENTERPStudio;
- ERPwaveview_erpsetops.SelectERPIdx = Selected_erpset;
- ERPwaveview_erpsetops.PageIndex = y_index;
- ERPwaveview_erpsetops.ERPLABFlag = 1;
- ERPdatasets = getERPDatasets(ALLERPin); % Get datasets from ALLERP
- ERPdatasets = sortdata(ERPdatasets);
- dsnames = {};
- if size(ERPdatasets,1)==1
- if strcmp(ERPdatasets{1},'No ERPset loaded')
- dsnames = {''};
- else
- dsnames{1} = strcat(num2str(cell2mat(ERPdatasets(1,2))),'.',32,ERPdatasets{1,1});
- end
+ end
+
+ if isempty(Selected_erpset) || Selected_erpset> length(ALLERPin)
+ Selected_erpset = length(ALLERPin);
+ end
+ if isempty(CURRENTERPStudio) || CURRENTERPStudio> length(ALLERPin)
+ CURRENTERPStudio = Selected_erpset(1);
+ ERPwaviewer_apply.PageIndex=1;
+ end
+
+
+ ERPwaveview_erpsetops.ALLERP = ALLERPin;
+ ERPwaveview_erpsetops.ERP = ALLERPin(CURRENTERPStudio);
+ ERPwaveview_erpsetops.CURRENTERP = CURRENTERPStudio;
+ ERPwaveview_erpsetops.SelectERPIdx = Selected_erpset;
+ ERPwaveview_erpsetops.PageIndex = ERPwaviewer_apply.PageIndex;
+ ERPwaveview_erpsetops.ERPLABFlag = 1;
+ ERPdatasets = getERPDatasets(ALLERPin); % Get datasets from ALLERP
+ ERPdatasets = sortdata(ERPdatasets);
+ dsnames = {};
+ if size(ERPdatasets,1)==1
+ if strcmp(ERPdatasets{1},'No ERPset loaded')
+ dsnames = {''};
else
- for Numofsub = 1:size(ERPdatasets,1)
- dsnames{Numofsub} = char(strcat(num2str(cell2mat(ERPdatasets(Numofsub,2))),'.',32,ERPdatasets{Numofsub,1}));
- end
+ dsnames{1} = strcat(num2str(cell2mat(ERPdatasets(1,2))),'.',32,ERPdatasets{1,1});
end
-
- ds_length = size(ERPdatasets,1);
- if ds_length<=2
- ERPwaveview_erpsetops.butttons_datasets.Max = ds_length+1;
- else
- ERPwaveview_erpsetops.butttons_datasets.Max = ds_length;
+ else
+ for Numofsub = 1:size(ERPdatasets,1)
+ dsnames{Numofsub} = char(strcat(num2str(cell2mat(ERPdatasets(Numofsub,2))),'.',32,ERPdatasets{Numofsub,1}));
end
- ERPwaveview_erpsetops.butttons_datasets.String = dsnames;
- ERPwaveview_erpsetops.butttons_datasets.Value = Selected_erpset;
-
-
- MessageViewer= char(strcat('ERPsets>" Same as',32,ERPtooltype,32,'"'));
- erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- viewer_ERPDAT.Process_messg =2;
+ end
+
+ ds_length = size(ERPdatasets,1);
+ if ds_length<=2
+ ERPwaveview_erpsetops.butttons_datasets.Max = ds_length+1;
else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- ERPwaveview_erpsetops.auto.Enable = 'off';
+ ERPwaveview_erpsetops.butttons_datasets.Max = ds_length;
end
+ ERPwaveview_erpsetops.butttons_datasets.String = dsnames;
+ ERPwaveview_erpsetops.butttons_datasets.Value = Selected_erpset;
else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- estudioworkingmemory('MyViewer_ERPsetpanel',0);
- ERPwaveview_erpsetops.erpset_apply.BackgroundColor = [1 1 1];
return;
end
- end
-
-%%---------------Setting for custom option---------------------------------
- function erpselect_custom(~,~)
- [messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
- if ~isempty(messgStr) && viewerpanelIndex~=1
- viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
- end
- estudioworkingmemory('MyViewer_ERPsetpanel',1);
- ERPwaveview_erpsetops.erpset_apply.BackgroundColor = [0.4940 0.1840 0.5560];
- ERPwaveview_erpsetops.erpset_apply.ForegroundColor = [1 1 1];
- ERPsets_waveviewer_box.TitleColor= [0.4940 0.1840 0.5560];
-
- ERPtooltype = erpgettoolversion('tooltype');
- if ~strcmpi(ERPtooltype,'EStudio') && ~strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- ERPwaveview_erpsetops.auto.Enable = 'off';
- else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- end
+ ERPwaviewer_apply.ALLERP = ALLERPin;
+ ERPwaviewer_apply.ERP = ALLERPin(CURRENTERPStudio);
+ ERPwaviewer_apply.SelectERPIdx =Selected_erpset;
+ ERPwaviewer_apply.CURRENTERP = CURRENTERPStudio;
+ % ERPwaviewer_apply.PageIndex = 1;
+ estudioworkingmemory('MyViewer_ERPsetpanel',0);
+ ERPwaveview_erpsetops.erpset_apply.BackgroundColor = [1 1 1];
+ ERPwaveview_erpsetops.erpset_apply.ForegroundColor = [0 0 0];
+ ERPsets_waveviewer_box.TitleColor= [0.5 0.5 0.9];
+ assignin('base','ALLERPwaviewer',ERPwaviewer_apply);
+ erpworkingmemory('ERPLAB_ERPWaviewer',0);
+ ERPset_apply();
end
-
% called datasets = sortdata(datasets), sorts datasets in order based on
% parents
function varargout = sortdata(data)
@@ -428,6 +356,9 @@ function erpset_help(~,~)
if changeFlag~=1
return;
end
+ MessageViewer= char(strcat('ERPsets > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =1;
try
ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
@@ -436,19 +367,8 @@ function erpset_help(~,~)
fprintf(2,'\n ERPsets > Cancel-f_ERPsets_waviewer_GUI() error: Cannot get parameters for whole panel.\n Please run My viewer again.\n\n');
return;
end
- ERPwaveview_erpsetops.ERPLABFlag=0;
-
- ERP_OP = ERPwaviewer_apply.erp_binchan_op;
- if ERP_OP ==1
- ERPwaveview_erpsetops.auto.Value = 1;
- ERPwaveview_erpsetops.custom.Value =0;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'off';
- else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- end
+ ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
ALLERPin = ERPwaviewer_apply.ALLERP;
ERPdatasets = getERPDatasets(ALLERPin); % Get datasets from ALLERP
ERPdatasets = sortdata(ERPdatasets);
@@ -485,6 +405,9 @@ function erpset_help(~,~)
ERPwaveview_erpsetops.erpset_apply.BackgroundColor = [1 1 1];
ERPwaveview_erpsetops.erpset_apply.ForegroundColor = [0 0 0];
ERPsets_waveviewer_box.TitleColor= [0.5 0.5 0.9];
+ MessageViewer= char(strcat('ERPsets > Cancel'));
+ erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+ viewer_ERPDAT.Process_messg =2;
end
%%------------------------------Apply--------------------------------------
@@ -518,32 +441,25 @@ function ERPset_apply(~,~)
for Numofselectederp = 1:numel(ERPsetArray)
SrateNum_mp(Numofselectederp,1) = ALLERPIN(ERPsetArray(Numofselectederp)).srate;
end
- % if numel(unique(SrateNum_mp))>1
- % MessageViewer= char(strcat('Sampling rate varies across the selected ERPsets, we therefore set "ERPsets" to be "Pages".'));
- % erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- % viewer_ERPDAT.Process_messg =4;
- % %%
- % MessageViewer= char(strcat('ERPsets > Apply'));
- % erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- % end
ERPwaviewer_apply.CURRENTERP = CurrentERP;
ERPwaviewer_apply.ERP = ERPwaviewer_apply.ALLERP(CurrentERP);
ERPwaviewer_apply.SelectERPIdx = ERPsetArray;
- ERPwaviewer_apply.erp_binchan_op = ERPwaveview_erpsetops.auto.Value;
-
- if ERPwaveview_erpsetops.auto.Value ==1
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
Geterpbinchan = estudioworkingmemory('geterpbinchan');
- CurrentERPIndex = Geterpbinchan.Select_index;
- chan_bin = Geterpbinchan.bins_chans(CurrentERPIndex);
- if chan_bin ==1
- ERPwaviewer_apply.plot_org.Grid =2;
- ERPwaviewer_apply.plot_org.Overlay=1;
- ERPwaviewer_apply.plot_org.Pages=3;
- elseif chan_bin==0
- ERPwaviewer_apply.plot_org.Grid =1;
- ERPwaviewer_apply.plot_org.Overlay=2;
- ERPwaviewer_apply.plot_org.Pages=3;
+ if ~isempty(Geterpbinchan)
+ CurrentERPIndex = Geterpbinchan.Select_index;
+ chan_bin = Geterpbinchan.bins_chans(CurrentERPIndex);
+ if chan_bin ==1
+ ERPwaviewer_apply.plot_org.Grid =2;
+ ERPwaviewer_apply.plot_org.Overlay=1;
+ ERPwaviewer_apply.plot_org.Pages=3;
+ elseif chan_bin==0
+ ERPwaviewer_apply.plot_org.Grid =1;
+ ERPwaviewer_apply.plot_org.Overlay=2;
+ ERPwaviewer_apply.plot_org.Pages=3;
+ end
end
%%% we may need to get the grid layout automatically
end
@@ -562,8 +478,8 @@ function ERPset_apply(~,~)
%%------------Update this panel based on the imported parameters-----------
- function count_loadproper_change(~,~)
- if viewer_ERPDAT.count_loadproper ==0
+ function loadproper_change(~,~)
+ if viewer_ERPDAT.loadproper_count ~=1
return;
end
try
@@ -572,7 +488,7 @@ function count_loadproper_change(~,~)
ALLERPup = ERPwaviewer_up.ALLERP;
if isempty(ALLERPup)
beep;
- disp('f_ERPsets_waviewer_GUI()>count_loadproper_change() error: ALLERP is empty.');
+ disp('f_ERPsets_waviewer_GUI()>loadproper_change() error: ALLERP is empty.');
return;
end
if max(SelectedIndex(:))> length(ALLERPup)
@@ -581,31 +497,11 @@ function count_loadproper_change(~,~)
end
catch
beep;
- disp('f_ERPsets_waviewer_GUI()>count_loadproper_change() error: Restart ERPwave Viewer');
+ disp('f_ERPsets_waviewer_GUI()>loadproper_change() error: Restart ERPwave Viewer');
return;
end
- ERPtooltype = erpgettoolversion('tooltype');
- if isempty(ERPtooltype)
- ERPtooltype = 'MyViewer';
- erpgettoolversion('tooltype','MyViewer');
- end
- if ~strcmpi(ERPtooltype,'EStudio') && ~strcmpi(ERPtooltype,'ERPLAB')
- ERPwaviewer_up.erp_binchan_op = 0;
- end
- try
- Enable_auto = ERPwaviewer_up.erp_binchan_op;
- catch
- Enable_auto = 1;
- ERPwaviewer_up.erp_binchan_op = 1;
- end
- if Enable_auto ==1
- Enable_label = 'off';
- elseif Enable_auto ==0
- Enable_label = 'on';
- end
- ERPwaveview_erpsetops.auto.Value = Enable_auto;
- ERPwaveview_erpsetops.custom.Value=~Enable_auto;
+ Enable_label = 'on';
ERPdatasets = getERPDatasets(ALLERPup); % Get datasets from ALLERP
ERPdatasets = sortdata(ERPdatasets);
dsnames = {};
@@ -626,170 +522,12 @@ function count_loadproper_change(~,~)
ERPwaveview_erpsetops.butttons_datasets.Max = ds_length;
ERPwaveview_erpsetops.butttons_datasets.String = dsnames;
ERPwaveview_erpsetops.butttons_datasets.Value = SelectedIndex;
- if strcmpi(ERPtooltype,'EStudio')
- ERPwaveview_erpsetops.auto.String = 'Same as EStudio';
- elseif strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_erpsetops.auto.String = 'Same as ERPLAB';
- else
- ERPwaveview_erpsetops.auto.String = '';
- ERPwaveview_erpsetops.auto.Enable = 'off';
- ERPwaveview_erpsetops.custom.String = '';
- ERPwaveview_erpsetops.custom.Enable = 'off';
- end
assignin('base','ALLERPwaviewer',ERPwaviewer_up);
+ viewer_ERPDAT.loadproper_count=2;
end
-%%change this panel based on the chaneges of main EStudio
- function Two_GUI_change(~,~)
- ERPtooltype = erpgettoolversion('tooltype');
- if observe_ERPDAT.Two_GUI~=1
- return;
- end
-
- if isempty(observe_ERPDAT.ALLERP)
- try
- close(gui_erp_waviewer.Window);%%close previous GUI if exists
- catch
- end
- return;
- end
- ALLERPNew = observe_ERPDAT.ALLERP;
- %%checking datatype
- counterp = 0;
- datatypeFlag = [];
- for Numoferpset = 1:length(ALLERPNew)
- if ~strcmpi(ALLERPNew(Numoferpset).datatype, 'ERP') && ~strcmpi(ALLERPNew(Numoferpset).datatype, 'CSD')
- counterp = counterp+1;
- datatypeFlag(counterp) = Numoferpset;
- end
- end
- if ~isempty(datatypeFlag)
- msgboxText = ['ERP Wave Viewer donot support to plot the wave for the data that donot belong to "ERP" or "CSD".\n'...
- 'Please remove the following ERPset with index(es):',32,num2str(datatypeFlag),'.'];
- if strcmpi(ERPtooltype,'ERPLAB')
- title_msg = 'ERPLAB: ERPLAB_ERP_Viewer() datatype error:';
- elseif strcmpi(ERPtooltype,'EStudio')
- title_msg = 'EStudio: ERPLAB_ERP_Viewer() datatype error:';
- else
- title_msg = ' ERPLAB_ERP_Viewer() datatype error:';
- end
- errorfound(sprintf(msgboxText), title_msg);
- return;
- end
-
- try
- ERPAutoValue = ERPwaveview_erpsetops.auto.Value;
- catch
- return;
- end
-
- if isempty(observe_ERPDAT.ALLERP)
- try
- close(gui_erp_waviewer.Window);
- catch
- end
- assignin('base','ALLERPwaviewer',[]);
- return;
- end
- MessageViewer= char(strcat('Update "ERP wave Viewer"'));
- erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- viewer_ERPDAT.Process_messg =1;
-
- %%check ALLERP for EStudio
- if strcmpi(ERPtooltype,'EStudio')
- if (length(ALLERPStudio)==1&& strcmpi(ALLERPStudio(1).erpname,'No ERPset loaded')) || strcmpi(ALLERPStudio(length(ALLERPStudio)).erpname,'No ERPset loaded')
- try
- % cprintf('red',['\n ERP Wave viewer will be closed because ALLERP is empty.\n\n']);
- close(gui_erp_waviewer.Window);
- catch
- end
- assignin('base','ALLERPwaviewer',[]);
- return;
- end
- end
- try
- ERPwaviewer_up = evalin('base','ALLERPwaviewer');
- catch
- beep;
- disp('f_ERPsets_waviewer_GUI() error: Restart ERPwave Viewer');
- return;
- end
- if ERPAutoValue ==1
- if strcmpi(ERPtooltype,'ERPLAB')
- ERPArrayStudio= observe_ERPDAT.CURRENTERP;
- elseif strcmpi(ERPtooltype,'EStudio')
- ERPArrayStudio= estudioworkingmemory('selectederpstudio');
- else
- ERPArrayStudio= observe_ERPDAT.CURRENTERP;
- end
- CURRENTERPStudio = observe_ERPDAT.CURRENTERP;
- estudioworkingmemory('PlotOrg_ERPLAB',1);%%This is used to Grid, Overlay, and Pages if "same as ERPLAB"
-
- end
-
- % else
- if ERPAutoValue ~=1
- ERPArrayStudio = ERPwaviewer_up.SelectERPIdx;
- CURRENTERPStudio=ERPwaviewer_up.CURRENTERP;
- % ALLERPStudio = evalin('base','ALLERP');
- end
- ALLERPStudio = observe_ERPDAT.ALLERP;
- if max(ERPArrayStudio(:))> length(ALLERPStudio) || min(ERPArrayStudio(:))<=0
- ERPArrayStudio = length(ALLERPStudio);
- CURRENTERPStudio = length(ALLERPStudio);
- end
- [x_index,y_index] = find(ERPArrayStudio==CURRENTERPStudio);
- if isempty(y_index)
- y_index = numel(ERPArrayStudio);
- end
-
- ERPwaviewer_up.ALLERP = ALLERPStudio;
- ERPwaviewer_up.ERP = ALLERPStudio(CURRENTERPStudio);
- ERPwaviewer_up.CURRENTERP = CURRENTERPStudio;
- ERPwaviewer_up.SelectERPIdx = ERPArrayStudio;
- ERPwaviewer_up.PageIndex = y_index;
- ERPdatasets = getERPDatasets(ALLERPStudio); % Get datasets from ALLERP
- ERPdatasets = sortdata(ERPdatasets);
- dsnames = {};
- if size(ERPdatasets,1)==1
- if strcmp(ERPdatasets{1},'No ERPset loaded')
- dsnames = {''};
- else
- dsnames{1} = strcat(num2str(cell2mat(ERPdatasets(1,2))),'.',32,ERPdatasets{1,1});
- end
- else
- for Numofsub = 1:size(ERPdatasets,1)
- dsnames{Numofsub} = char(strcat(num2str(cell2mat(ERPdatasets(Numofsub,2))),'.',32,ERPdatasets{Numofsub,1}));
- end
- end
-
- % ERPwaveview_erpsetops.butttons_datasets.Enable = Enable_label;
- ds_length = length(ERPdatasets);
- if ds_length<=2
- ERPwaveview_erpsetops.butttons_datasets.Max = ds_length+1;
- else
- ERPwaveview_erpsetops.butttons_datasets.Max = ds_length;
- end
- ERPwaveview_erpsetops.butttons_datasets.String = dsnames;
- ERPwaveview_erpsetops.butttons_datasets.Value = ERPArrayStudio;
-
- if strcmpi(ERPtooltype,'ERPLAB') && ERPAutoValue ==1
- % ERPwaviewer_up.bin= [1:observe_ERPDAT.ERP.nbin];
- % ERPwaviewer_up.chan = [1:observe_ERPDAT.ERP.nchan];
- ERPwaviewer_up.PageIndex = 1;
- end
-
- assignin('base','ALLERPwaviewer',ERPwaviewer_up);
- viewer_ERPDAT.Count_currentERP = viewer_ERPDAT.Count_currentERP+1;
- f_redrawERP_viewer_test();%%Plot the waves
-
- MessageViewer= char(strcat('Update "ERP wave Viewer"'));
- erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
- viewer_ERPDAT.Process_messg =2;
- observe_ERPDAT.Two_GUI =2;
- end
%%-------------------------------------------------------------------------
%%Automatically saving the changed parameters for the current panel if the
@@ -811,17 +549,6 @@ function count_twopanels_change(~,~)
function Reset_Waviewer_panel_change(~,~)
if viewer_ERPDAT.Reset_Waviewer_panel==1
ERPtooltype = erpgettoolversion('tooltype');
- if strcmpi(ERPtooltype,'EStudio') || strcmpi(ERPtooltype,'ERPLAB')
- ERPwaveview_erpsetops.auto.Value = 1;
- ERPwaveview_erpsetops.custom.Value =0;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'off';
- else
- ERPwaveview_erpsetops.auto.Value = 0;
- ERPwaveview_erpsetops.custom.Value =1;
- ERPwaveview_erpsetops.butttons_datasets.Enable = 'on';
- ERPwaveview_erpsetops.auto.Enable = 'off';
- ERPwaveview_erpsetops.custom.Enable = 'off';
- end
if strcmpi(ERPtooltype,'EStudio') || strcmpi(ERPtooltype,'ERPLAB')
if strcmpi(ERPtooltype,'ERPLAB')
try
@@ -935,4 +662,35 @@ function Reset_Waviewer_panel_change(~,~)
end
+%%change the ERPset indeces when they are changed in Plot organization panel
+ function ERPset_Chan_bin_label_change(~,~)
+ if viewer_ERPDAT.ERPset_Chan_bin_label~=1 %% 1 means ERPset indeces were changed
+ if viewer_ERPDAT.ERPset_Chan_bin_label==2%%Update Viewer based on the change in ERPLAB
+ erpselect_refresh();
+ end
+ return;
+ end
+ try
+ ERPwaviewer_apply = evalin('base','ALLERPwaviewer');
+ catch
+ viewer_ERPDAT.Process_messg =3;
+ fprintf(2,'\n ERPsets > f_ERPsets_waviewer_GUI() error: Cannot get parameters for whole panel.\n Please run My viewer again.\n\n');
+ return;
+ end
+
+ ERPsetArray = ERPwaviewer_apply.SelectERPIdx;
+ if max(ERPsetArray(:)) <= length(ERPwaveview_erpsetops.butttons_datasets.String)
+ ERPwaveview_erpsetops.butttons_datasets.Value = ERPsetArray;
+ end
+ end
+
+%%execute this panel when press "return" or "Enter"
+ function ERPset_keypress(hObject, eventdata)
+ keypress = eventdata.Key;
+ if strcmp (keypress, 'return') || strcmp (keypress , 'enter')
+ ERPset_apply();
+ else
+ return;
+ end
+ end
end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_MarkLabels_gridlocations_ERP_Waveiwer.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_MarkLabels_gridlocations_ERP_Waveiwer.m
new file mode 100644
index 00000000..6b636054
--- /dev/null
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_MarkLabels_gridlocations_ERP_Waveiwer.m
@@ -0,0 +1,45 @@
+function [LabelStrout] = f_MarkLabels_gridlocations_ERP_Waveiwer(Gridata,usedIndex,AllabelArray)
+% usedIndex = zeros(length(AllabelArray),1);
+% for jj = 1:length(AllabelArray)
+% for ii = 1:length(LabelStr)
+% if strcmp(AllabelArray{jj},LabelStr{ii})
+% usedIndex(jj) = 1;
+% end
+% end
+% end
+
+LabelsFlag = [0 0 0];
+for ii = 1:length(AllabelArray)
+ code1 = 0;
+ % for jj = 1:size(Gridata,1)
+ % for kk = 1:size(Gridata,2)
+ % if strcmp(AllabelArray{ii},Gridata{jj,kk})
+ % code1 = code1+1;
+ % end
+ % end
+ % end
+ [C,IA]=ismember(Gridata,AllabelArray{ii});
+ C = reshape(C,size(C,1)*size(C,2),1);
+ Xpos =find(C==1);
+ if isempty(Xpos)
+ code1 = 0;
+ else
+ code1 = numel(Xpos);
+ end
+ if usedIndex(ii)==1%% the item will be marked with * if the labels was selected
+ Numstr = strcat('*',num2str(ii));
+ else
+ Numstr = strcat(num2str(ii));
+ end
+
+ if code1 ==0
+ LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+ LabelsFlag(1) = 1;
+ elseif code1 >1
+ LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+ LabelsFlag(3) = 1;
+ else
+ LabelStrout{ii} = ['',Numstr,'.',32,AllabelArray{ii},' '];
+ LabelsFlag(2) = 1;
+ end
+end
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_checktable_gridlocations_waviewer.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_checktable_gridlocations_waviewer.m
new file mode 100644
index 00000000..12934eb0
--- /dev/null
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_checktable_gridlocations_waviewer.m
@@ -0,0 +1,62 @@
+function [Dataout, EPStr]= f_checktable_gridlocations_waviewer(Data,LabelStr)
+countEp = 0;
+EPStr = '';
+Dataout = cell(size(Data,1),size(Data,2));
+
+Data = string(Data);
+Data= strrep(Data,'','');
+Data = strrep(Data,'
','');
+for ii = 1:size(Data,1)
+ for jj = 1:size(Data,2)
+ count = 0;
+ % for kk = 1:length(LabelStr)
+ % Data1= strrep(Data{ii,jj},'','');
+ % Data1 = strrep(Data1,'
','');
+ % Data{ii,jj} = char(Data1);
+ % if strcmp(strrep(char(LabelStr{kk}),' ',''),strtrim(char(Data{ii,jj})))
+ % Data{ii,jj} = char(LabelStr{kk});
+ % count = count +1;
+ % end
+ % end
+
+ % [C,IA] =ismember_bc2(strtrim(char(Data(ii,jj))), strrep(string(LabelStr),' ',''));
+ try
+ [C,IA] =ismember_bc2(strtrim(char(Data(ii,jj))), string(LabelStr));
+ catch
+ [C,IA] =ismember_bc2(strtrim(char(Data(ii,jj))), LabelStr);
+ end
+ if C ==1 && IA ~=0
+ Dataout{ii,jj} = char(LabelStr{IA});
+ count = count +1;
+ else
+ Dataout{ii,jj} = char('');
+ count=0;
+ end
+
+ if count==0
+ countEp = countEp+1;
+ if countEp==1
+ if isstring(Data(ii,jj))
+ if ~isempty(Data(ii,jj))
+ EPStr = char(Data(ii,jj));
+ end
+ elseif isnumeric(Data(ii,jj))
+ if ~isempty(Data(ii,jj))
+ EPStr = num2str(Data(ii,jj));
+ end
+ end
+ else
+ if isstring(Data(ii,jj))
+ if ~isempty(Data(ii,jj))
+ EPStr = strcat(EPStr,32,char(Data(ii,jj)));
+ end
+ elseif isnumeric(Data(ii,jj))
+ if ~isempty(Data(ii,jj))
+ EPStr = strcat(EPStr,32,num2str(Data(ii,jj)));
+ end
+ end
+ end
+% Data{ii,jj} = char('');
+ end
+ end
+end
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_geterpschanbin.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_geterpschanbin.m
index e6919fe8..cf07318d 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_geterpschanbin.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_geterpschanbin.m
@@ -74,7 +74,11 @@
BinName = ERP.bindescr;
binStr = cell(BinNum,1);
for i = 1:BinNum
- binStr(i) = {char(BinName{i})};
+ try
+ binStr(i) = {char(BinName{i})};
+ catch
+ binStr(i) = {['Bin',num2str(i)]};
+ end
end
%%--------Get the names of chans-----------
@@ -82,7 +86,11 @@
Chanlist = ERP.chanlocs;
chanStr = cell(ChanNum,1);
for Numofchan = 1:length(Chanlist)
- chanStr(Numofchan) = {char(Chanlist(Numofchan).labels)};
+ try
+ chanStr(Numofchan) = {char(Chanlist(Numofchan).labels)};
+ catch
+ chanStr(Numofchan) = {['Chan',num2str(Numofchan)]};
+ end
end
return;
end
@@ -124,7 +132,11 @@
Chanlist = ERP.chanlocs;
chanStr_max = cell(ChanNum,1);
for Numofchan = 1:length(Chanlist)
- chanStr_max(Numofchan) = {Chanlist(Numofchan).labels};
+ try
+ chanStr_max(Numofchan) = {Chanlist(Numofchan).labels};
+ catch
+ chanStr_max(Numofchan) = {['Chan',num2str(Numofchan)]};
+ end
end
SelectedERPIndex_chan_lf =SelectedERPIndex(setdiff(1:numel(SelectedERPIndex),x_chan));
@@ -166,7 +178,11 @@
BinName = ERP.bindescr;
binStr = cell(BinNum,1);
for Numofbin = 1:BinNum
- binStr(Numofbin) = {char(BinName{Numofbin})};
+ try
+ binStr(Numofbin) = {char(BinName{Numofbin})};
+ catch
+ binStr(Numofbin) = {['Bin',num2str(Numofbin)]};
+ end
end
elseif numel(unique(BinNum_mp))>1%%varies across the selected ERPsets
@@ -180,7 +196,11 @@
binStr_max = cell(BinNum,1);
for Numofbin = 1:BinNum
- binStr_max(Numofbin) = {char(BinName{Numofbin})};
+ try
+ binStr_max(Numofbin) = {char(BinName{Numofbin})};
+ catch
+ binStr_max(Numofbin) = {['Bin',num2str(Numofbin)]};
+ end
end
diff --git a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ploterpserpviewer.m b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ploterpserpviewer.m
index 9aa20851..54fe8ebd 100755
--- a/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ploterpserpviewer.m
+++ b/studio_functions/Functions/EStudio/ERP Tab/ERP wave viewer/f_ploterpserpviewer.m
@@ -71,10 +71,11 @@
%qLabelcolor -Channel/Bin/ERPset label color in RGB, e.g., [0 0 0]
%qYtickdecimal -determine the number of decimals of y tick labels
% - e.g., -6.0 -3.0 0.0 3.0 6.0 if qYtickdecimal is 1
-%qXtickdecimal -determine the nunmber of decimals of x tick labels
+%qXtickdecimal -determine the nunmber of decimals of x tick labels
% -e.g., -0.2 0.0 0.2 0.4 0.6 0.8 if qXtickdecimal is 1
%qXdisFlag -the way is to display xticks: 1 is in millisecond, 0 is in second
-
+%qFigOutpos - The width and height for the figure. The default one is
+% the same to the monitor.
% *** This function is part of EStudio Toolbox ***
@@ -88,7 +89,7 @@
function f_ploterpserpviewer(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGridposArray,plotBox,qBlc,qLineColorspec,qLineStylespec,qLineMarkerspec,qLineWidthspec,...
qLegendName,qLegendFont,qLegendFontsize,qCBELabels,qLabelfont,qLabelfontsize,qPolarityWave,qSEM,qTransparency,qGridspace,qtimeRange,qXticks,qXticklabel,...
qXlabelfont,qXlabelfontsize,qXlabelcolor,qMinorTicksX,qXunits,qYScales,qYticks,qYticklabel,qYlabelfont,qYlabelfontsize,qYlabelcolor,qYunits,qMinorTicksY,...
- qplotArrayStr,qERPArray,qlegcolor,qlegcolumns,qFigureName,qFigbgColor,qLabelcolor,qYtickdecimal,qXtickdecimal,qXdisFlag)
+ qplotArrayStr,qERPArray,qlegcolor,qlegcolumns,qFigureName,qFigbgColor,qLabelcolor,qYtickdecimal,qXtickdecimal,qXdisFlag,qFigOutpos)
if nargin<1
help f_ploterpserpviewer;
@@ -257,7 +258,9 @@ function f_ploterpserpviewer(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,
end
end
-
+if nargin<49
+ qFigOutpos =[];
+end
if nargin<48 || (qXdisFlag~=1 && qXdisFlag~=0)
qXdisFlag =1;
end
@@ -652,7 +655,7 @@ function f_ploterpserpviewer(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,
elseif strcmpi(qBlc,'post')
indxtimelock = length(ERP.times);
aa = find(ERP.times==0);
- elseif strcmpi(qBlc,'all')
+ elseif strcmpi(qBlc,'all') || strcmpi(qBlc,'whole')
indxtimelock = length(ERP.times);
aa = 1;
else
@@ -995,18 +998,34 @@ function f_ploterpserpviewer(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,
hold on;
% hbig= axes('Parent',fig_gui_wave);
end
-
-set(fig_gui,'outerposition',get(0,'screensize'));%%Maximum figure
+try
+ outerpos = fig_gui.OuterPosition;
+ set(fig_gui,'outerposition',[outerpos(1),(2),qFigOutpos(1) 1.05*qFigOutpos(2)])
+catch
+ set(fig_gui,'outerposition',get(0,'screensize'));%%Maximum figure
+end
if ~isempty(extfig)
set(fig_gui,'visible','off');
end
-
+set(fig_gui, 'Renderer', 'painters');%%vector figure
try
y_scale_def(1) = min([1.1*y_scale_def(1),1.1*qYScales(1)]);
y_scale_def(2) = max([1.1*y_scale_def(2),1.1*qYScales(2)]);
catch
end
+%%remove the margins of a plot
+ax = hbig;
+outerpos = ax.OuterPosition;
+ti = ax.TightInset;
+left = outerpos(1) + ti(1);
+bottom = outerpos(2) + ti(2);
+ax_width = outerpos(3) - ti(1) - ti(3);
+ax_height = outerpos(4) - ti(2) - ti(4);
+ax.Position = [left bottom ax_width ax_height];
+
+
+
%%--------------Plot ERPwave-----------------
stdalpha = qTransparency;
countPlot = 0;
@@ -1368,8 +1387,12 @@ function f_ploterpserpviewer(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,
% disp(['Data at',32,'R',num2str(Numofrows),',','C',num2str(Numofcolumns), 32,'is empty!']);
end
try
- if isxaxislabel==2
- set(hbig,'xlim',[Xtimerange(1)-(Xtimerange(end)-Xtimerange(1)/10),XtimerangetrasfALL(end)+(Xtimerange(end)-Xtimerange(1))/10]);
+ if 21
help f_redrawERP_viewer;
return;
@@ -34,6 +31,25 @@ function f_redrawERP_viewer_test()
return;
end
+%%save figure size:width and height
+try
+ ScreenPos = get( groot, 'Screensize' );
+catch
+ ScreenPos = get( 0, 'Screensize' );
+end
+FigOutposition = gui_erp_waviewer.ViewBox.OuterPosition(3:4);
+FigOutposition(1) = 100*FigOutposition(1)/ScreenPos(3);
+FigOutposition(2) = 100*FigOutposition(2)/ScreenPos(4);
+ERPwaviewer.FigOutpos=FigOutposition;
+assignin('base','ALLERPwaviewer',ERPwaviewer);
+try
+ gui_erp_waviewer.ScrollVerticalOffsets = gui_erp_waviewer.ViewAxes.VerticalOffsets/gui_erp_waviewer.ViewAxes.Heights;
+ gui_erp_waviewer.ScrollHorizontalOffsets = gui_erp_waviewer.ViewAxes.HorizontalOffsets/gui_erp_waviewer.ViewAxes.Widths;
+catch
+ gui_erp_waviewer.ScrollVerticalOffsets=0;
+ gui_erp_waviewer.ScrollHorizontalOffsets=0;
+end
+
% We first clear the existing axes ready to build a new one
if ishandle( gui_erp_waviewer.ViewAxes )
delete( gui_erp_waviewer.ViewAxes );
@@ -63,6 +79,10 @@ function f_redrawERP_viewer_test()
zoomSpace =0;
end
end
+if zoomSpace ==0
+ gui_erp_waviewer.ScrollVerticalOffsets=0;
+ gui_erp_waviewer.ScrollHorizontalOffsets=0;
+end
pb_height = 1*Res(4);
try
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;%%Get background color
@@ -116,8 +136,12 @@ function f_redrawERP_viewer_test()
% gui_erp_waviewer.ViewAxes_legend = uix.ScrollingPanel( 'Parent', gui_erp_waviewer.plot_wav_legend,'BackgroundColor',ColorBviewer_def);
uicontrol('Parent',gui_erp_waviewer.plot_wav_legend,'Style','text','String','','FontSize',FonsizeDefault,'FontWeight','bold','BackgroundColor',ColorBviewer_def);
-gui_erp_waviewer.Resize = 0;
-gui_erp_waviewer.ViewAxes = uix.ScrollingPanel( 'Parent', gui_erp_waviewer.plot_wav_legend,'BackgroundColor',figbgdColor,'SizeChangedFcn',@WAviewerResize);%
+% gui_erp_waviewer.Resize = 0;
+
+
+% gui_erp_waviewer.ViewAxes = uix.ScrollingPanel( 'Parent', gui_erp_waviewer.plot_wav_legend,'BackgroundColor',figbgdColor,'SizeChangedFcn',@WAviewerResize);%
+gui_erp_waviewer.ViewAxes = uix.ScrollingPanel( 'Parent', gui_erp_waviewer.plot_wav_legend,'BackgroundColor',figbgdColor);
+
%%Changed by Guanghui Zhang Dec. 2022-------panel for display the processing procedure for some functions, e.g., filtering
gui_erp_waviewer.zoomin_out_title = uiextras.HBox( 'Parent', gui_erp_waviewer.plotgrid,'BackgroundColor',ColorBviewer_def);%%%Message
@@ -132,6 +156,10 @@ function f_redrawERP_viewer_test()
'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Callback',@zoomout);
uicontrol('Parent',gui_erp_waviewer.zoomin_out_title,'Style','text','String','','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
+gui_erp_waviewer.figuresaveas = uicontrol('Parent',gui_erp_waviewer.zoomin_out_title,'Style','pushbutton','String','Show Command',...
+ 'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Callback',@Show_command);
+
+
gui_erp_waviewer.figuresaveas = uicontrol('Parent',gui_erp_waviewer.zoomin_out_title,'Style','pushbutton','String','Save Figure as',...
'FontSize',FonsizeDefault,'BackgroundColor',[1 1 1],'Callback',@figure_saveas);
@@ -143,7 +171,7 @@ function f_redrawERP_viewer_test()
uicontrol('Parent',gui_erp_waviewer.zoomin_out_title,'Style','text','String','','FontSize',FonsizeDefault,'BackgroundColor',ColorBviewer_def);
-set(gui_erp_waviewer.zoomin_out_title, 'Sizes', [10 70 70 70 -1 100 170 70 20]);
+set(gui_erp_waviewer.zoomin_out_title, 'Sizes', [10 70 50 70 -1 100 100 170 70 5]);
%%Changed by Guanghui Zhang Dec. 2022-------panel for display the processing procedure for some functions, e.g., filtering
@@ -168,6 +196,7 @@ function f_redrawERP_viewer_test()
gui_erp_waviewer.pageinfo_plus.Enable = 'off';
% end
+
if pageNum ==1
Enable_minus = 'off';
Enable_plus = 'off';
@@ -219,6 +248,8 @@ function f_redrawERP_viewer_test()
return;
end
+
+%%Plot the waves
f_plotviewerwave(OutputViewerpar{1},OutputViewerpar{2}, OutputViewerpar{3},OutputViewerpar{4},OutputViewerpar{5},OutputViewerpar{6},OutputViewerpar{9},OutputViewerpar{8},OutputViewerpar{10},OutputViewerpar{11},...
OutputViewerpar{12},OutputViewerpar{13},OutputViewerpar{14},OutputViewerpar{15},OutputViewerpar{16},OutputViewerpar{17},OutputViewerpar{18},OutputViewerpar{19},OutputViewerpar{20},OutputViewerpar{21},OutputViewerpar{22},...
OutputViewerpar{23},OutputViewerpar{24},OutputViewerpar{25},OutputViewerpar{26},OutputViewerpar{27},OutputViewerpar{28},OutputViewerpar{29},OutputViewerpar{31},OutputViewerpar{30},OutputViewerpar{32},OutputViewerpar{33},...
@@ -250,18 +281,40 @@ function f_redrawERP_viewer_test()
end
gui_erp_waviewer.plotgrid.Units = 'normalized';
-gui_erp_waviewer.Resize =1;
+
+
+
+%%Keep the same positions for Vertical and Horizontal scrolling bars asbefore
+if zoomSpace~=0 && zoomSpace>0
+ if gui_erp_waviewer.ScrollVerticalOffsets<=1
+ try
+ gui_erp_waviewer.ViewAxes.VerticalOffsets= gui_erp_waviewer.ScrollVerticalOffsets*gui_erp_waviewer.ViewAxes.Heights;
+ catch
+ end
+ end
+ if gui_erp_waviewer.ScrollHorizontalOffsets<=1
+ try
+ gui_erp_waviewer.ViewAxes.HorizontalOffsets =gui_erp_waviewer.ScrollHorizontalOffsets*gui_erp_waviewer.ViewAxes.Widths;
+ catch
+ end
+ end
+end
+% gui_erp_waviewer.ViewAxes.BackgroundColor = 'b';
end % redrawDemo
+
+
+
%%Resize the GUI automatically as the user changes the size of the window at run-time.
-function WAviewerResize(~,~)
-global gui_erp_waviewer;
-if gui_erp_waviewer.Resize ~= 0
- f_redrawERP_viewer_test();
-end
-end
+% function WAviewerResize(~,~)
+% global gui_erp_waviewer;
+% if gui_erp_waviewer.Resize ~= 0
+% set( gui_erp_waviewer.tabERP, 'Widths', [-4, 270]);
+% f_redrawERP_viewer_test();
+% end
+% end
%%-------------------------------Page Editor-------------------------------
@@ -406,6 +459,29 @@ function page_plus(~,~)
end
+function Show_command(~,~)
+global viewer_ERPDAT;
+[messgStr,viewerpanelIndex] = f_check_erpviewerpanelchanges();
+if ~isempty(messgStr)
+ viewer_ERPDAT.count_twopanels = viewer_ERPDAT.count_twopanels +1;
+end
+
+ViewerName = estudioworkingmemory('viewername');
+if isempty(ViewerName)
+ ViewerName = char('My Viewer');
+end
+MessageViewer= char(strcat('Show Command'));
+erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
+try
+ viewer_ERPDAT.Process_messg =1;
+ OutputViewerpar = f_preparms_erpwaviewer(ViewerName,'command');
+ viewer_ERPDAT.Process_messg =2;
+catch
+ viewer_ERPDAT.Process_messg =3;
+end
+end
+
+
%%-------------------------Save figure as----------------------------------
function figure_saveas(~,~)
@@ -470,7 +546,7 @@ function figure_out(~,~)
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
try
viewer_ERPDAT.Process_messg =1;
- OutputViewerpar = f_preparms_erpwaviewer(ViewerName);
+ OutputViewerpar = f_preparms_erpwaviewer(ViewerName,'script');
viewer_ERPDAT.Process_messg =2;
catch
viewer_ERPDAT.Process_messg =3;
@@ -512,6 +588,10 @@ function zoomin(~,~)
%%Reset each panel that using the default parameters
function Panel_Reset(~,~)
global viewer_ERPDAT;
+global gui_erp_waviewer
+
+estudioworkingmemory('MERPWaveViewer_label',[]);
+estudioworkingmemory('MERPWaveViewer_others',[]);
MessageViewer= char(strcat('Reset'));
erpworkingmemory('ERPViewer_proces_messg',MessageViewer);
@@ -526,6 +606,18 @@ function Panel_Reset(~,~)
viewer_ERPDAT.Process_messg =3;
end
+%%Reset the window size and position
+new_pos = [0.01,0.01,75,75];
+erpworkingmemory('ERPWaveScreenPos',new_pos);
+try
+ ScreenPos = get( groot, 'Screensize' );
+catch
+ ScreenPos = get( 0, 'Screensize' );
+end
+gui_erp_waviewer.screen_pos = new_pos;
+new_pos =[ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100,ScreenPos(3)*new_pos(3)/100,ScreenPos(4)*new_pos(4)/100];
+set(gui_erp_waviewer.Window, 'Position', new_pos);
+
end
@@ -555,17 +647,17 @@ function zoomedit(Source,~)
end
else
if isempty(zoomspaceEdit)
- fprintf(2,['\n Zoom Editor:The input must be a numeric','.\n']);
+ fprintf(2,['\n Zoom Editor:The input must be a number','.\n']);
viewer_ERPDAT.Process_messg =3;
return;
end
if numel(zoomspaceEdit)>1
- fprintf(2,['\n Zoom Editor:The input must be a single numeric','.\n']);
+ fprintf(2,['\n Zoom Editor:The input must be a single number','.\n']);
viewer_ERPDAT.Process_messg =3;
return;
end
if zoomspaceEdit<0
- fprintf(2,['\n Zoom Editor:The input must be a positive numeric','.\n']);
+ fprintf(2,['\n Zoom Editor:The input must be a positive number','.\n']);
viewer_ERPDAT.Process_messg =3;
return;
end
@@ -627,10 +719,17 @@ function V_messg_change(~,~)
gui_erp_waviewer.Process_messg.ForegroundColor = [0 0.5 0];
elseif viewer_ERPDAT.Process_messg ==3
+ if ~strcmp(gui_erp_waviewer.Process_messg.String,strcat('3- ',Processed_Method,': Error (see Command Window)'))
+ fprintf([Processed_Method,32,32,32,datestr(datetime('now')),'\n.']);
+ end
gui_erp_waviewer.Process_messg.String = strcat('3- ',Processed_Method,': Error (see Command Window)');
gui_erp_waviewer.Process_messg.ForegroundColor = [1 0 0];
else
- gui_erp_waviewer.Process_messg.String = strcat('Warning:',Processed_Method,'(see Command Window).');
+ if ~strcmpi(gui_erp_waviewer.Process_messg.String,strcat('Warning:',32,Processed_Method,32,'(see Command Window).'))
+ fprintf([Processed_Method,32,32,32,datestr(datetime('now')),'\n.']);
+ end
+ gui_erp_waviewer.Process_messg.String = strcat('Warning:',32,Processed_Method,32,'(see Command Window).');
+
pause(0.5);
gui_erp_waviewer.Process_messg.ForegroundColor = [1 0.65 0];
end
@@ -779,7 +878,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
LineStyledef = {'-','--',':','-.','-','-','-',};
[ERPdatadef,legendNamedef,ERPerrordatadef,timeRangedef] = f_geterpdata(ALLERP,[1:length(ALLERP)],qPLOTORG);
%%%%%%%%%%%%%%%%%%%%--------------------------------------------------------
-
+plotArrayStrdef ='';
if qPLOTORG(1) ==1 %% if the selected Channel is "Grid"
plotArray = qchanArray;
for Numofchan = 1:numel(plotArray)
@@ -885,7 +984,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
%%ylable font
if nargin <34
- qYlabelfont = 'Geneva';
+ qYlabelfont = 'Helvetica';
end
%%display ylabels?
@@ -897,10 +996,18 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
datresh = squeeze(ERPdatadef(qchanArray,:,qbinArray,qERPArray));
yymax = max(datresh(:));
yymin = min(datresh(:));
-if abs(yymax)<1 && abs(yymin)<1
- scalesdef(1:2) = [yymin*1.2 yymax*1.1]; % JLC. Mar 11, 2015
+if ~isempty(yymax) && isempty(yymin)
+ if abs(yymax)<1 && abs(yymin)<1
+ try
+ scalesdef(1:2) = [yymin*1.2 yymax*1.1]; % JLC. Mar 11, 2015
+ catch
+ scalesdef(1:2) = [-1 1];
+ end
+ else
+ scalesdef(1:2) = [floor(yymin*1.2) ceil(yymax*1.1)]; % JLC. Sept 26, 2012
+ end
else
- scalesdef(1:2) = [floor(yymin*1.2) ceil(yymax*1.1)]; % JLC. Sept 26, 2012
+ scalesdef(1:2) = [-1 1];
end
yylim_out = f_erpAutoYLim(ALLERP, qERPArray,qPLOTORG,qbinArray, qchanArray,qCURRENTPLOT);
try
@@ -943,7 +1050,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
%%xlabel font
if nargin <26
- qXlabelfont= 'Geneva';
+ qXlabelfont= 'Helvetica';
end
%%disply xtick labels ?
@@ -1033,7 +1140,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
%%font of channel/bin/erpset label
if nargin <17
- qLabelfont= 'Geneva';
+ qLabelfont= 'Helvetica';
end
%%location of channel/bin/erpset label
@@ -1048,7 +1155,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
%%font of legend name
if nargin <14
- qLegendFont = 'Geneva';
+ qLegendFont = 'Helvetica';
end
%%legend name
@@ -1202,7 +1309,7 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
elseif strcmpi(qBlc,'post')
indxtimelock = length(ERP.times);
aa = find(ERP.times==0);
- elseif strcmpi(qBlc,'all')
+ elseif strcmpi(qBlc,'all') || strcmpi(qBlc,'whole')
indxtimelock = length(ERP.times);
aa = 1;
else
@@ -1385,6 +1492,9 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
if isempty( qYScales)
qYScales = [floor(min(bindata(:))),ceil(max(bindata(:)))];
end
+if isempty(y_scale_def)
+ y_scale_def = qYScales;
+end
if isyaxislabel==1 %% y axis GAP
if Ypert<0
Ypert = 100;
@@ -1524,6 +1634,21 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
y_scale_def(2) = max([1.1*y_scale_def(2),1.1*qYScales(2)]);
catch
end
+
+
+
+%%remove the margins of a plot
+ax = hbig;
+outerpos = ax.OuterPosition;
+ti = ax.TightInset;
+left = outerpos(1) + ti(1);
+bottom = outerpos(2) + ti(2);
+ax_width = outerpos(3) - ti(1) - ti(3);
+ax_height = outerpos(4) - ti(2) - ti(4);
+ax.Position = [left bottom ax_width ax_height];
+
+
+
%%--------------Plot ERPwave-----------------
stdalpha = qTransparency;
countPlot = 0;
@@ -1872,8 +1997,12 @@ function f_plotviewerwave(ALLERP,qCURRENTPLOT, qPLOTORG,qbinArray,qchanArray,qGr
% disp(['Data at',32,'R',num2str(Numofrows),',','C',num2str(Numofcolumns), 32,'is not defined!']);
end
try
- if isxaxislabel==2
- set(hbig,'xlim',[Xtimerange(1)-(Xtimerange(end)-Xtimerange(1)/10),XtimerangetrasfALL(end)+(Xtimerange(end)-Xtimerange(1))/10]);
+ if 2 b % number of columns increasing
- obj.MinimumWidths_(end+1:c,:) = -1;
+ obj.MinimumWidths_(end+1:c,:) = 1;
if r < q % number of rows decreasing
obj.Heights_(r+1:end,:) = [];
obj.MinimumHeights_(r+1:end,:) = [];
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/GridFlex.m b/studio_functions/GUI Layout Toolbox/layout/+uix/GridFlex.m
index d93038bf..e8a019b0 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/GridFlex.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/GridFlex.m
@@ -80,7 +80,9 @@
function set.DividerMarkings( obj, value )
% Check
- assert( ischar( value ) && any( strcmp( value, {'on','off'} ) ), ...
+ value = uix.validateScalarStringOrCharacterArray( value, ...
+ 'DividerMarkings' );
+ assert( any( strcmp( value, {'on','off'} ) ), ...
'uix:InvalidArgument', ...
'Property ''DividerMarkings'' must be ''on'' or ''off'.' )
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/HBoxFlex.m b/studio_functions/GUI Layout Toolbox/layout/+uix/HBoxFlex.m
index 43a7cdee..c82f300c 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/HBoxFlex.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/HBoxFlex.m
@@ -79,7 +79,9 @@
function set.DividerMarkings( obj, value )
% Check
- assert( ischar( value ) && any( strcmp( value, {'on','off'} ) ), ...
+ value = uix.validateScalarStringOrCharacterArray( value, ...
+ 'DividerMarkings' );
+ assert( any( strcmp( value, {'on','off'} ) ), ...
'uix:InvalidArgument', ...
'Property ''DividerMarkings'' must be ''on'' or ''off'.' )
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/Panel.m b/studio_functions/GUI Layout Toolbox/layout/+uix/Panel.m
index 0a416b8e..9047da3c 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/Panel.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/Panel.m
@@ -19,7 +19,7 @@
% p = uix.Panel() constructs a standard panel.
%
% p = uix.Panel(p1,v1,p2,v2,...) sets parameter p1 to value
- % v1, etc.
+ % v1, etc.
% Set properties
try
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/ScrollingPanel.m b/studio_functions/GUI Layout Toolbox/layout/+uix/ScrollingPanel.m
index b2834cca..bf0fd5fd 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/ScrollingPanel.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/ScrollingPanel.m
@@ -351,7 +351,9 @@
function set.MouseWheelEnabled( obj, value )
- assert( ischar( value ) && any( strcmp( value, {'on','off'} ) ), ...
+ value = uix.validateScalarStringOrCharacterArray( value, ...
+ 'MouseWheelEnabled' );
+ assert( any( strcmp( value, {'on','off'} ) ), ...
'uix:InvalidArgument', ...
'Property ''MouseWheelEnabled'' must ''on'' or ''off''.' )
listener = obj.MouseWheelListener;
@@ -605,7 +607,7 @@ function showSelection( obj )
end % template methods
- methods( Access = private )
+ methods( Access = ?matlab.unittest.TestCase )
function onSliderScrolling( obj, ~, ~ )
%onSliderScrolling Event handler
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/VBoxFlex.m b/studio_functions/GUI Layout Toolbox/layout/+uix/VBoxFlex.m
index 10275490..dca279ae 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/VBoxFlex.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/VBoxFlex.m
@@ -79,7 +79,9 @@
function set.DividerMarkings( obj, value )
% Check
- assert( ischar( value ) && any( strcmp( value, {'on','off'} ) ), ...
+ value = uix.validateScalarStringOrCharacterArray( value, ...
+ 'DividerMarkings' );
+ assert( any( strcmp( value, {'on','off'} ) ), ...
'uix:InvalidArgument', ...
'Property ''DividerMarkings'' must be ''on'' or ''off'.' )
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/getPosition.m b/studio_functions/GUI Layout Toolbox/layout/+uix/getPosition.m
index bd9cb608..84dd5a27 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/getPosition.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/getPosition.m
@@ -1,7 +1,7 @@
function p = getPosition( o, u )
%getPosition Get position of graphics object
%
-% p = getPosition(o,u) sets the position of a graphics object o with units
+% p = getPosition(o,u) gets the position of a graphics object o with units
% u.
%
% In contrast to getting the Position property directly, this function
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/loadIcon.m b/studio_functions/GUI Layout Toolbox/layout/+uix/loadIcon.m
index 607c1d24..081f052e 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/loadIcon.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/loadIcon.m
@@ -82,17 +82,11 @@
switch lower( class( cdata ) )
case 'double'
- % do nothing
- case 'single'
- cdata = double( cdata );
+ % do nothing
case 'uint8'
cdata = double( cdata ) / 255;
case 'uint16'
- cdata = double( cdata ) / 65535;
- case 'int8'
- cdata = ( double( cdata ) + 128 ) / 255;
- case 'int16'
- cdata = ( double( cdata ) + 32768 ) / 65535;
+ cdata = double( cdata ) / 65535;
otherwise
error( 'uix:InvalidArgument', ...
'Image data of type ''%s'' is not supported.', class( cdata ) )
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/tracking.m b/studio_functions/GUI Layout Toolbox/layout/+uix/tracking.m
index 84eaee14..94d27427 100644
--- a/studio_functions/GUI Layout Toolbox/layout/+uix/tracking.m
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/tracking.m
@@ -102,12 +102,11 @@ function spoof()
%track Do tracking
a = sprintf( '%s/%s (%s)', MATLAB, v, OS );
+ ds = 'unknown';
if isdeployed()
ds = 'deployed';
elseif strcmp( DOMAIN, 'mathworks' )
- ds = DOMAIN;
- else
- ds = 'unknown';
+ ds = DOMAIN;
end
pv = {'v', '1', 'tid', p, 'ua', escape( a ), 'ul', LANGUAGE, ...
'cid', CLIENT, 'ht', 'pageview', ...
@@ -165,6 +164,7 @@ function spoof()
function s = os()
%os Operating system string
+s = 'unknown';
if ispc()
s = sprintf( 'Windows NT %s', ...
char( java.lang.System.getProperty( 'os.version' ) ) );
@@ -173,8 +173,6 @@ function spoof()
elseif ismac()
s = sprintf( 'Macintosh; Intel OS X %s', ...
strrep( char( java.lang.System.getProperty( 'os.version' ) ), ' ', '_' ) );
-else
- s = 'unknown';
end
end % os
diff --git a/studio_functions/GUI Layout Toolbox/layout/+uix/validateScalarStringOrCharacterArray.m b/studio_functions/GUI Layout Toolbox/layout/+uix/validateScalarStringOrCharacterArray.m
new file mode 100644
index 00000000..09a96e7a
--- /dev/null
+++ b/studio_functions/GUI Layout Toolbox/layout/+uix/validateScalarStringOrCharacterArray.m
@@ -0,0 +1,26 @@
+function value = validateScalarStringOrCharacterArray( value, propertyName )
+%VALIDATESCALARSTRINGORCHARACTERARRAY Verify that the given value is a
+%scalar string or a character array.
+
+% Check if we have a string scalar.
+if isa( value, 'string' ) && isscalar( value )
+ % Convert the string to a character array, handling the missing case
+ % separately.
+ if ismissing( value )
+ value = '';
+ else
+ value = char( value );
+ end % if
+end % if
+
+% Check that we have a character array.
+try
+ assert( ischar( value ), ...
+ 'uix:InvalidPropertyValue', ...
+ ['Property ''', propertyName, ''' must be a scalar ', ...
+ 'string or a character array.'] )
+catch e
+ e.throwAsCaller()
+end % try/catch
+
+end % validateScalarStringOrCharacterArray
\ No newline at end of file
diff --git a/studio_functions/GUI Layout Toolbox/layout/Contents.m b/studio_functions/GUI Layout Toolbox/layout/Contents.m
index 42a7f207..caf540c3 100644
--- a/studio_functions/GUI Layout Toolbox/layout/Contents.m
+++ b/studio_functions/GUI Layout Toolbox/layout/Contents.m
@@ -1,5 +1,5 @@
% GUI Layout Toolbox
-% Version 2.3.5 (R2020b) 31-October-2020
+% Version 2.3.6 (R2023a) 21-May-2023
%
% Panels
% uix.Panel - arrange a single element inside a standard panel
@@ -24,4 +24,4 @@
% uix.Empty - create an empty space
% uix.tracking - track anonymized usage data
-% Copyright 2009-2020 The MathWorks, Inc.
+% Copyright 2009-2023 The MathWorks, Inc.
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/AxesExample.html b/studio_functions/GUI Layout Toolbox/layoutdoc/AxesExample.html
index 9190c604..19f38b92 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/AxesExample.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/AxesExample.html
@@ -1 +1 @@
- >
+ >
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/AxesLegendsColorbars.html b/studio_functions/GUI Layout Toolbox/layoutdoc/AxesLegendsColorbars.html
index 3b8e3b36..6d14634d 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/AxesLegendsColorbars.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/AxesLegendsColorbars.html
@@ -1 +1 @@
- >
+ >
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/BoxPanelFancyStuff.html b/studio_functions/GUI Layout Toolbox/layoutdoc/BoxPanelFancyStuff.html
index ade0fa6a..88371c09 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/BoxPanelFancyStuff.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/BoxPanelFancyStuff.html
@@ -1 +1 @@
- >
+ >
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Compiling.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Compiling.html
index 5e762277..ea0a2024 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Compiling.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Compiling.html
@@ -1 +1 @@
- >
+ >
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/ExampleApp.html b/studio_functions/GUI Layout Toolbox/layoutdoc/ExampleApp.html
index 4dfbaa5f..3818e426 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/ExampleApp.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/ExampleApp.html
@@ -1 +1 @@
- >
+ >
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples.html
index 51160f2d..e10b8df4 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples.html
@@ -4,7 +4,7 @@
-
+
Examples
@@ -14,7 +14,7 @@
@@ -79,7 +79,7 @@ Applications
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/displayEndOfDemoMessage.m b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/displayEndOfDemoMessage.m
index cd1ef215..71588a4a 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/displayEndOfDemoMessage.m
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/displayEndOfDemoMessage.m
@@ -1,4 +1,4 @@
-function displayEndOfDemoMessage(filename)
-% Dummy function - do nothing.
-
-% Copyright 2009-2020 The MathWorks, Inc.
+function displayEndOfDemoMessage(filename)
+% Dummy function - do nothing.
+
+% Copyright 2009-2020 The MathWorks, Inc.
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/guideApp.m b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/guideApp.m
index 30978d30..607d23ee 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/guideApp.m
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Examples/guideApp.m
@@ -1,106 +1,106 @@
-function varargout = guideApp(varargin)
-% GUIDEAPP MATLAB code for guideApp.fig
-% GUIDEAPP, by itself, creates a new GUIDEAPP or raises the existing
-% singleton*.
-%
-% H = GUIDEAPP returns the handle to a new GUIDEAPP or the handle to
-% the existing singleton*.
-%
-% GUIDEAPP('CALLBACK',hObject,eventData,handles,...) calls the local
-% function named CALLBACK in GUIDEAPP.M with the given input arguments.
-%
-% GUIDEAPP('Property','Value',...) creates a new GUIDEAPP or raises the
-% existing singleton*. Starting from the left, property value pairs are
-% applied to the GUI before guideApp_OpeningFcn gets called. An
-% unrecognized property name or invalid value makes property application
-% stop. All inputs are passed to guideApp_OpeningFcn via varargin.
-%
-% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
-% instance to run (singleton)".
-%
-% See also: GUIDE, GUIDATA, GUIHANDLES
-
-% Copyright 2009-2020 The MathWorks, Inc.
-
-% Edit the above text to modify the response to help guideApp
-
-% Last Modified by GUIDE v2.5 21-Jul-2010 07:36:25
-
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 1;
-gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @guideApp_OpeningFcn, ...
- 'gui_OutputFcn', @guideApp_OutputFcn, ...
- 'gui_LayoutFcn', [] , ...
- 'gui_Callback', []);
-if nargin && ischar(varargin{1})
- gui_State.gui_Callback = str2func(varargin{1});
-end
-
-if nargout
- [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
- gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
-
-
-% --- Executes just before guideApp is made visible.
-function guideApp_OpeningFcn(hObject, eventdata, handles, varargin)
-% This function has no output args, see OutputFcn.
-% hObject handle to figure
-% eventdata reserved - to be defined in a future version of MATLAB
-% handles structure with handles and user data (see GUIDATA)
-% varargin command line arguments to guideApp (see VARARGIN)
-
-% Choose default command line output for guideApp
-handles.output = hObject;
-
-% Update handles structure
-guidata(hObject, handles);
-
-% Put a layout in the panel
-g = uix.GridFlex( 'Parent', handles.uipanel1, ...
- 'Units', 'Normalized', 'Position', [0 0 1 1], ...
- 'Spacing', 5 );
-uix.BoxPanel( 'Parent', g, 'Title', 'Panel 1' );
-uix.BoxPanel( 'Parent', g, 'Title', 'Panel 2' );
-uix.BoxPanel( 'Parent', g, 'Title', 'Panel 3' );
-uix.BoxPanel( 'Parent', g, 'Title', 'Panel 4' );
-g.Heights = [-1 -1];
-
-% UIWAIT makes guideApp wait for user response (see UIRESUME)
-% uiwait(handles.figure1);
-
-
-% --- Outputs from this function are returned to the command line.
-function varargout = guideApp_OutputFcn(hObject, eventdata, handles)
-% varargout cell array for returning output args (see VARARGOUT);
-% hObject handle to figure
-% eventdata reserved - to be defined in a future version of MATLAB
-% handles structure with handles and user data (see GUIDATA)
-
-% Get default command line output from handles structure
-varargout{1} = handles.output;
-
-
-% --- Executes on button press in pushbutton1.
-function pushbutton1_Callback(hObject, eventdata, handles)
-% hObject handle to pushbutton1 (see GCBO)
-% eventdata reserved - to be defined in a future version of MATLAB
-% handles structure with handles and user data (see GUIDATA)
-
-
-% --- Executes on button press in pushbutton2.
-function pushbutton2_Callback(hObject, eventdata, handles)
-% hObject handle to pushbutton2 (see GCBO)
-% eventdata reserved - to be defined in a future version of MATLAB
-% handles structure with handles and user data (see GUIDATA)
-
-
-% --- Executes on button press in pushbutton3.
-function pushbutton3_Callback(hObject, eventdata, handles)
-% hObject handle to pushbutton3 (see GCBO)
-% eventdata reserved - to be defined in a future version of MATLAB
-% handles structure with handles and user data (see GUIDATA)
+function varargout = guideApp(varargin)
+% GUIDEAPP MATLAB code for guideApp.fig
+% GUIDEAPP, by itself, creates a new GUIDEAPP or raises the existing
+% singleton*.
+%
+% H = GUIDEAPP returns the handle to a new GUIDEAPP or the handle to
+% the existing singleton*.
+%
+% GUIDEAPP('CALLBACK',hObject,eventData,handles,...) calls the local
+% function named CALLBACK in GUIDEAPP.M with the given input arguments.
+%
+% GUIDEAPP('Property','Value',...) creates a new GUIDEAPP or raises the
+% existing singleton*. Starting from the left, property value pairs are
+% applied to the GUI before guideApp_OpeningFcn gets called. An
+% unrecognized property name or invalid value makes property application
+% stop. All inputs are passed to guideApp_OpeningFcn via varargin.
+%
+% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
+% instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Copyright 2009-2020 The MathWorks, Inc.
+
+% Edit the above text to modify the response to help guideApp
+
+% Last Modified by GUIDE v2.5 21-Jul-2010 07:36:25
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name', mfilename, ...
+ 'gui_Singleton', gui_Singleton, ...
+ 'gui_OpeningFcn', @guideApp_OpeningFcn, ...
+ 'gui_OutputFcn', @guideApp_OutputFcn, ...
+ 'gui_LayoutFcn', [] , ...
+ 'gui_Callback', []);
+if nargin && ischar(varargin{1})
+ gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+ [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+ gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before guideApp is made visible.
+function guideApp_OpeningFcn(hObject, eventdata, handles, varargin)
+% This function has no output args, see OutputFcn.
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+% varargin command line arguments to guideApp (see VARARGIN)
+
+% Choose default command line output for guideApp
+handles.output = hObject;
+
+% Update handles structure
+guidata(hObject, handles);
+
+% Put a layout in the panel
+g = uix.GridFlex( 'Parent', handles.uipanel1, ...
+ 'Units', 'Normalized', 'Position', [0 0 1 1], ...
+ 'Spacing', 5 );
+uix.BoxPanel( 'Parent', g, 'Title', 'Panel 1' );
+uix.BoxPanel( 'Parent', g, 'Title', 'Panel 2' );
+uix.BoxPanel( 'Parent', g, 'Title', 'Panel 3' );
+uix.BoxPanel( 'Parent', g, 'Title', 'Panel 4' );
+g.Heights = [-1 -1];
+
+% UIWAIT makes guideApp wait for user response (see UIRESUME)
+% uiwait(handles.figure1);
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = guideApp_OutputFcn(hObject, eventdata, handles)
+% varargout cell array for returning output args (see VARARGOUT);
+% hObject handle to figure
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+% Get default command line output from handles structure
+varargout{1} = handles.output;
+
+
+% --- Executes on button press in pushbutton1.
+function pushbutton1_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton1 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+
+% --- Executes on button press in pushbutton2.
+function pushbutton2_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton2 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+
+
+% --- Executes on button press in pushbutton3.
+function pushbutton3_Callback(hObject, eventdata, handles)
+% hObject handle to pushbutton3 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference.html
index 93363cab..98d6397a 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference.html
@@ -4,7 +4,7 @@
-
+
Function reference
@@ -14,7 +14,7 @@
@@ -180,7 +180,7 @@ Function reference
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_1.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_1.html
index aceb184d..66f8c11c 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_1.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_1.html
@@ -3,7 +3,7 @@
-
+
uix.Panel
@@ -73,7 +73,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_2.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_2.html
index 57991f02..ec6c9a1a 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_2.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_2.html
@@ -3,7 +3,7 @@
-
+
uix.CardPanel
@@ -67,7 +67,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_3.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_3.html
index c803a727..96f863d3 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_3.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_3.html
@@ -3,7 +3,7 @@
-
+
uix.BoxPanel
@@ -77,7 +77,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_4.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_4.html
index 272fc42f..181bb502 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_4.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_4.html
@@ -3,7 +3,7 @@
-
+
uix.TabPanel
@@ -65,7 +65,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_5.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_5.html
index 2a5b9102..347404f5 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_5.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference1_5.html
@@ -3,7 +3,7 @@
-
+
uix.ScrollingPanel
@@ -65,7 +65,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_1.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_1.html
index 334aa25d..4d6f3f65 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_1.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_1.html
@@ -3,7 +3,7 @@
-
+
uix.HBox
@@ -78,7 +78,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_2.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_2.html
index 4c9f6724..84d36736 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_2.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_2.html
@@ -3,7 +3,7 @@
-
+
uix.VBox
@@ -77,7 +77,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_3.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_3.html
index 8c933031..391fb83c 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_3.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_3.html
@@ -3,7 +3,7 @@
-
+
uix.HBoxFlex
@@ -69,7 +69,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_4.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_4.html
index 99e656c6..1bf7a727 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_4.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_4.html
@@ -3,7 +3,7 @@
-
+
uix.VBoxFlex
@@ -68,7 +68,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_5.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_5.html
index 27c84dff..122a230d 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_5.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_5.html
@@ -3,7 +3,7 @@
-
+
uix.HButtonBox
@@ -70,7 +70,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_6.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_6.html
index a9d9304c..bf38e9b4 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_6.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference2_6.html
@@ -3,7 +3,7 @@
-
+
uix.VButtonBox
@@ -70,7 +70,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_1.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_1.html
index 24a71509..6f72ca96 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_1.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_1.html
@@ -3,7 +3,7 @@
-
+
uix.Grid
@@ -72,7 +72,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_2.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_2.html
index 2d709f41..02e07d5f 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_2.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference3_2.html
@@ -3,7 +3,7 @@
-
+
uix.GridFlex
@@ -73,7 +73,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_1.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_1.html
index 0afb71ab..5610a177 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_1.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_1.html
@@ -3,7 +3,7 @@
-
+
uix.Empty
@@ -59,7 +59,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_2.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_2.html
index 9bbc620f..efe3537e 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_2.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_2.html
@@ -3,7 +3,7 @@
-
+
uix.tracking
@@ -53,7 +53,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_3.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_3.html
index 9955a1d3..441d71f5 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_3.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Function_reference4_3.html
@@ -3,7 +3,7 @@
-
+
layoutRoot
@@ -47,7 +47,7 @@ For example:
- © 2020 The MathWorks Ltd
+ © 2023 The MathWorks Ltd
Terms of Use
Patents
Trademarks
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/GUI Layout.html b/studio_functions/GUI Layout Toolbox/layoutdoc/GUI Layout.html
index c0141bd5..3b0037a0 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/GUI Layout.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/GUI Layout.html
@@ -1,5 +1,5 @@
-
+
diff --git a/studio_functions/GUI Layout Toolbox/layoutdoc/Getting_Started.html b/studio_functions/GUI Layout Toolbox/layoutdoc/Getting_Started.html
index 2ed741a6..fbd55ee3 100644
--- a/studio_functions/GUI Layout Toolbox/layoutdoc/Getting_Started.html
+++ b/studio_functions/GUI Layout Toolbox/layoutdoc/Getting_Started.html
@@ -4,7 +4,7 @@
-
+
Getting Started
@@ -14,7 +14,7 @@
@@ -75,7 +75,7 @@