-To install ERPLAB v10.11, download the zip file (linked above), unzip and place the folder in the 'plugins' folder of your existing [EEGLAB](https://sccn.ucsd.edu/eeglab/download.php) installation (e.g. `/Users/Steve/Documents/MATLAB/eeglab2019_1/plugins/erplab/`). More [installation help can be found here](https://github.com/lucklab/erplab/wiki/Installation).
+This download contains both [ERPLAB Studio](./ERPLAB-Studio-Manual) (our standalone Matlab program) and [ERPLAB Classic](./Manual) (an EEGLAB plugin). If you are new to ERPLAB, we strongly recommend that you go through the [ERPLAB Studio Tutorial](./ERPLAB-Studio-Tutorial) or ERPLAB Classic Tutorial before trying to analyze your own data.
-To run ERPLAB, ensure that the correct EEGLAB folder is in your current Matlab path, and run `eeglab` as a command from the Matlab Command Window. If you are new to ERPLAB, we strongly recommend that you go through the [ERPLAB Tutorial](https://github.com/lucklab/erplab/wiki/Tutorial) before using ERPLAB with your own data.
+[Click here](./Installation) for installation instructions.
+
+[Click here](./Compatability-and-Required-Toolboxes) for information about required Matlab toolboxes and compatibility with different versions of Matlab, EEGLAB, Windows, MacOS, and Linux.
We encourage most users to use this latest major version.
-
----
-## Compatibility and Required Toolboxes
-
-We anticipate that ERPLAB will work with most recent OSs, Matlab versions and EEGLAB versions.
-
-- The [Matlab Signal Processing Toolbox](https://www.mathworks.com/products/signal.html) is required.
-- [EEGLAB v2021 or later](https://sccn.ucsd.edu/eeglab/download.php) is almost always necessary.
-
-However, in order to use the latest MVPC routines (see [here](https://github.com/ucdavis/erplab/wiki/Decoding-Tutorial)), Matlab versions and EEGLAB versions must be recent. In addition, some MATLAB toolboxes are required.
-- Matlab 2020b + is REQUIRED for MVPC routines.
-- EEGLAB 2023.1 + is REQUIRED for MVPC routines.
-- The [Matlab Statistics and Machine Learning Toolbox](https://www.mathworks.com/products/statistics.html)
-- The [Matlab Parallel Processing Toolbox](https://www.mathworks.com/products/parallel-computing.html) (recommended)
-
-Find [more ERPLAB installation help here](http://erpinfo.org/erplab).
-
-
-### ERPLAB compatibility table
-
-Here is a list of some confirmed-working environments for ERPLAB.
-
-**ERPLAB v10.0+ works with...**
-| **OS** | **Matlab** | **EEGLAB** | Working? |
-| --- | --- | --- | --- |
-| Mac OS 14.2.1 'Sonoma' | Matlab R 2023a | EEGLAB v2023.1 | ✓|
-| Mac OS 11.7.6 'Big Sur' | Matlab R 2020a | EEGLAB v2023.0 | ✓|
-| Mac OS 10.15.7 'Catalina' | Matlab R2020b | EEGLAB v2023.0 | ✓ |
-| Mac OS 10.15 'Catalina' | Matlab R2016a | EEGLAB v2019_1 | ✓ |
-(https://www.mathworks.com/downloads/web_downloads/download_update?release=R2018a&s_tid=ebrg_R2018a_2_1757132&s_tid=mwa_osa_a) |
-| Mac OS 10.13.5 'High Sierra' | Matlab R2015a | EEGLAB v14.1.2 | ✓ |
-| Windows 10 | Matlab R2021a | EEGLAB v2023.0 | ✓ |
-| Windows 10 | Matlab R2020b | EEGLAB v2021.1 | ✓ |
-| Ubuntu 18.04 LTS | Matlab R2019a | EEGLAB v2020 | ✓ |
-| Ubuntu 18.04 LTS | Matlab R2019a | EEGLAB v2019_1 | ✓ |
-
-ERPLAB should work with most modern OSs, Matlab versions, and EEGLAB releases. Let us know if you see any incompatibility.
-**Starting in ERPLAB v10.0, MATLAB'S "App Designer" was the default GUI system used for the MVPC routines and require at least MATLAB 2020a+ & EEGLAB 2023.1+ in order to work as expected.**
-
## Release Notes
+### ERPLAB v11.0 Release Notes
+
+ERPLAB can now be accessed from two different user interfaces:
+- [ERPLAB Classic](./Manual) (our original software, which operates as an EEGLAB plugin)
+- [ERPLAB Studio](./ERPLAB-Studio-Manual) (a standalone application that provides a more user-friendly GUI)
+
+ERPLAB Studio makes use of the same underlying code as EEGLAB and ERPLAB Classic. It is essentially a different user interface for the same functions. You will therefore get identical results with ERPLAB Studio and ERPLAB Classic, and scripting is the same for both packages. But ERPLAB Studio is much easier to use.
+
+[Click here](https://www.youtube.com/watch?v=lIaKVQ9DD6E) for a 2-minute video overview of ERPLAB Studio.
+
+The most commonly used EEGLAB functions are available from within ERPLAB Studio. For example, you can import EEG data into ERPLAB Studio, filter the EEG, apply ICA for artifact correction, etc. If you need an EEGLAB function that is not implemented within ERPLAB Studio, you can apply that function using the EEGLAB GUI or a script.
+
+If you are already familiar with ERPLAB, you can rapidly learn how to use ERPLAB Studio with our [Transition Guide](). If you are new to ERPLAB, please go through the [ERPLAB Studio Tutorial](./ERPLAB-Studio-Tutorial) before attempting to process your own data. Once you understand the basics of ERPLAB Studio, you can get detailed information about the individual processing steps in the [ERPLAB Studio Manual](./ERPLAB-Studio-Manual).
+
+
### ERPLAB v10.1 Release Notes
Now Includes:
Update to decoding toolbox. By default, beta weights will no longer be saved with MVPC files, dramatically reducing file size.
diff --git a/eegplugin_erplab.m b/eegplugin_erplab.m
index c0d851e6..fc6bc192 100755
--- a/eegplugin_erplab.m
+++ b/eegplugin_erplab.m
@@ -1,10 +1,10 @@
-% Author: Aaron Matthew Simmons, Guanghui Zhang, David R Garrett,
-% 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-2024
-% Version 10.1
+% 2007-2023
+% Version 10.0
%b8d3721ed219e65100184c6b95db209bb8d3721ed219e65100184c6b95db209b
%
@@ -64,8 +64,13 @@
catch
end
+%%running erplab%%GH 2024
+p_location = which('o_ERPDAT');
+p_location = p_location(1:findstr(p_location,'o_ERPDAT.m')-1);
+tooltype = 'ERPLAB';
+save(fullfile(p_location,'erplab_running_version.erpm'),'tooltype');
+
-%erplab_running_version('Version',erplabver,'tooltype','ERPLAB');%%GH,Mar 2023
global observe_EEGDAT;
observe_EEGDAT = o_EEGDATA;
@@ -87,6 +92,7 @@
observe_ERPDAT.Count_ERP = 0;
observe_ERPDAT.Count_currentERP = 0;
observe_ERPDAT.Process_messg = 0;%%change end
+observe_ERPDAT.erp_between_panels = 0;
%
% CHECK VERSION NUMBER & FOLDER NAME
@@ -105,11 +111,6 @@
fprintf('\nERPLAB''s folder does not show the current version number.\n')
end
-%%running estudio
-p_location = which('o_ERPDAT');
-p_location = p_location(1:findstr(p_location,'o_ERPDAT.m')-1);
-tooltype = 'erplab';
-save(fullfile(p_location,'erplab_running_version.erpm'),'tooltype');
%
% CHECK EEGLAB Version
@@ -200,7 +201,7 @@
ERP = []; % Start ERP Structure on workspace
ALLERPCOM = [];
CURRENTERP = 0;
-BEST = []; %Start BEST structure on workspace
+BEST = []; %Start BEST structure on workspace
CURRENTBEST = 0;
plotset.ptime = [];
plotset.pscalp = [];
@@ -293,10 +294,10 @@
comDeleteTimeSegments = [trystrs.no_check '[EEG, LASTCOM] = pop_erplabDeleteTimeSegments(EEG);' catchstrs.new_and_hist];
comRemoveResponseMistakes = [trystrs.no_check '[ALLEEG,EEG,LASTCOM] = pop_remove_response_mistakes(ALLEEG,EEG,CURRENTSET);' catchstrs.new_and_hist];
comInterpolateElectrodes = [trystrs.no_check '[EEG, LASTCOM] = pop_erplabInterpolateElectrodes(EEG);' catchstrs.new_and_hist];
-%comDFT = [trystrs.no_check '[EEG, fft_out, LASTCOM] = pop_continuousFFT(EEG);' catchstrs.add_to_hist];
comDFT = ['[EEG, fft_out, LASTCOM] = pop_continuousFFT(EEG);'];
+
%
% EVENTLIST callback
%
diff --git a/erplab_default_values.m b/erplab_default_values.m
index d1a4a294..4c9a07c8 100755
--- a/erplab_default_values.m
+++ b/erplab_default_values.m
@@ -1,5 +1,5 @@
-erplabver = '10.11'; % current erplab version
-erplabrel = '17-May-2024'; % DOB
+erplabver = '11'; % current erplab version
+erplabrel = '10-June-2024'; % DOB
erplabdeveloper = 'Simmons,Zhang,Garrett';
%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/averager.m b/functions/averager.m
index de43db75..6f5367ac 100755
--- a/functions/averager.m
+++ b/functions/averager.m
@@ -66,7 +66,12 @@
end
if nargin<8
- avgText = 1;
+ ERPtooltype = erpgettoolversion('tooltype');
+ if strcmpi(ERPtooltype,'EStudio')
+ avgText = 0;
+ else
+ avgText = 1;
+ end
end
if nargin<7
@@ -401,9 +406,9 @@
if stderror == 1
sample_SD_rearrange = sqrt((sumERP2(:,:,k) - N*ERP.bindata(:,:,k).^2)/(N-1)); % get ERP's standard deviation
elseif stderror == 2 %corrected point-wise SEM
- sample_SD_rearrange = sqrt((sumERP2(:,:,k) - N*ERP.bindata(:,:,k).^2)/(N-(3/2)+(1/(8*(N-1)))));
+ sample_SD_rearrange = sqrt((sumERP2(:,:,k) - N*ERP.bindata(:,:,k).^2)/(N-(3/2)+(1/(8*(N-1)))));
end
-
+
% The Standard Error of the Mean is then:
ERP.binerror(:,:,k) = sample_SD_rearrange./sqrt(N); % get ERP's standard error
end
@@ -441,7 +446,7 @@
ERP.datatype = 'TFFT';
end
ERP.pnts = size(ERP.bindata, 2);
-if ~iscell(artcrite)
+if ~iscell(artcrite) && avgText == 1
fprintf('----------------------------------------------------------------------------------------\n');
else
countbiORI = countbinOK;
@@ -472,8 +477,8 @@
tapwin(s1:s2,1) = hann(winpnts);
case 'blackmanharris'
tapwin(s1:s2,1) = blackmanharris(winpnts);
- case 'rectangular'
- tapwin(s1:s2,1) = rectwin(winpnts);
+ case 'rectangular'
+ tapwin(s1:s2,1) = rectwin(winpnts);
otherwise
error('Invalid taper function name (only ''Hamming'', ''Hanning'', ''blackmanharris'' or ''rectangular'' can be used)')
end
diff --git a/functions/delerpchan.m b/functions/delerpchan.m
index 4061f184..83aaad13 100755
--- a/functions/delerpchan.m
+++ b/functions/delerpchan.m
@@ -42,39 +42,39 @@
cherror = 0;
if nargin<1
- help avgchan
- return
+ help avgchan
+ return
end
if ~iserpstruct(ERP)
- error('ERPLAB says: delerpchan() only works with ERP structure.')
+ error('ERPLAB says: delerpchan() only works with ERP structure.')
end
if ischar(chin)
- chin = str2num(char(regexp(chin,'\d+','match')'))';
+ chin = str2num(char(regexp(chin,'\d+','match')'))';
end
if size(chin,1)>1
- error('ERPLAB says: error, delerpchan works with row-array inputs')
+ error('ERPLAB says: error, delerpchan works with row-array inputs')
end
chanarray = unique_bc2(chin);
if length(chanarray)~=length(chin)
- fprintf('\n*** WARNING: Repeated channels were ignored.\n\n')
+ fprintf('\n*** WARNING: Repeated channels were ignored.\n\n')
end
nchan = ERP.nchan;
if max(chanarray)>nchan
- error('ERPLAB says: error at delerpchan. Some specified channels do not exist!')
+ error('ERPLAB says: error at delerpchan. Some specified channels do not exist!')
end
ERP.bindata(chanarray,:,:)=[];
-if ~isempty(ERP.binerror) %% GH March 2024
+if ~isempty(ERP.binerror)%%GH Mar 2024
ERP.binerror(chanarray,:,:)=[];
end
ERP.nchan = size(ERP.bindata, 1);
if isfield(ERP.chanlocs, 'labels')
- if ~isempty([ERP.chanlocs.labels])
- labaux = {ERP.chanlocs.labels};
- [labaux{chanarray}] = deal([]);
- indxl = ~cellfun(@isempty, labaux);
- labelout = labaux(indxl);
- ERP.chanlocs = [];
- [ERP.chanlocs(1:ERP.nchan).labels] = labelout{:};
- end
+ if ~isempty([ERP.chanlocs.labels])
+ labaux = {ERP.chanlocs.labels};
+ [labaux{chanarray}] = deal([]);
+ indxl = ~cellfun(@isempty, labaux);
+ labelout = labaux(indxl);
+ ERP.chanlocs = [];
+ [ERP.chanlocs(1:ERP.nchan).labels] = labelout{:};
+ end
end
diff --git a/functions/erpworkingmemory.m b/functions/erpworkingmemory.m
index a123ea27..677c4245 100755
--- a/functions/erpworkingmemory.m
+++ b/functions/erpworkingmemory.m
@@ -65,17 +65,6 @@
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
@@ -98,25 +87,12 @@
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
+ p = which('eegplugin_erplab');
+ p = p(1:findstr(p,'eegplugin_erplab.m')-1);
+ v = load(fullfile(p,'memoryerp.erpm'), '-mat');
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
-
+ 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'];
try
cprintf([0.45 0.45 0.45], msgboxText');
catch
@@ -148,26 +124,16 @@
end
else % file for storing/reading memory
try
- 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
+
+ eval([field '=input2store;'])
+ p = which('eegplugin_erplab');
+ p = p(1:findstr(p,'eegplugin_erplab.m')-1);
+ save(fullfile(p,'memoryerp.erpm'), field,'-append');
+
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
+
+ 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
diff --git a/functions/filterp.m b/functions/filterp.m
index 57f41738..a4db05b8 100755
--- a/functions/filterp.m
+++ b/functions/filterp.m
@@ -48,106 +48,114 @@
% You should have received a copy of the GNU General Public License
% along with this program. If not, see .
-function ERP = filterp(ERP, chanArray, locutoff, hicutoff, filterorder, typef, remove_dc)
+function ERP = filterp(ERP, chanArray, locutoff, hicutoff, filterorder, typef, remove_dc,binArray)
if nargin < 1
- help filterp
- return
+ help filterp
+ return
end
if exist('filtfilt','file') ~= 2
- disp('filterp error: cannot find the Signal Processing Toolbox');
- return
+ disp('filterp error: cannot find the Signal Processing Toolbox');
+ return
end
if isempty(ERP.bindata)
- disp('filterp error: cannot filter an empty erpset')
- return
+ disp('filterp error: cannot filter an empty erpset')
+ return
end
-if nargin < 7
- disp('filterp error: please, enter all arguments!')
- return
+if nargin < 8%%GH Apr. 2024
+ disp('filterp error: please, enter all arguments!')
+ return
end
+
+
if ERP.pnts <= 3*filterorder
- msgboxText = 'Error: The length of the data must be more than three times the filter order.';
- title = 'ERPLAB: filterp(), filtfilt constraint';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'Error: The length of the data must be more than three times the filter order.';
+ title = 'ERPLAB: filterp(), filtfilt constraint';
+ errorfound(msgboxText, title);
+ return
end
if locutoff == 0 && hicutoff == 0,
- msgboxText = 'Error: What???? low cutoff == 0 && high cutoff == 0?';
- title = 'ERPLAB: filterp(), Cutoff frequency';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'Error: What???? low cutoff == 0 && high cutoff == 0?';
+ title = 'ERPLAB: filterp(), Cutoff frequency';
+ errorfound(msgboxText, title);
+ return
end
chanArray = unique_bc2(chanArray); % does not allow repeated channels
fnyquist = 0.5*ERP.srate; % half sample rate
pnts = size(ERP.bindata,2);
numchan = length(chanArray);
+binArray = unique_bc2(binArray);%%GH Apr. 2024
+nbin = ERP(1).nbin;
+if isempty(binArray) || any(binArray(:)>nbin) || any(binArray(:)<1)
+ binArray = [1:nbin];
+end
+
if numchan>ERP.nchan
- msgboxText = 'Error: You have selected more channels than are contained within your data!';
- title = 'ERPLAB: filterp() error:';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'Error: You have selected more channels than are contained within your data!';
+ title = 'ERPLAB: filterp() error:';
+ errorfound(msgboxText, title);
+ return
end
nbin = ERP.nbin;
fprintf('Channels to be filtered : %s\n\n', vect2colon(chanArray, 'Delimiter', 'on'));
if locutoff >= fnyquist
- error('ERPLAB says: errot at filterp(). Low cutoff frequency cannot be >= srate/2');
+ error('ERPLAB says: errot at filterp(). Low cutoff frequency cannot be >= srate/2');
end
if hicutoff >= fnyquist
- error('ERPLAB says: errot at filterp().High cutoff frequency cannot be >= srate/2');
+ error('ERPLAB says: errot at filterp().High cutoff frequency cannot be >= srate/2');
end
if ~typef && filterorder*3 > pnts % filtfilt restriction
- fprintf('filterp: filter order too high');
- error('ERPLAB says: errot at filterp(). Samples must be at least 3 times the filter order.');
+ fprintf('filterp: filter order too high');
+ error('ERPLAB says: errot at filterp(). Samples must be at least 3 times the filter order.');
end
if locutoff >0 % option in order to remove dc value is only for high-pass filtering
- if remove_dc
- disp('Removing DC bias from ERPs...')
- for i = 1:nbin
- auxdata = ERP.bindata(chanArray,:,i);
- ERP.bindata(chanArray,:,i) = detrend(auxdata', 'constant')';
- end
- fprintf('\n')
+ if remove_dc
+ disp('Removing DC bias from ERPs...')
+ for i = binArray
+ auxdata = ERP.bindata(chanArray,:,i);
+ ERP.bindata(chanArray,:,i) = detrend(auxdata', 'constant')';
end
+ fprintf('\n')
+ end
end
[b, a, labelf, v] = filter_tf(typef, filterorder, hicutoff, locutoff, ERP.srate);
if ~v % something is wrong or turned off
- msgboxText = 'filterp() error: Wrong parameters for filtering.';
- title = 'ERPLAB: filterp():';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'filterp() error: Wrong parameters for filtering.';
+ title = 'ERPLAB: filterp():';
+ errorfound(msgboxText, title);
+ return
end
disp([labelf ' filtering input data, please wait...'])
-for j=1:nbin
- if size(b,1)>1
- if strcmpi(labelf,'Band-Pass')
- % Butterworth bandpass (cascade)
- ERP.bindata(chanArray,:,j) = filtfilt(b(1,:),a(1,:), ERP.bindata(chanArray,:,j)')';
- ERP.bindata(chanArray,:,j) = filtfilt(b(2,:),a(2,:), ERP.bindata(chanArray,:,j)')';
- else
- %Butterworth Notch (parallel)
- datalowpass = filtfilt(b(1,:),a(1,:), ERP.bindata(chanArray,:,j)')';
- datahighpass = filtfilt(b(2,:),a(2,:), ERP.bindata(chanArray,:,j)')';
- ERP.bindata(chanArray,:,j) = datalowpass + datahighpass;
- end
+for j= binArray%%GH Apr. 2024
+ if size(b,1)>1
+ if strcmpi(labelf,'Band-Pass')
+ % Butterworth bandpass (cascade)
+ ERP.bindata(chanArray,:,j) = filtfilt(b(1,:),a(1,:), ERP.bindata(chanArray,:,j)')';
+ ERP.bindata(chanArray,:,j) = filtfilt(b(2,:),a(2,:), ERP.bindata(chanArray,:,j)')';
else
- % Butterworth lowpass)
- % Butterworth highpass
- % FIR lowpass
- % FIR highpass
- % FIR bandpass
- % FIR notch
- % Parks-McClellan Notch
- ERP.bindata(chanArray,:,j) = filtfilt(b,a, ERP.bindata(chanArray,:,j)')';
+ %Butterworth Notch (parallel)
+ datalowpass = filtfilt(b(1,:),a(1,:), ERP.bindata(chanArray,:,j)')';
+ datahighpass = filtfilt(b(2,:),a(2,:), ERP.bindata(chanArray,:,j)')';
+ ERP.bindata(chanArray,:,j) = datalowpass + datahighpass;
end
+ else
+ % Butterworth lowpass)
+ % Butterworth highpass
+ % FIR lowpass
+ % FIR highpass
+ % FIR bandpass
+ % FIR notch
+ % Parks-McClellan Notch
+ ERP.bindata(chanArray,:,j) = filtfilt(b,a, ERP.bindata(chanArray,:,j)')';
+ end
end
%
@@ -155,14 +163,14 @@
%
ERP = clear_dq(ERP);
if isfield(ERP, 'binerror')
- if ~isempty(ERP.binerror)
-
- if numchan ERP.binerror = [];
- end
+ if ~isempty(ERP.binerror)
+
+ if numchan ERP.binerror = [];
end
+ end
end
ERP.isfilt = 1;
diff --git a/functions/gaverager.m b/functions/gaverager.m
old mode 100644
new mode 100755
index 71ee08c1..c25b88dd
--- a/functions/gaverager.m
+++ b/functions/gaverager.m
@@ -122,8 +122,8 @@
% basic test for number of points (for now...)
if pre_pnts ~= ERPT.pnts
msgboxText = sprintf('Erpsets #%g and #%g have different number of points!', j-1, j);
- msgboxText = sprintf([msgboxText,'\n','ERPset',32, num2str(j-1),32,'has',32,num2str(ALLERP(j-1).pnts),32,'points.\n',...
- 'ERPset',32, num2str(j),32,'has',32,num2str(ALLERP(j).pnts),32,'points.\n']);
+ msgboxText = sprintf([msgboxText,'\n','ERPset',32, num2str(j-1),32,'has',32,num2str(ALLERP(j-1).pnts),32,'points (from',32,num2str(ALLERP(j-1).times(1)),32,'to',32,num2str(ALLERP(j-1).times(end)),'ms; fs=',num2str(ALLERP(j-1).srate),'Hz).\n',...
+ 'ERPset',32, num2str(j),32,'has',32,num2str(ALLERP(j).pnts),32,'points (from',32,num2str(ALLERP(j).times(1)),32,'to',32,num2str(ALLERP(j).times(end)),'ms; fs=',num2str(ALLERP(j).srate),'Hz).\n']);
%title = 'ERPLAB: pop_gaverager() Error';
%errorfound(msgboxText, title);
%return
diff --git a/functions/geterpvalues.m b/functions/geterpvalues.m
index 1ef90de5..e60d04c3 100755
--- a/functions/geterpvalues.m
+++ b/functions/geterpvalues.m
@@ -90,95 +90,95 @@
function varargout = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, localopt, frac, fracmearep, intfactor,peakonset)
if nargin<1
- help geterpvalues
- return
+ help geterpvalues
+ return
end
if nargin<2
- error('ERROR geterpvalues(): You must specify ERP struct and latency(ies), at least.')
+ error('ERROR geterpvalues(): You must specify ERP struct and latency(ies), at least.')
end
if nargin<14
peakonset = 1;
end
if nargin<13
- intfactor = 1;
+ intfactor = 1;
end
if nargin<12
- fracmearep = 0; %0=write a NaN when frac measure is not found. 1 = export frac absolute peak when frac local peak is not found.; 2=shows error message
+ fracmearep = 0; %0=write a NaN when frac measure is not found. 1 = export frac absolute peak when frac local peak is not found.; 2=shows error message
end
if nargin<11
- frac = 0.5; % 50% area latency (if needed, by default)
+ frac = 0.5; % 50% area latency (if needed, by default)
end
if nargin<10
- localopt = 0; % 0=write a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
+ localopt = 0; % 0=write a NaN when local peak is not found. 1=export absolute peak when local peak is not found.; 2=shows error message
end
if nargin<9
- sampeak = 0; % absolute peak. No neighbor samples
+ sampeak = 0; % absolute peak. No neighbor samples
end
if nargin<8
- polpeak = 1; % positive
+ polpeak = 1; % positive
end
if nargin<7
- coi = 0; % 0= as it is; 1=first component; 2=2nd component
+ coi = 0; % 0= as it is; 1=first component; 2=2nd component
end
if nargin<6
- blc = 'pre';
+ blc = 'pre';
end
if nargin<5
- moption = 'instabl';
+ moption = 'instabl';
end
if nargin<4
- chanArray = 1:ERP.nchan;
+ chanArray = 1:ERP.nchan;
end
if nargin<3
- binArray = 1:ERP.nbin;
+ binArray = 1:ERP.nbin;
end
if ischar(blc)
- blcnum = str2num(blc);
- if isempty(blcnum)
- if ~ismember_bc2(blc,{'no','none','pre','post','all','whole'})
- msgboxText = 'Invalid baseline range dude!';
- %title = 'ERPLAB: geterpvalues() baseline input';
- %errorfound(msgboxText, title);
- %return
- varargout{1} = msgboxText;
- varargout{2} = [];
- return
- end
- else
- if size(blcnum,1)>1 || size(blcnum,2)>2
- msgboxText = 'Invalid baseline range, dude!';
- %title = 'ERPLAB: geterpvalues() baseline input';
- %errorfound(msgboxText, title);
- %return
- varargout{1} = msgboxText;
- varargout{2} = [];
- return
- end
+ blcnum = str2num(blc);
+ if isempty(blcnum)
+ if ~ismember_bc2(blc,{'no','none','pre','post','all','whole'})
+ msgboxText = 'Invalid baseline range dude!';
+ %title = 'ERPLAB: geterpvalues() baseline input';
+ %errorfound(msgboxText, title);
+ %return
+ varargout{1} = msgboxText;
+ varargout{2} = [];
+ return
end
+ else
+ if size(blcnum,1)>1 || size(blcnum,2)>2
+ msgboxText = 'Invalid baseline range, dude!';
+ %title = 'ERPLAB: geterpvalues() baseline input';
+ %errorfound(msgboxText, title);
+ %return
+ varargout{1} = msgboxText;
+ varargout{2} = [];
+ return
+ end
+ end
end
if ~ismember_bc2({moption}, {'instabl', 'meanbl', 'peakampbl', 'peaklatbl', 'fpeaklat',...
- 'area','areat', 'areap', 'arean','areazt','areazp','areazn','fareatlat',...
- 'fareaplat', 'fninteglat', 'fareanlat', 'ninteg','nintegz' });
- msgboxText = [moption ' is not a valid option for geterpvalues!'];
- %title = 'ERPLAB: geterpvalues wrong inputs';
- %errorfound(msgboxText, title);
- %return
- varargout{1} = msgboxText;
- varargout{2} = [];
- return
+ 'area','areat', 'areap', 'arean','areazt','areazp','areazn','fareatlat',...
+ 'fareaplat', 'fninteglat', 'fareanlat', 'ninteg','nintegz' });
+ msgboxText = [moption ' is not a valid option for geterpvalues!'];
+ %title = 'ERPLAB: geterpvalues wrong inputs';
+ %errorfound(msgboxText, title);
+ %return
+ varargout{1} = msgboxText;
+ varargout{2} = [];
+ return
end
if isempty(coi)
- coi = 1;
+ coi = 1;
end
if nargout==1
- condf = 0; % only includes area values
+ condf = 0; % only includes area values
elseif nargout==2
- condf = 1; % include latency values and limits...
+ condf = 1; % include latency values and limits...
else
- error('ERPLAB says: error at geterpvalues(). Too many output arguments!')
+ error('ERPLAB says: error at geterpvalues(). Too many output arguments!')
end
if isempty(sampeak)
- sampeak =0;
+ sampeak =0;
end
fs = ERP.srate;
@@ -195,19 +195,19 @@
p1 = timeor(1);
p2 = timeor(end);
if intfactor~=1
- timex = linspace(p1,p2,round(pnts*intfactor));
- pnts = length(timex);
- fs = round(fs*intfactor);
+ timex = linspace(p1,p2,round(pnts*intfactor));
+ pnts = length(timex);
+ fs = round(fs*intfactor);
else
- timex = timeor;
+ timex = timeor;
end
msgboxText4peak = ['The requested measurement window is invalid given the number of points specified for finding a local peak '...
- 'and the epoch length of the ERP waveform.\n\n You have specified a local peak over ±%g points, which means that '...
- 'there must be %g sample points between the onset of your measurement window and the onset of the waveform, '...
- 'and/or %g sample points between the end of your measurement window and the end of the waveform.\n\n'...
- 'Because the waveform starts at %.1f ms and ends at %.1f ms, your measurement window cannot go beyond [%.1f %.1f] ms (unless you reduce '...
- 'the number of points required to define the local peak).'];
+ 'and the epoch length of the ERP waveform.\n\n You have specified a local peak over ±%g points, which means that '...
+ 'there must be %g sample points between the onset of your measurement window and the onset of the waveform, '...
+ 'and/or %g sample points between the end of your measurement window and the end of the waveform.\n\n'...
+ 'Because the waveform starts at %.1f ms and ends at %.1f ms, your measurement window cannot go beyond [%.1f %.1f] ms (unless you reduce '...
+ 'the number of points required to define the local peak).'];
% latsamp = [find(ERP.times>=latency(1), 1, 'first') find(ERP.times<=550, 1, 'last')];
% % its fields are "value" and "ilimits"
@@ -217,366 +217,402 @@
[worklate{1:nbin,1:nchan}] = deal(latency); % specified latency(ies) for getting measurements.
if length(latency)==2
- [xxx, latsamp, latdiffms] = closest(timex, latency);
- if latency(1)2 %JLC.10/16/2013
- msgboxText = sprintf('The onset of your measurement window cannot be more than 2 samples earlier than the ERP window (%.1f ms)\n', timex(1));
- varargout{1} = msgboxText;
- varargout{2} = 'limit';
- return
- end
- if latency(2)2 %JLC.10/16/2013
+ msgboxText = sprintf('The onset of your measurement window cannot be more than 2 samples earlier than the ERP window (%.1f ms)\n', timex(1));
+ varargout{1} = msgboxText;
+ varargout{2} = 'limit';
+ return
+ end
+ if latency(2)=(pnts-sampeak)) && (ms2sample(latdiffms(1),fs)<(-2+sampeak) || ms2sample(latdiffms(1),fs)>(2-sampeak)) %JLC.20/08/13
- msgboxText = sprintf('The specified latency is more than 2 samples away from the ERP window [%.1f %.1f] ms\n', timex(1), timex(end));
- varargout{1} = msgboxText;
- varargout{2} = 'limit';
- return
- end
- if latsamp(1)<1
- latsamp(1) = 1;
- fprintf('\n%s\n', repmat('*',1,60));
- fprintf('WARNING: Latency %.1f ms was adjusted to %.1f ms \n', latency(2), mintime);
- fprintf('%s\n\n', repmat('*',1,60));
- elseif latsamp(1)>pnts
- latsamp(1) = pnts;
- fprintf('\n%s\n', repmat('*',1,60));
- fprintf('WARNING: Latency %.1f ms was adjusted to %.1f ms \n', latency(2), maxtime);
- fprintf('%s\n\n', repmat('*',1,60));
- end
+ [xxx, latsamp, latdiffms] = closest(timex, latency(1));
+ if (latsamp(1)<=(1+sampeak) || latsamp(1)>=(pnts-sampeak)) && (ms2sample(latdiffms(1),fs)<(-2+sampeak) || ms2sample(latdiffms(1),fs)>(2-sampeak)) %JLC.20/08/13
+ msgboxText = sprintf('The specified latency is more than 2 samples away from the ERP window [%.1f %.1f] ms\n', timex(1), timex(end));
+ varargout{1} = msgboxText;
+ varargout{2} = 'limit';
+ return
+ end
+ if latsamp(1)<1
+ latsamp(1) = 1;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Latency %.1f ms was adjusted to %.1f ms \n', latency(2), mintime);
+ fprintf('%s\n\n', repmat('*',1,60));
+ elseif latsamp(1)>pnts
+ latsamp(1) = pnts;
+ fprintf('\n%s\n', repmat('*',1,60));
+ fprintf('WARNING: Latency %.1f ms was adjusted to %.1f ms \n', latency(2), maxtime);
+ fprintf('%s\n\n', repmat('*',1,60));
+ end
else
- error('Wrong number of latencies...')
+ error('Wrong number of latencies...')
end
try
- for b=1:nbin
- for ch = 1:nchan
- %
- % Get data
- %
- dataux = ERP.bindata(chanArray(ch), :, binArray(b));
-
- %
- % re-sampling
- %
- if intfactor~=1
- dataux = spline(timeor, dataux, timex); % re-sampled data
- end
+ for b=1:nbin
+ for ch = 1:nchan
+ %
+ % Get data
+ %
+ dataux = ERP.bindata(chanArray(ch), :, binArray(b));
+
+ %
+ % re-sampling
+ %
+ if intfactor~=1
+ dataux = spline(timeor, dataux, timex); % re-sampled data
+ end
+
+ %
+ % Baseline correction
+ %
+ blv = blvalue2(dataux, timex, blc);
+ dataux = dataux - blv;
+
+ if nlat==1 % 1 latency was specified
+ if strcmpi(moption,'areazt') || strcmpi(moption,'areazp') || strcmpi(moption,'areazn')
+
+ %
+ % get area (automatic limits, 1 seed latency)
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ switch moption
+ case 'areazt'
+ aoption = 'autot';
+ case 'areazp'
+ aoption = 'autop';
+ case 'areazn'
+ aoption = 'auton';
+ end
+
+ % gets values
+ [A, Lx, il] = areaerp(dataux, fs, latsamp, aoption, coi);
+ worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
+ VALUES(b,ch) = A;
+ elseif strcmpi(moption,'nintegz')
+
+ %
+ % get numerical integration (automatic limits)
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ [A, Lx, il] = areaerp(dataux, fs,latsamp, 'auto', coi);
+ worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
+ VALUES(b,ch) = A;
+ elseif strcmpi(moption,'instabl')
+
+ %
+ % get instantaneous amplitud (at 1 latency)
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ VALUES(b,ch) = dataux(latsamp);
+ else
+ stre1 = 'ERROR in geterpvalues.m: You must enter 2 latencies for ';
+ stre2 = '''meanbl'', ''peakampbl'', ''peaklatbl'', or ''area''';
+ strerr = [stre1 stre2];
+ error( strerr )
+ end
+ else % between 2 latencies measurements.
+ if strcmpi(moption,'meanbl')
+
+ %
+ % get mean value
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ VALUES(b,ch) = mean(dataux(latsamp(1):latsamp(2)));
+ elseif strcmpi(moption,'peakampbl')
+
+ %
+ % get peak amplitude
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ try
+ dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
+ timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
+ catch
+ extrastr = msgboxText4peak;
+ error('Error:peakampbl', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
+ end
+
+ if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
+ localoptstr = 'abs';
+ elseif localopt==2 %% GH May 2024
+ localoptstr = 'errormsg';
+ else
+ localoptstr = 'NaN';
+ end
+
+ % gets values
+ [valx, latpeak] = localpeak(dataux, timex2, 'Neighborhood',sampeak, 'Peakpolarity', polpeak, 'Measure','amplitude',...
+ 'Peakreplace', localoptstr);
+
+ if isempty(valx)
+ error('Peak-related measurement failed...')
+ end
+
+ worklate{b,ch} = latpeak; %((il-1)/fs + ERP.xmin)*1000;
+ VALUES(b,ch) = valx; % value of amplitude
+ elseif strcmpi(moption,'peaklatbl')
+
+ %
+ % get peak latency
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+
+ try
+ dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
+ timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
+ catch
+ extrastr = msgboxText4peak;
+ error('Error:peaklatbl', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
+ end
+ if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
+ localoptstr = 'abs';
+ elseif localopt==2 %% GH May 2024
+ localoptstr = 'errormsg';
- %
- % Baseline correction
- %
- blv = blvalue2(dataux, timex, blc);
- dataux = dataux - blv;
+ else
+ localoptstr = 'NaN';
+ end
+
+ % gets values
+ valx = localpeak(dataux, timex2, 'Neighborhood', sampeak, 'Peakpolarity', polpeak, 'Measure','peaklat',...
+ 'Peakreplace', localoptstr);
+ if isempty(valx)
+ error('Peak-related measurement failed...')
+ end
+
+ VALUES(b,ch) = valx;
+ elseif strcmpi(moption,'area') || strcmpi(moption,'areat') || strcmpi(moption,'areap') || strcmpi(moption,'arean')
+
+ %
+ % get area
+ %
+ switch moption
+ case {'areat', 'area'}
+ aoption = 'total';
+ case 'areap'
+ aoption = 'positive';
+ case 'arean'
+ aoption = 'negative';
+ end
+
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ A = areaerp(dataux, fs, latsamp, aoption, coi);
+ VALUES(b,ch) = A;
+ elseif strcmpi(moption,'50arealat') % deprecated
+
+ %
+ % get 50% area latency (old)
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ [aaaxxx, L] = areaerp(dataux, fs,latsamp, 'total', coi);
+ VALUES(b,ch) = sample2ms((L-1),fs,0) + mintime; % 50 % area latency (temporary)
+ elseif strcmpi(moption,'fareatlat') || strcmpi(moption,'fninteglat') || strcmpi(moption,'fareaplat') || strcmpi(moption,'fareanlat')
+
+ %
+ % get fractional area latency
+ %
+ if frac<0 || frac>1
+ error('ERPLAB says: error at geterpvalues(). Fractional area value must be between 0 and 1')
+ end
+ switch moption
+ case 'fareatlat'
+ aoption = 'total';
+ case 'fninteglat'
+ aoption = 'integral'; % default
+ case 'fareaplat'
+ aoption = 'positive';
+ case 'fareanlat'
+ aoption = 'negative';
+ end
+
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ [aaaxxx, L] = areaerp(dataux, fs,latsamp, aoption, coi, frac, fracmearep);
+ VALUES(b,ch) = sample2ms((L-1),fs,0) + mintime; % frac area latency
+ elseif strcmpi(moption,'fpeaklat')
+
+ %
+ % get fractional "peak" latency
+ %
+ if frac<0 || frac>1
+ error('ERPLAB says: error at geterpvalues(). Fractional peak value must be between 0 and 1')
+ end
+
+ % try
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+
+ try
+ dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
+ timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
+ catch
+ extrastr = msgboxText4peak;
+ error('Error:fpeaklat', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
+ end
+ if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
+ localoptstr = 'abs';
+ elseif localopt==2 %% GH May 2024
+ localoptstr = 'errormsg';
+ else
+ localoptstr = 'NaN';
+ end
+ if fracmearep==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
+ fracmearepstr = 'abs';
- if nlat==1 % 1 latency was specified
- if strcmpi(moption,'areazt') || strcmpi(moption,'areazp') || strcmpi(moption,'areazn')
-
- %
- % get area (automatic limits, 1 seed latency)
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- switch moption
- case 'areazt'
- aoption = 'autot';
- case 'areazp'
- aoption = 'autop';
- case 'areazn'
- aoption = 'auton';
- end
-
- % gets values
- [A, Lx, il] = areaerp(dataux, fs, latsamp, aoption, coi);
- worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
- VALUES(b,ch) = A;
- elseif strcmpi(moption,'nintegz')
-
- %
- % get numerical integration (automatic limits)
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- [A, Lx, il] = areaerp(dataux, fs,latsamp, 'auto', coi);
- worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
- VALUES(b,ch) = A;
- elseif strcmpi(moption,'instabl')
-
- %
- % get instantaneous amplitud (at 1 latency)
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- VALUES(b,ch) = dataux(latsamp);
- else
- stre1 = 'ERROR in geterpvalues.m: You must enter 2 latencies for ';
- stre2 = '''meanbl'', ''peakampbl'', ''peaklatbl'', or ''area''';
- strerr = [stre1 stre2];
- error( strerr )
- end
- else % between 2 latencies measurements.
- if strcmpi(moption,'meanbl')
-
- %
- % get mean value
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- VALUES(b,ch) = mean(dataux(latsamp(1):latsamp(2)));
- elseif strcmpi(moption,'peakampbl')
-
- %
- % get peak amplitude
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- try
- dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
- timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
- catch
- extrastr = msgboxText4peak;
- error('Error:peakampbl', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
- end
-
- if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
- localoptstr = 'abs';
- else
- localoptstr = 'NaN';
- end
-
- % gets values
- [valx, latpeak] = localpeak(dataux, timex2, 'Neighborhood',sampeak, 'Peakpolarity', polpeak, 'Measure','amplitude',...
- 'Peakreplace', localoptstr);
-
- if isempty(valx)
- error('Peak-related measurement failed...')
- end
-
- worklate{b,ch} = latpeak; %((il-1)/fs + ERP.xmin)*1000;
- VALUES(b,ch) = valx; % value of amplitude
- elseif strcmpi(moption,'peaklatbl')
-
- %
- % get peak latency
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
-
- try
- dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
- timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
- catch
- extrastr = msgboxText4peak;
- error('Error:peaklatbl', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
- end
- if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
- localoptstr = 'abs';
- else
- localoptstr = 'NaN';
- end
-
- % gets values
- valx = localpeak(dataux, timex2, 'Neighborhood', sampeak, 'Peakpolarity', polpeak, 'Measure','peaklat',...
- 'Peakreplace', localoptstr);
- if isempty(valx)
- error('Peak-related measurement failed...')
- end
-
- VALUES(b,ch) = valx;
- elseif strcmpi(moption,'area') || strcmpi(moption,'areat') || strcmpi(moption,'areap') || strcmpi(moption,'arean')
-
- %
- % get area
- %
- switch moption
- case {'areat', 'area'}
- aoption = 'total';
- case 'areap'
- aoption = 'positive';
- case 'arean'
- aoption = 'negative';
- end
-
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- A = areaerp(dataux, fs, latsamp, aoption, coi);
- VALUES(b,ch) = A;
- elseif strcmpi(moption,'50arealat') % deprecated
-
- %
- % get 50% area latency (old)
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- [aaaxxx, L] = areaerp(dataux, fs,latsamp, 'total', coi);
- VALUES(b,ch) = sample2ms((L-1),fs,0) + mintime; % 50 % area latency (temporary)
- elseif strcmpi(moption,'fareatlat') || strcmpi(moption,'fninteglat') || strcmpi(moption,'fareaplat') || strcmpi(moption,'fareanlat')
-
- %
- % get fractional area latency
- %
- if frac<0 || frac>1
- error('ERPLAB says: error at geterpvalues(). Fractional area value must be between 0 and 1')
- end
- switch moption
- case 'fareatlat'
- aoption = 'total';
- case 'fninteglat'
- aoption = 'integral'; % default
- case 'fareaplat'
- aoption = 'positive';
- case 'fareanlat'
- aoption = 'negative';
- end
-
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- [aaaxxx, L] = areaerp(dataux, fs,latsamp, aoption, coi, frac, fracmearep);
- VALUES(b,ch) = sample2ms((L-1),fs,0) + mintime; % frac area latency
- elseif strcmpi(moption,'fpeaklat')
-
- %
- % get fractional "peak" latency
- %
- if frac<0 || frac>1
- error('ERPLAB says: error at geterpvalues(). Fractional peak value must be between 0 and 1')
- end
-
- % try
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
-
- try
- dataux = dataux(latsamp(1)-sampeak:latsamp(2)+sampeak); % no filtered
- timex2 = timex(latsamp(1)-sampeak:latsamp(2)+sampeak);
- catch
- extrastr = msgboxText4peak;
- error('Error:fpeaklat', extrastr, sampeak, sampeak, sampeak, mintime, maxtime, mintime+sample2ms(sampeak,fs), maxtime-sample2ms(sampeak,fs));
- end
- if localopt==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
- localoptstr = 'abs';
- else
- localoptstr = 'NaN';
- end
- if fracmearep==1 %0=writes a NaN when local peak is not found. 1=export absolute peak when local peak is not found.
- fracmearepstr = 'abs';
- else
- fracmearepstr = 'NaN';
- end
-
- % gets values
- [aaaxxx, latpeak, latfracpeak] = localpeak(dataux, timex2, 'Neighborhood',sampeak, 'Peakpolarity', polpeak, 'Measure','fraclat',...
- 'Peakreplace', localoptstr, 'Fraction', frac, 'Fracpeakreplace', fracmearepstr, 'Peakonset',peakonset);
-
- if isempty(aaaxxx)
- error('Peak-related measurement failed...')
- end
-
- worklate{b,ch} = latpeak; % peak
- VALUES(b,ch) = latfracpeak; % fractional peak
- elseif strcmpi(moption,'areazt') || strcmpi(moption,'areazp') || strcmpi(moption,'areazn')
-
- %
- % get area (automatic limits)
- %
- switch moption
- case 'areazt'
- aoption = 'autot';
- case 'areazp'
- aoption = 'autop';
- case 'areazn'
- aoption = 'auton';
- end
-
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- [A, L, il] = areaerp(dataux, fs,latsamp, aoption, coi);
- worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integration limits
- VALUES(b,ch) = A;
- elseif strcmpi(moption,'errorbl') % for Rick Addante
-
- %
- % get standard deviation
- %
- if isempty(ERP.binerror)
- error('ERPLAB says: The data field for standard deviation is empty!')
- end
-
- dataux = ERP.bindata; % temporary store for data field
- ERP.bindata = ERP.binerror; % error data to data
- blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- VALUES(b,ch) = mean(ERP.bindata(chanArray(ch),latsamp(1):latsamp(2), binArray(b))) - blv;
- ERP.bindata = dataux; % recover original data
- elseif strcmpi(moption,'rmsbl')
-
- %
- % get root mean square value (RMS)
- %
- VALUES(b,ch) = sqrt(mean(dataux(latsamp(1):latsamp(2)).^2));
- elseif strcmpi(moption,'ninteg')
-
- %
- % get numerical integration
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- A = areaerp(dataux, fs,latsamp, 'integral', coi);
- VALUES(b,ch) = A;
- elseif strcmpi(moption,'nintegz')
-
- %
- % get numerical integration (automatic limits)
- %
- %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
- %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
-
- % gets values
- [A, Lx, il] = areaerp(dataux, fs,latsamp, 'auto', coi);
- worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
- VALUES(b,ch) = A;
- end
- end
+ else
+ fracmearepstr = 'NaN';
+ end
+
+ % gets values
+ [aaaxxx, latpeak, latfracpeak] = localpeak(dataux, timex2, 'Neighborhood',sampeak, 'Peakpolarity', polpeak, 'Measure','fraclat',...
+ 'Peakreplace', localoptstr, 'Fraction', frac, 'Fracpeakreplace', fracmearepstr, 'Peakonset',peakonset);
+
+ if isempty(aaaxxx)
+ error('Peak-related measurement failed...')
+ end
+
+ worklate{b,ch} = latpeak; % peak
+ VALUES(b,ch) = latfracpeak; % fractional peak
+ elseif strcmpi(moption,'areazt') || strcmpi(moption,'areazp') || strcmpi(moption,'areazn')
+
+ %
+ % get area (automatic limits)
+ %
+ switch moption
+ case 'areazt'
+ aoption = 'autot';
+ case 'areazp'
+ aoption = 'autop';
+ case 'areazn'
+ aoption = 'auton';
+ end
+
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ [A, L, il] = areaerp(dataux, fs,latsamp, aoption, coi);
+ worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integration limits
+ VALUES(b,ch) = A;
+ elseif strcmpi(moption,'errorbl') % for Rick Addante
+
+ %
+ % get standard deviation
+ %
+ if isempty(ERP.binerror)
+ error('ERPLAB says: The data field for standard deviation is empty!')
+ end
+
+ dataux = ERP.bindata; % temporary store for data field
+ ERP.bindata = ERP.binerror; % error data to data
+ blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ VALUES(b,ch) = mean(ERP.bindata(chanArray(ch),latsamp(1):latsamp(2), binArray(b))) - blv;
+ ERP.bindata = dataux; % recover original data
+ elseif strcmpi(moption,'rmsbl')
+
+ %
+ % get root mean square value (RMS)
+ %
+ VALUES(b,ch) = sqrt(mean(dataux(latsamp(1):latsamp(2)).^2));
+ elseif strcmpi(moption,'ninteg')
+
+ %
+ % get numerical integration
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ A = areaerp(dataux, fs,latsamp, 'integral', coi);
+ VALUES(b,ch) = A;
+ elseif strcmpi(moption,'nintegz')
+
+ %
+ % get numerical integration (automatic limits)
+ %
+ %blv = blvalue(ERP, chanArray(ch), binArray(b), blc); % baseline value
+ %dataux = ERP.bindata(chanArray(ch), :, binArray(b)) - blv;
+
+ % gets values
+ [A, Lx, il] = areaerp(dataux, fs,latsamp, 'auto', coi);
+ worklate{b,ch} = sample2ms((il-1),fs,0) + mintime; % integratin limits
+ VALUES(b,ch) = A;
end
+ end
end
+ end
catch
- serr = lasterror;
- varargout{1} = serr.message;
- varargout{2} = [];
- return
+ serr = lasterror;
+ switch moption%%GH May 2024
+ case 'fareanlat'
+ varargout{1} = ['Error: There was no negative area (i.e., area below the baseline) in one or more of the waveforms during the specified measurement window. It is impossible to quantify the fractional area latency when there is no negative area. To solve this problem, you can either change the measurement parameters (e.g., the time window) so that a negative area exists for all waveforms, or you can use the Options button to output a value of "not a number (NaN)" when there is no negative area. Here is the first waveform in which there was no negative area detected: bin',num2str(b),', chan',num2str(ch)];
+ case 'fareaplat'
+ varargout{1} = ['Error: There was no positive area (i.e., area above the baseline) in one or more of the waveforms during the specified measurement window. It is impossible to quantify the fractional area latency when there is no positive area. To solve this problem, you can either change the measurement parameters (e.g., the time window) so that a positive area exists for all waveforms, or you can use the Options button to output a value of "not a number (NaN)" when there is no positive area. Here is the first waveform in which there was no positive area detected: bin',num2str(b),', chan',num2str(ch)];
+ case 'peakampbl'
+ varargout{1} = ['Error: There was no local peak in one or more of the waveforms during the specified measurement window. To solve this problem, you can either change the measurement parameters (e.g., reducing the number of points required for a local peak) so that a local peak exists for all waveforms, or you can use the Options button to output a value of "non a number (NaN)" when there is no local peak. Here is the first waveform in which there was no local peak detected: bin',num2str(b),', chan',num2str(ch)];
+ case 'peaklatbl'
+ if polpeak==1
+ polpeakstr = 'positive';
+ else
+ polpeakstr = 'negative';
+ end
+ varargout{1} = ['Error: There was no',32,polpeakstr,32,'latency in one or more of the waveforms during the specified measurement window. It is impossible to quantify the peak latency when there is no',...
+ 32,polpeakstr,32,'latency. To solve this problem, you can either change the measurement parameters (e.g., the time window) so that a',32,polpeakstr,32,'latency exists for all waveforms, or you can use the Options button to output a value of "not a number (NaN)" when there is no',32,polpeakstr,32,...
+ 'latency. Here is the first waveform in which there was no',32,polpeakstr,32,'latency detected: bin',num2str(b),', chan',num2str(ch)];
+ case 'fpeaklat'
+ if polpeak==1
+ polpeakstr = 'positive';
+ else
+ polpeakstr = 'negative';
+ end
+ varargout{1} = ['Error: There was no',32,polpeakstr,32,'latency in one or more of the waveforms during the specified measurement window. It is impossible to quantify the fractional peak latency when there is no',...
+ 32,polpeakstr,32,'latency. To solve this problem, you can either change the measurement parameters (e.g., the time window) so that a',32,polpeakstr,32,'latency exists for all waveforms, or you can use the Options button to output a value of "not a number (NaN)" when there is no',32,polpeakstr,32,...
+ 'latency. Here is the first waveform in which there was no',32,polpeakstr,32,'latency detected: bin',num2str(b),', chan',num2str(ch)];
+ otherwise
+ varargout{1} = serr.message;
+ end
+
+ varargout{2} = [];
+ return
end
%
% Creates Output
%
if ~condf
- varargout{1} = VALUES;
+ varargout{1} = VALUES;
elseif condf
- varargout{1} = VALUES;
- varargout{2} = worklate;
+ varargout{1} = VALUES;
+ varargout{2} = worklate;
else
- error('ERPLAB says: error at geterpvalues. Too many output arguments!')
+ error('ERPLAB says: error at geterpvalues. Too many output arguments!')
end
diff --git a/functions/inputvalue.m b/functions/inputvalue.m
index 1f5ffee6..f716993c 100755
--- a/functions/inputvalue.m
+++ b/functions/inputvalue.m
@@ -1,7 +1,13 @@
function [response] = inputvalue(prompt,dlg_title,num_lines,def)
BackERPLABcolor = erpworkingmemory('ColorB');
+if isempty(BackERPLABcolor) || numel(BackERPLABcolor)~=3 || any(BackERPLABcolor(:)>1) || any(BackERPLABcolor(:)<0)
+ BackERPLABcolor = [0.7020 0.77 0.85];
+end
ForeERPLABcolor = erpworkingmemory('ColorF');
+if isempty(ForeERPLABcolor) || numel(ForeERPLABcolor)~=3 || any(ForeERPLABcolor(:)>1) || any(ForeERPLABcolor(:)<0)
+ ForeERPLABcolor = [0 0 0];
+end
BKGoldcolor = get(0,'DefaultUicontrolBackgroundColor'); % current background color
FORoldcolor = get(0,'DefaultUicontrolForegroundColor'); % current foreground color
oldimage = get(0,'DefaultImageVisible');
diff --git a/functions/localpeak.m b/functions/localpeak.m
index ebbc066e..489eeb9b 100755
--- a/functions/localpeak.m
+++ b/functions/localpeak.m
@@ -226,11 +226,14 @@
poslocalpf = posabspf;
latlocalpeak = timex(posabspf);
ltypeoutput = 2; % abs peak
- else % replace with NaN
+ elseif strcmpi(p.Results.Peakreplace,'NaN') % replace with NaN %%GH May 2024
vlocalpf = NaN;
poslocalpf = NaN;
latlocalpeak = NaN;
ltypeoutput = 3; % NaN instead of a peak
+ else%%GH May 2024
+ errorcode = 1; % no fractional value was specified
+ return
end
end
diff --git a/functions/setcodebit.m b/functions/setcodebit.m
index a48b4503..483a8b65 100755
--- a/functions/setcodebit.m
+++ b/functions/setcodebit.m
@@ -1,9 +1,9 @@
% PURPOSE: subroutine for pop_setcodebit.m
% sets the bit(s) at position(s) "bitindex" in each EEG.event(i).type value to 0 (off).
% "bitindex" must contain number(s) between 1 and 16.
-%
+%
% EEG = setcodebit(EEG, bitindex, newvalue) sets the bit(s) at position(s) "bitindex" to the value "newvalue", which must be either 0 or 1.
-%
+%
% Example:
% In Biosemi system you have a 16-bit word for sending your event codes. However, you generally use event codes from 1 to 255
% (8-bit numbers). In this case, the upper byte (bits 9 to 16) should be silent, and these bits should be zero.
@@ -13,11 +13,11 @@
% Hence, you will be able to set each bit, or a group of them, to either "0" or "1", using a single line command.
% For example, if you want to assure that your event codes keep values from 1 to 255, you must set the upper byte
% (bits 9 to 16) to zero (cleaning any spuriously activated bit), using a command like the following:
-%
+%
% EEG = setcodebit(EEG, 9:16, 0);
-%
+%
% Note, EEG = setcodebit(EEG, 9:16); will work as well, since "0" is the default value for "newvalue".
-%
+%
%
% *** This function is part of ERPLAB Toolbox ***
% Author: Javier Lopez-Calderon & Johanna Kreither
@@ -30,53 +30,53 @@
function EEG = setcodebit(EEG,bitindex, newvalue)
if nargin<1
- help setcodebit
- return
+ help setcodebit
+ return
end
if nargin<3
- newvalue = 0;
+ newvalue = 0;
end
if nargin<2
- msgboxText = 'Error: setcodebit() works with 3 inputs.';
- error(msgboxText)
+ msgboxText = 'Error: setcodebit() works with 3 inputs.';
+ error(msgboxText)
end
if ~isempty(EEG.epoch)
- msgboxText = 'setcodebit.m only works for continuous dataset.';
- error(msgboxText)
+ msgboxText = 'setcodebit.m only works for continuous dataset.';
+ error(msgboxText)
end
if isempty(bitindex)
- msgboxText = 'Error: you must specify one bit index, at least.';
- error(msgboxText)
+ msgboxText = 'Error: you must specify one bit index, at least.';
+ error(msgboxText)
else
- if isnumeric(bitindex)
- if min(bitindex)<1 || max(bitindex)>16
- msgboxText = 'Error: bit index must be a positive integer between 1 and 16.';
- error(msgboxText)
- end
- else
- msgboxText = 'Error: bit index must be numeric.';
- error(msgboxText)
- end
- bitindex = unique_bc2(bitindex);
+ if isnumeric(bitindex)
+ if min(bitindex)<1 || max(bitindex)>16
+ msgboxText = 'Error: bit index must be a positive integer between 1 and 16.';
+ error(msgboxText)
+ end
+ else
+ msgboxText = 'Error: bit index must be numeric.';
+ error(msgboxText)
+ end
+ bitindex = unique_bc2(bitindex);
end
if ischar(newvalue)
- msgboxText = 'Error: new value must be numeric.';
- error(msgboxText)
+ msgboxText = 'Error: new value must be numeric.';
+ error(msgboxText)
else
- if length(newvalue)~=1
- msgboxText = 'Error: new value must be a single value, either 0 or 1.';
- error(msgboxText)
- end
- if newvalue~=0 && newvalue~=1
- msgboxText = 'Error: new value must be a single value, either 0 or 1.';
- error(msgboxText)
- end
+ if length(newvalue)~=1
+ msgboxText = 'Error: new value must be a single value, either 0 or 1.';
+ error(msgboxText)
+ end
+ if newvalue~=0 && newvalue~=1
+ msgboxText = 'Error: new value must be a single value, either 0 or 1.';
+ error(msgboxText)
+ end
end
if ischar(EEG.event(1).type)
- msgboxText = 'Your event codes are not numeric.';
- error(msgboxText)
+ msgboxText = 'Your event codes are not numeric.';
+ error(msgboxText)
else
- currentcodes = uint16([EEG.event.type]); %numeric codes
+ currentcodes = uint16([EEG.event.type]); %numeric codes
end
nevents = length(currentcodes);
bitbase = dec2bin(0,16);
@@ -85,9 +85,13 @@
for i=1:nevents
if newvalue==0 % set to zero
- EEG.event(i).type = double(bitand(currentcodes(i), bitcmp(bitbase,16)));
+ try %%GH June 2024
+ EEG.event(i).type = double(bitand(currentcodes(i), bitcmp(bitbase,16)));
+ catch
+ EEG.event(i).type = double(bitand(currentcodes(i), bitcmp(bitbase,'uint16')));
+ end
else % set to one
- EEG.event(i).type = double(bitor(currentcodes(i), bitbase));
+ EEG.event(i).type = double(bitor(currentcodes(i), bitbase));
end
end
EEG = eeg_checkset( EEG, 'eventconsistency' );
diff --git a/functions/summary_rejectflags.m b/functions/summary_rejectflags.m
index 08fa3ee2..a1e43ad0 100755
--- a/functions/summary_rejectflags.m
+++ b/functions/summary_rejectflags.m
@@ -1,12 +1,12 @@
% PURPOSE: summarizes marked flag for artifact detection
%
% FORMAT
-%
+%
% histoflags = summary_rejectflags(EEG);
-%
+%
%
% *** This function is part of ERPLAB Toolbox ***
-% Author: Javier Lopez-Calderon
+% Author: Javier Lopez-Calderon
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
@@ -36,7 +36,7 @@
function histoflags = summary_rejectflags(EEG)
if isempty(EEG.epoch)
- error('ERPLAB: summary_rejectflags() only works with epoched dataset')
+ error('ERPLAB: summary_rejectflags() only works with epoched dataset')
end
ntrial = EEG.trials;
@@ -44,40 +44,40 @@
oldflag = zeros(1,ntrial);
for b=1:nbin
- for i=1:ntrial
- if length(EEG.epoch(i).eventlatency) == 1
- binix = [EEG.epoch(i).eventbini];
- if iscell(binix)
- binix = cell2mat(binix);
- end
- if ismember(b, binix)
- flagx = [EEG.epoch(i).eventflag];
- if iscell(flagx)
- flagx = cell2mat(flagx);
- end
- oldflag(b,i) = flagx;
- else
- oldflag(b,i) =0;
- end
- elseif length(EEG.epoch(i).eventlatency) > 1
- indxtimelock = find(cell2mat(EEG.epoch(i).eventlatency) == 0,1,'first'); % catch zero-time locked type
- if ismember(b, EEG.epoch(i).eventbini{indxtimelock})
- oldflag(b,i) = EEG.epoch(i).eventflag{indxtimelock};
- else
- oldflag(b,i) =0;
- end
- else
- errorm = 1;
+ for i=1:ntrial
+ if length(EEG.epoch(i).eventlatency) == 1
+ binix = [EEG.epoch(i).eventbini];
+ if iscell(binix)
+ binix = cell2mat(binix);
+ end
+ if ismember(b, binix)
+ flagx = [EEG.epoch(i).eventflag];
+ if iscell(flagx)
+ flagx = cell2mat(flagx);
end
+ oldflag(b,i) = flagx;
+ else
+ oldflag(b,i) =0;
+ end
+ elseif length(EEG.epoch(i).eventlatency) > 1
+ indxtimelock = find(cell2mat(EEG.epoch(i).eventlatency) == 0,1,'first'); % catch zero-time locked type
+ if ismember(b, EEG.epoch(i).eventbini{indxtimelock})
+ oldflag(b,i) = EEG.epoch(i).eventflag{indxtimelock};
+ else
+ oldflag(b,i) =0;
+ end
+ else
+ errorm = 1;
end
+ end
end
histoflags = zeros(1,16);
flagbit = bitshift(1, 0:15);
for b=1:nbin
- for j=1:16
- C = bitand(flagbit(j), oldflag(b,:));
- histoflags(b,j) = nnz(C);
- end
+ for j=1:16
+ C = bitand(flagbit(j), oldflag(b,:));
+ histoflags(b,j) = nnz(C);
+ end
end
diff --git a/images/EstudioLogo.jpg b/images/EstudioLogo.jpg
new file mode 100644
index 00000000..37d891b5
Binary files /dev/null and b/images/EstudioLogo.jpg differ
diff --git a/images/EstudioLogo.png b/images/EstudioLogo.png
new file mode 100644
index 00000000..8299485a
Binary files /dev/null and b/images/EstudioLogo.png differ
diff --git a/pop_functions/pop_DQ_preavg.m b/pop_functions/pop_DQ_preavg.m
index c7686e35..968a2288 100755
--- a/pop_functions/pop_DQ_preavg.m
+++ b/pop_functions/pop_DQ_preavg.m
@@ -1,4 +1,4 @@
-% Purpose: Outputs DQ Table on Epoched Dataset (not ERP)
+% Purpose: Outputs DQ Table on Epoched Dataset (not ERP)
%
% Format :
%
@@ -11,16 +11,16 @@
%
-function pop_DQ_preavg(ALLEEG, varargin)
+function pop_DQ_preavg(ALLEEG, varargin)
-%ERP = preloadERP;
+%ERP = preloadERP;
if nargin < 1
help pop_DQ_preavg
return
end
-if isobject(ALLEEG) % eegobj
+if isobject(ALLEEG) % eegobj
whenEEGisanObject
return
end
@@ -36,16 +36,16 @@ function pop_DQ_preavg(ALLEEG, varargin)
end
% read values in memory for this function
- def = erpworkingmemory('pop_DQ_preavg');
+ def = erpworkingmemory('pop_DQ_preavg');
% def{1} - dataset indx, def{2} - artcrit, def{3} - wavg, def{4} - stderror, def{5} - exclude boundaries,
% def{6} - ERP type, def{7} - wintaper type, def{8} - wintaper function,
- % def{9} - data quality flag, def{10} - DQ_spec_structure,
+ % def{9} - data quality flag, def{10} - DQ_spec_structure,
% def{11} - DQ pre-avg flag, def {12} - DQ_custom_wins
-
- if isempty(def) || numel(def)~=12
+
+ if isempty(def) || numel(def)~=12
% Should not be empty, and have exactly 12 elements. Else, fallback to:
- def = {1 1 1 1 1 0 0 [] 1 [] 1 0};
+ def = {1 1 1 1 1 0 0 [] 1 [] 1 0};
end
@@ -69,7 +69,7 @@ function pop_DQ_preavg(ALLEEG, varargin)
answer = DQ_preavg(currdata, def, nepochperdata, timelimits);
-
+
if isempty(answer)
disp('User selected Cancel')
return
@@ -78,10 +78,10 @@ function pop_DQ_preavg(ALLEEG, varargin)
if numel(setindex) > 1
disp('This tool cannot consider more than one .set file at a time!')
- return
+ return
end
-
+
%
% Artifact rejection criteria for averaging
@@ -120,7 +120,7 @@ function pop_DQ_preavg(ALLEEG, varargin)
% Write the analytic Standardized Measurment Error info
DQ_flag = answer{9};
DQ_spec = answer{10};
- DQ_preavg_txt = answer{11};
+ DQ_preavg_txt = answer{11};
DQcustom_wins = answer{12};
% store setting in erplab working memory
@@ -150,28 +150,16 @@ function pop_DQ_preavg(ALLEEG, varargin)
'DQ_flag',DQ_flag,'DQ_spec',DQ_spec, 'DQ_preavg_txt', DQ_preavg_txt,'DQ_custom_wins', DQcustom_wins, 'History', '');
- pause(0.1);
+ pause(0.1);
%Here, pass hidden ERP struct to DQTableGUI
- ALLERP = [];
- CURRENTPREAVG = 1;
+ ALLERP = [];
+ CURRENTPREAVG = 1;
ERPpreavg.erpname = ALLEEG(setindex).setname; %setname instead of erpname in DQ Table
- DQ_Table_GUI(ERPpreavg,ALLERP,CURRENTPREAVG,1);
+ DQ_Table_GUI(ERPpreavg,ALLERP,CURRENTPREAVG,1);
end
-
-
-
-
-
-
-
-
-
-
-
-
-end
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/pop_functions/pop_ERP_simulation.m b/pop_functions/pop_ERP_simulation.m
old mode 100644
new mode 100755
diff --git a/pop_functions/pop_artextval.m b/pop_functions/pop_artextval.m
index 047102ce..5318d5e9 100755
--- a/pop_functions/pop_artextval.m
+++ b/pop_functions/pop_artextval.m
@@ -108,7 +108,7 @@
ampth = answer{2};
chanArray = unique_bc2(answer{3}); % avoids repeated channels
lpfilt = answer{4};
- lpopt = answer{5}
+ lpopt = answer{5};
flag = answer{6};
viewer = answer{end};
diff --git a/pop_functions/pop_artinterp.m b/pop_functions/pop_artinterp.m
index c17849a7..82fd6e4c 100755
--- a/pop_functions/pop_artinterp.m
+++ b/pop_functions/pop_artinterp.m
@@ -7,7 +7,7 @@
% INPUTS :
%
% EEG - input dataset
-%
+%
% [EEG, com] = pop_artinterp(EEG, 'FlagToUse', replaceFlag, 'InterpMethod', interpolationMethod, ...
% 'ChanToInterp', replaceChannelInd, ...
% 'ChansToIgnore', ignoreChannels);
@@ -20,14 +20,14 @@
% 'InterpMethod' - [string] method used for interpolation (default is 'spherical').
% 'invdist'/'v4' uses inverse distance on the scalp
% 'spherical' uses superfast spherical interpolation.
-% 'ChanToInterp' - [integer] Index of channel to interpolate.
+% 'ChanToInterp' - [integer] Index of channel to interpolate.
% 'ChansToIgnore' - [integer array] Do not include these electrodes
% as input for interpolation.
% 'InterpAnyChan' - default = 0; If 1, all channels that are flagged with artifacts
% will be interpolated IF no more than THRESHOLD
% percent of channels are flagged
-% 'Threshold' - default = 10%; if greater than X% of channels are flagged,
-% then interpolation routine will NOT work for that epoch
+% 'Threshold' - default = 10%; if greater than X% of channels are flagged,
+% then interpolation routine will NOT work for that epoch
%
%
% OUTPUTS :
@@ -73,112 +73,112 @@
function [EEG, com] = pop_artinterp(EEG, varargin)
com = '';
if nargin<1
- help pop_artinterp
- return
+ help pop_artinterp
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- serror = erplab_eegscanner(EEG, 'pop_artinterp', 2, 0, 1, 2, 1);
- if serror
- return
- end
-
- dlg_title = {'Interpolate Flagged Artifact Epochs'};
-
- %defaults
- defx = {0, 'spherical',[],[],[],0,10};
- %first pos: no previous flag selected
- %second pos: no previous method selected (default to 'spherical')
- %third pos: no prev electrode selected (should agree with fourth pos)
- %fourth pos: no prev "channel-label" selected (should agree with third pos)
- %fifth pos: no prev "channels" to ignore
- %sixth pos: set to 0 = "interpolate only one" electrode option
- %seventh pos: set to 10% default threshold (of artifacts across
- % electrode) for 'any electrode interpolation' option
- %eigth pos: set [] default, for measurment channel rule
-
- %take previously selected electrodes and flags used from previous
- % artinterp() usage?
- def = erpworkingmemory('pop_artinterp');
-
- if isempty(def)
- def = defx;
- else
- %make sure that electrode number exists in current list of
- %available channels
- %def{1} = def{1}(ismember_bc2(def{1},1:EEG(1).nbchan));
- def{3} = def{3}(ismember_bc2(def{3},1:EEG(1).nbchan));
- end
-
- try
- chanlabels = {EEG(1).chanlocs.labels}; %only works on single datasets
- catch
- chanlabels = [];
- end
-
-
-
- histoflags = summary_rejectflags(EEG);
-
- %check currently activated flags
- flagcheck = sum(histoflags);
- active_flags = (flagcheck>1);
-
- % def{end} = active_flags;
-
-
- %
- % Call GUI
- %
- answer = artifactinterpGUI(dlg_title, def, defx, chanlabels, active_flags);
-
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
-
- replaceFlag = answer{1};
- interpolationMethod = answer{2};
- replaceChannelInd = answer{3};
- replaceChannelLabel = answer{4};
- ignoreChannels = unique_bc2(answer{5}); % avoids repeted channels
- many_electrodes = answer{6};
- threshold_perc = answer{7};
- % measurement_chan = answer{8};
-
- % displayEEG = answer{6}; %no display EEG for now
- % viewer = answer{end}; %no viewer for Now
-
- viewer = 0; % no viewer
- if viewer
- viewstr = 'on';
- else
- viewstr = 'off';
- end
- if ~isempty(find(replaceFlag<1 | replaceFlag>16, 1))
- msgboxText{1} = 'ERROR, flag cannot be greater than 16 nor lesser than 1';
- title = 'ERPLAB: Flag input';
- errorfound(msgboxText, title);
- return
- end
- erpworkingmemory('pop_artinterp', {answer{1} answer{2} answer{3} answer{4} answer{5} ...
- answer{6}, answer{7}});
-
- if length(EEG)==1
- EEG.setname = [EEG.setname '_arInterp']; %suggest a new name
- end
-
- %
- % Somersault
- %
- [EEG, com] = pop_artinterp(EEG, 'FlagToUse', replaceFlag, 'InterpMethod', interpolationMethod, ...
- 'ChanToInterp', replaceChannelInd, 'ChansToIgnore', ignoreChannels, ...
- 'InterpAnyChan', many_electrodes, 'Threshold',threshold_perc,...
- 'Review', viewstr, 'History', 'gui');
+ serror = erplab_eegscanner(EEG, 'pop_artinterp', 2, 0, 1, 2, 1);
+ if serror
return
+ end
+
+ dlg_title = {'Interpolate Flagged Artifact Epochs'};
+
+ %defaults
+ defx = {0, 'spherical',[],[],[],0,10};
+ %first pos: no previous flag selected
+ %second pos: no previous method selected (default to 'spherical')
+ %third pos: no prev electrode selected (should agree with fourth pos)
+ %fourth pos: no prev "channel-label" selected (should agree with third pos)
+ %fifth pos: no prev "channels" to ignore
+ %sixth pos: set to 0 = "interpolate only one" electrode option
+ %seventh pos: set to 10% default threshold (of artifacts across
+ % electrode) for 'any electrode interpolation' option
+ %eigth pos: set [] default, for measurment channel rule
+
+ %take previously selected electrodes and flags used from previous
+ % artinterp() usage?
+ def = erpworkingmemory('pop_artinterp');
+
+ if isempty(def)
+ def = defx;
+ else
+ %make sure that electrode number exists in current list of
+ %available channels
+ %def{1} = def{1}(ismember_bc2(def{1},1:EEG(1).nbchan));
+ def{3} = def{3}(ismember_bc2(def{3},1:EEG(1).nbchan));
+ end
+
+ try
+ chanlabels = {EEG(1).chanlocs.labels}; %only works on single datasets
+ catch
+ chanlabels = [];
+ end
+
+
+
+ histoflags = summary_rejectflags(EEG);
+
+ %check currently activated flags
+ flagcheck = sum(histoflags);
+ active_flags = (flagcheck>1);
+
+ % def{end} = active_flags;
+
+
+ %
+ % Call GUI
+ %
+ answer = artifactinterpGUI(dlg_title, def, defx, chanlabels, active_flags);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ replaceFlag = answer{1};
+ interpolationMethod = answer{2};
+ replaceChannelInd = answer{3};
+ replaceChannelLabel = answer{4};
+ ignoreChannels = unique_bc2(answer{5}); % avoids repeted channels
+ many_electrodes = answer{6};
+ threshold_perc = answer{7};
+ % measurement_chan = answer{8};
+
+ % displayEEG = answer{6}; %no display EEG for now
+ % viewer = answer{end}; %no viewer for Now
+
+ viewer = 0; % no viewer
+ if viewer
+ viewstr = 'on';
+ else
+ viewstr = 'off';
+ end
+ if ~isempty(find(replaceFlag<1 | replaceFlag>16, 1))
+ msgboxText{1} = 'ERROR, flag cannot be greater than 16 nor lesser than 1';
+ title = 'ERPLAB: Flag input';
+ errorfound(msgboxText, title);
+ return
+ end
+ erpworkingmemory('pop_artinterp', {answer{1} answer{2} answer{3} answer{4} answer{5} ...
+ answer{6}, answer{7}});
+
+ if length(EEG)==1
+ EEG.setname = [EEG.setname '_arInterp']; %suggest a new name
+ end
+
+ %
+ % Somersault
+ %
+ [EEG, com] = pop_artinterp(EEG, 'FlagToUse', replaceFlag, 'InterpMethod', interpolationMethod, ...
+ 'ChanToInterp', replaceChannelInd, 'ChansToIgnore', ignoreChannels, ...
+ 'InterpAnyChan', many_electrodes, 'Threshold',threshold_perc,...
+ 'Review', viewstr, 'History', 'gui');
+ return
end
%
@@ -193,14 +193,14 @@
t2 = single(EEG(1).xmax*1000);
%p.addParamValue('Twindow', [t1 t2], @isnumeric);
%p.addParamValue('Channels', 1:EEG(1).nbchan, @isnumeric); %all channels
-p.addParamValue('FlagToUse', 0, @isnumeric);
-p.addParamValue('InterpMethod', 'spherical', @ischar);
+p.addParamValue('FlagToUse', 0, @isnumeric);
+p.addParamValue('InterpMethod', 'spherical', @ischar);
p.addParamValue('ChanToInterp', 0, @isnumeric); %%%%%%%%%%%%% <<<<
%p.addParamValue('ChanLabel', 'none', @ischar);
-p.addParamValue('ChansToIgnore', [], @isnumeric);
+p.addParamValue('ChansToIgnore', [], @isnumeric);
p.addParamValue('InterpAnyChan', 0,@isnumeric);
-p.addParamValue('Threshold', 10, @isnumeric); %percentage value
-%p.addParamValue('MeasurementChanIdx',[],@isnumeric);
+p.addParamValue('Threshold', 10, @isnumeric); %percentage value
+%p.addParamValue('MeasurementChanIdx',[],@isnumeric);
p.addParamValue('Review', 'off', @ischar); % to open a window with the marked epochs
%p.addParamValue('Flag', 1, @isnumeric); %param for things to-be flagged
p.addParamValue('History', 'script', @ischar); % history from scripting
@@ -209,37 +209,37 @@
replaceFlag = p.Results.FlagToUse;
interpolationMethod = p.Results.InterpMethod;
-replaceChannelInd = p.Results.ChanToInterp;
+replaceChannelInd = p.Results.ChanToInterp;
%replaceChannelLabel = p.Results.ChanLabel;
-ignoreChannels = p.Results.ChansToIgnore;
-many_electrodes = p.Results.InterpAnyChan;
-threshold_perc = p.Results.Threshold;
-%meas_chan = p.Results.MeasurementChanIdx;
+ignoreChannels = p.Results.ChansToIgnore;
+many_electrodes = p.Results.InterpAnyChan;
+threshold_perc = p.Results.Threshold;
+%meas_chan = p.Results.MeasurementChanIdx;
%flag = p.Results.Flag;
-displayEEG = p.Results.Review;
+displayEEG = p.Results.Review;
if strcmpi(p.Results.Review, 'on')% to open a window with the marked epochs
- eprev = 1;
+ eprev = 1;
else
- eprev = 0;
+ eprev = 0;
end
if ~isempty(find(ignoreChannels<1 | ignoreChannels>EEG(1).nbchan, 1))
- error('ERPLAB says: error at pop_artstep(). Channel indices cannot be greater than EEG.nbchan')
+ error('ERPLAB says: error at pop_artstep(). Channel indices cannot be greater than EEG.nbchan')
end
if ~isempty(find(replaceFlag<1 | replaceFlag>16, 1))
- error('ERPLAB says: error at pop_artstep(). Flag cannot be greater than 16 or lesser than 1')
+ error('ERPLAB says: error at pop_artstep(). Flag cannot be greater than 16 or lesser than 1')
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
@@ -258,25 +258,25 @@
-%% first, index the epochs to interpolate based on the flag used
-ntrial = EEG.trials; %number of original trials
-oldflag = zeros(1,ntrial);
+%% first, index the epochs to interpolate based on the flag used
+ntrial = EEG.trials; %number of original trials
+oldflag = zeros(1,ntrial);
for i = 1:ntrial
if length(EEG.epoch(i).eventlatency) == 1
- flagx = [EEG.epoch(i).eventflag];
+ flagx = [EEG.epoch(i).eventflag];
- if iscell(flagx)
- flagx = cell2mat(flagx)
+ if iscell(flagx)
+ flagx = cell2mat(flagx);
end
oldflag(i) = flagx;
-
+
elseif length(EEG.epoch(i).eventlatency) > 1
- indxtimelock = find(cell2mat(EEG.epoch(i).eventlatency) == 0,1,'first');% catch zero-time locked type
- oldflag(i) = EEG.epoch(i).eventflag{indxtimelock};
-
+ indxtimelock = find(cell2mat(EEG.epoch(i).eventlatency) == 0,1,'first');% catch zero-time locked type
+ oldflag(i) = EEG.epoch(i).eventflag{indxtimelock};
+
end
@@ -285,43 +285,39 @@
% filter oldflag by specified flag
flagbit = bitshift(1,0:15);
-flagged_epochs = bitand(flagbit(replaceFlag), oldflag);
+flagged_epochs = bitand(flagbit(replaceFlag), oldflag);
epoch_ind = find(flagged_epochs); %list of index of epochs, filtered by specified flag, to interpolate
-%% interpolate only the epochs with the specified flag
-N_interpolate = numel(epoch_ind);
-
+%% interpolate only the epochs with the specified flag
-
-for e = 1:N_interpolate
-
- tmpEEG = EEG; %temp EEG struct
-
-
- tmpEEG.data = tmpEEG.data(:,:,epoch_ind(e)); %index current epoch
- tmpEEG.trials = 1; %update temp single trial EEG struct
- all_chans = EEG.reject.rejmanualE(:,epoch_ind(e));
-
- ignoreChannelsE = ignoreChannels;
- chanlocs = tmpEEG.chanlocs;
+if many_electrodes == 1
- %skip epoch if the channel to be interpolated is itself a not-real
- %channel (i.e. no theta information)
- nonemptychans = find(~cellfun('isempty', { chanlocs.theta }));
+ epoch_ind = find(flagged_epochs); %list of index of epochs, filtered by specified flag, to interpolate
+ %% interpolate only the epochs with the specified flag
+ N_interpolate = numel(epoch_ind);
-
- if many_electrodes == 1
+ for e = 1:N_interpolate
+
+ tmpEEG = EEG; %temp EEG struct
+ tmpEEG.data = tmpEEG.data(:,:,epoch_ind(e)); %index current epoch
+ tmpEEG.trials = 1; %update temp single trial EEG struct
+ all_chans = EEG.reject.rejmanualE(:,epoch_ind(e));
+ ignoreChannelsE = ignoreChannels;
+ chanlocs = tmpEEG.chanlocs;
+ %skip epoch if the channel to be interpolated is itself a not-real
+ %channel (i.e. no theta information)
+ nonemptychans = find(~cellfun('isempty', { chanlocs.theta }));
chans_to_interp = find(all_chans)';
-
+
%skip channels to be interpolated is itself a not-real
%channel (i.e. no theta information)
- [~,chan_ind ] = intersect_bc(chans_to_interp,nonemptychans);
- chans_to_interp2 = chans_to_interp(chan_ind);
+ [~,chan_ind ] = intersect_bc(chans_to_interp,nonemptychans);
+ chans_to_interp2 = chans_to_interp(chan_ind);
if isempty(chans_to_interp2)
@@ -330,8 +326,6 @@
continue
end
-
-
%fix redundancies between chan_to_interp & ignore channels
if any(ismember(chans_to_interp,ignoreChannels))
@@ -352,9 +346,6 @@
continue
else
-
-
-
fprintf('\nInterpolating epoch #%s by flag %s \n', num2str(epoch_ind(e)), ...
num2str(replaceFlag));
@@ -366,76 +357,91 @@
%reset flag at EEG.reject.manual
EEG.reject.rejmanual(epoch_ind(e)) = 0;
-
-
-
-
end
-
-
-
- else
- %one electrode case
-
- %skip channels to be interpolated is itself a not-real
- %channel (i.e. no theta information)
- [~,chan_ind ] = intersect_bc(replaceChannelInd,nonemptychans);
- replaceChannelInd2 = replaceChannelInd(chan_ind);
-
- if isempty(replaceChannelInd2)
- fprintf('\nSkipping epoch #%s since the channel(s) #%i to be interpolated are not real channels (no channel location theta info)', ...
- num2str(epoch_ind(e)), replaceChannelInd);
- continue
- end
-
- %fix redundancies between chan_to_interp & ignore channels
- if ismember(replaceChannelInd,ignoreChannels)
- ignoreChannelsE = setdiff(ignoreChannels, replaceChannelInd);
- end
-
- %fix ignoreChannels to not include channels that are bad (unless it's the chosen channel)!
- include_to_ignore = double(find(all_chans)');
+ %re-add interpolated temp EEG epoch into original EEG
+ EEG.data(:,:,epoch_ind(e)) = tmpEEG.data;
+ end
+else
+ epochrej1 = EEG.reject.rejmanualE(replaceChannelInd,:);
+ [~,epoch_ind1] = find(epochrej1==1);
+ epoch_ind= intersect(epoch_ind,epoch_ind1);
+ N_interpolate = numel(epoch_ind);
+
+ for e = 1:N_interpolate
+ tmpEEG = EEG; %temp EEG struct
+ tmpEEG.data = tmpEEG.data(:,:,epoch_ind(e)); %index current epoch
+ tmpEEG.trials = 1; %update temp single trial EEG struct
+ all_chans = EEG.reject.rejmanualE(:,epoch_ind(e));
- if replaceChannelInd ~= include_to_ignore
- ignoreChannelsE = cat(2,ignoreChannelsE, include_to_ignore);
- end
+ ignoreChannelsE = ignoreChannels;
+ chanlocs = tmpEEG.chanlocs;
- %adjust bad channel count with updated ignored channels
- total_chans = numel(all_chans) - numel(ignoreChannelsE);
+ %skip epoch if the channel to be interpolated is itself a not-real
+ %channel (i.e. no theta information)
+ nonemptychans = find(~cellfun('isempty', { chanlocs.theta }));
-
- if sum(all_chans)/(total_chans) >= (threshold_perc/100)
+ %one electrode case
+ if EEG.reject.rejmanualE(replaceChannelInd,epoch_ind(e))==1%%GH May 2024
+ %skip channels to be interpolated is itself a not-real
+ %channel (i.e. no theta information)
+ [~,chan_ind ] = intersect_bc(replaceChannelInd,nonemptychans);
+ replaceChannelInd2 = replaceChannelInd(chan_ind);
- fprintf('\nSkipping epoch #%s by flag %s since amount of channels with artifact threshold %i percent exceeded\n', ...
- num2str(epoch_ind(e)),num2str(replaceFlag), threshold_perc);
+ if isempty(replaceChannelInd2)
+ fprintf('\nSkipping epoch #%s since the channel(s) #%i to be interpolated are not real channels (no channel location theta info)', ...
+ num2str(epoch_ind(e)), replaceChannelInd);
+ continue
+ end
- continue
- else
+ %fix redundancies between chan_to_interp & ignore channels
+ if ismember(replaceChannelInd,ignoreChannels)
+ ignoreChannelsE = setdiff(ignoreChannels, replaceChannelInd);
+ end
+
+ %fix ignoreChannels to not include channels that are bad (unless it's the chosen channel)!
+ include_to_ignore = double(find(all_chans)');
+
+
+ if replaceChannelInd ~= include_to_ignore
+ ignoreChannelsE = cat(2,ignoreChannelsE, include_to_ignore);
+ end
+ %adjust bad channel count with updated ignored channels
+% total_chans = numel(all_chans) - numel(ignoreChannelsE);
+
+
+ % if sum(all_chans)/(total_chans) >= (threshold_perc/100)
+ % fprintf('\nSkipping epoch #%s by flag %s since amount of channels with artifact threshold %i percent exceeded\n', ...
+ % num2str(epoch_ind(e)),num2str(replaceFlag), threshold_perc);
+ % continue
+ % else
+ %
fprintf('\nInterpolating epoch #%s by flag %s \n', num2str(epoch_ind(e)), ...
num2str(replaceFlag));
fprintf('\nFlag for epoch %s has been reset in EEG.rejmanual \n', num2str(epoch_ind(e)));
-
tmpEEG = erplab_interpolateElectrodes(tmpEEG, replaceChannelInd, ...
ignoreChannelsE,interpolationMethod);
- %reset flag at EEG.reject.manual
- EEG.reject.rejmanual(epoch_ind(e)) = 0;
+ %reset flag at EEG.reject.manual%%GH May 2024
+ EEG.reject.rejmanualE(replaceChannelInd,epoch_ind(e))=0;
+ [xpos,~] = find(EEG.reject.rejmanualE(:,epoch_ind(e))==1);
+ if isempty(xpos)
+ EEG.reject.rejmanual(epoch_ind(e)) = 0;
+ end
+ % end
+
+ %re-add interpolated temp EEG epoch into original EEG
+ EEG.data(:,:,epoch_ind(e)) = tmpEEG.data;
end
-
end
-
-
- %re-add interpolated temp EEG epoch into original EEG
- EEG.data(:,:,epoch_ind(e)) = tmpEEG.data;
-
end
+
% transfer the EEG.reject artifact marks to EVENTLIST
EEG = pop_syncroartifacts(EEG, 'Direction','eeglab2erplab'); % GUI: 30-May-2023 21:02:55
@@ -443,8 +449,8 @@
fprintf('\n');
if N_interpolate == 0
+ warning('on');
warning('No epochs were actually flagged, so no epochs were interpolated!');
-
else
% performance
@@ -460,9 +466,9 @@
com = sprintf( '%s = pop_artinterp( %s ', inputname(1), inputname(1));
if many_electrodes
idx= strcmp(fn,'ChanToInterp');
- fn(idx) = [];
+ fn(idx) = [];
end
-
+
for q=1:length(fn)
fn2com = fn{q};
diff --git a/pop_functions/pop_basicfilter.m b/pop_functions/pop_basicfilter.m
index 4590066e..a3fa71d1 100755
--- a/pop_functions/pop_basicfilter.m
+++ b/pop_functions/pop_basicfilter.m
@@ -76,9 +76,7 @@
function [EEG, com] = pop_basicfilter( EEG, chanArray, varargin)
com = '';
if exist('filtfilt','file') ~= 2
- msgboxText = ['ERPLAB''s filtering functions require the Matlab Signal Processing Toolbox.' ...
- 'You do not appear to have this toolbox installed. The Signal Processing Toolbox can be purchased from The Mathworks (but it may be included in your institution''s license for no additional cost).'...
- 'If you do not know how to obtain or install it, please contact your system administrator.'];
+ msgboxText = 'cannot find the signal processing toolbox';
title = 'ERPLAB: pop_basicfilter() error';
errorfound(msgboxText, title);
return
diff --git a/pop_functions/pop_blcerp.m b/pop_functions/pop_blcerp.m
index c14cb03f..cedef571 100755
--- a/pop_functions/pop_blcerp.m
+++ b/pop_functions/pop_blcerp.m
@@ -2,16 +2,16 @@
%
% FORMAT :
%
-% ERP = pop_blcerp(ERP, blc)
+% ERP = pop_blcerp(ERP, 'Baseline',blc)
%
% ERP - ERPLAB structure
% blc - window for baseline correction in msec or either a string like 'pre', 'post', or 'all'
% (strings with the baseline interval also works. e.g. '-300 100')
%
% Example :
-% >> ERP = pop_blcerp( ERP , [-200 800], [-100 0]);
-% >> ERP = pop_blcerp( ERP , [-200 800], '-100 0');
-% >> ERP = pop_blcerp( ERP , [-400 2000], 'post');
+% >> ERP = pop_blcerp( ERP , [-200 800], 'Baseline', [-100 0]);
+% >> ERP = pop_blcerp( ERP , [-200 800], 'Baseline', '-100 0');
+% >> ERP = pop_blcerp( ERP , [-400 2000], 'Baseline', 'post');
%
% INPUTS :
%
@@ -91,10 +91,13 @@
end
blcorr = answer{1};
+ ChanArray = answer{2};
+ BinArray = answer{3};
%
% Somersault
%
- [ERP, erpcom] = pop_blcerp(ERP, 'Baseline', blcorr, 'Saveas', 'on', 'History', 'gui');
+ [ERP, erpcom] = pop_blcerp(ERP, 'Baseline', blcorr,'ChanArray',ChanArray,...
+ 'BinArray',BinArray,'Saveas', 'on', 'History', 'gui');
return
end
@@ -108,9 +111,22 @@
% option(s)
p.addParamValue('Baseline', 'pre'); % erpset index or input file
p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
+p.addParamValue('ChanArray', [], @isnumeric);
+p.addParamValue('BinArray', [], @isnumeric);
p.addParamValue('History', 'script', @ischar); % history from scripting
p.parse(ERP, varargin{:});
+ChanArray = p.Results.ChanArray;
+if isempty(ChanArray) || any(ChanArray(:)>ERP.nchan) || any(ChanArray(:)<1)
+ ChanArray = [1:ERP.nchan];
+end
+
+
+BinArray = p.Results.BinArray;
+if isempty(BinArray) || any(BinArray(:)>ERP.nbin) || any(BinArray(:)<1)
+ BinArray = [1:ERP.nbin];
+end
+
@@ -192,6 +208,8 @@
ERPaux = ERP; % original ERP
nbin = ERP.nbin;
+
+
%
% baseline correction 01-14-2009
%
@@ -213,6 +231,18 @@
ERP.saved = 'no';
% erpcom = sprintf('%s = pop_blcerp( %s, %s);', inputname(1), inputname(1), blcorrcomm);
+ChanArrayleft = setdiff([1:ERP.nchan],ChanArray);%% channles are not for baseline correction
+if ~isempty(ChanArrayleft)
+ ERP.bindata(ChanArrayleft,:,:) = ERPaux.bindata(ChanArrayleft,:,:);
+end
+
+
+BinArrayleft = setdiff([1:ERP.nbin],BinArray);%% bins are not for baseline correction
+if ~isempty(BinArrayleft)
+ ERP.bindata(:,:,BinArrayleft) = ERPaux.bindata(:,:,BinArrayleft);
+end
+
+
%
% History
%
diff --git a/pop_functions/pop_creabasiceventlist.m b/pop_functions/pop_creabasiceventlist.m
index 3b609ed4..15ff9d9d 100755
--- a/pop_functions/pop_creabasiceventlist.m
+++ b/pop_functions/pop_creabasiceventlist.m
@@ -65,88 +65,88 @@
function [EEG, com] = pop_creabasiceventlist(EEG, varargin)
com = '';
if nargin < 1
- help pop_creabasiceventlist
- return
+ help pop_creabasiceventlist
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- serror = erplab_eegscanner(EEG, 'pop_creabasiceventlist', 2, 0, 0, 0, 2);
- if serror
- return
- end
- if isfield(EEG(1).event, 'type')
- if ~all(cellfun(@isnumeric, { EEG(1).event.type }))
- msgboxText = ['Some or all of your events contain a text-based event label, '...
- 'and not a numeric event code.\n\nERPLAB must have a numeric code '...
- 'for every event (a text label can also be present). For labels such as "S14", '...
- 'you can automatically create an equivalent numeric event code (e.g., 14) by '...
- 'checking the box labeled "Create numeric equivalents of nonnumeric event codes '...
- 'when possible" when creating the EventList.\n\nFor labels that cannot be automatically '...
- 'converted (e.g., "RESP"), or for ambiguous cases (e.g., when you have both "S14" and '...
- '"R14"), you can flexibly create numeric versions using the Advanced button at EVENTLIST GUI.\n'];
-
- title_msg = 'ERPLAB: Warning';
- %button = askquest(sprintf(msgboxText), title_msg);
- button = askquestpoly(sprintf(msgboxText), title_msg, {'Continue'});
- if ~strcmpi(button,'Continue')
- disp('User selected Cancel')
- return
- end
- end
- end
-
- def = erpworkingmemory('pop_creabasiceventlist');
- if isempty(def)
- def = {'' 'boundary' -99 1 1};
- end
-
- %
- % Call GUI
- %
- if length(EEG)>1
- multieeg = 1; % when multi eeg
- else
- multieeg = 0; % just single eeg
- end
- inputstrMat = creabasiceventlistGUI(def, multieeg); % GUI
-
- if isempty(inputstrMat) && ~strcmp(inputstrMat,'')
+ serror = erplab_eegscanner(EEG, 'pop_creabasiceventlist', 2, 0, 0, 0, 2);
+ if serror
+ return
+ end
+ if isfield(EEG(1).event, 'type')
+ if ~all(cellfun(@isnumeric, { EEG(1).event.type }))
+ msgboxText = ['Some or all of your events contain a text-based event label, '...
+ 'and not a numeric event code.\n\nERPLAB must have a numeric code '...
+ 'for every event (a text label can also be present). For labels such as "S14", '...
+ 'you can automatically create an equivalent numeric event code (e.g., 14) by '...
+ 'checking the box labeled "Create numeric equivalents of nonnumeric event codes '...
+ 'when possible" when creating the EventList.\n\nFor labels that cannot be automatically '...
+ 'converted (e.g., "RESP"), or for ambiguous cases (e.g., when you have both "S14" and '...
+ '"R14"), you can flexibly create numeric versions using the Advanced button at EVENTLIST GUI.\n'];
+
+ title_msg = 'ERPLAB: Warning';
+ %button = askquest(sprintf(msgboxText), title_msg);
+ button = askquestpoly(sprintf(msgboxText), title_msg, {'Continue'});
+ if ~strcmpi(button,'Continue')
disp('User selected Cancel')
return
- elseif strcmp(inputstrMat,'advanced')
- %[EEG, com ] = pop_editeventlist(EEG, 'History', 'off');
- [EEG, com ] = pop_editeventlist(EEG);
- return
- end
-
- elname = inputstrMat{1};
- boundarystrcode = inputstrMat{2};
- newboundarynumcode = inputstrMat{3};
- rwwarn = inputstrMat{4};
- alphanum = inputstrMat{5};
-
- erpworkingmemory('pop_creabasiceventlist', {elname, boundarystrcode, newboundarynumcode, rwwarn, alphanum});
-
- if rwwarn==1
- striswarning = 'on';
- else
- striswarning = 'off';
- end
- if alphanum==1
- stralphanum = 'on';
- else
- stralphanum = 'off';
- end
- if length(EEG)==1
- EEG.setname = [EEG.setname '_elist']; %suggest a new name
+ end
end
-
- [EEG, com] = pop_creabasiceventlist(EEG, 'Eventlist', elname, 'BoundaryString', boundarystrcode,...
- 'BoundaryNumeric', newboundarynumcode,'Warning', striswarning, 'AlphanumericCleaning', stralphanum, 'History', 'gui');
+ end
+
+ def = erpworkingmemory('pop_creabasiceventlist');
+ if isempty(def)
+ def = {'' 'boundary' -99 1 1};
+ end
+
+ %
+ % Call GUI
+ %
+ if length(EEG)>1
+ multieeg = 1; % when multi eeg
+ else
+ multieeg = 0; % just single eeg
+ end
+ inputstrMat = creabasiceventlistGUI(def, multieeg); % GUI
+
+ if isempty(inputstrMat) && ~strcmp(inputstrMat,'')
+ disp('User selected Cancel')
+ return
+ elseif strcmp(inputstrMat,'advanced')
+ %[EEG, com ] = pop_editeventlist(EEG, 'History', 'off');
+ [EEG, com ] = pop_editeventlist(EEG);
return
+ end
+
+ elname = inputstrMat{1};
+ boundarystrcode = inputstrMat{2};
+ newboundarynumcode = inputstrMat{3};
+ rwwarn = inputstrMat{4};
+ alphanum = inputstrMat{5};
+
+ erpworkingmemory('pop_creabasiceventlist', {elname, boundarystrcode, newboundarynumcode, rwwarn, alphanum});
+
+ if rwwarn==1
+ striswarning = 'on';
+ else
+ striswarning = 'off';
+ end
+ if alphanum==1
+ stralphanum = 'on';
+ else
+ stralphanum = 'off';
+ end
+ if length(EEG)==1
+ EEG.setname = [EEG.setname '_elist']; %suggest a new name
+ end
+
+ [EEG, com] = pop_creabasiceventlist(EEG, 'Eventlist', elname, 'BoundaryString', boundarystrcode,...
+ 'BoundaryNumeric', newboundarynumcode,'Warning', striswarning, 'AlphanumericCleaning', stralphanum, 'History', 'gui');
+ return
end
%
@@ -173,49 +173,49 @@
newboundarynumcode_old = p.Results.Newboundary; % new numeric code for replacing string boundaries (old versions)
if isempty(boundarystrcode_old)
- boundarystrcode = p.Results.BoundaryString; % current string for boundaries
+ boundarystrcode = p.Results.BoundaryString; % current string for boundaries
else
- boundarystrcode = boundarystrcode_old; % current string for boundaries
+ boundarystrcode = boundarystrcode_old; % current string for boundaries
end
if isempty(newboundarynumcode_old)
- newboundarynumcode = p.Results.BoundaryNumeric; % new numeric code for replacing string boundaries
+ newboundarynumcode = p.Results.BoundaryNumeric; % new numeric code for replacing string boundaries
else
- newboundarynumcode = newboundarynumcode_old; % new numeric code for replacing string boundaries
-
+ newboundarynumcode = newboundarynumcode_old; % new numeric code for replacing string boundaries
+
end
boundarystrcode = strtrim(boundarystrcode);
boundarystrcode = regexprep(boundarystrcode, '''|"','');
if strcmpi(p.Results.Warning, 'on')
- rwwarn = 1;
+ rwwarn = 1;
else
- rwwarn = 0;
+ rwwarn = 0;
end
if strcmpi(p.Results.AlphanumericCleaning, 'on')
- alphanum = 1;
+ alphanum = 1;
else
- alphanum = 0;
+ alphanum = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
% process multiple datasets. Updated August 23, 2013 JLC
%
if length(EEG) > 1
- options1 = {'Eventlist', p.Results.Eventlist, 'BoundaryString', p.Results.BoundaryString,...
- 'BoundaryNumeric', p.Results.BoundaryNumeric,'Warning', p.Results.Warning,...
- 'AlphanumericCleaning', p.Results.AlphanumericCleaning, 'History', 'gui'};
- [ EEG, com ] = eeg_eval( 'pop_creabasiceventlist', EEG, 'warning', 'on', 'params', options1);
- return;
+ options1 = {'Eventlist', p.Results.Eventlist, 'BoundaryString', p.Results.BoundaryString,...
+ 'BoundaryNumeric', p.Results.BoundaryNumeric,'Warning', p.Results.Warning,...
+ 'AlphanumericCleaning', p.Results.AlphanumericCleaning, 'History', 'gui'};
+ [ EEG, com ] = eeg_eval( 'pop_creabasiceventlist', EEG, 'warning', 'on', 'params', options1);
+ return;
end
%
@@ -225,108 +225,108 @@
auxEvent = EEG.event;
if isfield(EEG, 'EVENTLIST')
- auxEVENTLIST = EEG.EVENTLIST; % keep old EVENTLIST just in case
- if rwwarn
- if isfield(EEG.EVENTLIST, 'eventinfo')
- if ~isempty(EEG.EVENTLIST.eventinfo)
- if nargin==1
- question = ['dataset %s already has attached an EVENTLIST structure.\n'...
- 'So, pop_creabasiceventlist() will totally overwrite it.\n'...
- 'Do you want to continue anyway?'];
- title = 'ERPLAB: binoperator, Overwriting Confirmation';
- button = askquest(sprintf(question, EEG.setname), title);
-
- if ~strcmpi(button,'yes')
- disp('User selected Cancel')
- return
- end
- else
- fprintf('\n\nWARNING: Previous EVENTLIST structure will be overwritten.\n\n')
- end
- %if ischar(EEG.event(1).type)
- % [ EEG.event.type ] = EEG.EVENTLIST.eventinfo.code;
- %end
- EEG.EVENTLIST = [];
- end
+ auxEVENTLIST = EEG.EVENTLIST; % keep old EVENTLIST just in case
+ if rwwarn
+ if isfield(EEG.EVENTLIST, 'eventinfo')
+ if ~isempty(EEG.EVENTLIST.eventinfo)
+ if nargin==1
+ question = ['dataset %s already has attached an EVENTLIST structure.\n'...
+ 'So, pop_creabasiceventlist() will totally overwrite it.\n'...
+ 'Do you want to continue anyway?'];
+ title = 'ERPLAB: binoperator, Overwriting Confirmation';
+ button = askquest(sprintf(question, EEG.setname), title);
+
+ if ~strcmpi(button,'yes')
+ disp('User selected Cancel')
+ return
+ end
+ else
+ fprintf('\n\nWARNING: Previous EVENTLIST structure will be overwritten.\n\n')
end
+ %if ischar(EEG.event(1).type)
+ % [ EEG.event.type ] = EEG.EVENTLIST.eventinfo.code;
+ %end
+ EEG.EVENTLIST = [];
+ end
end
+ end
else
- auxEVENTLIST = 'none';
+ auxEVENTLIST = 'none';
end
field2del = {'bepoch','bini','binlabel', 'code', 'codelabel','enable','flag','item'};
tf = ismember_bc2(field2del,fieldnames(EEG.event)');
if rwwarn && nnz(tf)>0
- question = ['The EEG.event field of %s contains subfield name(s) reserved for ERPLAB.\n\n'...
- 'What would you like to do?\n\n'];
-
- BackERPLABcolor = [1 0.9 0.3]; % yellow
- title = 'ERPLAB: pop_creabasiceventlist, Overwriting Confirmation';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(sprintf(question, EEG.setname), title,'Cancel','Overwrite them', 'Continue as it is', 'Overwrite them');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor)
-
- if strcmpi(button,'Continue as it is')
- fprintf('|WARNING: Fields found in EEG.event that has ERPLAB''s reserved names will not be overwritten.\n\n');
- elseif strcmpi(button,'Cancel') || strcmpi(button,'')
- return
- elseif strcmpi(button,'Overwrite them')
- %bepoch bini binlabel codelabel duration enable flag item latency type urevent
- EEG.event = rmfield(EEG.event, field2del(tf));
- fprintf('|WARNING: Fields found in EEG.event that has ERPLAB''s reserved names were overwritten.\n\n')
- end
+ question = ['The EEG.event field of %s contains subfield name(s) reserved for ERPLAB.\n\n'...
+ 'What would you like to do?\n\n'];
+
+ BackERPLABcolor = [1 0.9 0.3]; % yellow
+ title = 'ERPLAB: pop_creabasiceventlist, Overwriting Confirmation';
+ oldcolor = get(0,'DefaultUicontrolBackgroundColor');
+ set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
+ button = questdlg(sprintf(question, EEG.setname), title,'Cancel','Overwrite them', 'Continue as it is', 'Overwrite them');
+ set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+
+ if strcmpi(button,'Continue as it is')
+ fprintf('|WARNING: Fields found in EEG.event that has ERPLAB''s reserved names will not be overwritten.\n\n');
+ elseif strcmpi(button,'Cancel') || strcmpi(button,'')
+ return
+ elseif strcmpi(button,'Overwrite them')
+ %bepoch bini binlabel codelabel duration enable flag item latency type urevent
+ EEG.event = rmfield(EEG.event, field2del(tf));
+ fprintf('|WARNING: Fields found in EEG.event that has ERPLAB''s reserved names were overwritten.\n\n')
+ end
end
if alphanum==1
- alphanstr = 'on';
+ alphanstr = 'on';
else
- alphanstr = 'off';
+ alphanstr = 'off';
end
% Warning
if rwwarn==0
- striswarning = 'off';
+ striswarning = 'off';
else
- striswarning = 'on';
+ striswarning = 'on';
end
% Send EVENTLIST to...
if strcmp(elname,'') || strcmp(elname,'no') || strcmp(elname,'none')
- stroption2do = 'EEG';
+ stroption2do = 'EEG';
else
- stroption2do = 'EEG&Text';
+ stroption2do = 'EEG&Text';
end
EEG = pop_editeventlist(EEG, 'SendEL2', stroption2do, 'ExportEL', elname,...
- 'BoundaryString', boundarystrcode,'BoundaryNumeric', newboundarynumcode, 'Warning', striswarning,...
- 'AlphanumericCleaning', alphanstr, 'History', 'off');
+ 'BoundaryString', boundarystrcode,'BoundaryNumeric', newboundarynumcode, 'Warning', striswarning,...
+ 'AlphanumericCleaning', alphanstr, 'History', 'off');
EEG = pop_overwritevent(EEG, 'code', 'History', 'off');
if rwwarn
- if ~all(cellfun(@isnumeric, { EEG.event.type }))
- msgboxText = ['Some or all of your events still contain a text-based event label, '...
- 'and not a numeric event code.\n\nERPLAB must have a numeric code '...
- 'for every event (a text label can also be present). For labels such as "S14", '...
- 'you can automatically create an equivalent numeric event code (e.g., 14) by '...
- 'checking the box labeled "Create numeric equivalents of nonnumeric event codes '...
- 'when possible" when creating the EventList.\n\nFor labels that cannot be automatically '...
- 'converted (e.g., "RESP"), or for ambiguous cases (e.g., when you have both "S14" and '...
- '"R14"), you can flexibly create numeric versions using the Advanced button at EVENTLIST GUI.\n\n'...
- 'Would you like to continue anyway?'];
- title_msg = 'ERPLAB: Warning';
- button = askquest(sprintf(msgboxText), title_msg);
-
- if ~strcmpi(button,'yes')
- if isempty(auxEVENTLIST) || isstruct(auxEVENTLIST)
- EEG.EVENTLIST = auxEVENTLIST;
- else
- EEG = rmfield(EEG, 'EVENTLIST');
- end
- EEG.event = auxEvent;
- disp('User selected Cancel')
- return
- end
+ if ~all(cellfun(@isnumeric, { EEG.event.type }))
+ msgboxText = ['Some or all of your events still contain a text-based event label, '...
+ 'and not a numeric event code.\n\nERPLAB must have a numeric code '...
+ 'for every event (a text label can also be present). For labels such as "S14", '...
+ 'you can automatically create an equivalent numeric event code (e.g., 14) by '...
+ 'checking the box labeled "Create numeric equivalents of nonnumeric event codes '...
+ 'when possible" when creating the EventList.\n\nFor labels that cannot be automatically '...
+ 'converted (e.g., "RESP"), or for ambiguous cases (e.g., when you have both "S14" and '...
+ '"R14"), you can flexibly create numeric versions using the Advanced button at EVENTLIST GUI.\n\n'...
+ 'Would you like to continue anyway?'];
+ title_msg = 'ERPLAB: Warning';
+ button = askquest(sprintf(msgboxText), title_msg);
+
+ if ~strcmpi(button,'yes')
+ if isempty(auxEVENTLIST) || isstruct(auxEVENTLIST)
+ EEG.EVENTLIST = auxEVENTLIST;
+ else
+ EEG = rmfield(EEG, 'EVENTLIST');
+ end
+ EEG.event = auxEvent;
+ disp('User selected Cancel')
+ return
end
+ end
end
%
@@ -336,56 +336,56 @@
fn = fieldnames(p.Results);
com = sprintf( '%s = pop_creabasiceventlist( %s ', inputname(1), inputname(1));
for q=1:length(fn)
- fn2com = fn{q}; % get fieldname
- if ~ismember_bc2(fn2com, skipfields)
- fn2res = p.Results.(fn2com); % get content of current field
- if ~isempty(fn2res)
- if iscell(fn2res)
- com = sprintf( '%s, ''%s'', {', com, fn2com);
- for c=1:length(fn2res)
- getcont = fn2res{c};
- if ischar(getcont)
- fnformat = '''%s''';
- else
- fnformat = '%s';
- getcont = num2str(getcont);
- end
- com = sprintf( [ '%s ' fnformat], com, getcont);
- end
- com = sprintf( '%s }', com);
- else
- if ischar(fn2res)
- if ~strcmpi(fn2res,'off')
- com = sprintf( '%s, ''%s'', ''%s''', com, fn2com, fn2res);
- end
- else
- %if iscell(fn2res)
- % fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
- % fnformat = '{%s}';
- %else
- fn2resstr = vect2colon(fn2res, 'Sort','on');
- fnformat = '%s';
- %end
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- end
+ fn2com = fn{q}; % get fieldname
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com); % get content of current field
+ if ~isempty(fn2res)
+ if iscell(fn2res)
+ com = sprintf( '%s, ''%s'', {', com, fn2com);
+ for c=1:length(fn2res)
+ getcont = fn2res{c};
+ if ischar(getcont)
+ fnformat = '''%s''';
+ else
+ fnformat = '%s';
+ getcont = num2str(getcont);
+ end
+ com = sprintf( [ '%s ' fnformat], com, getcont);
+ end
+ com = sprintf( '%s }', com);
+ else
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ com = sprintf( '%s, ''%s'', ''%s''', com, fn2com, fn2res);
+ end
+ else
+ %if iscell(fn2res)
+ % fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ % fnformat = '{%s}';
+ %else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
+ %end
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
end
+ end
end
+ end
end
com = sprintf( '%s );', com);
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- otherwise %off or none
- com = '';
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ otherwise %off or none
+ com = '';
end
@@ -395,6 +395,6 @@
prefunc = dbstack;
nf = length(unique_bc2({prefunc.name}));
if nf==1
- msg2end
+ msg2end
end
return
\ No newline at end of file
diff --git a/pop_functions/pop_currentsourcedensity.m b/pop_functions/pop_currentsourcedensity.m
index 40f26ef5..1c4a327a 100755
--- a/pop_functions/pop_currentsourcedensity.m
+++ b/pop_functions/pop_currentsourcedensity.m
@@ -49,6 +49,11 @@
else
isERP = 0;
end
+try
+ ERPtooltype = varargin{1};%%GH 2024
+catch
+ ERPtooltype = 'erplab';
+end
% check input dataset
try
@@ -124,15 +129,19 @@
MapMontage(M)
%%%changed by Guanghui August 10 2022
-csd_param = erpworkingmemory('csd_param');
-ERPtooltype = erpgettoolversion('tooltype');
if strcmpi(ERPtooltype,'EStudio')
+ csd_param = estudioworkingmemory('csd_param');
+ if isempty(csd_param)
+ csd_param = [4,0.00001,10,1];
+ estudioworkingmemory('csd_param',csd_param);
+ end
csd_param(4) = 0;
erpworkingmemory('csd_param',csd_param);
csd_param = csd_param(1:3);
savepref=0;
else
+ csd_param = erpworkingmemory('csd_param');
[csd_param] = csd_generate;
csd_param(4) = 1;
erpworkingmemory('csd_param',csd_param);
@@ -218,9 +227,15 @@
erpcom = 'pop_currentsourcedensity(EEG)';
end
+
+else%%GH Mar. 2024
+ if isERP
+ EEG.bindata = csd_data;
+ erpcom = sprintf('%s=pop_currentsourcedensity(%s, %s);', 'ERP','ERP', ['"',varargin{1},'"']);
+ else
+ EEG.data = csd_data;
+ erpcom = sprintf('%s=pop_currentsourcedensity(%s, %s);', 'EEG','EEG', ['"',varargin{1},'"']);
+ end
end
-
-
-%eeglab redraw
-
+%eeglab redraw
\ No newline at end of file
diff --git a/pop_functions/pop_deleterpset.m b/pop_functions/pop_deleterpset.m
index 20bbf243..81fe343f 100755
--- a/pop_functions/pop_deleterpset.m
+++ b/pop_functions/pop_deleterpset.m
@@ -27,65 +27,65 @@
function [ALLERP, erpcom] = pop_deleterpset(ALLERP, varargin)
erpcom = '';
if nargin<1
- help pop_deleterpset
+ help pop_deleterpset
end
if nargin==1
- try
- CURRENTERP = evalin('base', 'CURRENTERP');
- catch
- CURRENTERP = 0;
- end
- if CURRENTERP == 0
- msgboxText = 'ERPsets menu is already empty...';
- title = 'ERPLAB: no erpset(s)';
- errorfound(msgboxText, title);
- return
- end
-
- prompt = {'Erpset(s) to clear:'};
- dlg_title = 'Delete erpset(s)';
- num_lines = 1;
- def = {num2str(CURRENTERP)}; %01-13-2009
-
- %
- % open window
- %
- answer = inputvalue(prompt,dlg_title,num_lines,def);
-
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
-
- erpindex = str2num(answer{1});
- nerpset = length(ALLERP);
- erpindex = unique_bc2(erpindex);
-
- if isempty(erpindex)
- msgboxText = 'Wrong erpset index(es)';
- title = 'ERPLAB: unrecognizable erpset(s)';
- errorfound(msgboxText, title);
- return
- end
- if max(erpindex)>nerpset || min(erpindex)<1
- erpm = findobj('tag', 'linerp');
- nerpmenu = length(erpm);
- if max(erpindex)<=nerpmenu && nerpmenu>=1 && max(erpindex)>=1
- %...
- else
- msgboxText = ['Wrong erpset index(es)\n'...
- 'Check your erpset menu or write length(ALLERP) at command window for comprobation'];
- title = 'ERPLAB: pop_deleterpset not existing erpset(s)';
- errorfound(sprintf(msgboxText), title);
- return
- end
- end
-
- %
- % Somersault
- %
- [ALLERP, erpcom] = pop_deleterpset(ALLERP, 'Erpsets', erpindex, 'Saveas', 'on','History', 'gui');
+ try
+ CURRENTERP = evalin('base', 'CURRENTERP');
+ catch
+ CURRENTERP = 0;
+ end
+ if CURRENTERP == 0
+ msgboxText = 'ERPsets menu is already empty...';
+ title = 'ERPLAB: no erpset(s)';
+ errorfound(msgboxText, title);
return
+ end
+
+ prompt = {'Erpset(s) to clear:'};
+ dlg_title = 'Delete erpset(s)';
+ num_lines = 1;
+ def = {num2str(CURRENTERP)}; %01-13-2009
+
+ %
+ % open window
+ %
+ answer = inputvalue(prompt,dlg_title,num_lines,def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ erpindex = str2num(answer{1});
+ nerpset = length(ALLERP);
+ erpindex = unique_bc2(erpindex);
+
+ if isempty(erpindex)
+ msgboxText = 'Wrong erpset index(es)';
+ title = 'ERPLAB: unrecognizable erpset(s)';
+ errorfound(msgboxText, title);
+ return
+ end
+ if max(erpindex)>nerpset || min(erpindex)<1
+ erpm = findobj('tag', 'linerp');
+ nerpmenu = length(erpm);
+ if max(erpindex)<=nerpmenu && nerpmenu>=1 && max(erpindex)>=1
+ %...
+ else
+ msgboxText = ['Wrong erpset index(es)\n'...
+ 'Check your erpset menu or write length(ALLERP) at command window for comprobation'];
+ title = 'ERPLAB: pop_deleterpset not existing erpset(s)';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ end
+
+ %
+ % Somersault
+ %
+ [ALLERP, erpcom] = pop_deleterpset(ALLERP, 'Erpsets', erpindex, 'Saveas', 'on','History', 'gui');
+ return
end
%
@@ -105,45 +105,45 @@
erpindex = p.Results.Erpsets;
if strcmpi(p.Results.Warning,'on')
- warnop = 1;
+ warnop = 1;
else
- warnop = 0;
+ warnop = 0;
end
if ismember_bc2({p.Results.Saveas}, {'on','yes'})
- issaveas = 1;
+ issaveas = 1;
else
- issaveas = 0;
+ issaveas = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
nerpset = length(ALLERP);
erpindex = unique_bc2(erpindex);
if isempty(erpindex)
- msgboxText = 'Wrong erpset index(es)';
- error(['ERPLAB says: ' msgboxText])
+ msgboxText = 'Wrong erpset index(es)';
+ error(['ERPLAB says: ' msgboxText])
end
if max(erpindex)>nerpset || min(erpindex)<1
- msgboxText = 'Wrong erpset index(es)';
- error(['ERPLAB says: ' msgboxText])
+ msgboxText = 'Wrong erpset index(es)';
+ error(['ERPLAB says: ' msgboxText])
end
detect = ~ismember_bc2(1:nerpset,erpindex);
newindex = find(detect);
if isempty(newindex)
- ALLERP = [];
+ ALLERP = [];
else
- ALLERP = ALLERP(newindex);
+ ALLERP = ALLERP(newindex);
end
if issaveas
- updatemenuerp(ALLERP, -1)
- assignin('base','ALLERP',ALLERP); % save to workspace. Dec 5, 2012
+ updatemenuerp(ALLERP, -1)
+ assignin('base','ALLERP',ALLERP); % save to workspace. Dec 5, 2012
end
% erpcom = sprintf('ALLERP = pop_deleterpset( ALLERP, [%s]);', num2str(erpindex));
%
@@ -153,61 +153,64 @@
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
+ 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(ALLERP)
- ALLERP(i) = erphistory(ALLERP(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 = '';
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ for i=1:length(ALLERP)
+ ALLERP(i) = erphistory(ALLERP(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
+ERPtooltype = erpgettoolversion('tooltype');
+if ~strcmpi(ERPtooltype,'EStudio')
+ eeglab redraw
+end
return
diff --git a/pop_functions/pop_eeglindetrend.m b/pop_functions/pop_eeglindetrend.m
index b93f1ba4..f174f0b0 100755
--- a/pop_functions/pop_eeglindetrend.m
+++ b/pop_functions/pop_eeglindetrend.m
@@ -2,7 +2,7 @@
%
% FORMAT :
%
-% >> EEG = pop_eeglindetrend( EEG, detwindow );
+% >> EEG = pop_eeglindetrend( EEG, 'Baseline',detwindow );
%
%
% INPUTS :
@@ -17,8 +17,8 @@
%
% EXAMPLE :
%
-% EEG = pop_eeglindetrend( EEG, 'pre');
-% EEG = pop_eeglindetrend( EEG, [-300 100]);
+% EEG = pop_eeglindetrend( EEG, 'Baseline','pre');
+% EEG = pop_eeglindetrend( EEG, 'Baseline', [-300 100]);
%
%
% See also blcerpGUI.m lindetrend.m
@@ -51,65 +51,70 @@
% You should have received a copy of the GNU General Public License
% along with this program. If not, see .
-function [EEG, com] = pop_eeglindetrend( EEG, detwindow, varargin)
+function [EEG, com] = pop_eeglindetrend( EEG, varargin)
com = '';
if nargin < 1
- help pop_lindetrend
- return
+ help pop_lindetrend
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- if isempty(EEG(1).data)
- msgboxText = 'pop_lindetrend() cannot read an empty dataset!';
- title = 'ERPLAB: pop_lindetrend error';
- errorfound(msgboxText, title);
- return
- end
- if isempty(EEG(1).epoch)
- msgboxText = 'pop_lindetrend has been tested for epoched data only';
- title = 'ERPLAB: pop_lindetrend error';
- errorfound(msgboxText, title);
- return
- end
-
- def = erpworkingmemory('pop_eeglindetrend');
- if isempty(def)
- def = 'pre';
- end
-
- %
- % Call GUI
- %
- titlegui = 'Linear Detrend';
- answer = blcerpGUI(EEG(1), titlegui, def); % open GUI
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
- detwindow = answer{1};
- if ischar(detwindow) && strcmpi(detwindow, 'none')
- disp('User selected Cancel')
- return
- end
- if isempty(detwindow)
- disp('User selected Cancel')
- return
- end
-
- erpworkingmemory('pop_eeglindetrend', detwindow);
-
- if length(EEG)==1
- EEG.setname = [EEG.setname '_ld']; % suggested name (si queris no mas!)
- end
- %
- % Somersault
- %
- wchmsgonstr ='off'; %temporary
- [EEG, com] = pop_eeglindetrend( EEG, detwindow, 'Warning', wchmsgonstr, 'History', 'gui');
+ if isempty(EEG(1).data)
+ msgboxText = 'pop_lindetrend() cannot read an empty dataset!';
+ title = 'ERPLAB: pop_lindetrend error';
+ errorfound(msgboxText, title);
return
+ end
+ if isempty(EEG(1).epoch)
+ msgboxText = 'pop_lindetrend has been tested for epoched data only';
+ title = 'ERPLAB: pop_lindetrend error';
+ errorfound(msgboxText, title);
+ return
+ end
+
+ def = erpworkingmemory('pop_eeglindetrend');
+ if isempty(def)
+ def = 'pre';
+ end
+
+ %
+ % Call GUI
+ %
+ titlegui = 'Linear Detrend';
+ answer = blcerpGUI(EEG(1), titlegui, def); % open GUI
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+ detwindow = answer{1};
+ if ischar(detwindow) && strcmpi(detwindow, 'none')
+ disp('User selected Cancel')
+ return
+ end
+ if isempty(detwindow)
+ disp('User selected Cancel')
+ return
+ end
+
+ erpworkingmemory('pop_eeglindetrend', detwindow);
+
+ if length(EEG)==1
+ EEG.setname = [EEG.setname '_ld']; % suggested name (si queris no mas!)
+ end
+
+ ChanArray = answer{2};
+
+
+ %
+ % Somersault
+ %
+ wchmsgonstr ='off'; %temporary
+ [EEG, com] = pop_eeglindetrend( EEG, 'Baseline', detwindow,'ChanArray',ChanArray,...
+ 'Warning', wchmsgonstr, 'History', 'gui');
+ return
end
%
@@ -119,116 +124,135 @@
p.FunctionName = mfilename;
p.CaseSensitive = false;
p.addRequired('EEG');
-p.addRequired('detwindow');
% option(s)
+p.addParamValue('Baseline', 'pre');
p.addParamValue('Warning', 'off', @ischar);
+p.addParamValue('ChanArray', [], @isnumeric); % 'on', 'off'
p.addParamValue('History', 'script', @ischar); % history from scripting
-p.parse(EEG, detwindow, varargin{:});
+p.parse(EEG, varargin{:});
if strcmpi(p.Results.Warning,'on')
- wchmsgon = 1;
+ wchmsgon = 1;
else
- wchmsgon = 0;
+ wchmsgon = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
+ChanArray = p.Results.ChanArray;
+if isempty(ChanArray) || any(ChanArray(:)>EEG.nbchan) || any(ChanArray(:)<1)
+ ChanArray = [1:EEG.nbchan];
+end
+
+detwindow = p.Results.Baseline;
% in case of an error
-if ischar(detwindow) && ~strcmpi(detwindow,'all') && ~strcmpi(detwindow,'pre') && ~strcmpi(detwindow,'post')
- internum = str2num(detwindow);
- if length(internum)~=2
- msgboxText = ['Unappropriated time range for detrending\n'...
- 'lindetrend() was ended.\n'];
- if shist == 1; % gui
- title = 'ERPLAB: pop_eeglindetrend() error';
- errorfound(sprintf(msgboxText), title);
- return
- else
- error('prog:input', msgboxText)
- end
+if ischar(detwindow) && ~strcmpi(detwindow,'all') && ~strcmpi(detwindow,'pre') && ~strcmpi(detwindow,'post') && ~strcmpi(detwindow,'none')
+ internum = str2num(detwindow);
+ if length(internum)~=2
+ msgboxText = ['Unappropriated time range for detrending\n'...
+ 'lindetrend() was ended.\n'];
+ if shist == 1; % gui
+ title = 'ERPLAB: pop_eeglindetrend() error';
+ errorfound(sprintf(msgboxText), title);
+ return
+ else
+ error('prog:input', msgboxText)
end
+ end
end
%
% process multiple datasets. Updated August 23, 2013 JLC
%
-options1 = {detwindow, 'Warning', p.Results.Warning, 'History', 'gui'};
+options1 = {'Baseline',detwindow,'ChanArray',ChanArray, 'Warning', p.Results.Warning, 'History', 'gui'};
+EEGaux = EEG;
+ChanArrayleft = setdiff([1:EEG.nbchan],ChanArray);
if length(EEG) > 1
- [ EEG, com ] = eeg_eval( 'pop_eeglindetrend', EEG, 'warning', 'on', 'params', options1);
- return;
+ [ EEG, com ] = eeg_eval( 'pop_eeglindetrend', EEG, 'warning', 'on', 'params', options1);
+ if ~isempty(ChanArrayleft)
+ if length(EEG) > 1
+ for Numofeeg = 1:length(EEG)
+ EEG(Numofeeg).data(ChanArrayleft,:,:) = EEGaux(Numofeeg).data(ChanArrayleft,:,:);
+ end
+ end
+ end
+ return;
end;
+
+
%
% subroutine
%
EEG = lindetrend( EEG, detwindow);
+if ~isempty(ChanArrayleft)
+ EEG.data(ChanArrayleft,:,:) = EEGaux.data(ChanArrayleft,:,:);
+end
+
+
% com = sprintf( '%s = pop_eeglindetrend( %s, ''%s'' );', inputname(1), inputname(1), detwindow);
%
% History
%
-skipfields = {'EEG', 'detwindow','Saveas','History'};
+skipfields = {'EEG','Saveas','History'};
fn = fieldnames(p.Results);
-if isnumeric(detwindow)
- dtwin = vect2colon(detwindow);
-else
- dtwin = ['''' detwindow ''''];
-end
-com = sprintf('%s = pop_eeglindetrend( %s, %s', inputname(1), inputname(1), dtwin);
-
+
+com = sprintf('%s = pop_eeglindetrend( %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')
- com = sprintf( '%s, ''%s'', ''%s''', com, 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
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- else
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- end
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ com = sprintf( '%s, ''%s'', ''%s''', com, 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
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
+ end
+ else
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
end
+ end
end
+ end
end
com = sprintf( '%s );', com);
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- otherwise %off or none
- com = '';
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ otherwise %off or none
+ com = '';
end
%
diff --git a/pop_functions/pop_eegtrim.m b/pop_functions/pop_eegtrim.m
index cdf8e9ed..b5c2fa30 100755
--- a/pop_functions/pop_eegtrim.m
+++ b/pop_functions/pop_eegtrim.m
@@ -4,18 +4,18 @@
%
% FORMAT:
% EEG = pop_eegtrim(EEG, pre, post)
-%
+%
% INPUT
%
% EEG - input dataset
% pre - pre-stimulation window in ms (time left before the first event)
% post - post-stimulation window in ms (time left after the last event)
-%
-%
+%
+%
% OUTPUT
%
% EEG - trimmed continuous dataset ()
-%
+%
% Author: Javier Lopez-Calderon & Johanna Kreither
% Center for Mind and Brain
% University of California, Davis,
@@ -25,39 +25,39 @@
function [EEG, com] = pop_eegtrim(EEG, pre, post, varargin)
com = '';
if nargin<1
- help pop_eegtrim
- return
+ help pop_eegtrim
+ return
end
if nargin==1
- serror = erplab_eegscanner(EEG, 'pop_creabasiceventlist', 2, 0, 0, 2, 2); % check for continuous dataset
- if serror
- return
- end
- def = erpworkingmemory('pop_eegtrim');
-
- %
- % Call GUI
- %
- answer = gui_eegtrim(def);
-
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
-
- pre = answer{1};
- post = answer{2};
-
- erpworkingmemory('pop_eegtrim', {answer{1} answer{2}});
- if length(EEG)==1
- EEG.setname = [EEG.setname '_trim']; %suggest a new name
- end
-
- %
- % Somersault
- %
- [EEG, com] = pop_eegtrim(EEG, pre, post, 'History', 'gui');
- return
+ serror = erplab_eegscanner(EEG, 'pop_creabasiceventlist', 2, 0, 0, 2, 2); % check for continuous dataset
+ if serror
+ return
+ end
+ def = erpworkingmemory('pop_eegtrim');
+
+ %
+ % Call GUI
+ %
+ answer = gui_eegtrim(def);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ pre = answer{1};
+ post = answer{2};
+
+ erpworkingmemory('pop_eegtrim', {answer{1} answer{2}});
+ if length(EEG)==1
+ EEG.setname = [EEG.setname '_trim']; %suggest a new name
+ end
+
+ %
+ % Somersault
+ %
+ [EEG, com] = pop_eegtrim(EEG, pre, post, 'History', 'gui');
+ return
end
%
@@ -74,22 +74,22 @@
p.parse(EEG, pre, post, varargin{:});
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
t1 = EEG.event(1).latency;
if t1<=2
- t1 = EEG.event(2).latency;
+ t1 = EEG.event(2).latency;
end
t2 = EEG.event(end).latency;
if t2>=EEG.pnts-2
- t2 = EEG.event(end-1).latency;
+ t2 = EEG.event(end-1).latency;
end
pnts = EEG.pnts;
fs = EEG.srate;
@@ -101,55 +101,55 @@
post2 = pnts;
if pre2<1
- error('There is not enough samples to keep the pre-stimulation window.')
+ error('There is not enough samples to keep the pre-stimulation window.')
end
if post1>pnts
- error('There is not enough samples to keep the post-stimulation window.')
+ error('There is not enough samples to keep the post-stimulation window.')
end
% trimming
disp('Trimming data...')
EEG = eeg_eegrej( EEG, [pre1 pre2;post1 post2]);
-skipfields = {'EEG', 'History'};
+skipfields = {'EEG', 'History','pre','post'};%%GH Mar. 2024
fn = fieldnames(p.Results);
com = sprintf( '%s = pop_eegtrim( %s, %g, %g ', inputname(1), inputname(1), pre, post);
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')
- com = sprintf( '%s, ''%s'', ''%s''', com, fn2com, fn2res);
- end
- else
- if iscell(fn2res)
- fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
- fnformat = '{%s}';
- else
- fn2resstr = vect2colon(fn2res, 'Sort','on');
- fnformat = '%s';
- end
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ com = sprintf( '%s, ''%s'', ''%s''', com, fn2com, fn2res);
+ end
+ else
+ if iscell(fn2res)
+ fn2resstr = vect2colon(cell2mat(fn2res), 'Sort','on');
+ fnformat = '{%s}';
+ else
+ fn2resstr = vect2colon(fn2res, 'Sort','on');
+ fnformat = '%s';
end
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
+ end
end
+ end
end
com = sprintf( '%s );', com);
% get history from script
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- otherwise %off or none
- com = '';
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ otherwise %off or none
+ com = '';
end
%
diff --git a/pop_functions/pop_epoch2continuous.m b/pop_functions/pop_epoch2continuous.m
old mode 100644
new mode 100755
index a24bd5b3..f6ac5170
--- a/pop_functions/pop_epoch2continuous.m
+++ b/pop_functions/pop_epoch2continuous.m
@@ -158,8 +158,7 @@
end
-% com = sprintf('%s = pop_epoch2continuous(%s);', inputname(1), inputname(1));
-com = sprintf( '%s = pop_bdfrecovery( %s ', inputname(1), inputname(1) );
+com = sprintf( '%s = pop_epoch2continuous( %s ', inputname(1), inputname(1) );
skipfields = {'History'};
fn = fieldnames(p.Results);
for q=1:length(fn)
diff --git a/pop_functions/pop_eraseventcodes.m b/pop_functions/pop_eraseventcodes.m
index 5e313d8d..42a8914e 100755
--- a/pop_functions/pop_eraseventcodes.m
+++ b/pop_functions/pop_eraseventcodes.m
@@ -95,7 +95,7 @@
errorfound(sprintf(msgboxText), title);
return
end
- prompt = {'expression (>, < ==, ~=):'};
+ prompt = {'expression (>, <, ==, ~=):'};
dlg_title = 'Input event-code condition to delete';
num_lines = 1;
def = erpworkingmemory('pop_eraseventcodes');
diff --git a/pop_functions/pop_erplindetrend.m b/pop_functions/pop_erplindetrend.m
index 706a7b60..6f233000 100755
--- a/pop_functions/pop_erplindetrend.m
+++ b/pop_functions/pop_erplindetrend.m
@@ -2,7 +2,7 @@
%
% FORMAT :
%
-% ERP = pop_erplindetrend( ERP, detwindow );
+% ERP = pop_erplindetrend( ERP,'Baseline', detwindow );
%
% INPUTS :
%
@@ -16,9 +16,9 @@
%
%
% EXAMPLE :
-% ERP = pop_erplindetrend( ERP, 'post');
-% ERP = pop_erplindetrend( ERP, '0 798');
-% ERP = pop_erplindetrend( ERP, [0 798]);
+% ERP = pop_erplindetrend( ERP, 'Baseline', 'post');
+% ERP = pop_erplindetrend( ERP,'Baseline', '0 798');
+% ERP = pop_erplindetrend( ERP, 'Baseline', [0 798]);
%
% See also blcerpGUI.m lindetrend.m
%
@@ -51,55 +51,57 @@
% You should have received a copy of the GNU General Public License
% along with this program. If not, see .
-function [ERP, erpcom] = pop_erplindetrend( ERP, detwindow, varargin)
+function [ERP, erpcom] = pop_erplindetrend( ERP, varargin)
erpcom = '';
if nargin < 1
- help pop_erplindetrend
- return
+ help pop_erplindetrend
+ return
end
if isfield(ERP(1), 'datatype')
- datatype = ERP.datatype;
+ datatype = ERP.datatype;
else
- datatype = 'ERP';
+ datatype = 'ERP';
end
if nargin==1
- title_msg = 'ERPLAB: pop_erplindetrend() error:';
- if isempty(ERP)
- ERP = preloadERP;
- if isempty(ERP)
- msgboxText = 'No ERPset was found!';
-
- errorfound(msgboxText, title_msg);
- return
- end
- end
- if ~strcmpi(datatype, 'ERP')
- msgboxText = 'Cannot detrend Power Spectrum waveforms. Sorry';
+ title_msg = 'ERPLAB: pop_erplindetrend() error:';
+ if isempty(ERP)
+ ERP = preloadERP;
+ if isempty(ERP)
+ msgboxText = 'No ERPset was found!';
+
errorfound(msgboxText, title_msg);
return
- end
- def = erpworkingmemory('pop_erplindetrend');
- if isempty(def)
- def = {'pre'};
- end
-
- %
- % Call GUI
- %
- titlegui = 'Linear Detrend';
- answer = blcerpGUI(ERP, titlegui, def);
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
- detwindow = answer{1};
- erpworkingmemory('pop_erplindetrend', detwindow);
-
- %
- % Somersault
- %
- [ERP, erpcom] = pop_erplindetrend(ERP, detwindow, 'Warning', 'on', 'Saveas', 'on','ErrorMsg', 'popup', 'History', 'gui');
- return
+ end
+ end
+ if ~strcmpi(datatype, 'ERP')
+ msgboxText = 'Cannot detrend Power Spectrum waveforms. Sorry';
+ errorfound(msgboxText, title_msg);
+ return
+ end
+ def = erpworkingmemory('pop_erplindetrend');
+ if isempty(def)
+ def = {'pre'};
+ end
+
+ %
+ % Call GUI
+ %
+ titlegui = 'Linear Detrend';
+ answer = blcerpGUI(ERP, titlegui, def);
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+ detwindow = answer{1};
+ erpworkingmemory('pop_erplindetrend', detwindow);
+ ChanArray = answer{2};
+ BinArray = answer{3};
+ %
+ % Somersault
+ %
+ [ERP, erpcom] = pop_erplindetrend(ERP,'Baseline', detwindow,'ChanArray',ChanArray,...
+ 'BinArray',BinArray, 'Warning', 'on', 'Saveas', 'on','ErrorMsg', 'popup', 'History', 'gui');
+ return
end
%
@@ -109,60 +111,76 @@
p.FunctionName = mfilename;
p.CaseSensitive = false;
p.addRequired('ERP');
-p.addRequired('detwindow');
% option(s)
+p.addParamValue('Baseline', 'pre');
p.addParamValue('Warning', 'off', @ischar);
+p.addParamValue('ChanArray', [], @isnumeric);
+p.addParamValue('BinArray', [], @isnumeric);
p.addParamValue('Saveas', 'off', @ischar); % 'on', 'off'
p.addParamValue('ErrorMsg', 'cw', @ischar); % cw = command window
p.addParamValue('History', 'script', @ischar); % history from scripting
-p.parse(ERP, detwindow, varargin{:});
+p.parse(ERP, varargin{:});
if strcmpi(p.Results.Warning,'on')
- wchmsgon = 1;
+ wchmsgon = 1;
else
- wchmsgon = 0;
+ wchmsgon = 0;
end
if ismember_bc2({p.Results.Saveas}, {'on','yes'})
- issaveas = 1;
+ issaveas = 1;
else
- issaveas = 0;
+ issaveas = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
if strcmpi(p.Results.ErrorMsg,'popup')
- errormsgtype = 1; % open popup window
+ errormsgtype = 1; % open popup window
else
- errormsgtype = 0; % error in red at command window
+ errormsgtype = 0; % error in red at command window
end
+
+
+ChanArray = p.Results.ChanArray;
+if isempty(ChanArray) || any(ChanArray(:)>ERP.nchan) || any(ChanArray(:)<1)
+ ChanArray = [1:ERP.nchan];
+end
+
+
+BinArray = p.Results.BinArray;
+if isempty(BinArray) || any(BinArray(:)>ERP.nbin) || any(BinArray(:)<1)
+ BinArray = [1:ERP.nbin];
+end
+detwindow = p.Results.Baseline;
+
if ischar(detwindow)
- if ~strcmpi(detwindow,'all') && ~strcmpi(detwindow,'pre') && ~strcmpi(detwindow,'post')
- internum = str2num(detwindow);
- if length(internum)~=2
- msgboxText = 'Wrong interval. Linear detrending will not be performed.';
- title = 'ERPLAB: pop_erplindetrend() error';
- errorfound(msgboxText, title);
- return
- end
- detwindowstr = ['[ ' num2str(internum) ' ]'];
- else
- detwindowstr = ['''' detwindow ''''];
- end
-else
- if length(detwindow)~=2
+ if ~strcmpi(detwindow,'all') && ~strcmpi(detwindow,'pre') && ~strcmpi(detwindow,'post') && ~strcmpi(detwindow,'none')
+ internum = str2num(detwindow);
+ if length(internum)~=2
msgboxText = 'Wrong interval. Linear detrending will not be performed.';
title = 'ERPLAB: pop_erplindetrend() error';
errorfound(msgboxText, title);
return
- end
- detwindowstr = ['[ ' num2str(detwindow) ' ]'];
+ end
+ detwindowstr = ['[ ' num2str(internum) ' ]'];
+ else
+ detwindowstr = ['''' detwindow ''''];
+ end
+else
+ if length(detwindow)~=2
+ msgboxText = 'Wrong interval. Linear detrending will not be performed.';
+ title = 'ERPLAB: pop_erplindetrend() error';
+ errorfound(msgboxText, title);
+ return
+ end
+ detwindowstr = ['[ ' num2str(detwindow) ' ]'];
end
ERPaux = ERP;
@@ -172,42 +190,94 @@
%
ERP = lindetrend( ERP, detwindow);
+
+ChanArrayleft = setdiff([1:ERP.nchan],ChanArray);%% channles are not for baseline correction
+if ~isempty(ChanArrayleft)
+ ERP.bindata(ChanArrayleft,:,:) = ERPaux.bindata(ChanArrayleft,:,:);
+end
+
+
+BinArrayleft = setdiff([1:ERP.nbin],BinArray);%% channles are not for baseline correction
+if ~isempty(BinArrayleft)
+ ERP.bindata(:,:,BinArrayleft) = ERPaux.bindata(:,:,BinArrayleft);
+end
+
+
%
% Completion statement
%
msg2end
ERP.saved = 'no';
-erpcom = sprintf( '%s = pop_erplindetrend( %s, %s );', inputname(1), inputname(1), detwindowstr);
-if issaveas
- [ERP, issave, erpcom_save] = pop_savemyerp(ERP,'gui','erplab', 'History', 'off');
- if issave>0
- if issave==2
- erpcom = sprintf('%s\n%s', erpcom, erpcom_save);
- msgwrng = '*** Your ERPset was saved on your hard drive.***';
- mcolor = [0 0 1];
+
+
+skipfields = {'ERP', 'History'};
+fn = fieldnames(p.Results);
+erpcom = sprintf( '%s = pop_erplindetrend( %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
- msgwrng = '*** Warning: Your ERPset was only saved on the workspace.***';
- mcolor = [1 0.52 0.2];
+ 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
- else
- ERP = ERPaux;
- msgwrng = 'ERPLAB Warning: Your changes were not saved';
- mcolor = [1 0.22 0.2];
- end
- try cprintf(mcolor, '%s\n\n', msgwrng);catch,fprintf('%s\n\n', msgwrng);end ;
+ end
+ end
+end
+erpcom = sprintf( '%s );', erpcom);
+
+
+if issaveas
+ [ERP, issave, erpcom_save] = pop_savemyerp(ERP,'gui','erplab', 'History', 'off');
+ if issave>0
+ if issave==2
+ erpcom = sprintf('%s\n%s', erpcom, erpcom_save);
+ msgwrng = '*** Your ERPset was saved on your hard drive.***';
+ mcolor = [0 0 1];
+ else
+ msgwrng = '*** Warning: Your ERPset was only saved on the workspace.***';
+ mcolor = [1 0.52 0.2];
+ end
+ else
+ ERP = ERPaux;
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ mcolor = [1 0.22 0.2];
+ end
+ try cprintf(mcolor, '%s\n\n', msgwrng);catch,fprintf('%s\n\n', msgwrng);end ;
end
% get history from script. ERP
switch shist
- case 1 % from GUI
- displayEquiComERP(erpcom);
- 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 = '';
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ 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 = '';
end
return
diff --git a/pop_functions/pop_exporteegeventlist.m b/pop_functions/pop_exporteegeventlist.m
index f23745df..d33b244c 100755
--- a/pop_functions/pop_exporteegeventlist.m
+++ b/pop_functions/pop_exporteegeventlist.m
@@ -52,154 +52,156 @@
function [EEG, com] = pop_exporteegeventlist(EEG, varargin)
com = '';
if nargin < 1
- help pop_exporteegeventlist
- return
+ help pop_exporteegeventlist
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if length(EEG)>1
- msgboxText = 'Unfortunately, this function does not work with multiple datasets';
- title = 'ERPLAB: multiple inputs';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'Unfortunately, this function does not work with multiple datasets';
+ title = 'ERPLAB: multiple inputs';
+ errorfound(msgboxText, title);
+ return
end
if nargin==1
- if isempty(EEG)
- msgboxText = 'pop_exporteegeventlist() error: cannot work with an empty dataset!';
- title = 'ERPLAB: No data';
- errorfound(msgboxText, title);
- return
- end
- if isempty(EEG.data)
- msgboxText = 'pop_exporteegeventlist() error: cannot work with an empty dataset!';
- title = 'ERPLAB: No data';
- errorfound(msgboxText, title);
- return
- end
- if isfield(EEG, 'EVENTLIST')
- if isempty(EEG.EVENTLIST)
- msgboxText = ['EEG.EVENTLIST structure is empty.\n\n'...
- 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
- title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
- errorfound(sprintf(msgboxText), title);
- return
- end
- if isfield(EEG.EVENTLIST, 'eventinfo')
- if isempty(EEG.EVENTLIST.eventinfo)
- msgboxText = ['EEG.EVENTLIST.eventinfo structure is empty.\n\n'...
- 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
- title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
- errorfound(sprintf(msgboxText), title);
- return
- end
- else
- msgboxText = ['EEG.EVENTLIST.eventinfo structure is empty.\n\n'...
- 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
- title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
- errorfound(sprintf(msgboxText), title);
- return
- end
- else
- msgboxText = ['EEG.EVENTLIST structure is empty.\n\n'...
- 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
- title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
- errorfound(sprintf(msgboxText), title);
- return
+ if isempty(EEG)
+ msgboxText = 'pop_exporteegeventlist() error: cannot work with an empty dataset!';
+ title = 'ERPLAB: No data';
+ errorfound(msgboxText, title);
+ return
+ end
+ if isempty(EEG.data)
+ msgboxText = 'pop_exporteegeventlist() error: cannot work with an empty dataset!';
+ title = 'ERPLAB: No data';
+ errorfound(msgboxText, title);
+ return
+ end
+ if isfield(EEG, 'EVENTLIST')
+ if isempty(EEG.EVENTLIST)
+ msgboxText = ['EEG.EVENTLIST structure is empty.\n\n'...
+ 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
+ title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
+ errorfound(sprintf(msgboxText), title);
+ return
end
- if ~isfield(EEG.EVENTLIST, 'bdf')
- msgboxText = ['EEG.EVENTLIST.bdf structure is empty.\n\n'...
- 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
+ if isfield(EEG.EVENTLIST, 'eventinfo')
+ if isempty(EEG.EVENTLIST.eventinfo)
+ msgboxText = ['EEG.EVENTLIST.eventinfo structure is empty.\n\n'...
+ 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
errorfound(sprintf(msgboxText), title);
return
+ end
+ else
+ msgboxText = ['EEG.EVENTLIST.eventinfo structure is empty.\n\n'...
+ 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
+ title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
+ errorfound(sprintf(msgboxText), title);
+ return
end
+ else
+ msgboxText = ['EEG.EVENTLIST structure is empty.\n\n'...
+ 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
+ title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ if ~isfield(EEG.EVENTLIST, 'bdf')
+ msgboxText = ['EEG.EVENTLIST.bdf structure is empty.\n\n'...
+ 'Please, use ERPLAB --> EVENTLIST --> Create EEG EventList menu before exporting to text.'];
+ title = 'ERPLAB: pop_exporteegeventlist() error, EVENTLIST structure';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+
+ %
+ % Save OUTPUT file
+ %
+ [fname, pathname,indx] = uiputfile({'*.txt';'*.xls,*.xlsx';'*.*'},'Save EVENTLIST file as');%%GH Mar 2024
+
+ if isequal(fname,0)
+ disp('User selected Cancel')
+ return
+ else
+ [xpath, fname, ext] = fileparts(fname);
- %
- % Save OUTPUT file
- %
- [fname, pathname] = uiputfile({'*.txt';'*.*'},'Save EVENTLIST file as');
-
- if isequal(fname,0)
- disp('User selected Cancel')
- return
+ if indx==2
+ ext = '.xls';
else
- [xpath, fname, ext] = fileparts(fname);
-
- if ~strcmp(ext,'.txt')
- ext = '.txt';
- end
-
- fname = [fname ext];
- elname = fullfile(pathname, fname);
- disp(['For EVENTLIST output user selected ', elname])
+ ext = '.txt';
end
- %
- % Somersault
- %
- [EEG, com] = pop_exporteegeventlist(EEG, 'Filename', elname, 'History', 'gui');
- return
+ fname = [fname ext];
+ elname = fullfile(pathname, fname);
+ disp(['For EVENTLIST output user selected ', elname])
+ end
+
+ %
+ % Somersault
+ %
+ [EEG, com] = pop_exporteegeventlist(EEG, 'Filename', elname, 'History', 'gui');
+ return
end
if nargin==2
- %
- % Parsing inputs (versions<4.0)
- %
- p = inputParser;
- p.FunctionName = mfilename;
- p.CaseSensitive = false;
- p.addRequired('EEG');
- p.addRequired('varargin');
-
- % option(s)
- p.addParamValue('History', 'script', @ischar); % history from scripting
- p.parse(EEG, varargin{:});
- elname = varargin{:};
+ %
+ % Parsing inputs (versions<4.0)
+ %
+ p = inputParser;
+ p.FunctionName = mfilename;
+ p.CaseSensitive = false;
+ p.addRequired('EEG');
+ p.addRequired('varargin');
+
+ % option(s)
+ p.addParamValue('History', 'script', @ischar); % history from scripting
+ p.parse(EEG, varargin{:});
+ elname = varargin{:};
else
- %
- % Parsing inputs
- %
- p = inputParser;
- p.FunctionName = mfilename;
- p.CaseSensitive = false;
- p.addRequired('EEG');
- % option(s)
- p.addParamValue('Filename', '', @ischar); % erpset index or input file
- p.addParamValue('History', 'script', @ischar); % history from scripting
- p.parse(EEG, varargin{:});
- elname = p.Results.Filename;
+ %
+ % Parsing inputs
+ %
+ p = inputParser;
+ p.FunctionName = mfilename;
+ p.CaseSensitive = false;
+ p.addRequired('EEG');
+ % option(s)
+ p.addParamValue('Filename', '', @ischar); % erpset index or input file
+ p.addParamValue('History', 'script', @ischar); % history from scripting
+ p.parse(EEG, varargin{:});
+ elname = p.Results.Filename;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
if isempty(EEG.data)
- error('ERPLAB says: error at pop_exporteegeventlist(). cannot work with an empty dataset!')
+ error('ERPLAB says: error at pop_exporteegeventlist(). cannot work with an empty dataset!')
end
if isfield(EEG, 'EVENTLIST')
- if isempty(EEG.EVENTLIST)
- error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST structure is empty.');
- end
-
- if isfield(EEG.EVENTLIST, 'eventinfo')
- if isempty(EEG.EVENTLIST.eventinfo)
- error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.eventinfo structure is empty.');
- end
- else
- error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.eventinfo structure was not found.');
+ if isempty(EEG.EVENTLIST)
+ error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST structure is empty.');
+ end
+
+ if isfield(EEG.EVENTLIST, 'eventinfo')
+ if isempty(EEG.EVENTLIST.eventinfo)
+ error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.eventinfo structure is empty.');
end
+ else
+ error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.eventinfo structure was not found.');
+ end
else
- error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST structure was not found.');
+ error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST structure was not found.');
end
if ~isfield(EEG.EVENTLIST, 'bdf')
- error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.bdf structure was not found.');
+ error('ERPLAB says: error at pop_exporteegeventlist(). EEG.EVENTLIST.bdf structure was not found.');
end
@@ -208,7 +210,16 @@
%
% subroutine
%
-creaeventlist(EEG, EVENTLIST, elname, 1);
+
+
+%%GH Mar 2024
+[xpath, fname, ext] = fileparts(elname);
+
+if strcmpi(ext,'.txt')
+ creaeventlist(EEG, EVENTLIST, elname, 1);
+else
+ f_creaeventlist_excel(EEG, EVENTLIST, elname, 1);
+end
%
% History
@@ -217,53 +228,53 @@
fn = fieldnames(p.Results);
com = sprintf( '%s = pop_exporteegeventlist( %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')
- com = sprintf( '%s, ''%s'', ''%s''', com, 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
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- else
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- end
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ com = sprintf( '%s, ''%s'', ''%s''', com, 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
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
+ end
+ else
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
end
+ end
end
+ end
end
com = sprintf( '%s );', com);
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- % EEG = erphistory(EEG, [], com, 1);
- % fprintf('%%Equivalent command:\n%s\n\n', com);
- otherwise %off or none
- com = '';
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ % EEG = erphistory(EEG, [], com, 1);
+ % fprintf('%%Equivalent command:\n%s\n\n', com);
+ otherwise %off or none
+ com = '';
end
%
diff --git a/pop_functions/pop_exporterpeventlist.m b/pop_functions/pop_exporterpeventlist.m
index 17972003..a8893b1f 100755
--- a/pop_functions/pop_exporterpeventlist.m
+++ b/pop_functions/pop_exporterpeventlist.m
@@ -204,7 +204,14 @@
%
% subroutine
%
+%%GH Mar 2024
+[xpath, fname, ext] = fileparts(elname);
+
+if strcmpi(ext,'.txt')
exporterpeventlist(ERP, indexel, elname);
+else
+ f_creaeventlist_excel(ERP, ERP.EVENTLIST, elname, 1);
+end
erpcom = sprintf( 'pop_exporterpeventlist(%s, %s, ''%s'');', inputname(1), num2str(indexel), elname);
% get history from script. ERP
switch shist
diff --git a/pop_functions/pop_filterp.m b/pop_functions/pop_filterp.m
index efdad214..17abfe55 100755
--- a/pop_functions/pop_filterp.m
+++ b/pop_functions/pop_filterp.m
@@ -94,13 +94,15 @@
return
end
nchan = ERP.nchan;
- defx = {0 30 2 1:nchan 1 'butter' 0 []};
+ nbin = ERP.nbin;
+ defx = {0 30 2 1:nchan 1 'butter' 0 [],1:nbin};
def = erpworkingmemory('pop_filterp');
if isempty(def)
def = defx;
else
def{4} = def{4}(ismember_bc2(def{4},1:nchan));
+ try def{9} = def{9}(ismember_bc2(def{9},1:nbin)); catch def{9} = 1:nbin; end
end
%
@@ -117,13 +119,11 @@
hicutoff = answer{2}; % for low pass filter
filterorder = answer{3};
chanArray = answer{4};
- filterallch = answer{5};
+% filterallch = answer{5};
fdesign = answer{6};
remove_dc = answer{7};
-
- if filterallch
- chanArray = 1:nchan;
- end
+ binArray = answer{9};
+
erpworkingmemory('pop_filterp', answer(:)');
@@ -155,11 +155,11 @@
else
error('ERPLAB says: Invalid type of filter ')
end
-
+% binArray = [1:ERP.nbin];%%GH Apr 2024
%
% Somersault
%
- [ERP, erpcom] = pop_filterp( ERP, chanArray, 'Filter',ftype, 'Design', fdesign, 'Cutoff', cutoff, 'Order', filterorder, 'RemoveDC', rdc,...
+ [ERP, erpcom] = pop_filterp( ERP, chanArray, 'binArray',binArray,'Filter',ftype, 'Design', fdesign, 'Cutoff', cutoff, 'Order', filterorder, 'RemoveDC', rdc,...
'Saveas', 'on', 'History', 'gui');
return
end
@@ -176,6 +176,7 @@
p.addParamValue('Filter', 'lowpass',@ischar);
p.addParamValue('Design', 'butter', @ischar);
p.addParamValue('Cutoff', 30, @isnumeric);
+p.addParamValue('binArray', [], @isnumeric);
p.addParamValue('Order', 2, @isnumeric);
p.addParamValue('RemoveDC', 'off', @ischar);
p.addParamValue('Saveas', 'off', @ischar);
@@ -183,13 +184,20 @@
p.parse(ERP, chanArray, varargin{:});
+
+binArray = p.Results.binArray;%%GH Apr 2024
+nbin = ERP(1).nbin;
+if isempty(binArray) || any(binArray(:)>nbin) || any(binArray(:)<1)
+ binArray = [1:nbin];
+end
+
filtp = p.Results.Filter;
fdesign = p.Results.Design;
filco = p.Results.Cutoff;
if ~strcmpi(datatype, 'ERP')
- msgboxText = 'Cannot filter Power Spectrum waveforms!';
- error(msgboxText);
+ msgboxText = 'Cannot filter Power Spectrum waveforms!';
+ error(msgboxText);
end
if strcmpi(filtp, 'lowpass')
if length(filco)~=1
@@ -286,7 +294,7 @@
%
% subroutine
%
-options = { chanArray, locutoff, hicutoff, filterorder, fdesignnum, remove_dc};
+options = { chanArray, locutoff, hicutoff, filterorder, fdesignnum, remove_dc,binArray};
ERPaux = ERP; % store original ERP
ERP = filterp(ERP, options{:});
ERP.saved = 'no';
diff --git a/pop_functions/pop_gaverager.m b/pop_functions/pop_gaverager.m
index c26d3c21..477e1ec3 100755
--- a/pop_functions/pop_gaverager.m
+++ b/pop_functions/pop_gaverager.m
@@ -318,7 +318,7 @@
end
catch
- warning('Dataquality measures not found in all these ERPsets. Setting DQ_flag = 0');
+ warning('Data quality measures not found in all these ERPsets. Setting DQ_flag = 0');
DQ_flag = 0;
end
end
diff --git a/pop_functions/pop_geterpvalues.m b/pop_functions/pop_geterpvalues.m
index 7c5629ff..95224f0d 100755
--- a/pop_functions/pop_geterpvalues.m
+++ b/pop_functions/pop_geterpvalues.m
@@ -9,7 +9,7 @@
% pop_geterpvalues(filename, latency, binArray, chanArray, parameters);
%
%
-% INPUTS :
+% INPUTS:
%
% ALLERP - structure array of ERP structures (ERPsets)
% To read the ERPset from a list in a text file,
@@ -106,180 +106,182 @@
Amp = [];
Lat = [];
if nargin<1
- help pop_geterpvalues
- return
+ help pop_geterpvalues
+ return
end
if nargin==1 % GUI
- if isstruct(ALLERP)
- if ~iserpstruct(ALLERP(1));
- ALLERP = [];
- nbinx = 1;
- nchanx = 1;
- else
- nbinx = ALLERP(1).nbin;
- nchanx = ALLERP(1).nchan;
- end
- else
- ALLERP = [];
- nbinx = 1;
- nchanx = 1;
- end
- cerpi = evalin('base', 'CURRENTERP'); % current erp index
- def = erpworkingmemory('pop_geterpvalues');
- if isempty(def)
- if isempty(ALLERP)
- inp1 = 1; %from hard drive
- erpset = [];
- else
- inp1 = 0; %from erpset menu
- erpset = 1:length(ALLERP);
- end
-
- def = {inp1 erpset '' 0 1:nbinx 1:nchanx 'instabl' 1 3 'pre' 0 1 5 0 0.5 0 0 0 '' 0 1};
- else
- if ~isempty(ALLERP)
- if isnumeric(def{2}) % JavierLC 11-17-11
- [uu, mm] = unique_bc2(def{2}, 'first');
- erpset_list_sorted = [def{2}(sort(mm))];
- %def{2} = def{2}(def{2}<=length(ALLERP));
- % non-empty check, axs jul17
- erpset_list = erpset_list_sorted(erpset_list_sorted<=length(ALLERP));
- if isempty(erpset_list)
- % if nothing in list, just go with current
- def{2} = cerpi;
- else
- % use JLC's sorting, iff not empty
- def{2} = erpset_list;
- end
-
- end
- end
- end
-
- %
- % call GUI
- %
- instr = geterpvaluesGUI2(ALLERP, def, cerpi);% open a GUI
-
- if isempty(instr)
- disp('User selected Cancel')
- return
- end
-
- optioni = instr{1}; %1 means from hard drive, 0 means from erpsets menu
- erpset = instr{2};
- fname = instr{3};
- latency = instr{4};
- binArray = instr{5};
- chanArray = instr{6};
- moption = instr{7}; % option: type of measurement ---> instabl, meanbl, peakampbl, peaklatbl, area, areaz, or errorbl.
- coi = instr{8};
- dig = instr{9};
- blc = instr{10};
- binlabop = instr{11}; % 0: bin number as bin label, 1: bin descriptor as bin label for table.
- polpeak = instr{12}; % local peak polarity
- sampeak = instr{13}; % number of samples (one-side) for local peak detection criteria
- locpeakrep = instr{14}; % 1 abs peak , 0 Nan
- frac = instr{15};
- fracmearep = instr{16}; % 1 zero , 0 Nan. Fractional area latency replacement
- send2ws = instr{17}; % send measurements to workspace
- appfile = instr{18}; % 1 means append file (it wont get into wmemory), 3 means call filter GUI
- foutput = instr{19};
- mlabel = instr{20};
- inclate = instr{21}; % include used latency values for measurements like mean, peak, area...
- intfactor = instr{22};
- viewmea = instr{23}; % viewer
- peak_onset = instr{24}; % 1 for
-
- if optioni==1 % from files
- filelist = erpset;
- disp(['pop_geterpvalues(): For file-List, user selected ', filelist])
- fid_list = fopen( filelist );
- inputfnamex = textscan(fid_list, '%[^\n]','CommentStyle','#');
- inputfname = cellstr(char(inputfnamex{:}));
- fclose(fid_list);
- ALLERP = {ALLERP, filelist}; % truco
- elseif optioni==2 % from current erpset (single)
- erpset = cerpi;
- else % from erpsets menu
- %erpset = erpset;
- end
- if strcmpi(fname,'no_save.no_save') %|| strcmpi(fname,'no_save.viewer')
- fnamer = '';
- else
- fnamer = fname;
- end
- if send2ws
- s2ws = 'on'; % send to workspace
+ if isstruct(ALLERP)
+ if ~iserpstruct(ALLERP(1));
+ ALLERP = [];
+ nbinx = 1;
+ nchanx = 1;
else
- s2ws = 'off';
- end
- if viewmea
- vmstr = 'on'; % open viewer
+ nbinx = ALLERP(1).nbin;
+ nchanx = ALLERP(1).nchan;
+ end
+ else
+ ALLERP = [];
+ nbinx = 1;
+ nchanx = 1;
+ end
+ cerpi = evalin('base', 'CURRENTERP'); % current erp index
+ def = erpworkingmemory('pop_geterpvalues');
+ if isempty(def)
+ if isempty(ALLERP)
+ inp1 = 1; %from hard drive
+ erpset = [];
else
- vmstr = 'off';
+ inp1 = 0; %from erpset menu
+ erpset = 1:length(ALLERP);
end
- erpworkingmemory('pop_geterpvalues', {optioni, erpset, fnamer, latency,...
- binArray, chanArray, moption, coi, dig, blc, binlabop, polpeak,...
- sampeak, locpeakrep, frac, fracmearep, send2ws, foutput, mlabel,...
- inclate, intfactor, peak_onset});
-
- if binlabop==0
- binlabopstr = 'off';
- else
- binlabopstr = 'on';
- end
- if polpeak==0
- polpeakstr = 'negative';
- else
- polpeakstr = 'positive';
- end
- if locpeakrep==0
- locpeakrepstr = 'NaN';
- else
- locpeakrepstr = 'absolute';
- end
- if fracmearep==0 % Fractional area latency replacement
- fracmearepstr = 'NaN';
- else
- if ismember_bc2({moption}, {'fareatlat', 'fninteglat','fareaplat','fareanlat'})
- fracmearepstr = 'errormsg';
+ def = {inp1 erpset '' 0 1:nbinx 1:nchanx 'instabl' 1 3 'pre' 0 1 5 0 0.5 0 0 0 '' 0 1};
+ else
+ if ~isempty(ALLERP)
+ if isnumeric(def{2}) % JavierLC 11-17-11
+ [uu, mm] = unique_bc2(def{2}, 'first');
+ erpset_list_sorted = [def{2}(sort(mm))];
+ %def{2} = def{2}(def{2}<=length(ALLERP));
+ % non-empty check, axs jul17
+ erpset_list = erpset_list_sorted(erpset_list_sorted<=length(ALLERP));
+ if isempty(erpset_list)
+ % if nothing in list, just go with current
+ def{2} = cerpi;
else
- fracmearepstr = 'absolute';
+ % use JLC's sorting, iff not empty
+ def{2} = erpset_list;
end
- end
- if appfile
- appfstr = 'on';
- else
- appfstr = 'off';
- end
- if foutput % 1 means "long format"; 0 means "wide format"
- foutputstr = 'long';
- else
- foutputstr = 'wide';
- end
- if inclate
- inclatestr = 'yes';
- else
- inclatestr = 'no';
- end
-
- %
- % Somersault
- %
-
- %latency, binArray, chanArray, erpset, moption, coi, dig, blc, binlabopstr, polpeakstr, sampeak, locpeakrepstr, fname, s2ws, appfstr, foutputstr, frac, mlabel, fracmearepstr, inclatestr, intfactor, vmstr
-
- [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP, latency, binArray, chanArray, 'Erpsets', erpset, 'Measure',...
- moption, 'Component', coi, 'Resolution', dig, 'Baseline', blc, 'Binlabel', binlabopstr, 'Peakpolarity',...
- polpeakstr, 'Neighborhood', sampeak, 'Peakreplace', locpeakrepstr, 'Filename', fname, 'Warning','on',...
- 'SendtoWorkspace', s2ws, 'Append', appfstr, 'FileFormat', foutputstr,'Afraction', frac, 'Mlabel', mlabel,...
- 'Fracreplace', fracmearepstr,'IncludeLat', inclatestr, 'InterpFactor', intfactor, 'Viewer', vmstr,...
- 'PeakOnset',peak_onset,'History', 'gui');
-
- pause(0.1)
+
+ end
+ end
+ end
+
+ %
+ % call GUI
+ %
+ instr = geterpvaluesGUI2(ALLERP, def, cerpi);% open a GUI
+
+ if isempty(instr)
+ disp('User selected Cancel')
return
+ end
+
+ optioni = instr{1}; %1 means from hard drive, 0 means from erpsets menu
+ erpset = instr{2};
+ fname = instr{3};
+ latency = instr{4};
+ binArray = instr{5};
+ chanArray = instr{6};
+ moption = instr{7}; % option: type of measurement ---> instabl, meanbl, peakampbl, peaklatbl, area, areaz, or errorbl.
+ coi = instr{8};
+ dig = instr{9};
+ blc = instr{10};
+ binlabop = instr{11}; % 0: bin number as bin label, 1: bin descriptor as bin label for table.
+ polpeak = instr{12}; % local peak polarity
+ sampeak = instr{13}; % number of samples (one-side) for local peak detection criteria
+ locpeakrep = instr{14}; % 1 abs peak , 0 Nan
+ frac = instr{15};
+ fracmearep = instr{16}; % 1 zero , 0 Nan. Fractional area latency replacement
+ send2ws = instr{17}; % send measurements to workspace
+ appfile = instr{18}; % 1 means append file (it wont get into wmemory), 3 means call filter GUI
+ foutput = instr{19};
+ mlabel = instr{20};
+ inclate = instr{21}; % include used latency values for measurements like mean, peak, area...
+ intfactor = instr{22};
+ viewmea = instr{23}; % viewer
+ peak_onset = instr{24}; % 1 for
+
+ if optioni==1 % from files
+ filelist = erpset;
+ disp(['pop_geterpvalues(): For file-List, user selected ', filelist])
+ fid_list = fopen( filelist );
+ inputfnamex = textscan(fid_list, '%[^\n]','CommentStyle','#');
+ inputfname = cellstr(char(inputfnamex{:}));
+ fclose(fid_list);
+ ALLERP = {ALLERP, filelist}; % truco
+ elseif optioni==2 % from current erpset (single)
+ erpset = cerpi;
+ else % from erpsets menu
+ %erpset = erpset;
+ end
+ if strcmpi(fname,'no_save.no_save') %|| strcmpi(fname,'no_save.viewer')
+ fnamer = '';
+ else
+ fnamer = fname;
+ end
+ if send2ws
+ s2ws = 'on'; % send to workspace
+ else
+ s2ws = 'off';
+ end
+ if viewmea
+ vmstr = 'on'; % open viewer
+ else
+ vmstr = 'off';
+ end
+
+ erpworkingmemory('pop_geterpvalues', {optioni, erpset, fnamer, latency,...
+ binArray, chanArray, moption, coi, dig, blc, binlabop, polpeak,...
+ sampeak, locpeakrep, frac, fracmearep, send2ws, foutput, mlabel,...
+ inclate, intfactor, peak_onset});
+
+ if binlabop==0
+ binlabopstr = 'off';
+ else
+ binlabopstr = 'on';
+ end
+ if polpeak==0
+ polpeakstr = 'negative';
+ else
+ polpeakstr = 'positive';
+ end
+ if locpeakrep==0
+ locpeakrepstr = 'NaN';
+ elseif locpeakrep==-1
+ locpeakrepstr = 'errormsg';%%GH May 2024
+ else
+ locpeakrepstr = 'absolute';
+ end
+ if fracmearep==0 % Fractional area latency replacement
+ fracmearepstr = 'NaN';
+ else
+ if ismember_bc2({moption}, {'fareatlat', 'fninteglat','fareaplat','fareanlat'})
+ fracmearepstr = 'errormsg';
+ else
+ fracmearepstr = 'absolute';
+ end
+ end
+ if appfile
+ appfstr = 'on';
+ else
+ appfstr = 'off';
+ end
+ if foutput % 1 means "long format"; 0 means "wide format"
+ foutputstr = 'long';
+ else
+ foutputstr = 'wide';
+ end
+ if inclate
+ inclatestr = 'yes';
+ else
+ inclatestr = 'no';
+ end
+
+ %
+ % Somersault
+ %
+
+ %latency, binArray, chanArray, erpset, moption, coi, dig, blc, binlabopstr, polpeakstr, sampeak, locpeakrepstr, fname, s2ws, appfstr, foutputstr, frac, mlabel, fracmearepstr, inclatestr, intfactor, vmstr
+
+ [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP, latency, binArray, chanArray, 'Erpsets', erpset, 'Measure',...
+ moption, 'Component', coi, 'Resolution', dig, 'Baseline', blc, 'Binlabel', binlabopstr, 'Peakpolarity',...
+ polpeakstr, 'Neighborhood', sampeak, 'Peakreplace', locpeakrepstr, 'Filename', fname, 'Warning','on',...
+ 'SendtoWorkspace', s2ws, 'Append', appfstr, 'FileFormat', foutputstr,'Afraction', frac, 'Mlabel', mlabel,...
+ 'Fracreplace', fracmearepstr,'IncludeLat', inclatestr, 'InterpFactor', intfactor, 'Viewer', vmstr,...
+ 'PeakOnset',peak_onset,'History', 'gui');
+
+ pause(0.1)
+ return
end
%
@@ -320,27 +322,27 @@
p.parse(ALLERP, latency, binArray, chanArray, varargin{:});
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
% Measurement types
%
meacell = {'instabl', 'meanbl', 'peakampbl', 'peaklatbl', 'fpeaklat',...
- 'areat', 'areap', 'arean','areazt','areazp','areazn','fareatlat',...
- 'fareaplat','fninteglat','fareanlat', 'ninteg','nintegz' };
+ 'areat', 'areap', 'arean','areazt','areazp','areazn','fareatlat',...
+ 'fareaplat','fninteglat','fareanlat', 'ninteg','nintegz' };
measurearray = {'Instantaneous amplitude','Mean amplitude between two fixed latencies',...
- 'Peak amplitude','Peak latency','Fractional Peak latency',...
- 'Numerical integration/Area between two fixed latencies',...
- 'Numerical integration/Area between two (automatically detected) zero-crossing latencies'...
- 'Fractional Area latency', ''};
+ 'Peak amplitude','Peak latency','Fractional Peak latency',...
+ 'Numerical integration/Area between two fixed latencies',...
+ 'Numerical integration/Area between two (automatically detected) zero-crossing latencies'...
+ 'Fractional Area latency', ''};
%
% Get inputs
@@ -349,66 +351,66 @@
cond1 = iserpstruct(ALLERP);
cond2 = isnumeric(erpsetArray);
if isempty(latency)
- latency = 0;
-end
-if cond1 && cond2 % either from GUI or script, when ALLERP exist and erpset indices were specified
- if isempty(erpsetArray)
- erpsetArray =1:length(ALLERP);
- elseif erpsetArray==0
- try
- erpsetArray = evalin('base', 'CURRENTERP'); % current erp index
- catch
- erpsetArray = length(ALLERP);
- end
-
+ latency = 0;
+end
+if cond1 && cond2 % either from GUI or script, when ALLERP exist and erpset indices were specified
+ if isempty(erpsetArray)
+ erpsetArray =1:length(ALLERP);
+ elseif erpsetArray==0
+ try
+ erpsetArray = evalin('base', 'CURRENTERP'); % current erp index
+ catch
+ erpsetArray = length(ALLERP);
end
- nfile = length(erpsetArray);
- optioni = 0; % from erpset menu or ALLERP struct
- if isempty(binArray) % JLC
- binArray = 1:min([ALLERP(erpsetArray).nbin]);
- end
- if isempty(chanArray)
- chanArray = 1:min([ALLERP(erpsetArray).nchan]);
- end
+ end
+ nfile = length(erpsetArray);
+ optioni = 0; % from erpset menu or ALLERP struct
+
+ if isempty(binArray) % JLC
+ binArray = 1:min([ALLERP(erpsetArray).nbin]);
+ end
+ if isempty(chanArray)
+ chanArray = 1:min([ALLERP(erpsetArray).nchan]);
+ end
else
- filelist = '';
- optioni = 1; % from file
- if iscell(ALLERP) % from the GUI, when ALLERP exist and user picks a list up as well
- filelist = ALLERP{2};
- ALLERP = ALLERP{1};
- elseif ischar(ALLERP) % from script, when user picks a list.
- filelist = ALLERP;
- end
- if isempty(binArray) % JLC
- binArray = 1;
- end
- if isempty(chanArray)
- chanArray = 1;
- end
- if ~iscell(filelist) && ~isempty(filelist)
- disp(['For file-List, user selected ', filelist])
- fid_list = fopen( filelist );
- inputfnamex = textscan(fid_list, '%[^\n]','CommentStyle','#');
- inputfname = cellstr(char(inputfnamex{:}));
- nfile = length(inputfname);
- fclose(fid_list);
- elseif ~isempty(filelist) && iscell(filelist)
- inputfname = filelist;
- nfile = length(inputfname);
- else
- error('ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ')
- end
- if isempty(erpsetArray)
- erpsetArray =1:nfile;
- elseif erpsetArray==0
- try
- erpsetArray = evalin('base', 'CURRENTERP'); % current erp index
- catch
- erpsetArray = nfile;
- end
-
+ filelist = '';
+ optioni = 1; % from file
+ if iscell(ALLERP) % from the GUI, when ALLERP exist and user picks a list up as well
+ filelist = ALLERP{2};
+ ALLERP = ALLERP{1};
+ elseif ischar(ALLERP) % from script, when user picks a list.
+ filelist = ALLERP;
+ end
+ if isempty(binArray) % JLC
+ binArray = 1;
+ end
+ if isempty(chanArray)
+ chanArray = 1;
+ end
+ if ~iscell(filelist) && ~isempty(filelist)
+ disp(['For file-List, user selected ', filelist])
+ fid_list = fopen( filelist );
+ inputfnamex = textscan(fid_list, '%[^\n]','CommentStyle','#');
+ inputfname = cellstr(char(inputfnamex{:}));
+ nfile = length(inputfname);
+ fclose(fid_list);
+ elseif ~isempty(filelist) && iscell(filelist)
+ inputfname = filelist;
+ nfile = length(inputfname);
+ else
+ error('ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ')
+ end
+ if isempty(erpsetArray)
+ erpsetArray =1:nfile;
+ elseif erpsetArray==0
+ try
+ erpsetArray = evalin('base', 'CURRENTERP'); % current erp index
+ catch
+ erpsetArray = nfile;
end
+
+ end
end
fname = p.Results.Filename;
@@ -420,72 +422,75 @@
mlabel = strrep(mlabel, ' ', '_');
if ~isempty(frac)
- if frac<0 || frac>1
- error('ERPLAB says: error at pop_geterpvalues(). Fractional area value must be between 0 and 1')
- end
+ if frac<0 || frac>1
+ error('ERPLAB says: error at pop_geterpvalues(). Fractional area value must be between 0 and 1')
+ end
end
if ischar(localrep)
- lr = str2num(localrep);
- if isempty(lr)
- if strcmpi(localrep,'absolute')
- locpeakrep = 1;
- else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' localrep])
- end
+ lr = str2num(localrep);
+ if isempty(lr)
+ if strcmpi(localrep,'absolute')
+ locpeakrep = 1;
+ elseif strcmpi(localrep,'error') || strcmpi(localrep,'errormsg') %%GH May 2024
+ locpeakrep = 2; % shows error message. Stop measuring.
else
- if isnan(lr)
- locpeakrep = 0;
- else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' localrep])
- end
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' localrep])
end
-else
- if isnan(localrep)
- locpeakrep = 0;
+ else
+ if isnan(lr)
+ locpeakrep = 0;
+
else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' num2str(localrep(1))])
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' localrep])
end
+ end
+else
+ if isnan(localrep)
+ locpeakrep = 0;
+ else
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' num2str(localrep(1))])
+ end
end
if ischar(fraclocalrep)
- flr = str2num(fraclocalrep);
- if isempty(flr)
- if strcmpi(fraclocalrep,'absolute')
- fracmearep = 1;
- elseif strcmpi(fraclocalrep,'error') || strcmpi(fraclocalrep,'errormsg')
- fracmearep = 2; % shows error message. Stop measuring.
- else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' fraclocalrep])
- end
+ flr = str2num(fraclocalrep);
+ if isempty(flr)
+ if strcmpi(fraclocalrep,'absolute')
+ fracmearep = 1;
+ elseif strcmpi(fraclocalrep,'error') || strcmpi(fraclocalrep,'errormsg')
+ fracmearep = 2; % shows error message. Stop measuring.
else
- if isnan(flr)
- fracmearep = 0;
- else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' fraclocalrep])
- end
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' fraclocalrep])
end
-else
- if isnan(fraclocalrep)
- fracmearep = 0;
+ else
+ if isnan(flr)
+ fracmearep = 0;
else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' num2str(fraclocalrep(1))])
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' fraclocalrep])
end
+ end
+else
+ if isnan(fraclocalrep)
+ fracmearep = 0;
+ else
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' num2str(fraclocalrep(1))])
+ end
end
sampeak = p.Results.Neighborhood; % samples around the peak
if strcmpi(p.Results.Peakpolarity, 'positive')
- polpeak = 1; % positive
+ polpeak = 1; % positive
elseif strcmpi(p.Results.Peakpolarity, 'negative')
- polpeak = 0;
+ polpeak = 0;
else
- error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' p.Results.Peakpolarity]);
+ error(['ERPLAB says: error at pop_geterpvalues(). Unrecognizable input ' p.Results.Peakpolarity]);
end
if strcmpi(p.Results.Binlabel, 'on')
- binlabop = 1; % bin descriptor as bin label for table
+ binlabop = 1; % bin descriptor as bin label for table
elseif strcmpi(p.Results.Binlabel, 'off')
- binlabop = 0; % bin# as bin label for table
+ binlabop = 0; % bin# as bin label for table
else
- error(['ERPLAB says: Unrecognizable input ' p.Results.Binlabel]);
+ error(['ERPLAB says: Unrecognizable input ' p.Results.Binlabel]);
end
blc = p.Results.Baseline;
@@ -496,422 +501,435 @@
peak_onset = p.Results.PeakOnset;
if isempty(moption)
- error('ERPLAB says: User must specify a type of measurement.')
+ error('ERPLAB says: User must specify a type of measurement.')
end
if ismember_bc2({moption}, {'instabl', 'areazt','areazp','areazn', 'nintegz'});
- if length(latency)~=1
- error(['ERPLAB says: ' moption ' only needs 1 latency value.'])
- end
+ if length(latency)~=1
+ error(['ERPLAB says: ' moption ' only needs 1 latency value.'])
+ end
else
- if length(latency)~=2
- error(['ERPLAB says: ' moption ' needs 2 latency values.'])
- else
- if latency(1)>=latency(2)
- msgboxText = ['For latency range, lower time limit must be on the left.\n'...
- 'Additionally, lower time limit must be at least 1/samplerate seconds lesser than the higher one.'];
- title = 'ERPLAB: pop_geterpvalues() inputs';
- errorfound(sprintf(msgboxText), title);
- return
- end
- end
+ if length(latency)~=2
+ error(['ERPLAB says: ' moption ' needs 2 latency values.'])
+ else
+ if latency(1)>=latency(2)
+ msgboxText = ['For latency range, lower time limit must be on the left.\n'...
+ 'Additionally, lower time limit must be at least 1/samplerate seconds lesser than the higher one.'];
+ title = 'ERPLAB: pop_geterpvalues() inputs';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+ end
end
if strcmpi(p.Results.Warning, 'on')
- menup = 1; % enable warning message
+ menup = 1; % enable warning message
else
- menup = 0;
+ menup = 0;
end
if strcmpi(p.Results.SendtoWorkspace, 'on')
- send2ws = 1; % send to workspace
+ send2ws = 1; % send to workspace
else
- send2ws = 0;
+ send2ws = 0;
end
if strcmpi(p.Results.Viewer, 'on')
- viewmea = 1; % open viewer
+ viewmea = 1; % open viewer
else
- viewmea = 0;
+ viewmea = 0;
end
if strcmpi(p.Results.Append, 'on')
- appendfile = 1;
+ appendfile = 1;
else
- appendfile = 0;
+ appendfile = 0;
end
if strcmpi(p.Results.FileFormat, 'long')
- foutput = 1; % 1 means "long format"; 0 means "wide format"
+ foutput = 1; % 1 means "long format"; 0 means "wide format"
else
- foutput = 0;
+ foutput = 0;
end
if strcmpi(p.Results.IncludeLat, 'yes') || strcmpi(p.Results.IncludeLat, 'on')
- inclate = 1;
+ inclate = 1;
else
- inclate = 0;
+ inclate = 0;
end
intfactor = p.Results.InterpFactor;
if ~ismember_bc2({moption}, meacell);
- msgboxText = [moption ' is not a valid option for pop_geterpvalues!'];
- if shist == 1; % gui
- title = 'ERPLAB: pop_geterpvalues wrong inputs';
- errorfound(msgboxText, title);
- return
- else
- error(msgboxText)
- end
+ msgboxText = [moption ' is not a valid option for pop_geterpvalues!'];
+ if shist == 1; % gui
+ title = 'ERPLAB: pop_geterpvalues wrong inputs';
+ errorfound(msgboxText, title);
+ return
+ else
+ error(msgboxText)
+ end
end
if ischar(blc)
- blcorrstr = ['''' blc '''' ];
+ blcorrstr = ['''' blc '''' ];
else
- blcorrstr = ['[' num2str(blc) ']'];
+ blcorrstr = ['[' num2str(blc) ']'];
end
if ~viewmea
- [pathtest, filtest, ext] = fileparts(fname);
+ [pathtest, filtest, ext] = fileparts(fname);
+
+ if isempty(filtest)
+ error('File name is empty.')
+ end
+ if strcmpi(ext,'.xls')
+ fprintf('\nWARNING:\n');
+ title = 'ERPLAB: WARNING, pop_geterpvalues() export to Excel' ;
+ question = ['Sorry. Export to Excel is not longer supported by ERPLAB.\n\n'...
+ 'Do you want to continue anyway using a text file instead?'];
+ button = askquest(sprintf(question), title);
- if isempty(filtest)
- error('File name is empty.')
- end
- if strcmpi(ext,'.xls')
- fprintf('\nWARNING:\n');
- title = 'ERPLAB: WARNING, pop_geterpvalues() export to Excel' ;
- question = ['Sorry. Export to Excel is not longer supported by ERPLAB.\n\n'...
- 'Do you want to continue anyway using a text file instead?'];
- button = askquest(sprintf(question), title);
-
- if ~strcmpi(button,'yes')
- disp('User selected Cancel')
- return
- end
- if strcmp(pathtest,'')
- pathtest = cd;
- end
- ext = '.txt';
- fname = fullfile(pathtest, [filtest ext]);
- fprintf('\nOutput file will have extension %s\n', ext);
- exceloption = 0;
- send_to_file = 1;
- % if ispc
- % exceloption = 1;
- % fprintf('\nOutput will be a Microsoft Excel spreadsheet file');
- % warning off MATLAB:xlswrite:AddSheet
- % if strcmp(pathtest,'')
- % pathtest = cd;
- % fname = fullfile(pathtest, [filtest ext]);
- % end
- % else
- % fprintf('\nWARNING:\n');
- % title = 'ERPLAB: WARNING, pop_geterpvalues() export to Excel' ;
- % question = ['The full functionality of XLSWRITE depends on the ability '...
- % 'to instantiate Microsoft Excel as a COM server.\n\n'...
- % 'COM is a technology developed for Windows platforms and, '...
- % 'at the current ERPLAB version, is not available for non-Windows machines\n\n'...
- % 'Do you want to continue anyway with a text file instead?'];
- % button = askquest(sprintf(question), title);
- %
- % if ~strcmpi(button,'yes')
- % disp('User selected Cancel')
- % return
- % end
- % if strcmp(pathtest,'')
- % pathtest = cd;
- % end
- % ext = '.txt';
- % fname = fullfile(pathtest, [filtest ext]);
- % fprintf('\nOutput file will have extension %s\n', ext);
- % exceloption = 0;
- % end
- % send_to_file = 1;
- elseif strcmpi(ext,'.no_save')
- send_to_file = 0;
- elseif strcmpi(ext,'.viewer') % temporary
- send_to_file = 0;
- else
- exceloption = 0;
- if strcmp(pathtest,'')
- pathtest = cd;
- end
- if ~strcmpi(ext,'.txt')&& ~strcmpi(ext,'.dat')
- ext = '.txt';
- fname = fullfile(pathtest, [filtest ext]);
- end
- fprintf('\nOutput file will have extension %s\n', ext);
- send_to_file = 1;
- end
-else
+ if ~strcmpi(button,'yes')
+ disp('User selected Cancel')
+ return
+ end
+ if strcmp(pathtest,'')
+ pathtest = cd;
+ end
+ ext = '.txt';
+ fname = fullfile(pathtest, [filtest ext]);
+ fprintf('\nOutput file will have extension %s\n', ext);
+ exceloption = 0;
+ send_to_file = 1;
+ % if ispc
+ % exceloption = 1;
+ % fprintf('\nOutput will be a Microsoft Excel spreadsheet file');
+ % warning off MATLAB:xlswrite:AddSheet
+ % if strcmp(pathtest,'')
+ % pathtest = cd;
+ % fname = fullfile(pathtest, [filtest ext]);
+ % end
+ % else
+ % fprintf('\nWARNING:\n');
+ % title = 'ERPLAB: WARNING, pop_geterpvalues() export to Excel' ;
+ % question = ['The full functionality of XLSWRITE depends on the ability '...
+ % 'to instantiate Microsoft Excel as a COM server.\n\n'...
+ % 'COM is a technology developed for Windows platforms and, '...
+ % 'at the current ERPLAB version, is not available for non-Windows machines\n\n'...
+ % 'Do you want to continue anyway with a text file instead?'];
+ % button = askquest(sprintf(question), title);
+ %
+ % if ~strcmpi(button,'yes')
+ % disp('User selected Cancel')
+ % return
+ % end
+ % if strcmp(pathtest,'')
+ % pathtest = cd;
+ % end
+ % ext = '.txt';
+ % fname = fullfile(pathtest, [filtest ext]);
+ % fprintf('\nOutput file will have extension %s\n', ext);
+ % exceloption = 0;
+ % end
+ % send_to_file = 1;
+ elseif strcmpi(ext,'.no_save')
send_to_file = 0;
+ elseif strcmpi(ext,'.viewer') % temporary
+ send_to_file = 0;
+ else
+ exceloption = 0;
+ if strcmp(pathtest,'')
+ pathtest = cd;
+ end
+ if ~strcmpi(ext,'.txt')&& ~strcmpi(ext,'.dat')
+ ext = '.txt';
+ fname = fullfile(pathtest, [filtest ext]);
+ end
+ fprintf('\nOutput file will have extension %s\n', ext);
+ send_to_file = 1;
+ end
+else
+ send_to_file = 0;
end
fprintf('\nBaseline period = %s will be used for measurements\n\n', blcorrstr);
if optioni==1 % from files
- erpsetArray = 1:nfile; % JLC. Sept 2012
+ erpsetArray = 1:nfile; % JLC. Sept 2012
end
conti = 1;
Lat = {[]};
for k=1:nfile
- if optioni==1 % from files
- filex = load(inputfname{k}, '-mat');
- ERP = filex.ERP;
- [ERP, conti, serror] = olderpscan(ERP, menup);
- if viewmea==1 && conti==1 && serror==0
- if k==1
- ALLERPX = buildERPstruct([]); % auxiliar ALLERP
- end
- ALLERPX(k) = ERP;
- end
- else % from erpsets
- ERP = ALLERP(erpsetArray(k));
- [ERP, conti, serror] = olderpscan(ERP, menup);
- end
- if conti==0
- break
- end
- if serror ==1
- kindex = k;
- kname = ERP.erpname;
- break
- end
- if k==1
- n1bin = ERP.nbin;
- n1chan = ERP.nchan;
- n1bdesc = ERP.bindescr;
-
- if isempty(binArray) % JLC
- binArray = 1:n1bin;
- end
- if isempty(chanArray)
- chanArray = 1:n1chan;
- end
- Amp = zeros(length(binArray), length(chanArray), nfile);
- else
- if ERP.nbin~=n1bin
- serror = 2;
- break
- end
- if ismember_bc2(0,ismember(lower(ERP.bindescr), lower(n1bdesc))) % May 25, 2010
- serror = 3;
- break
- end
- end
+ if optioni==1 % from files
+ filex = load(inputfname{k}, '-mat');
+ ERP = filex.ERP;
+ [ERP, conti, serror] = olderpscan(ERP, menup);
+ if viewmea==1 && conti==1 && serror==0
+ if k==1
+ ALLERPX = buildERPstruct([]); % auxiliar ALLERP
+ end
+ ALLERPX(k) = ERP;
+ end
+ else % from erpsets
+ ERP = ALLERP(erpsetArray(k));
+ [ERP, conti, serror] = olderpscan(ERP, menup);
+ end
+ if conti==0
+ break
+ end
+ if serror ==1
+ kindex = k;
+ kname = ERP.erpname;
+ break
+ end
+ if k==1
+ n1bin = ERP.nbin;
+ n1chan = ERP.nchan;
+ n1bdesc = ERP.bindescr;
- datatype = checkdatatype(ERP);
- if ~strcmpi(datatype, 'ERP') && ismember(moption, {'areazt','areazp','areazn', 'nintegz'} )
- error('This type of measurement (automatic area/integration) is not allowed for Power Spectrum data ');
+ if isempty(binArray) % JLC
+ binArray = 1:n1bin;
end
-
- %
- % subroutine
- %
- %
- % Get measurements
- %
- fprintf('Taking measurements across ERPset #%g...\n', erpsetArray(k))
-
- if inclate || viewmea % JLC. Sept 2012
- [A, lat4mea] = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor,peak_onset);
+ if isempty(chanArray)
+ chanArray = 1:n1chan;
+ end
+ Amp = zeros(length(binArray), length(chanArray), nfile);
+ else
+ if ERP.nbin~=n1bin
+ serror = 2;
+ break
+ end
+ if ismember_bc2(0,ismember(lower(ERP.bindescr), lower(n1bdesc))) % May 25, 2010
+ serror = 3;
+ break
+ end
+ end
+
+ datatype = checkdatatype(ERP);
+ if ~strcmpi(datatype, 'ERP') && ismember(moption, {'areazt','areazp','areazn', 'nintegz'} )
+ error('This type of measurement (automatic area/integration) is not allowed for Power Spectrum data ');
+ end
+
+ %
+ % subroutine
+ %
+ %
+ % Get measurements
+ %
+ fprintf('Taking measurements across ERPset #%g...\n', erpsetArray(k))
+
+ if inclate || viewmea % JLC. Sept 2012
+ [A, lat4mea] = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor,peak_onset);
+ else
+ %ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor
+ A = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor,peak_onset);
+ lat4mea = [];
+ end
+
+ %
+ %
+ % en vez de abortar la lectura de valores debido a un error, es mejor llenar con NAN y seguir midiendo la sgte medida....
+ % Cambiar los "breaks"!
+ %
+
+ if isempty(A) && viewmea==0
+ errmsg = 'Empty outcome.';
+ serror = 4;
+ break
+ elseif ischar(A) && viewmea==0
+ errmsg = A;
+ serror = 4;
+ break
+ elseif (isempty(A) || ischar(A)) && viewmea==1
+ if isempty(lat4mea)
+ A = NaN(length(binArray), length(chanArray)); % for viewer, when measurement was not possible.
+ lat4mea = {latency(1)};
else
- %ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor
- A = geterpvalues(ERP, latency, binArray, chanArray, moption, blc, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor,peak_onset);
- lat4mea = [];
- end
-
- %
- %
- % en vez de abortar la lectura de valores debido a un error, es mejor llenar con NAN y seguir midiendo la sgte medida....
- % Cambiar los "breaks"!
- %
-
- if isempty(A) && viewmea==0
- errmsg = 'Empty outcome.';
- serror = 4;
- break
- elseif ischar(A) && viewmea==0
- errmsg = A;
- serror = 4;
- break
- elseif (isempty(A) || ischar(A)) && viewmea==1
- if isempty(lat4mea)
- A = NaN(length(binArray), length(chanArray)); % for viewer, when measurement was not possible.
- lat4mea = {latency(1)};
- else
- errmsg = A;
- serror = 4;
- break
- end
- %lat4mea = {};
- %[lat4mea{1:length(binArray),1:length(chanArray)}] = deal(latency); % specified latency(ies) for getting measurements.
- %lat4mea = {latency(1)};
- end
-
- %
- % Store values
- %
- Amp(:,:,k) = A; % bin x channel x erpset
- Lat{:,:,k} = lat4mea; % bin x channel x erpset
-
- if send_to_file && ~viewmea
- if exceloption
- %
- % Excel
- %
- exportvalues2xls(ERP, {A}, binArray,chanArray, 0, moption, fname, k+appendfile)
- else
- %
- % Text
- %
- % (ERP, values, binArray, chanArray, fname, dig, ncall, binlabop, formatout, mlabel, lat4mea)
- exportvaluesV2(ERP, {A}, binArray, chanArray, fname, dig, k+appendfile, binlabop, foutput, mlabel, lat4mea)
- end
-
- prew = 'Additionally, m';
+ errmsg = A;
+ serror = 4;
+ break
+ end
+ %lat4mea = {};
+ %[lat4mea{1:length(binArray),1:length(chanArray)}] = deal(latency); % specified latency(ies) for getting measurements.
+ %lat4mea = {latency(1)};
+ end
+
+ %
+ % Store values
+ %
+ Amp(:,:,k) = A; % bin x channel x erpset
+ Lat{:,:,k} = lat4mea; % bin x channel x erpset
+
+ if send_to_file && ~viewmea
+ if exceloption
+ %
+ % Excel
+ %
+ exportvalues2xls(ERP, {A}, binArray,chanArray, 0, moption, fname, k+appendfile)
else
- prew = 'M';
+ %
+ % Text
+ %
+ % (ERP, values, binArray, chanArray, fname, dig, ncall, binlabop, formatout, mlabel, lat4mea)
+ exportvaluesV2(ERP, {A}, binArray, chanArray, fname, dig, k+appendfile, binlabop, foutput, mlabel, lat4mea)
end
+
+ prew = 'Additionally, m';
+ else
+ prew = 'M';
+ end
end
%
% Errors
%
if conti==0
- return
+ return
end
+
+ERPtooltype = erpgettoolversion('tooltype');%%GH May 2024
+
if serror~=0
- switch serror
- case 1
- msgboxText = sprintf('A problem was found at ERPset %s (%gth).', kname, kindex);
- case 2
- msgboxText = ['Number of bins is different across datasets .\n'...
- 'You must use ERPset related to the same experiment.'];
- case 3
- msgboxText = ['The bin description set among datasets is different.\n'...
- 'You must use ERPset related to the same experiment.'];
- case 4
- msgboxText = errmsg ;
+ switch serror
+ case 1
+ msgboxText = sprintf('A problem was found at ERPset %s (%gth).', kname, kindex);
+ case 2
+ msgboxText = ['Number of bins is different across datasets .\n'...
+ 'You must use ERPset related to the same experiment.'];
+ case 3
+ msgboxText = ['The bin description set among datasets is different.\n'...
+ 'You must use ERPset related to the same experiment.'];
+ case 4
+
+ switch moption%%GH May 2024
+ case {'fareanlat','fareaplat','peakampbl','peaklatbl','fpeaklat'}
+ msgboxText = [errmsg,', erpset',num2str(k) ];
otherwise
- msgboxText = 'Sorry, something went wrong.';
- end
- if shist == 1; % gui
- tittle = 'ERPLAB: geterpvalues() error:';
- errorfound(sprintf(msgboxText), tittle);
- [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP);
- pause(0.1)
- return
- else
- error('Error:measurements', msgboxText)
+ msgboxText = errmsg ;
+ end
+ otherwise
+ msgboxText = 'Sorry, something went wrong.';
+ end
+ if shist == 1; % gui
+ tittle = 'ERPLAB: geterpvalues() error:';
+ errorfound(sprintf(msgboxText), tittle);
+ if strcmpi(ERPtooltype,'ERPLAB')%%GH May 2024
+ [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP);
end
+ pause(0.1)
+ return
+ else
+ error('Error:measurements', msgboxText)
+ end
end
%
% Send measurements to workspace (from GUI)
%
if send2ws==1
- assignin('base','ERP_MEASURES', Amp);
- fprintf('\n%seasured values were sent to Workspace as ERP_MEASURES.\n', prew);
+ assignin('base','ERP_MEASURES', Amp);
+ fprintf('\n%seasured values were sent to Workspace as ERP_MEASURES.\n', prew);
end
%
% Open Viewer ********
%
if viewmea==1
- comme = '';
- switch moption
- case 'instabl'
- moptionstr = measurearray{1};
- case 'meanbl'
- moptionstr = measurearray{2};
- case 'peakampbl'
- moptionstr = measurearray{3};
- if polpeak
- comme = ', positive';
- else
- comme = ', negative';
- end
- case 'peaklatbl'
- moptionstr = measurearray{4};
- if polpeak
- comme = ', positive';
- else
- comme = ', negative';
- end
- case 'fpeaklat'
- moptionstr = measurearray{5};
- if polpeak
- comme = ', positive';
- else
- comme = ', negative';
- end
- case {'areat', 'areap', 'arean', 'ninteg'}
- moptionstr = measurearray{6};
- if strcmpi(moption, 'areat')
- comme = ', total';
- elseif strcmpi(moption, 'areap')
- comme = ', positive';
- elseif strcmpi(moption, 'arean')
- comme = ', negative';
- else
- comme = '. Integral';
- end
- case {'areazt','areazp','areazn', 'nintegz'}
- moptionstr = measurearray{7};
- if strcmpi(moption, 'areazt')
- comme = ', total';
- elseif strcmpi(moption, 'areazp')
- comme = ', positive';
- elseif strcmpi(moption, 'areazn')
- comme = ', negative';
- else
- comme = '. Integral';
- end
- case {'fareatlat', 'fareaplat','fninteglat','fareanlat', }
- moptionstr = measurearray{8};
- if strcmpi(moption, 'fareatlat')
- comme = ', total';
- elseif strcmpi(moption, 'fareaplat')
- comme = ', positive';
- elseif strcmpi(moption, 'fareanlat')
- comme = ', negative';
- else
- comme = '. Integral';
- end
- otherwise
- return
- end
-
- moptionstr = [moptionstr comme];
- moreoptions = {blc, moption, moptionstr, dig, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor};
-
- %
- % Call Viewer GUI
- %
- if optioni==1 % from files
- mout = meaviewerGUI(ALLERPX, {Amp, Lat, binArray, chanArray, erpsetArray, latency, moreoptions});
- clear ALLERPX % auxiliar ALLERP
- else
- mout = meaviewerGUI(ALLERP, {Amp, Lat, binArray, chanArray, erpsetArray, latency, moreoptions});
- end
- if ~isempty(mout) && iscell(mout)
- %try
- latfromviewer = mout{2};
- %catch
- %end
- if ~isempty(latfromviewer)
-
- if isnan(latfromviewer)% when viewer is open from plotted figure
- return
- end
-
- def = erpworkingmemory('pop_geterpvalues');
- def{4} = latfromviewer;
- erpworkingmemory('pop_geterpvalues', def);
- end
- [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP);
- pause(0.1)
- return
- elseif isnan(mout) % when viewer is open from plotted figure
- return
- else
- disp('User selected Cancel')
+ comme = '';
+ switch moption
+ case 'instabl'
+ moptionstr = measurearray{1};
+ case 'meanbl'
+ moptionstr = measurearray{2};
+ case 'peakampbl'
+ moptionstr = measurearray{3};
+ if polpeak
+ comme = ', positive';
+ else
+ comme = ', negative';
+ end
+ case 'peaklatbl'
+ moptionstr = measurearray{4};
+ if polpeak
+ comme = ', positive';
+ else
+ comme = ', negative';
+ end
+ case 'fpeaklat'
+ moptionstr = measurearray{5};
+ if polpeak
+ comme = ', positive';
+ else
+ comme = ', negative';
+ end
+ case {'areat', 'areap', 'arean', 'ninteg'}
+ moptionstr = measurearray{6};
+ if strcmpi(moption, 'areat')
+ comme = ', total';
+ elseif strcmpi(moption, 'areap')
+ comme = ', positive';
+ elseif strcmpi(moption, 'arean')
+ comme = ', negative';
+ else
+ comme = '. Integral';
+ end
+ case {'areazt','areazp','areazn', 'nintegz'}
+ moptionstr = measurearray{7};
+ if strcmpi(moption, 'areazt')
+ comme = ', total';
+ elseif strcmpi(moption, 'areazp')
+ comme = ', positive';
+ elseif strcmpi(moption, 'areazn')
+ comme = ', negative';
+ else
+ comme = '. Integral';
+ end
+ case {'fareatlat', 'fareaplat','fninteglat','fareanlat', }
+ moptionstr = measurearray{8};
+ if strcmpi(moption, 'fareatlat')
+ comme = ', total';
+ elseif strcmpi(moption, 'fareaplat')
+ comme = ', positive';
+ elseif strcmpi(moption, 'fareanlat')
+ comme = ', negative';
+ else
+ comme = '. Integral';
+ end
+ otherwise
+ return
+ end
+
+ moptionstr = [moptionstr comme];
+ moreoptions = {blc, moption, moptionstr, dig, coi, polpeak, sampeak, locpeakrep, frac, fracmearep, intfactor};
+
+ %
+ % Call Viewer GUI
+ %
+ if optioni==1 % from files
+ mout = meaviewerGUI(ALLERPX, {Amp, Lat, binArray, chanArray, erpsetArray, latency, moreoptions});
+ clear ALLERPX % auxiliar ALLERP
+ else
+ mout = meaviewerGUI(ALLERP, {Amp, Lat, binArray, chanArray, erpsetArray, latency, moreoptions});
+ end
+ if ~isempty(mout) && iscell(mout)
+ %try
+ latfromviewer = mout{2};
+ %catch
+ %end
+ if ~isempty(latfromviewer)
+
+ if isnan(latfromviewer)% when viewer is open from plotted figure
return
+ end
+
+ def = erpworkingmemory('pop_geterpvalues');
+ def{4} = latfromviewer;
+ erpworkingmemory('pop_geterpvalues', def);
+ end
+ if strcmpi(ERPtooltype,'ERPLAB')%%GH May 2024
+ [ALLERP, Amp, Lat, erpcom] = pop_geterpvalues(ALLERP);
end
+ pause(0.1)
+ return
+ elseif isnan(mout) % when viewer is open from plotted figure
+ return
+ else
+ disp('User selected Cancel')
+ return
+ end
end
@@ -934,57 +952,57 @@
skipfields = {'ALLERP', 'latency', 'binArray','chanArray', 'Component', 'Warning','History'};
if isstruct(ALLERP) && optioni~=1 % from files
- if length(erpsetArray)==1 && erpsetArray==1
- DATIN = 'ERP';
- skipfields = [skipfields, 'Erpsets'];
- else
- DATIN = inputname(1);
- end
-else
- %DATIN = ['''' ALLERP ''''];
- DATIN = sprintf('''%s''', filelist);
+ if length(erpsetArray)==1 && erpsetArray==1
+ DATIN = 'ERP';
skipfields = [skipfields, 'Erpsets'];
+ else
+ DATIN = inputname(1);
+ end
+else
+ %DATIN = ['''' ALLERP ''''];
+ DATIN = sprintf('''%s''', filelist);
+ skipfields = [skipfields, 'Erpsets'];
end
if ~ismember_bc2({moption}, {'peakampbl', 'peaklatbl', 'fpeaklat'}) % JLC. 08/22/13
- skipfields = [skipfields {'Neighborhood', 'Peakpolarity', 'Peakreplace'}];
+ skipfields = [skipfields {'Neighborhood', 'Peakpolarity', 'Peakreplace'}];
end
if strcmpi(fname,'no_save.no_save') || strcmpi(fname,'tempofile.txt')
- skipfields = [skipfields {'Filename'}];
+ skipfields = [skipfields {'Filename'}];
end
fn = fieldnames(p.Results);
erpcom = sprintf( 'ALLERP = pop_geterpvalues( %s, %s, %s, %s ', DATIN, latencystr, binArraystr, chanArraystr);
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') && ~strcmpi(fn2res,'no')
- erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
- end
- else
- erpcom = sprintf( '%s, ''%s'', %s', erpcom, fn2com, vect2colon(fn2res,'Repeat','on'));
- end
+ fn2com = fn{q};
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com);
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off') && ~strcmpi(fn2res,'no')
+ erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
end
+ else
+ erpcom = sprintf( '%s, ''%s'', %s', erpcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ 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(ALLERP)
- ALLERP(i) = erphistory(ALLERP(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 = '';
- return
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ for i=1:length(ALLERP)
+ ALLERP(i) = erphistory(ALLERP(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 = '';
+ return
end
return
diff --git a/pop_functions/pop_importeegeventlist.m b/pop_functions/pop_importeegeventlist.m
index 9d4703c3..0570ee66 100755
--- a/pop_functions/pop_importeegeventlist.m
+++ b/pop_functions/pop_importeegeventlist.m
@@ -54,68 +54,68 @@
function [EEG, com] = pop_importeegeventlist(EEG, ELfullname, varargin)
com = '';
if nargin < 1
- help pop_importeegeventlist
- return
+ help pop_importeegeventlist
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- if length(EEG)>1
- msgboxText = 'Unfortunately, this function does not work with multiple datasets';
- title = 'ERPLAB: multiple inputs';
- errorfound(msgboxText, title);
- return
- end
- if isempty(EEG)
- msgboxText = 'pop_importeegeventlist() error: cannot work with an empty dataset!';
- title = 'ERPLAB: pop_importeegeventlist() error';
- errorfound(msgboxText, title);
- return
- end
- if isempty(EEG.data)
- msgboxText = 'pop_importeegeventlist() cannot work with an empty dataset!';
- title = 'ERPLAB: pop_importeegeventlist() error';
- errorfound(msgboxText, title);
- return
- end
- if ~isempty(EEG.epoch)
- msgboxText = 'pop_importeegeventlist() has been tested for continuous data only.';
- title = 'ERPLAB: pop_importeegeventlist Permission denied';
- errorfound(msgboxText, title);
- return
- end
- [filename,pathname] = uigetfile({'*.*';'*.txt'},'Select a EVENTLIST file');
- ELfullname = fullfile(pathname, filename);
-
- if isequal(filename,0)
- disp('User selected Cancel')
- return
- else
- disp(['For read an EVENTLIST, user selected ', ELfullname])
- end
-
- question = ['Do you want to replace your EEG.EVENTLIST field with this file?\n\n'...
- ' (YES: replace) (NO: sent EVENTLIST to workspace)'];
- title = 'ERPLAB: Confirmation';
- button = askquest(sprintf(question), title);
-
- if strcmpi(button,'yes')
- repEL = 'on';
- elseif strcmpi(button,'no')
- repEL = 'off';
- else
- disp('User selected Cancel')
- return
- end
-
- %
- % Somersault
- %
- EEG.setname = [EEG.setname '_impel']; %suggest a new name (Imported Event List)
- [EEG, com] = pop_importeegeventlist(EEG, ELfullname, 'ReplaceEventList', repEL, 'History', 'gui');
+ if length(EEG)>1
+ msgboxText = 'Unfortunately, this function does not work with multiple datasets';
+ title = 'ERPLAB: multiple inputs';
+ errorfound(msgboxText, title);
+ return
+ end
+ if isempty(EEG)
+ msgboxText = 'pop_importeegeventlist() error: cannot work with an empty dataset!';
+ title = 'ERPLAB: pop_importeegeventlist() error';
+ errorfound(msgboxText, title);
+ return
+ end
+ if isempty(EEG.data)
+ msgboxText = 'pop_importeegeventlist() cannot work with an empty dataset!';
+ title = 'ERPLAB: pop_importeegeventlist() error';
+ errorfound(msgboxText, title);
return
+ end
+ if ~isempty(EEG.epoch)
+ msgboxText = 'pop_importeegeventlist() has been tested for continuous data only.';
+ title = 'ERPLAB: pop_importeegeventlist Permission denied';
+ errorfound(msgboxText, title);
+ return
+ end
+ [filename,pathname] = uigetfile({'*.txt';'*.xls,*.xlsx';'*.*'},'Select a EVENTLIST file');
+ ELfullname = fullfile(pathname, filename);
+
+ if isequal(filename,0)
+ disp('User selected Cancel')
+ return
+ else
+ disp(['For read an EVENTLIST, user selected ', ELfullname])
+ end
+
+ question = ['Do you want to replace your EEG.EVENTLIST field with this file?\n\n'...
+ ' (YES: replace) (NO: sent EVENTLIST to workspace)'];
+ title = 'ERPLAB: Confirmation';
+ button = askquest(sprintf(question), title);
+
+ if strcmpi(button,'yes')
+ repEL = 'on';
+ elseif strcmpi(button,'no')
+ repEL = 'off';
+ else
+ disp('User selected Cancel')
+ return
+ end
+
+ %
+ % Somersault
+ %
+ EEG.setname = [EEG.setname '_impel']; %suggest a new name (Imported Event List)
+ [EEG, com] = pop_importeegeventlist(EEG, ELfullname, 'ReplaceEventList', repEL, 'History', 'gui');
+ return
end
%
@@ -134,134 +134,138 @@
p.parse(EEG, ELfullname, varargin{:});
if length(EEG)>1
- msgboxText = 'Unfortunately, this function does not work with multiple datasets';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'Unfortunately, this function does not work with multiple datasets';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if isempty(EEG)
- msgboxText = 'pop_importeegeventlist() error: cannot work with an empty dataset!';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'pop_importeegeventlist() error: cannot work with an empty dataset!';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if isempty(EEG.data)
- msgboxText = 'pop_importeegeventlist() cannot work with an empty dataset!';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'pop_importeegeventlist() cannot work with an empty dataset!';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if ~isempty(EEG.epoch)
- msgboxText = 'pop_importeegeventlist() has been tested for continuous data only.';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'pop_importeegeventlist() has been tested for continuous data only.';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if strcmpi(p.Results.ReplaceEventList,'on')
- repEL = 1;
+ repEL = 1;
else
- repEL = 0;
+ repEL = 0;
end
if strcmpi(p.Results.Warning, 'on')
- rwwarn = 1;
+ rwwarn = 1;
else
- rwwarn = 0;
+ rwwarn = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
% subroutine
%
-[EEG, EVENTLIST] = readeventlist(EEG, ELfullname);
-[pathstr, filename, ext] = fileparts(ELfullname);
+[pathstr, filename, ext] = fileparts(ELfullname);%%GH Mar 2024
+if strcmpi(ext,'.txt')
+ [EEG, EVENTLIST] = readeventlist(EEG, ELfullname);
+else
+ [EEG, EVENTLIST] = f_readeventlist_excel(EEG, ELfullname);
+end
if repEL
- if ~isempty(EVENTLIST)
- EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
- EEG = pop_overwritevent(EEG, 'code');
- EEG.EVENTLIST = [];
- [EEG, EVENTLIST] = creaeventlist(EEG, EVENTLIST, [filename '_new_' num2str((datenum(datestr(now))*1e10)) '.txt'], 0);
- EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
-
- disp('EVENTLIST was added to the current EEG structure')
- else
- EEG.EVENTLIST = [];
- [EEG, EVENTLIST] = creaeventlist(EEG, EVENTLIST, [filename '_new_' num2str((datenum(datestr(now))*1e10)) '.txt'], 1);
- EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
- end
-
- %
- % History
- %
- skipfields = {'EEG', 'ELfullname','History'};
- fn = fieldnames(p.Results);
+ if ~isempty(EVENTLIST)
+ EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
+ EEG = pop_overwritevent(EEG, 'code');
+ EEG.EVENTLIST = [];
+ [EEG, EVENTLIST] = creaeventlist(EEG, EVENTLIST, [filename '_new_' num2str((datenum(datestr(now))*1e10)) '.txt'], 0);
+ EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
- com = sprintf('%s = pop_importeegeventlist( %s, ''%s'' ', inputname(1), inputname(1), ELfullname);
-
- 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')
- com = sprintf( '%s, ''%s'', ''%s''', com, 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
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- else
- com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
- end
- end
+ disp('EVENTLIST was added to the current EEG structure')
+ else
+ EEG.EVENTLIST = [];
+ [EEG, EVENTLIST] = creaeventlist(EEG, EVENTLIST, [filename '_new_' num2str((datenum(datestr(now))*1e10)) '.txt'], 1);
+ EEG = pasteeventlist(EEG, EVENTLIST, 1); % joints both structs
+ end
+
+ %
+ % History
+ %
+ skipfields = {'EEG', 'ELfullname','History'};
+ fn = fieldnames(p.Results);
+
+ com = sprintf('%s = pop_importeegeventlist( %s, ''%s'' ', inputname(1), inputname(1), ELfullname);
+
+ 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')
+ com = sprintf( '%s, ''%s'', ''%s''', com, 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
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
end
+ else
+ com = sprintf( ['%s, ''%s'', ' fnformat], com, fn2com, fn2resstr);
+ end
end
+ end
end
- com = sprintf( '%s );', com);
-
- % com = sprintf( '%s = pop_importeegeventlist( %s, ''%s'', %s );', inputname(1), inputname(1),...
- % ELfullname, num2str(repEL));
- % % get history from script
- % if shist
- % EEG = erphistory(EEG, [], com, 1);
- % else
- % com = sprintf('%s %% %s', com, datestr(now));
- % end
+ end
+ com = sprintf( '%s );', com);
+
+ % com = sprintf( '%s = pop_importeegeventlist( %s, ''%s'', %s );', inputname(1), inputname(1),...
+ % ELfullname, num2str(repEL));
+ % % get history from script
+ % if shist
+ % EEG = erphistory(EEG, [], com, 1);
+ % else
+ % com = sprintf('%s %% %s', com, datestr(now));
+ % end
else
- filenamex = regexprep(filename, ' ', '_');
- assignin('base',filenamex,EVENTLIST);
- disp(['EVENTLIST was added to WORKSPACE as ' filenamex] )
+ filenamex = regexprep(filename, ' ', '_');
+ assignin('base',filenamex,EVENTLIST);
+ disp(['EVENTLIST was added to WORKSPACE as ' filenamex] )
end
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- %EEG = erphistory(EEG, [], com, 1);
- %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
- otherwise %off or none
- com = '';
- return
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ %EEG = erphistory(EEG, [], com, 1);
+ %fprintf('%%Equivalent command:\n%s\n\n', erpcom);
+ otherwise %off or none
+ com = '';
+ return
end
%
diff --git a/pop_functions/pop_importerpeventlist.m b/pop_functions/pop_importerpeventlist.m
index 99786fff..51930ea9 100755
--- a/pop_functions/pop_importerpeventlist.m
+++ b/pop_functions/pop_importerpeventlist.m
@@ -59,54 +59,54 @@
function [ERP, erpcom] = pop_importerpeventlist(ERP, ELfullname, varargin)
erpcom = '';
if nargin < 1
- help pop_importerpeventlist
- return
+ help pop_importerpeventlist
+ return
end
if isempty(ERP)
- msgboxText = 'pop_importerpeventlist() cannot work with an empty erpset!';
- title = 'ERPLAB: pop_importerpeventlist() error';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_importerpeventlist() cannot work with an empty erpset!';
+ title = 'ERPLAB: pop_importerpeventlist() error';
+ errorfound(msgboxText, title);
+ return
end
if isempty(ERP.bindata)
- msgboxText = 'pop_importerpeventlist() cannot work with an empty erpset!';
- title = 'ERPLAB: pop_importerpeventlist() error';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_importerpeventlist() cannot work with an empty erpset!';
+ title = 'ERPLAB: pop_importerpeventlist() error';
+ errorfound(msgboxText, title);
+ return
end
if nargin==1
- %
- % Call GUI
- %
- answer = eventlist2erpGUI(ERP);
-
- if isempty(answer)
- disp('User selected Cancel')
- return
- end
-
- ELfullname = answer{1};
- repEL = answer{2};
- indexel = answer{3};
-
- if repEL==0
- repEL = 'replaceall';
- elseif repEL==1
- repEL = 'replace';
- elseif repEL==2
- repEL = 'append';
- else
- disp('User selected Cancel')
- return
- end
-
- ERP.erpname = [ERP.erpname '_impel']; %suggest a new name (Imported Event List)
-
- %
- % Somersault
- %
- [ERP, erpcom] = pop_importerpeventlist(ERP, ELfullname, 'ReplaceEventList', repEL, 'EventListIndex', indexel, 'Saveas', 'on', 'History', 'gui');
+ %
+ % Call GUI
+ %
+ answer = eventlist2erpGUI(ERP);
+
+ if isempty(answer)
+ disp('User selected Cancel')
+ return
+ end
+
+ ELfullname = answer{1};
+ repEL = answer{2};
+ indexel = answer{3};
+
+ if repEL==0
+ repEL = 'replaceall';
+ elseif repEL==1
+ repEL = 'replace';
+ elseif repEL==2
+ repEL = 'append';
+ else
+ disp('User selected Cancel')
return
+ end
+
+ ERP.erpname = [ERP.erpname '_impel']; %suggest a new name (Imported Event List)
+
+ %
+ % Somersault
+ %
+ [ERP, erpcom] = pop_importerpeventlist(ERP, ELfullname, 'ReplaceEventList', repEL, 'EventListIndex', indexel, 'Saveas', 'on', 'History', 'gui');
+ return
end
%
@@ -129,59 +129,66 @@
indexel = p.Results.EventListIndex;
if strcmpi(p.Results.ReplaceEventList,'replaceall')
- repEL = 0;
+ repEL = 0;
elseif strcmpi(p.Results.ReplaceEventList,'replace')
- repEL = 1;
+ repEL = 1;
elseif strcmpi(p.Results.ReplaceEventList,'append')
- repEL = 2;
+ repEL = 2;
else
- error('ERPLAB says: Invalid value for "ReplaceEventList"')
+ error('ERPLAB says: Invalid value for "ReplaceEventList"')
end
if strcmpi(p.Results.Warning, 'on')
- rwwarn = 1;
+ rwwarn = 1;
else
- rwwarn = 0;
+ rwwarn = 0;
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
if ismember_bc2({p.Results.Saveas}, {'on','yes'})
- issaveas = 1;
+ issaveas = 1;
else
- issaveas = 0;
+ issaveas = 0;
end
ERPaux = ERP;
%
% subroutine
%
-[ERP, EVENTLIST, serror] = importerpeventlist(ERP, ELfullname);
+[pathstr, filename, ext] = fileparts(ELfullname);%%GH Mar 2024
+if strcmpi(ext,'.txt')
+ [ERP, EVENTLIST, serror] = importerpeventlist(ERP, ELfullname);
+else
+ [ERP1, EVENTLIST] = f_readeventlist_excel(ERP, ELfullname);
+ ERP.EVENTLIST.eventinfo = EVENTLIST.eventinfo;
+ serror = 0;
+end
if serror==1
- return
+ return
end
% [pathstr, filename, ext] = fileparts(ELfullname); %#ok
if repEL==0 % make #1
- ERP.EVENTLIST = [];
- ERP = pasteeventlist(ERP, EVENTLIST, 1);
+ ERP.EVENTLIST = [];
+ ERP = pasteeventlist(ERP, EVENTLIST, 1);
elseif repEL==1 % replace
- ERP = pasteeventlist(ERP, EVENTLIST, 1, indexel);
+ ERP = pasteeventlist(ERP, EVENTLIST, 1, indexel);
elseif repEL==2 % append
- nelnext = length(ERP.EVENTLIST)+1;
- ERP = pasteeventlist(ERP, EVENTLIST, 1, nelnext);
+ nelnext = length(ERP.EVENTLIST)+1;
+ ERP = pasteeventlist(ERP, EVENTLIST, 1, nelnext);
else
- ERP = pasteeventlist(ERP, EVENTLIST, 0);
- %filenamex = regexprep(filename, ' ', '_');
- %assignin('base',filenamex,EVENTLIST);
- %disp(['EVENTLIST was added to WORKSPACE as ' filenamex] )
- return
+ ERP = pasteeventlist(ERP, EVENTLIST, 0);
+ %filenamex = regexprep(filename, ' ', '_');
+ %assignin('base',filenamex,EVENTLIST);
+ %disp(['EVENTLIST was added to WORKSPACE as ' filenamex] )
+ return
end
ERP.saved = 'no';
@@ -192,70 +199,70 @@
fn = fieldnames(p.Results);
erpcom = sprintf( '%s = pop_importerpeventlist( %s, "%s" ', inputname(1), inputname(1), ELfullname);
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
+ 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);
-if issaveas
- [ERP, issave, erpcom_save] = pop_savemyerp(ERP,'gui','erplab', 'History', 'off');
- if issave>0
- % generate text command
- 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
- fprintf('\n%s\n\n', msgwrng)
- try cprintf([0 0 1], 'COMPLETE\n\n');catch,fprintf('COMPLETE\n\n');end ;
- else
- ERP = ERPaux;
- msgwrng = 'ERPLAB Warning: Your changes were not saved';
- try cprintf([1 0.52 0.2], '%s\n\n', msgwrng);catch,fprintf('%s\n\n', msgwrng);end ;
- end
+if issaveas
+ [ERP, issave, erpcom_save] = pop_savemyerp(ERP,'gui','erplab', 'History', 'off');
+ if issave>0
+ % generate text command
+ 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
+ fprintf('\n%s\n\n', msgwrng)
+ try cprintf([0 0 1], 'COMPLETE\n\n');catch,fprintf('COMPLETE\n\n');end ;
+ else
+ ERP = ERPaux;
+ msgwrng = 'ERPLAB Warning: Your changes were not saved';
+ try cprintf([1 0.52 0.2], '%s\n\n', msgwrng);catch,fprintf('%s\n\n', msgwrng);end ;
+ end
end
% get history from script. ERP
switch shist
- case 1 % from GUI
- displayEquiComERP(erpcom);
- 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
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ 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
%
% Completion statement
diff --git a/pop_functions/pop_remove_response_mistakes.m b/pop_functions/pop_remove_response_mistakes.m
index 3e5aa916..8dae7042 100755
--- a/pop_functions/pop_remove_response_mistakes.m
+++ b/pop_functions/pop_remove_response_mistakes.m
@@ -12,8 +12,10 @@
end
EEG = remove_response_mistakes(EEG,stim_codes,resp_codes,1);
-
-[ALLEEG,EEG] = pop_newset(ALLEEG,EEG,CURRENTSET);
-
-hist_com = ['[ALLEEG EEG] = pop_remove_response_mistakes(ALLEEG, EEG, CURRENTSET, ' num2str(stim_codes) ',' num2str(resp_codes) ];
+ERPtooltype = erpgettoolversion('tooltype');
+if ~strcmpi(ERPtooltype,'estudio')
+ [ALLEEG,EEG] = pop_newset(ALLEEG,EEG,CURRENTSET);
+end
+stim_codesstr = vect2colon(stim_codes);resp_codesstr = vect2colon(resp_codes);
+hist_com = ['[ALLEEG EEG] = pop_remove_response_mistakes(ALLEEG, EEG, CURRENTSET,', stim_codesstr, ',',resp_codesstr,');' ];
diff --git a/pop_functions/pop_squeezevents.m b/pop_functions/pop_squeezevents.m
index 30617952..9134d843 100755
--- a/pop_functions/pop_squeezevents.m
+++ b/pop_functions/pop_squeezevents.m
@@ -47,38 +47,38 @@
function [EEG, com] = pop_squeezevents(EEG, varargin)
com = '';
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if isempty(EEG(1))
- msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
- title = 'ERPLAB: pop_squeezevents Permission denied';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
+ title = 'ERPLAB: pop_squeezevents Permission denied';
+ errorfound(msgboxText, title);
+ return
end
if ~isempty(EEG(1).epoch)
- msgboxText = 'pop_squeezevents() has been tested for continuous data only.';
- title = 'ERPLAB: pop_squeezevents Permission denied';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_squeezevents() has been tested for continuous data only.';
+ title = 'ERPLAB: pop_squeezevents Permission denied';
+ errorfound(msgboxText, title);
+ return
end
if isempty(EEG(1).data)
- msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
- title = 'ERPLAB: pop_squeezevents Permission denied';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
+ title = 'ERPLAB: pop_squeezevents Permission denied';
+ errorfound(msgboxText, title);
+ return
end
if isempty(EEG(1).event)
- msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
- title = 'ERPLAB: pop_squeezevents Permission denied';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
+ title = 'ERPLAB: pop_squeezevents Permission denied';
+ errorfound(msgboxText, title);
+ return
end
if isempty([EEG(1).event.type])
- msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
- title = 'ERPLAB: pop_squeezevents Permission denied';
- errorfound(msgboxText, title);
- return
+ msgboxText = 'pop_squeezevents() cannot work with an empty dataset.';
+ title = 'ERPLAB: pop_squeezevents Permission denied';
+ errorfound(msgboxText, title);
+ return
end
p = inputParser;
@@ -89,41 +89,58 @@
p.parse(EEG, varargin{:});
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
% process multiple datasets April 13, 2011 JLC
%
if length(EEG) > 1
- [EEG, com ] = eeg_eval( 'pop_squeezevents', EEG, 'warning', 'on');
- return;
+ [EEG, com ] = eeg_eval( 'pop_squeezevents', EEG, 'warning', 'on');
+ return;
end
-
+%%for events
squeezevents(EEG.event);
+
+%%for bins if exist---Jan 09 2024 GH
+if isfield(EEG,'EVENTLIST') && ~isempty(EEG.EVENTLIST)
+ if ~isempty(EEG.EVENTLIST.trialsperbin)
+ for jjj = 1:length(EEG.EVENTLIST.eventinfo)
+ eventbini(jjj,1) = EEG.EVENTLIST.eventinfo(jjj).bini;
+ end
+ if any(eventbini(:)>0)
+ fprintf('\n\n**Below is the number and description of each bin:\n\n')
+ for ii = 1:numel(EEG.EVENTLIST.trialsperbin)
+ fprintf(['bin',32,num2str(ii),', #',32,num2str(EEG.EVENTLIST.trialsperbin(ii)),',',32,EEG.EVENTLIST.bdf(ii).description,'\n'])
+ end
+ end
+ end
+end%%change end
+
+
com = sprintf( 'pop_squeezevents(%s);', inputname(1));
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- % EEG = erphistory(EEG, [], com, 1);
- % fprintf('%%Equivalent command:\n%s\n\n', com);
- otherwise %off or none
- com = '';
- return
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ % EEG = erphistory(EEG, [], com, 1);
+ % fprintf('%%Equivalent command:\n%s\n\n', com);
+ otherwise %off or none
+ com = '';
+ return
end
%
diff --git a/pop_functions/pop_summary_AR_eeg_detection.m b/pop_functions/pop_summary_AR_eeg_detection.m
index c31f03c5..40e32a7c 100755
--- a/pop_functions/pop_summary_AR_eeg_detection.m
+++ b/pop_functions/pop_summary_AR_eeg_detection.m
@@ -52,74 +52,80 @@
rej = [];
histoflags = [];
if nargin<1
- help pop_summary_AR_eeg_detection
- return
+ help pop_summary_AR_eeg_detection
+ return
end
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- if length(EEG)>1
- msgboxText = 'Unfortunately, pop_summary_AR_eeg_detection() does not work with multiple datasets';
- title = 'ERPLAB: multiple inputs';
- errorfound(msgboxText, title);
- return
- end
- if isempty(EEG.epoch)
- msgboxText = 'pop_summary_AR_eeg_detection() only works with epoched dataset.';
- title = 'ERPLAB: pop_summary_AR_eeg_detection';
- errorfound(sprintf(msgboxText), title);
- return
- end
-
- BackERPLABcolor = [1 0.9 0.3]; % ERPLAB main window background
- question = 'In order to see your summary, what would you like to do?';
+ if length(EEG)>1
+ msgboxText = 'Unfortunately, pop_summary_AR_eeg_detection() does not work with multiple datasets';
+ title = 'ERPLAB: multiple inputs';
+ errorfound(msgboxText, title);
+ return
+ end
+ if isempty(EEG.epoch)
+ msgboxText = 'pop_summary_AR_eeg_detection() only works with epoched dataset.';
+ title = 'ERPLAB: pop_summary_AR_eeg_detection';
+ errorfound(sprintf(msgboxText), title);
+ return
+ end
+
+ BackERPLABcolor = [1 0.9 0.3]; % ERPLAB main window background
+ question = 'In order to see your summary, what would you like to do?';
+
+ if isempty(EEG.setname)%%changed by GH Sep. 2023
title = 'Artifact detection summary';
- oldcolor = get(0,'DefaultUicontrolBackgroundColor');
- set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
- button = questdlg(question, title,'Save in a file','Show at Command Window', 'Cancel','Show at Command Window');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+ else
+ title = ['Artifact detection summary for ',EEG.setname];
+ end
+
+ oldcolor = get(0,'DefaultUicontrolBackgroundColor');
+ set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
+ button = questdlg(question, title,'Save in a file','Show at Command Window', 'Cancel','Show at Command Window');
+ set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+
+ if strcmpi(button,'Show at Command Window')
+ fullname = '';
+ elseif strcmpi(button,'Save in a file')
- if strcmpi(button,'Show at Command Window')
- fullname = '';
- elseif strcmpi(button,'Save in a file')
-
- %
- % Save OUTPUT file
- %
- [filename, filepath, filterindex] = uiputfile({'*.txt';'*.dat';'*.*'},'Save Artifact Detection Summary as', ['AR_summary_' EEG.setname]);
+ %
+ % Save OUTPUT file
+ %
+ [filename, filepath, filterindex] = uiputfile({'*.txt';'*.dat';'*.*'},'Save Artifact Detection Summary as', ['AR_summary_' EEG.setname]);
+
+ if isequal(filename,0)
+ disp('User selected Cancel')
+ return
+ else
+ [px, fname, ext] = fileparts(filename);
+
+ if strcmp(ext,'')
- if isequal(filename,0)
- disp('User selected Cancel')
- return
+ if filterindex==1 || filterindex==3
+ ext = '.txt';
else
- [px, fname, ext] = fileparts(filename);
-
- if strcmp(ext,'')
-
- if filterindex==1 || filterindex==3
- ext = '.txt';
- else
- ext = '.dat';
- end
- end
-
- fname = [ fname ext];
- fullname = fullfile(filepath, fname);
- disp(['For saving artifact detection summary, user selected ' fullname ''])
-
+ ext = '.dat';
end
- elseif strcmpi(button,'Cancel') || strcmpi(button,'')
- disp('User selected Cancel')
- return
+ end
+
+ fname = [ fname ext];
+ fullname = fullfile(filepath, fname);
+ disp(['For saving artifact detection summary, user selected ' fullname ''])
+
end
-
- %
- % Somersault
- %
- [EEG, tprej, acce, rej, histoflags, com] = pop_summary_AR_eeg_detection(EEG, fullname, 'History', 'gui');
+ elseif strcmpi(button,'Cancel') || strcmpi(button,'')
+ disp('User selected Cancel')
return
+ end
+
+ %
+ % Somersault
+ %
+ [EEG, tprej, acce, rej, histoflags, com] = pop_summary_AR_eeg_detection(EEG, fullname, 'History', 'gui');
+ return
end
%
@@ -135,30 +141,30 @@
p.parse(EEG, fullname, varargin{:});
if length(EEG)>1
- msgboxText = 'Unfortunately, pop_summary_AR_eeg_detection() does not work with multiple datasets';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'Unfortunately, pop_summary_AR_eeg_detection() does not work with multiple datasets';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if isempty(EEG.epoch)
- msgboxText = 'pop_summary_AR_eeg_detection() only works with epoched dataset.';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'pop_summary_AR_eeg_detection() only works with epoched dataset.';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
if isempty(strtrim(fullname))
- fidsumm = 1; % to command window
+ fidsumm = 1; % to command window
else
- if strcmpi(strtrim(fullname), 'none')
- fidsumm = -99;
- else
- fidsumm = fopen( fullname , 'w'); % to a file
- end
+ if strcmpi(strtrim(fullname), 'none')
+ fidsumm = -99;
+ else
+ fidsumm = fopen( fullname , 'w'); % to a file
+ end
end
F = fieldnames(EEG.reject);
@@ -170,66 +176,66 @@
histT = zeros(1, EEG.trials);
for i=1:nfield
- fieldnameE = char(sfields2{i});
- fieldnameT = char(rfields{i});
-
- if ~isempty(EEG.reject.(fieldnameE))
- histE = histE | [EEG.reject.(fieldnameE)]; %electrodes
- histT = histT | [EEG.reject.(fieldnameT)]; %trials (epochs)
- end
+ fieldnameE = char(sfields2{i});
+ fieldnameT = char(rfields{i});
+
+ if ~isempty(EEG.reject.(fieldnameE))
+ histE = histE | [EEG.reject.(fieldnameE)]; %electrodes
+ histT = histT | [EEG.reject.(fieldnameT)]; %trials (epochs)
+ end
end
nbin = EEG.EVENTLIST.nbin;
Sumbin = zeros(1,nbin);
for i=1:nbin
- for j=1:EEG.trials
- if length(EEG.epoch(j).eventlatency) == 1
- binix = [EEG.epoch(j).eventbini];
- if iscell(binix)
- binix = cell2mat(binix);
- end
- if ismember(i, binix)
- Sumbin(i) = Sumbin(i) + histT(j);
- end
- elseif length(EEG.epoch(j).eventlatency) > 1
- indxtimelock = find(cell2mat(EEG.epoch(j).eventlatency) == 0,1,'first'); % catch zero-time locked type,
- if ismember(i, EEG.epoch(j).eventbini{indxtimelock})
- Sumbin(i) = Sumbin(i) + histT(j);
- end
- end
+ for j=1:EEG.trials
+ if length(EEG.epoch(j).eventlatency) == 1
+ binix = [EEG.epoch(j).eventbini];
+ if iscell(binix)
+ binix = cell2mat(binix);
+ end
+ if ismember(i, binix)
+ Sumbin(i) = Sumbin(i) + histT(j);
+ end
+ elseif length(EEG.epoch(j).eventlatency) > 1
+ indxtimelock = find(cell2mat(EEG.epoch(j).eventlatency) == 0,1,'first'); % catch zero-time locked type,
+ if ismember(i, EEG.epoch(j).eventbini{indxtimelock})
+ Sumbin(i) = Sumbin(i) + histT(j);
+ end
end
+ end
end
histoflags = summary_rejectflags(EEG);
if fidsumm~=-99
- %
- % Table
- %
- hdr = {'Bin' '#(%) accepted' '#(%) rejected' '# F2' '# F3' '# F4' '# F5' '# F6' '# F7' '# F8' };
- fprintf(fidsumm, '%s %15s %15s %7s %7s %7s %7s %7s %7s %7s\n', hdr{:});
+ %
+ % Table
+ %
+ hdr = {'Bin' '#(%) accepted' '#(%) rejected' '# F2' '# F3' '# F4' '# F5' '# F6' '# F7' '# F8' };
+ fprintf(fidsumm, '%s %15s %15s %7s %7s %7s %7s %7s %7s %7s\n', hdr{:});
end
acce = zeros(1,nbin);
rej = zeros(1,nbin);
for i=1:nbin
- rej(i) = Sumbin(i) ;
- acce(i) = EEG.EVENTLIST.trialsperbin(i)-rej(i);
-
- if EEG.EVENTLIST.trialsperbin(i) ~= 0
- pacce = (acce(i)/EEG.EVENTLIST.trialsperbin(i))*100;
- paccestr = sprintf('%.1f', pacce);
- prej = (rej(i)/EEG.EVENTLIST.trialsperbin(i))*100;
- prejstr = sprintf('%.1f', prej);
- else
- paccestr = 'error';
- prejstr = 'error';
- end
- if fidsumm~=-99
- fprintf(fidsumm, '%3g %6g(%5s) %8g(%5s) %7g %7g %7g %7g %7g %7g %7g\n', i,acce(i), paccestr, rej(i), prejstr, histoflags(i,2:8));
- end
+ rej(i) = Sumbin(i) ;
+ acce(i) = EEG.EVENTLIST.trialsperbin(i)-rej(i);
+
+ if EEG.EVENTLIST.trialsperbin(i) ~= 0
+ pacce = (acce(i)/EEG.EVENTLIST.trialsperbin(i))*100;
+ paccestr = sprintf('%.1f', pacce);
+ prej = (rej(i)/EEG.EVENTLIST.trialsperbin(i))*100;
+ prejstr = sprintf('%.1f', prej);
+ else
+ paccestr = 'error';
+ prejstr = 'error';
+ end
+ if fidsumm~=-99
+ fprintf(fidsumm, '%3g %6g(%5s) %8g(%5s) %7g %7g %7g %7g %7g %7g %7g\n', i,acce(i), paccestr, rej(i), prejstr, histoflags(i,2:8));
+ end
end
trej = sum(Sumbin);
@@ -240,29 +246,29 @@
tprejstr = sprintf('%.1f', tprej);
thistoflags = sum(histoflags,1);
if fidsumm~=-99
- fprintf(fidsumm, [repmat('_',1,100) '\n']);
- fprintf(fidsumm, 'Total %5g(%5s) %8g(%5s) %7g %7g %7g %7g %7g %7g %7g\n', tacce, tpaccestr, trej, tprejstr, thistoflags(2:8));
- fprintf(fidsumm, '\n');
+ fprintf(fidsumm, [repmat('_',1,100) '\n']);
+ fprintf(fidsumm, 'Total %5g(%5s) %8g(%5s) %7g %7g %7g %7g %7g %7g %7g\n', tacce, tpaccestr, trej, tprejstr, thistoflags(2:8));
+ fprintf(fidsumm, '\n');
end
if fidsumm>1
- fclose(fidsumm);
- com = sprintf('EEG = pop_summary_AR_eeg_detection(EEG, ''%s'');', fullname);
+ fclose(fidsumm);
+ com = sprintf('EEG = pop_summary_AR_eeg_detection(EEG, ''%s'');', fullname);
else
- com = sprintf('[EEG, tprej, acce, rej, histoflags ] = pop_summary_AR_eeg_detection(EEG,''none'');');
+ com = sprintf('[EEG, tprej, acce, rej, histoflags ] = pop_summary_AR_eeg_detection(EEG,''none'');');
end
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- otherwise %off or none
- com = '';
- return
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ otherwise %off or none
+ com = '';
+ return
end
%
diff --git a/pop_functions/pop_summary_AR_erp_detection.m b/pop_functions/pop_summary_AR_erp_detection.m
index 69cbb978..d2900b04 100755
--- a/pop_functions/pop_summary_AR_erp_detection.m
+++ b/pop_functions/pop_summary_AR_erp_detection.m
@@ -84,7 +84,7 @@
oldcolor = get(0,'DefaultUicontrolBackgroundColor');
set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
button = questdlg(question, title,'Save in a file','Show at Command Window', 'Cancel','Show at Command Window');
- set(0,'DefaultUicontrolBackgroundColor',oldcolor)
+ set(0,'DefaultUicontrolBackgroundColor',oldcolor);
if strcmpi(button,'Show at Command Window')
fullname = '';
@@ -184,6 +184,9 @@
% Table
%
if fidsumm~=-99
+ fprintf(fidsumm, ['\n',repmat('_',1,100) '\n']);
+ fprintf(fidsumm, ['ERP Name:',32,ERP.erpname '\n']);
+ fprintf(fidsumm, [repmat('_',1,100) '\n']);
hdr = {'Bin' '#(%) accepted' '#(%) rejected' '# F2' '# F3' '# F4' '# F5' '# F6' '# F7' '# F8' };
fprintf(fidsumm, '%s %15s %15s %7s %7s %7s %7s %7s %7s %7s\n', hdr{:});
end
diff --git a/pop_functions/pop_syncroartifacts.m b/pop_functions/pop_syncroartifacts.m
index 519b76f5..be3d3210 100755
--- a/pop_functions/pop_syncroartifacts.m
+++ b/pop_functions/pop_syncroartifacts.m
@@ -14,7 +14,7 @@
% 'Direction' 'erplab2eeglab' - erplab to eeglab synchro
% 'eeglab2erplab' - eeglab to erplab synchro
% 'bidirectional' - (default) both
-%
+%
% OUTPUTS
%
% EEG - updated epoched dataset
@@ -56,46 +56,46 @@
com = '';
if isobject(EEG) % eegobj
- whenEEGisanObject % calls a script for showing an error window
- return
+ whenEEGisanObject % calls a script for showing an error window
+ return
end
if nargin==1
- serror = erplab_eegscanner(EEG, 'pop_syncroartifacts', 2, 0, 1, 2, 1);
- if serror
- return
- end
-
- %
- % Call GUI
- %
- direction = synchroartifactsGUI;
- % direction = 1; % erplab to eeglab synchro
- % direction = 2; % eeglab to erplab synchro
- % direction = 3; % both
- % direction = 0; % none
- if isempty(direction)
- disp('User selected Cancel')
- return
- end
- if direction==1 % erplab to eeglab synchro
- dircom = 'erplab2eeglab';
- elseif direction==2 %eeglab to erplab synchro
- dircom = 'eeglab2erplab';
- elseif direction==3 % both
- dircom = 'bidirectional';
- else
- dircom = 'none';
- end
- if length(EEG)==1
- EEG.setname = [EEG.setname '_synctrej']; %suggest a new name
- end
-
- %
- % Somersault
- %
- [EEG, com] = pop_syncroartifacts(EEG, 'Direction', dircom, 'History', 'gui');
- pause(0.1);
+ serror = erplab_eegscanner(EEG, 'pop_syncroartifacts', 2, 0, 1, 2, 1);
+ if serror
+ return
+ end
+
+ %
+ % Call GUI
+ %
+ direction = synchroartifactsGUI;
+ % direction = 1; % erplab to eeglab synchro
+ % direction = 2; % eeglab to erplab synchro
+ % direction = 3; % both
+ % direction = 0; % none
+ if isempty(direction)
+ disp('User selected Cancel')
return
+ end
+ if direction==1 % erplab to eeglab synchro
+ dircom = 'erplab2eeglab';
+ elseif direction==2 %eeglab to erplab synchro
+ dircom = 'eeglab2erplab';
+ elseif direction==3 % both
+ dircom = 'bidirectional';
+ else
+ dircom = 'none';
+ end
+ if length(EEG)==1
+ EEG.setname = [EEG.setname '_synctrej']; %suggest a new name
+ end
+
+ %
+ % Somersault
+ %
+ [EEG, com] = pop_syncroartifacts(EEG, 'Direction', dircom, 'History', 'gui');
+ pause(0.1);
+ return
end
%
@@ -110,22 +110,22 @@
p.parse(EEG, varargin{:});
if strcmpi(p.Results.History,'implicit')
- shist = 3; % implicit
+ shist = 3; % implicit
elseif strcmpi(p.Results.History,'script')
- shist = 2; % script
+ shist = 2; % script
elseif strcmpi(p.Results.History,'gui')
- shist = 1; % gui
+ shist = 1; % gui
else
- shist = 0; % off
+ shist = 0; % off
end
%
% process multiple datasets. Updated August 23, 2013 JLC
%
if length(EEG) > 1
- options1 = {'Direction', p.Results.Direction, 'History', 'gui'};
- [ EEG, com ] = eeg_eval( 'pop_syncroartifacts', EEG, 'warning', 'on', 'params', options1);
- return;
+ options1 = {'Direction', p.Results.Direction, 'History', 'gui'};
+ [ EEG, com ] = eeg_eval( 'pop_syncroartifacts', EEG, 'warning', 'on', 'params', options1);
+ return;
end
%erplab_eegscanner(EEG, funcname, chckmultieeg, chckemptyeeg, chckepocheeg, chcknoevents, chckeventlist, varargin)
@@ -133,20 +133,20 @@
if strcmpi(p.Results.Direction,'no') || strcmpi(p.Results.Direction,'none')
- direction = 0;
+ direction = 0;
elseif strcmpi(p.Results.Direction,'erplab2eeglab')
- direction = 1;
+ direction = 1;
elseif strcmpi(p.Results.Direction,'eeglab2erplab')
- direction = 2;
+ direction = 2;
elseif strcmpi(p.Results.Direction,'bidirectional')
- direction = 3;
+ direction = 3;
else
- msgboxText = 'ERPLAB says: Invalid synchronization direction parameter.';
- error('prog:input', ['ERPLAB says: ' msgboxText]);
+ msgboxText = 'ERPLAB says: Invalid synchronization direction parameter.';
+ error('prog:input', ['ERPLAB says: ' msgboxText]);
end
if direction==0
- fprintf('User decided not to synchronize.\n');
- return
+ fprintf('User decided not to synchronize.\n');
+ return
end
%
@@ -154,46 +154,46 @@
%
isRT = 1; % there is RT info by default
if ~isfield(EEG.EVENTLIST.bdf, 'rt')
- isRT = 0; % no RT info
+ isRT = 0; % no RT info
else
- valid_rt = nnz(~cellfun(@isempty,{EEG.EVENTLIST.bdf.rt}));
- if valid_rt==0
- isRT = 0; % no RT info
- end
+ valid_rt = nnz(~cellfun(@isempty,{EEG.EVENTLIST.bdf.rt}));
+ if valid_rt==0
+ isRT = 0; % no RT info
+ end
end
%
% Synchronization
%
if direction==1 % erplab to eeglab synchro
- EEG = synchroner1(EEG);
+ EEG = synchroner1(EEG);
elseif direction==2 %eeglab to erplab synchro
- EEG = synchroner2(EEG, isRT);
+ EEG = synchroner2(EEG, isRT);
elseif direction==3 % both
- %EEG = synchroner1(EEG);
- %EEG = synchroner2(EEG, isRT);
- EEG = synchroner3(EEG, isRT);
+ %EEG = synchroner1(EEG);
+ %EEG = synchroner2(EEG, isRT);
+ EEG = synchroner3(EEG, isRT);
else
- fprintf('no synchronization.\n');
+ fprintf('no synchronization.\n');
end
com = sprintf( '%s = pop_syncroartifacts(%s, %s);', inputname(1), inputname(1), num2str(direction));
% get history from script. EEG
switch shist
- case 1 % from GUI
- com = sprintf('%s %% GUI: %s', com, datestr(now));
- %fprintf('%%Equivalent command:\n%s\n\n', com);
- displayEquiComERP(com);
- case 2 % from script
- EEG = erphistory(EEG, [], com, 1);
- case 3
- % implicit
- % EEG = erphistory(EEG, [], com, 1);
- % fprintf('%%Equivalent command:\n%s\n\n', com);
- otherwise %off or none
- com = '';
- return
+ case 1 % from GUI
+ com = sprintf('%s %% GUI: %s', com, datestr(now));
+ %fprintf('%%Equivalent command:\n%s\n\n', com);
+ displayEquiComERP(com);
+ case 2 % from script
+ EEG = erphistory(EEG, [], com, 1);
+ case 3
+ % implicit
+ % EEG = erphistory(EEG, [], com, 1);
+ % fprintf('%%Equivalent command:\n%s\n\n', com);
+ otherwise %off or none
+ com = '';
+ return
end
%
@@ -213,33 +213,39 @@
fprintf('---------------------------------------------------------\n\n');
nepoch = EEG.trials;
for i=1:nepoch
- cflag = EEG.epoch(i).eventflag; % flag(s) from event(s) within this epoch
- if iscell(cflag)
- %cflag = cell2mat(cflag);
- cflag = uint16([cflag{:}]); % giving some problems with uint16 type of flags
- end
- laten = EEG.epoch(i).eventlatency;% latency(ies) from event(s) within this epoch
- if iscell(laten)
- laten = cell2mat(laten);
+ cflag = EEG.epoch(i).eventflag; % flag(s) from event(s) within this epoch
+ if iscell(cflag)
+ %cflag = cell2mat(cflag);
+ cflag = uint16([cflag{:}]); % giving some problems with uint16 type of flags
+ end
+ laten = EEG.epoch(i).eventlatency;% latency(ies) from event(s) within this epoch
+ if iscell(laten)
+ laten = cell2mat(laten);
+ end
+
+ indxtimelock = find(laten == 0,1,'first'); % catch zero-time locked code position,
+ flag = cflag(indxtimelock);
+
+ %sum(bitget(flag, 1:8))>0;
+ if sum(bitget(flag, 1:8))>0
+ if ~isempty(EEG.reject.rejmanual)%%GH Jun 2024
+ if EEG.reject.rejmanual(i)==0
+ EEG.reject.rejmanual(i) = 1; % marks epoch with artifact
+ %EEG.reject.rejmanualE(chanArray(ch), i) = 1; % marks channel with artifact
+ iflag = find(bitget(flag,1:8));
+ fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for its home item.\n',i, num2str(iflag));
+ end
+
end
-
- indxtimelock = find(laten == 0,1,'first'); % catch zero-time locked code position,
- flag = cflag(indxtimelock);
-
- %sum(bitget(flag, 1:8))>0;
- if sum(bitget(flag, 1:8))>0
- if EEG.reject.rejmanual(i)==0
- EEG.reject.rejmanual(i) = 1; % marks epoch with artifact
- %EEG.reject.rejmanualE(chanArray(ch), i) = 1; % marks channel with artifact
- iflag = find(bitget(flag,1:8));
- fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for its home item.\n',i, num2str(iflag));
- end
- else
- if EEG.reject.rejmanual(i)==1
- EEG.reject.rejmanual(i)=0;
- fprintf('The mark at epoch # %g was removed due to no set flag was found at its home item.\n',i);
- end
+ else
+ if ~isempty(EEG.reject.rejmanual)%%GH Jun 2024
+ if EEG.reject.rejmanual(i)==1
+ EEG.reject.rejmanual(i)=0;
+ fprintf('The mark at epoch # %g was removed due to no set flag was found at its home item.\n',i);
+ end
+
end
+ end
end
%
@@ -250,22 +256,28 @@
fprintf('---------------------------------------------------------\n\n');
nitem = length(EEG.EVENTLIST.eventinfo);
for i=1:nitem
- flag = EEG.EVENTLIST.eventinfo(i).flag;
- bepoch = EEG.EVENTLIST.eventinfo(i).bepoch;
- if bepoch>0
- if sum(bitget(flag, 1:8))>0
- if EEG.reject.rejmanual(bepoch)==0
- EEG.reject.rejmanual(bepoch) = 1; % marks epoch with artifact
- iflag = find(bitget(flag,1:8));
- fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for item # %g.\n',bepoch, num2str(iflag), i);
- end
- else
- if EEG.reject.rejmanual(bepoch)==1
- EEG.reject.rejmanual(bepoch)=0;
- fprintf('The mark at epoch # %g was removed due to no set flag was found at item # %g.\n', bepoch, i);
- end
+ flag = EEG.EVENTLIST.eventinfo(i).flag;
+ bepoch = EEG.EVENTLIST.eventinfo(i).bepoch;
+ if bepoch>0
+ if sum(bitget(flag, 1:8))>0
+ if ~isempty(EEG.reject.rejmanual)%%GH Jun 2024
+ if EEG.reject.rejmanual(bepoch)==0
+ EEG.reject.rejmanual(bepoch) = 1; % marks epoch with artifact
+ iflag = find(bitget(flag,1:8));
+ fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for item # %g.\n',bepoch, num2str(iflag), i);
end
+
+ end
+ else
+ if ~isempty(EEG.reject.rejmanual)%%GH Jun 2024
+ if EEG.reject.rejmanual(bepoch)==1
+ EEG.reject.rejmanual(bepoch)=0;
+ fprintf('The mark at epoch # %g was removed due to no set flag was found at item # %g.\n', bepoch, i);
+ end
+
+ end
end
+ end
end
fprintf('\nEEG.reject.rejmanual(i) was synchronized according to EEG.epoch(i).eventflag values.\n')
return
@@ -287,9 +299,9 @@
indx = [];
for i=1:length(arfields)
- if ~isempty(EEG.reject.(arfields{i}))
- indx = [indx i];
- end
+ if ~isempty(EEG.reject.(arfields{i}))
+ indx = [indx i];
+ end
end
fprintf('\n---------------------------------------------------------\n');
@@ -299,23 +311,23 @@
selarfields = arfields(indx); % not empty EEGLAB's artifact rejection fields
nsarf = length(selarfields);
for i=1:ntrial;
- r = zeros(1,nsarf);
- for j=1:nsarf
- r(j) = EEG.reject.(selarfields{j})(i);
- end
- if nnz(r)>0
- EEG = markartifacts(EEG, 1, [], [], i, isRT, 1);
- else
- EEG = markartifacts(EEG, 0, [], [], i, isRT, 1); % JLC Sept 1, 2012
- end
+ r = zeros(1,nsarf);
+ for j=1:nsarf
+ r(j) = EEG.reject.(selarfields{j})(i);
+ end
+ if nnz(r)>0
+ EEG = markartifacts(EEG, 1, [], [], i, isRT, 1);
+ else
+ EEG = markartifacts(EEG, 0, [], [], i, isRT, 1); % JLC Sept 1, 2012
+ end
end
fprintf('\nFlag 1 was marked at EEG.EVENTLIST.eventinfo and EEG.epoch, according to EEG.reject.{ar_tool}.\n');
if isRT
- fprintf('For reaction time filtering, EEG.EVENTLIST.bdf was synchronized with artifact detection info as well.\n\n');
+ fprintf('For reaction time filtering, EEG.EVENTLIST.bdf was synchronized with artifact detection info as well.\n\n');
else
- fprintf('EEG.EVENTLIST.bdf was not synchronized due to reaction time measurement was not found in this dataset.\n\n');
+ fprintf('EEG.EVENTLIST.bdf was not synchronized due to reaction time measurement was not found in this dataset.\n\n');
end
return
@@ -344,9 +356,9 @@
indx = [];
for i=1:length(arfields)
- if ~isempty(EEG.reject.(arfields{i}))
- indx = [indx i];
- end
+ if ~isempty(EEG.reject.(arfields{i}))
+ indx = [indx i];
+ end
end
fprintf('\n---------------------------------------------------------\n');
@@ -378,25 +390,25 @@
fprintf('---------------------------------------------------------\n\n');
for qEpoch=1:nepoch
- cflag = EEG.epoch(qEpoch).eventflag; % flag(s) from event(s) within this epoch
- if iscell(cflag)
- %cflag = cell2mat(cflag);
- cflag = uint16([cflag{:}]); % giving some problems with uint16 type of flags
- end
- laten = EEG.epoch(qEpoch).eventlatency;% latency(ies) from event(s) within this epoch
- if iscell(laten)
- laten = cell2mat(laten);
- end
-
- indxtimelock = find(laten == 0,1,'first'); % catch zero-time locked code position,
- flag = cflag(indxtimelock);
-
- if sum(bitget(flag, 1:8))>0 && EEG.reject.rejmanual(qEpoch) == 0
- EEG.reject.rejmanual(qEpoch) = 1; % % marks epoch with artifact only if flag is marked (no unmarking)
- %EEG.reject.rejmanualE(chanArray(ch), qEpoch) = 1; % marks channel with artifact
- iflag = find(bitget(flag,1:8));
- fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for its home item.\n',qEpoch, num2str(iflag));
- end
+ cflag = EEG.epoch(qEpoch).eventflag; % flag(s) from event(s) within this epoch
+ if iscell(cflag)
+ %cflag = cell2mat(cflag);
+ cflag = uint16([cflag{:}]); % giving some problems with uint16 type of flags
+ end
+ laten = EEG.epoch(qEpoch).eventlatency;% latency(ies) from event(s) within this epoch
+ if iscell(laten)
+ laten = cell2mat(laten);
+ end
+
+ indxtimelock = find(laten == 0,1,'first'); % catch zero-time locked code position,
+ flag = cflag(indxtimelock);
+
+ if sum(bitget(flag, 1:8))>0 && EEG.reject.rejmanual(qEpoch) == 0
+ EEG.reject.rejmanual(qEpoch) = 1; % % marks epoch with artifact only if flag is marked (no unmarking)
+ %EEG.reject.rejmanualE(chanArray(ch), qEpoch) = 1; % marks channel with artifact
+ iflag = find(bitget(flag,1:8));
+ fprintf('Epoch # %g was marked due to flag(s) # %s was(were) set for its home item.\n',qEpoch, num2str(iflag));
+ end
end
%
diff --git a/studio_functions/.txt b/studio_functions/.txt
new file mode 100644
index 00000000..93380506
--- /dev/null
+++ b/studio_functions/.txt
@@ -0,0 +1,1028 @@
+# Non-editable header begin --------------------------------------------------------------------------------
+#
+# data format...............: continuous
+# setname...................: 1_MMN_shifted_ds_reref_ucbip_hpfilt_ica_weighted_new
+# filename..................: 1_MMN_shifted_ds_reref_ucbip_hpfilt_ica_weighted_new.set
+# filepath..................: /Users/gzhang/Documents/Demo data/EEGsets/EEG set/
+# nchan.....................: 30
+# pnts......................: 155648
+# srate.....................: 256
+# nevents...................: 1002
+# generated by (bdf)........:
+# generated by (set)........: 1_MMN_shifted_ds_reref_ucbip_hpfilt_ica_weighted_new
+# reported in ..............:
+# prog Version..............: 11.0
+# creation date.............: 25-Apr-2024 14:39:36
+# user Account..............:
+#
+# Non-editable header end --------------------------------------------------------------------------------
+
+
+
+
+# item bepoch ecode label onset diff dura b_flags a_flags enable bin
+# (sec) (msec) (msec) (binary) (binary)
+
+
+1 0 1 "" 12.0752 0.00 0.0 00000000 00000000 1 [ ]
+2 0 180 "" 15.1162 3041.02 0.0 00000000 00000000 1 [ ]
+3 0 180 "" 15.7129 596.68 0.0 00000000 00000000 1 [ ]
+4 0 180 "" 16.3330 620.12 0.0 00000000 00000000 1 [ ]
+5 0 180 "" 16.9170 583.98 0.0 00000000 00000000 1 [ ]
+6 0 180 "" 17.4834 566.41 0.0 00000000 00000000 1 [ ]
+7 0 180 "" 18.1064 623.05 0.0 00000000 00000000 1 [ ]
+8 0 180 "" 18.6465 540.04 0.0 00000000 00000000 1 [ ]
+9 0 180 "" 19.2734 626.95 0.0 00000000 00000000 1 [ ]
+10 0 180 "" 19.9033 629.88 0.0 00000000 00000000 1 [ ]
+11 0 180 "" 20.4336 530.27 0.0 00000000 00000000 1 [ ]
+12 0 180 "" 20.9932 559.57 0.0 00000000 00000000 1 [ ]
+13 0 180 "" 21.5801 586.91 0.0 00000000 00000000 1 [ ]
+14 0 180 "" 22.1895 609.38 0.0 00000000 00000000 1 [ ]
+15 0 180 "" 22.7793 589.84 0.0 00000000 00000000 1 [ ]
+16 0 180 "" 23.3398 560.55 0.0 00000000 00000000 1 [ ]
+17 0 80 "" 23.8965 556.64 0.0 00000000 00000000 1 [ ]
+18 0 80 "" 24.5264 629.88 0.0 00000000 00000000 1 [ ]
+19 0 80 "" 25.1465 620.12 0.0 00000000 00000000 1 [ ]
+20 0 80 "" 25.7568 610.35 0.0 00000000 00000000 1 [ ]
+21 0 80 "" 26.3701 613.28 0.0 00000000 00000000 1 [ ]
+22 0 80 "" 26.9160 545.90 0.0 00000000 00000000 1 [ ]
+23 0 70 "" 27.5361 620.12 0.0 00000000 00000000 1 [ ]
+24 0 80 "" 28.1533 617.19 0.0 00000000 00000000 1 [ ]
+25 0 80 "" 28.7500 596.68 0.0 00000000 00000000 1 [ ]
+26 0 80 "" 29.3799 629.88 0.0 00000000 00000000 1 [ ]
+27 0 80 "" 29.9629 583.01 0.0 00000000 00000000 1 [ ]
+28 0 80 "" 30.5830 620.12 0.0 00000000 00000000 1 [ ]
+29 0 80 "" 31.1494 566.41 0.0 00000000 00000000 1 [ ]
+30 0 80 "" 31.6934 543.95 0.0 00000000 00000000 1 [ ]
+31 0 80 "" 32.3232 629.88 0.0 00000000 00000000 1 [ ]
+32 0 80 "" 32.9365 613.28 0.0 00000000 00000000 1 [ ]
+33 0 80 "" 33.4893 552.73 0.0 00000000 00000000 1 [ ]
+34 0 70 "" 34.0527 563.48 0.0 00000000 00000000 1 [ ]
+35 0 80 "" 34.6260 573.24 0.0 00000000 00000000 1 [ ]
+36 0 70 "" 35.1797 553.71 0.0 00000000 00000000 1 [ ]
+37 0 80 "" 35.7998 620.12 0.0 00000000 00000000 1 [ ]
+38 0 80 "" 36.3691 569.34 0.0 00000000 00000000 1 [ ]
+39 0 70 "" 36.9863 617.19 0.0 00000000 00000000 1 [ ]
+40 0 80 "" 37.5664 580.08 0.0 00000000 00000000 1 [ ]
+41 0 80 "" 38.1357 569.34 0.0 00000000 00000000 1 [ ]
+42 0 80 "" 38.7725 636.72 0.0 00000000 00000000 1 [ ]
+43 0 80 "" 39.4023 629.88 0.0 00000000 00000000 1 [ ]
+44 0 80 "" 39.9658 563.48 0.0 00000000 00000000 1 [ ]
+45 0 80 "" 40.5361 570.31 0.0 00000000 00000000 1 [ ]
+46 0 80 "" 41.0996 563.48 0.0 00000000 00000000 1 [ ]
+47 0 80 "" 41.6426 542.97 0.0 00000000 00000000 1 [ ]
+48 0 80 "" 42.2197 577.15 0.0 00000000 00000000 1 [ ]
+49 0 70 "" 42.8262 606.45 0.0 00000000 00000000 1 [ ]
+50 0 80 "" 43.4023 576.17 0.0 00000000 00000000 1 [ ]
+51 0 70 "" 43.9727 570.31 0.0 00000000 00000000 1 [ ]
+52 0 80 "" 44.5391 566.41 0.0 00000000 00000000 1 [ ]
+53 0 80 "" 45.0762 537.11 0.0 00000000 00000000 1 [ ]
+54 0 80 "" 45.6826 606.45 0.0 00000000 00000000 1 [ ]
+55 0 80 "" 46.2227 540.04 0.0 00000000 00000000 1 [ ]
+56 0 80 "" 46.8330 610.35 0.0 00000000 00000000 1 [ ]
+57 0 70 "" 47.4863 653.32 0.0 00000000 00000000 1 [ ]
+58 0 80 "" 48.0791 592.77 0.0 00000000 00000000 1 [ ]
+59 0 80 "" 48.6689 589.84 0.0 00000000 00000000 1 [ ]
+60 0 80 "" 49.2793 610.35 0.0 00000000 00000000 1 [ ]
+61 0 80 "" 49.8193 540.04 0.0 00000000 00000000 1 [ ]
+62 0 80 "" 50.3691 549.80 0.0 00000000 00000000 1 [ ]
+63 0 80 "" 50.9092 540.04 0.0 00000000 00000000 1 [ ]
+64 0 80 "" 51.4922 583.01 0.0 00000000 00000000 1 [ ]
+65 0 80 "" 52.0859 593.75 0.0 00000000 00000000 1 [ ]
+66 0 80 "" 52.6689 583.01 0.0 00000000 00000000 1 [ ]
+67 0 70 "" 53.2422 573.24 0.0 00000000 00000000 1 [ ]
+68 0 80 "" 53.8721 629.88 0.0 00000000 00000000 1 [ ]
+69 0 80 "" 54.4795 607.42 0.0 00000000 00000000 1 [ ]
+70 0 70 "" 55.0557 576.17 0.0 00000000 00000000 1 [ ]
+71 0 80 "" 55.6025 546.88 0.0 00000000 00000000 1 [ ]
+72 0 80 "" 56.1455 542.97 0.0 00000000 00000000 1 [ ]
+73 0 80 "" 56.6924 546.88 0.0 00000000 00000000 1 [ ]
+74 0 80 "" 57.2422 549.80 0.0 00000000 00000000 1 [ ]
+75 0 80 "" 57.7920 549.80 0.0 00000000 00000000 1 [ ]
+76 0 80 "" 58.3359 543.95 0.0 00000000 00000000 1 [ ]
+77 0 80 "" 58.8955 559.57 0.0 00000000 00000000 1 [ ]
+78 0 80 "" 59.5186 623.05 0.0 00000000 00000000 1 [ ]
+79 0 80 "" 60.1191 600.59 0.0 00000000 00000000 1 [ ]
+80 0 80 "" 60.6758 556.64 0.0 00000000 00000000 1 [ ]
+81 0 70 "" 61.2256 549.80 0.0 00000000 00000000 1 [ ]
+82 0 80 "" 61.8320 606.45 0.0 00000000 00000000 1 [ ]
+83 0 80 "" 62.4326 600.59 0.0 00000000 00000000 1 [ ]
+84 0 80 "" 63.0557 623.05 0.0 00000000 00000000 1 [ ]
+85 0 80 "" 63.6357 580.08 0.0 00000000 00000000 1 [ ]
+86 0 70 "" 64.2588 623.05 0.0 00000000 00000000 1 [ ]
+87 0 80 "" 64.8359 577.15 0.0 00000000 00000000 1 [ ]
+88 0 70 "" 65.3818 545.90 0.0 00000000 00000000 1 [ ]
+89 0 80 "" 65.9219 540.04 0.0 00000000 00000000 1 [ ]
+90 0 80 "" 66.4893 567.38 0.0 00000000 00000000 1 [ ]
+91 0 80 "" 67.1152 625.98 0.0 00000000 00000000 1 [ ]
+92 0 80 "" 67.7393 624.02 0.0 00000000 00000000 1 [ ]
+93 0 70 "" 68.3789 639.65 0.0 00000000 00000000 1 [ ]
+94 0 80 "" 68.9756 596.68 0.0 00000000 00000000 1 [ ]
+95 0 70 "" 69.5557 580.08 0.0 00000000 00000000 1 [ ]
+96 0 80 "" 70.1221 566.41 0.0 00000000 00000000 1 [ ]
+97 0 80 "" 70.7451 623.05 0.0 00000000 00000000 1 [ ]
+98 0 70 "" 71.3350 589.84 0.0 00000000 00000000 1 [ ]
+99 0 80 "" 71.8955 560.55 0.0 00000000 00000000 1 [ ]
+100 0 70 "" 72.4883 592.77 0.0 00000000 00000000 1 [ ]
+101 0 80 "" 73.0957 607.42 0.0 00000000 00000000 1 [ ]
+102 0 70 "" 73.6621 566.41 0.0 00000000 00000000 1 [ ]
+103 0 80 "" 74.2490 586.91 0.0 00000000 00000000 1 [ ]
+104 0 80 "" 74.8457 596.68 0.0 00000000 00000000 1 [ ]
+105 0 80 "" 75.3887 542.97 0.0 00000000 00000000 1 [ ]
+106 0 80 "" 75.9355 546.88 0.0 00000000 00000000 1 [ ]
+107 0 80 "" 76.5557 620.12 0.0 00000000 00000000 1 [ ]
+108 0 80 "" 77.1816 625.98 0.0 00000000 00000000 1 [ ]
+109 0 80 "" 77.7256 543.95 0.0 00000000 00000000 1 [ ]
+110 0 80 "" 78.2715 545.90 0.0 00000000 00000000 1 [ ]
+111 0 80 "" 78.8486 577.15 0.0 00000000 00000000 1 [ ]
+112 0 80 "" 79.4648 616.21 0.0 00000000 00000000 1 [ ]
+113 0 80 "" 80.0684 603.52 0.0 00000000 00000000 1 [ ]
+114 0 80 "" 80.6123 543.95 0.0 00000000 00000000 1 [ ]
+115 0 80 "" 81.2354 623.05 0.0 00000000 00000000 1 [ ]
+116 0 80 "" 81.8623 626.95 0.0 00000000 00000000 1 [ ]
+117 0 80 "" 82.4453 583.01 0.0 00000000 00000000 1 [ ]
+118 0 80 "" 83.0723 626.95 0.0 00000000 00000000 1 [ ]
+119 0 70 "" 83.6289 556.64 0.0 00000000 00000000 1 [ ]
+120 0 80 "" 84.1787 549.80 0.0 00000000 00000000 1 [ ]
+121 0 80 "" 84.8047 625.98 0.0 00000000 00000000 1 [ ]
+122 0 80 "" 85.3721 567.38 0.0 00000000 00000000 1 [ ]
+123 0 80 "" 85.9785 606.45 0.0 00000000 00000000 1 [ ]
+124 0 80 "" 86.6084 629.88 0.0 00000000 00000000 1 [ ]
+125 0 70 "" 87.2119 603.52 0.0 00000000 00000000 1 [ ]
+126 0 80 "" 87.7783 566.41 0.0 00000000 00000000 1 [ ]
+127 0 70 "" 88.3818 603.52 0.0 00000000 00000000 1 [ ]
+128 0 80 "" 88.9688 586.91 0.0 00000000 00000000 1 [ ]
+129 0 70 "" 89.5420 573.24 0.0 00000000 00000000 1 [ ]
+130 0 80 "" 90.1016 559.57 0.0 00000000 00000000 1 [ ]
+131 0 80 "" 90.7383 636.72 0.0 00000000 00000000 1 [ ]
+132 0 80 "" 91.3682 629.88 0.0 00000000 00000000 1 [ ]
+133 0 80 "" 91.9785 610.35 0.0 00000000 00000000 1 [ ]
+134 0 80 "" 92.5879 609.38 0.0 00000000 00000000 1 [ ]
+135 0 80 "" 93.1514 563.48 0.0 00000000 00000000 1 [ ]
+136 0 80 "" 93.7520 600.59 0.0 00000000 00000000 1 [ ]
+137 0 70 "" 94.3418 589.84 0.0 00000000 00000000 1 [ ]
+138 0 80 "" 94.9053 563.48 0.0 00000000 00000000 1 [ ]
+139 0 80 "" 95.5215 616.21 0.0 00000000 00000000 1 [ ]
+140 0 80 "" 96.0752 553.71 0.0 00000000 00000000 1 [ ]
+141 0 80 "" 96.6914 616.21 0.0 00000000 00000000 1 [ ]
+142 0 80 "" 97.2480 556.64 0.0 00000000 00000000 1 [ ]
+143 0 80 "" 97.7910 542.97 0.0 00000000 00000000 1 [ ]
+144 0 80 "" 98.3779 586.91 0.0 00000000 00000000 1 [ ]
+145 0 80 "" 98.9180 540.04 0.0 00000000 00000000 1 [ ]
+146 0 80 "" 99.4648 546.88 0.0 00000000 00000000 1 [ ]
+147 0 80 "" 100.0645 599.61 0.0 00000000 00000000 1 [ ]
+148 0 70 "" 100.6582 593.75 0.0 00000000 00000000 1 [ ]
+149 0 80 "" 101.2510 592.77 0.0 00000000 00000000 1 [ ]
+150 0 80 "" 101.8652 614.26 0.0 00000000 00000000 1 [ ]
+151 0 80 "" 102.4014 536.13 0.0 00000000 00000000 1 [ ]
+152 0 70 "" 102.9883 586.91 0.0 00000000 00000000 1 [ ]
+153 0 80 "" 103.5576 569.34 0.0 00000000 00000000 1 [ ]
+154 0 80 "" 104.1084 550.78 0.0 00000000 00000000 1 [ ]
+155 0 80 "" 104.6611 552.73 0.0 00000000 00000000 1 [ ]
+156 0 80 "" 105.2783 617.19 0.0 00000000 00000000 1 [ ]
+157 0 70 "" 105.8711 592.77 0.0 00000000 00000000 1 [ ]
+158 0 80 "" 106.4248 553.71 0.0 00000000 00000000 1 [ ]
+159 0 70 "" 106.9580 533.20 0.0 00000000 00000000 1 [ ]
+160 0 80 "" 107.5576 599.61 0.0 00000000 00000000 1 [ ]
+161 0 80 "" 108.1016 543.95 0.0 00000000 00000000 1 [ ]
+162 0 80 "" 108.6816 580.08 0.0 00000000 00000000 1 [ ]
+163 0 80 "" 109.2812 599.61 0.0 00000000 00000000 1 [ ]
+164 0 80 "" 109.8408 559.57 0.0 00000000 00000000 1 [ ]
+165 0 80 "" 110.4043 563.48 0.0 00000000 00000000 1 [ ]
+166 0 70 "" 111.0010 596.68 0.0 00000000 00000000 1 [ ]
+167 0 80 "" 111.5742 573.24 0.0 00000000 00000000 1 [ ]
+168 0 70 "" 112.1680 593.75 0.0 00000000 00000000 1 [ ]
+169 0 80 "" 112.7275 559.57 0.0 00000000 00000000 1 [ ]
+170 0 70 "" 113.2676 540.04 0.0 00000000 00000000 1 [ ]
+171 0 80 "" 113.8545 586.91 0.0 00000000 00000000 1 [ ]
+172 0 70 "" 114.4346 580.08 0.0 00000000 00000000 1 [ ]
+173 0 80 "" 115.0781 643.55 0.0 00000000 00000000 1 [ ]
+174 0 80 "" 115.6445 566.41 0.0 00000000 00000000 1 [ ]
+175 0 80 "" 116.2344 589.84 0.0 00000000 00000000 1 [ ]
+176 0 70 "" 116.7744 540.04 0.0 00000000 00000000 1 [ ]
+177 0 80 "" 117.3740 599.61 0.0 00000000 00000000 1 [ ]
+178 0 80 "" 117.9277 553.71 0.0 00000000 00000000 1 [ ]
+179 0 80 "" 118.4873 559.57 0.0 00000000 00000000 1 [ ]
+180 0 80 "" 119.0713 583.98 0.0 00000000 00000000 1 [ ]
+181 0 70 "" 119.6182 546.88 0.0 00000000 00000000 1 [ ]
+182 0 80 "" 120.2080 589.84 0.0 00000000 00000000 1 [ ]
+183 0 80 "" 120.8477 639.65 0.0 00000000 00000000 1 [ ]
+184 0 70 "" 121.4814 633.79 0.0 00000000 00000000 1 [ ]
+185 0 80 "" 122.0439 562.50 0.0 00000000 00000000 1 [ ]
+186 0 80 "" 122.6875 643.55 0.0 00000000 00000000 1 [ ]
+187 0 70 "" 123.2842 596.68 0.0 00000000 00000000 1 [ ]
+188 0 80 "" 123.9238 639.65 0.0 00000000 00000000 1 [ ]
+189 0 80 "" 124.4678 543.95 0.0 00000000 00000000 1 [ ]
+190 0 80 "" 125.0811 613.28 0.0 00000000 00000000 1 [ ]
+191 0 80 "" 125.7109 629.88 0.0 00000000 00000000 1 [ ]
+192 0 80 "" 126.3340 623.05 0.0 00000000 00000000 1 [ ]
+193 0 80 "" 126.8838 549.80 0.0 00000000 00000000 1 [ ]
+194 0 80 "" 127.4307 546.88 0.0 00000000 00000000 1 [ ]
+195 0 80 "" 128.0537 623.05 0.0 00000000 00000000 1 [ ]
+196 0 70 "" 128.6543 600.59 0.0 00000000 00000000 1 [ ]
+197 0 80 "" 129.1904 536.13 0.0 00000000 00000000 1 [ ]
+198 0 70 "" 129.8145 624.02 0.0 00000000 00000000 1 [ ]
+199 0 80 "" 130.3809 566.41 0.0 00000000 00000000 1 [ ]
+200 0 70 "" 130.9609 580.08 0.0 00000000 00000000 1 [ ]
+201 0 80 "" 131.5342 573.24 0.0 00000000 00000000 1 [ ]
+202 0 80 "" 132.0811 546.88 0.0 00000000 00000000 1 [ ]
+203 0 80 "" 132.6406 559.57 0.0 00000000 00000000 1 [ ]
+204 0 70 "" 133.2637 623.05 0.0 00000000 00000000 1 [ ]
+205 0 80 "" 133.8770 613.28 0.0 00000000 00000000 1 [ ]
+206 0 80 "" 134.4609 583.98 0.0 00000000 00000000 1 [ ]
+207 0 70 "" 135.0508 589.84 0.0 00000000 00000000 1 [ ]
+208 0 80 "" 135.6270 576.17 0.0 00000000 00000000 1 [ ]
+209 0 80 "" 136.2676 640.62 0.0 00000000 00000000 1 [ ]
+210 0 80 "" 136.8838 616.21 0.0 00000000 00000000 1 [ ]
+211 0 80 "" 137.4941 610.35 0.0 00000000 00000000 1 [ ]
+212 0 80 "" 138.0840 589.84 0.0 00000000 00000000 1 [ ]
+213 0 80 "" 138.6709 586.91 0.0 00000000 00000000 1 [ ]
+214 0 80 "" 139.2070 536.13 0.0 00000000 00000000 1 [ ]
+215 0 80 "" 139.8203 613.28 0.0 00000000 00000000 1 [ ]
+216 0 80 "" 140.4502 629.88 0.0 00000000 00000000 1 [ ]
+217 0 80 "" 141.0605 610.35 0.0 00000000 00000000 1 [ ]
+218 0 80 "" 141.6377 577.15 0.0 00000000 00000000 1 [ ]
+219 0 70 "" 142.2168 579.10 0.0 00000000 00000000 1 [ ]
+220 0 80 "" 142.7637 546.88 0.0 00000000 00000000 1 [ ]
+221 0 70 "" 143.3574 593.75 0.0 00000000 00000000 1 [ ]
+222 0 80 "" 143.9434 585.94 0.0 00000000 00000000 1 [ ]
+223 0 80 "" 144.4971 553.71 0.0 00000000 00000000 1 [ ]
+224 0 80 "" 145.0840 586.91 0.0 00000000 00000000 1 [ ]
+225 0 70 "" 145.7002 616.21 0.0 00000000 00000000 1 [ ]
+226 0 80 "" 146.2734 573.24 0.0 00000000 00000000 1 [ ]
+227 0 70 "" 146.8643 590.82 0.0 00000000 00000000 1 [ ]
+228 0 80 "" 147.4307 566.41 0.0 00000000 00000000 1 [ ]
+229 0 80 "" 148.0137 583.01 0.0 00000000 00000000 1 [ ]
+230 0 70 "" 148.6201 606.45 0.0 00000000 00000000 1 [ ]
+231 0 80 "" 149.1738 553.71 0.0 00000000 00000000 1 [ ]
+232 0 80 "" 149.7266 552.73 0.0 00000000 00000000 1 [ ]
+233 0 70 "" 150.3135 586.91 0.0 00000000 00000000 1 [ ]
+234 0 80 "" 150.8506 537.11 0.0 00000000 00000000 1 [ ]
+235 0 80 "" 151.4238 573.24 0.0 00000000 00000000 1 [ ]
+236 0 80 "" 151.9766 552.73 0.0 00000000 00000000 1 [ ]
+237 0 80 "" 152.6074 630.86 0.0 00000000 00000000 1 [ ]
+238 0 80 "" 153.2207 613.28 0.0 00000000 00000000 1 [ ]
+239 0 70 "" 153.8438 623.05 0.0 00000000 00000000 1 [ ]
+240 0 80 "" 154.4766 632.81 0.0 00000000 00000000 1 [ ]
+241 0 80 "" 155.0498 573.24 0.0 00000000 00000000 1 [ ]
+242 0 80 "" 155.6865 636.72 0.0 00000000 00000000 1 [ ]
+243 0 70 "" 156.3066 620.12 0.0 00000000 00000000 1 [ ]
+244 0 80 "" 156.8740 567.38 0.0 00000000 00000000 1 [ ]
+245 0 70 "" 157.5068 632.81 0.0 00000000 00000000 1 [ ]
+246 0 80 "" 158.0771 570.31 0.0 00000000 00000000 1 [ ]
+247 0 80 "" 158.6299 552.73 0.0 00000000 00000000 1 [ ]
+248 0 80 "" 159.2168 586.91 0.0 00000000 00000000 1 [ ]
+249 0 80 "" 159.8604 643.55 0.0 00000000 00000000 1 [ ]
+250 0 80 "" 160.4600 599.61 0.0 00000000 00000000 1 [ ]
+251 0 70 "" 161.0664 606.45 0.0 00000000 00000000 1 [ ]
+252 0 80 "" 161.6299 563.48 0.0 00000000 00000000 1 [ ]
+253 0 70 "" 162.2568 626.95 0.0 00000000 00000000 1 [ ]
+254 0 80 "" 162.8896 632.81 0.0 00000000 00000000 1 [ ]
+255 0 70 "" 163.4570 567.38 0.0 00000000 00000000 1 [ ]
+256 0 80 "" 164.0566 599.61 0.0 00000000 00000000 1 [ ]
+257 0 80 "" 164.6367 580.08 0.0 00000000 00000000 1 [ ]
+258 0 80 "" 165.2100 573.24 0.0 00000000 00000000 1 [ ]
+259 0 80 "" 165.7930 583.01 0.0 00000000 00000000 1 [ ]
+260 0 80 "" 166.3730 580.08 0.0 00000000 00000000 1 [ ]
+261 0 80 "" 166.9268 553.71 0.0 00000000 00000000 1 [ ]
+262 0 80 "" 167.5068 580.08 0.0 00000000 00000000 1 [ ]
+263 0 70 "" 168.1201 613.28 0.0 00000000 00000000 1 [ ]
+264 0 80 "" 168.6865 566.41 0.0 00000000 00000000 1 [ ]
+265 0 80 "" 169.2363 549.80 0.0 00000000 00000000 1 [ ]
+266 0 80 "" 169.8535 617.19 0.0 00000000 00000000 1 [ ]
+267 0 70 "" 170.4902 636.72 0.0 00000000 00000000 1 [ ]
+268 0 80 "" 171.0596 569.34 0.0 00000000 00000000 1 [ ]
+269 0 80 "" 171.6768 617.19 0.0 00000000 00000000 1 [ ]
+270 0 80 "" 172.3037 626.95 0.0 00000000 00000000 1 [ ]
+271 0 80 "" 172.8633 559.57 0.0 00000000 00000000 1 [ ]
+272 0 80 "" 173.4531 589.84 0.0 00000000 00000000 1 [ ]
+273 0 70 "" 174.0166 563.48 0.0 00000000 00000000 1 [ ]
+274 0 80 "" 174.5830 566.41 0.0 00000000 00000000 1 [ ]
+275 0 80 "" 175.1699 586.91 0.0 00000000 00000000 1 [ ]
+276 0 80 "" 175.7266 556.64 0.0 00000000 00000000 1 [ ]
+277 0 80 "" 176.2695 542.97 0.0 00000000 00000000 1 [ ]
+278 0 80 "" 176.8936 624.02 0.0 00000000 00000000 1 [ ]
+279 0 70 "" 177.5000 606.45 0.0 00000000 00000000 1 [ ]
+280 0 80 "" 178.0898 589.84 0.0 00000000 00000000 1 [ ]
+281 0 80 "" 178.7197 629.88 0.0 00000000 00000000 1 [ ]
+282 0 70 "" 179.2930 573.24 0.0 00000000 00000000 1 [ ]
+283 0 80 "" 179.8867 593.75 0.0 00000000 00000000 1 [ ]
+284 0 70 "" 180.4434 556.64 0.0 00000000 00000000 1 [ ]
+285 0 80 "" 181.0029 559.57 0.0 00000000 00000000 1 [ ]
+286 0 80 "" 181.5664 563.48 0.0 00000000 00000000 1 [ ]
+287 0 80 "" 182.1826 616.21 0.0 00000000 00000000 1 [ ]
+288 0 70 "" 182.7959 613.28 0.0 00000000 00000000 1 [ ]
+289 0 80 "" 183.3760 580.08 0.0 00000000 00000000 1 [ ]
+290 0 80 "" 183.9893 613.28 0.0 00000000 00000000 1 [ ]
+291 0 80 "" 184.6133 624.02 0.0 00000000 00000000 1 [ ]
+292 0 70 "" 185.1895 576.17 0.0 00000000 00000000 1 [ ]
+293 0 80 "" 185.7900 600.59 0.0 00000000 00000000 1 [ ]
+294 0 80 "" 186.3564 566.41 0.0 00000000 00000000 1 [ ]
+295 0 80 "" 186.9795 623.05 0.0 00000000 00000000 1 [ ]
+296 0 70 "" 187.5859 606.45 0.0 00000000 00000000 1 [ ]
+297 0 80 "" 188.2129 626.95 0.0 00000000 00000000 1 [ ]
+298 0 70 "" 188.8359 623.05 0.0 00000000 00000000 1 [ ]
+299 0 80 "" 189.3828 546.88 0.0 00000000 00000000 1 [ ]
+300 0 80 "" 189.9463 563.48 0.0 00000000 00000000 1 [ ]
+301 0 70 "" 190.5430 596.68 0.0 00000000 00000000 1 [ ]
+302 0 80 "" 191.1631 620.12 0.0 00000000 00000000 1 [ ]
+303 0 80 "" 191.8027 639.65 0.0 00000000 00000000 1 [ ]
+304 0 70 "" 192.3965 593.75 0.0 00000000 00000000 1 [ ]
+305 0 80 "" 192.9766 580.08 0.0 00000000 00000000 1 [ ]
+306 0 80 "" 193.5996 623.05 0.0 00000000 00000000 1 [ ]
+307 0 80 "" 194.1758 576.17 0.0 00000000 00000000 1 [ ]
+308 0 80 "" 194.7490 573.24 0.0 00000000 00000000 1 [ ]
+309 0 80 "" 195.3057 556.64 0.0 00000000 00000000 1 [ ]
+310 0 80 "" 195.9160 610.35 0.0 00000000 00000000 1 [ ]
+311 0 80 "" 196.5430 626.95 0.0 00000000 00000000 1 [ ]
+312 0 80 "" 197.1289 585.94 0.0 00000000 00000000 1 [ ]
+313 0 80 "" 197.7227 593.75 0.0 00000000 00000000 1 [ ]
+314 0 70 "" 198.3262 603.52 0.0 00000000 00000000 1 [ ]
+315 0 80 "" 198.9355 609.38 0.0 00000000 00000000 1 [ ]
+316 0 80 "" 199.5527 617.19 0.0 00000000 00000000 1 [ ]
+317 0 70 "" 200.1289 576.17 0.0 00000000 00000000 1 [ ]
+318 0 80 "" 200.7627 633.79 0.0 00000000 00000000 1 [ ]
+319 0 70 "" 201.3027 540.04 0.0 00000000 00000000 1 [ ]
+320 0 80 "" 201.9092 606.45 0.0 00000000 00000000 1 [ ]
+321 0 70 "" 202.4756 566.41 0.0 00000000 00000000 1 [ ]
+322 0 80 "" 203.0762 600.59 0.0 00000000 00000000 1 [ ]
+323 0 80 "" 203.6924 616.21 0.0 00000000 00000000 1 [ ]
+324 0 80 "" 204.3457 653.32 0.0 00000000 00000000 1 [ ]
+325 0 80 "" 204.9658 620.12 0.0 00000000 00000000 1 [ ]
+326 0 80 "" 205.6025 636.72 0.0 00000000 00000000 1 [ ]
+327 0 70 "" 206.2061 603.52 0.0 00000000 00000000 1 [ ]
+328 0 80 "" 206.8057 599.61 0.0 00000000 00000000 1 [ ]
+329 0 70 "" 207.3623 556.64 0.0 00000000 00000000 1 [ ]
+330 0 80 "" 207.9922 629.88 0.0 00000000 00000000 1 [ ]
+331 0 70 "" 208.5625 570.31 0.0 00000000 00000000 1 [ ]
+332 0 80 "" 209.1162 553.71 0.0 00000000 00000000 1 [ ]
+333 0 70 "" 209.6787 562.50 0.0 00000000 00000000 1 [ ]
+334 0 80 "" 210.3096 630.86 0.0 00000000 00000000 1 [ ]
+335 0 80 "" 210.9355 625.98 0.0 00000000 00000000 1 [ ]
+336 0 80 "" 211.4922 556.64 0.0 00000000 00000000 1 [ ]
+337 0 80 "" 212.1162 624.02 0.0 00000000 00000000 1 [ ]
+338 0 80 "" 212.6729 556.64 0.0 00000000 00000000 1 [ ]
+339 0 80 "" 213.2588 585.94 0.0 00000000 00000000 1 [ ]
+340 0 80 "" 213.8828 624.02 0.0 00000000 00000000 1 [ ]
+341 0 80 "" 214.4453 562.50 0.0 00000000 00000000 1 [ ]
+342 0 80 "" 215.0723 626.95 0.0 00000000 00000000 1 [ ]
+343 0 80 "" 215.6494 577.15 0.0 00000000 00000000 1 [ ]
+344 0 80 "" 216.2061 556.64 0.0 00000000 00000000 1 [ ]
+345 0 80 "" 216.7627 556.64 0.0 00000000 00000000 1 [ ]
+346 0 80 "" 217.3057 542.97 0.0 00000000 00000000 1 [ ]
+347 0 70 "" 217.9521 646.48 0.0 00000000 00000000 1 [ ]
+348 0 80 "" 218.5322 580.08 0.0 00000000 00000000 1 [ ]
+349 0 80 "" 219.0791 546.88 0.0 00000000 00000000 1 [ ]
+350 0 80 "" 219.6660 586.91 0.0 00000000 00000000 1 [ ]
+351 0 70 "" 220.2090 542.97 0.0 00000000 00000000 1 [ ]
+352 0 80 "" 220.8223 613.28 0.0 00000000 00000000 1 [ ]
+353 0 80 "" 221.4121 589.84 0.0 00000000 00000000 1 [ ]
+354 0 80 "" 222.0322 620.12 0.0 00000000 00000000 1 [ ]
+355 0 80 "" 222.6084 576.17 0.0 00000000 00000000 1 [ ]
+356 0 80 "" 223.1758 567.38 0.0 00000000 00000000 1 [ ]
+357 0 80 "" 223.7959 620.12 0.0 00000000 00000000 1 [ ]
+358 0 80 "" 224.4053 609.38 0.0 00000000 00000000 1 [ ]
+359 0 80 "" 224.9424 537.11 0.0 00000000 00000000 1 [ ]
+360 0 80 "" 225.5283 585.94 0.0 00000000 00000000 1 [ ]
+361 0 80 "" 226.0820 553.71 0.0 00000000 00000000 1 [ ]
+362 0 80 "" 226.7090 626.95 0.0 00000000 00000000 1 [ ]
+363 0 80 "" 227.2988 589.84 0.0 00000000 00000000 1 [ ]
+364 0 80 "" 227.9258 626.95 0.0 00000000 00000000 1 [ ]
+365 0 80 "" 228.5352 609.38 0.0 00000000 00000000 1 [ ]
+366 0 80 "" 229.1016 566.41 0.0 00000000 00000000 1 [ ]
+367 0 80 "" 229.6885 586.91 0.0 00000000 00000000 1 [ ]
+368 0 80 "" 230.2617 573.24 0.0 00000000 00000000 1 [ ]
+369 0 80 "" 230.8320 570.31 0.0 00000000 00000000 1 [ ]
+370 0 80 "" 231.4082 576.17 0.0 00000000 00000000 1 [ ]
+371 0 70 "" 232.0186 610.35 0.0 00000000 00000000 1 [ ]
+372 0 80 "" 232.5850 566.41 0.0 00000000 00000000 1 [ ]
+373 0 80 "" 233.2021 617.19 0.0 00000000 00000000 1 [ ]
+374 0 80 "" 233.7549 552.73 0.0 00000000 00000000 1 [ ]
+375 0 80 "" 234.3320 577.15 0.0 00000000 00000000 1 [ ]
+376 0 70 "" 234.9424 610.35 0.0 00000000 00000000 1 [ ]
+377 0 80 "" 235.5352 592.77 0.0 00000000 00000000 1 [ ]
+378 0 80 "" 236.1123 577.15 0.0 00000000 00000000 1 [ ]
+379 0 80 "" 236.6953 583.01 0.0 00000000 00000000 1 [ ]
+380 0 70 "" 237.2822 586.91 0.0 00000000 00000000 1 [ ]
+381 0 80 "" 237.8418 559.57 0.0 00000000 00000000 1 [ ]
+382 0 80 "" 238.3848 542.97 0.0 00000000 00000000 1 [ ]
+383 0 80 "" 239.0020 617.19 0.0 00000000 00000000 1 [ ]
+384 0 80 "" 239.5547 552.73 0.0 00000000 00000000 1 [ ]
+385 0 80 "" 240.1582 603.52 0.0 00000000 00000000 1 [ ]
+386 0 70 "" 240.7188 560.55 0.0 00000000 00000000 1 [ ]
+387 0 80 "" 241.2783 559.57 0.0 00000000 00000000 1 [ ]
+388 0 80 "" 241.8682 589.84 0.0 00000000 00000000 1 [ ]
+389 0 80 "" 242.4980 629.88 0.0 00000000 00000000 1 [ ]
+390 0 80 "" 243.0684 570.31 0.0 00000000 00000000 1 [ ]
+391 0 80 "" 243.6748 606.45 0.0 00000000 00000000 1 [ ]
+392 0 70 "" 244.2188 543.95 0.0 00000000 00000000 1 [ ]
+393 0 80 "" 244.8350 616.21 0.0 00000000 00000000 1 [ ]
+394 0 70 "" 245.4150 580.08 0.0 00000000 00000000 1 [ ]
+395 0 80 "" 246.0088 593.75 0.0 00000000 00000000 1 [ ]
+396 0 80 "" 246.6445 635.74 0.0 00000000 00000000 1 [ ]
+397 0 80 "" 247.1885 543.95 0.0 00000000 00000000 1 [ ]
+398 0 80 "" 247.7852 596.68 0.0 00000000 00000000 1 [ ]
+399 0 80 "" 248.3779 592.77 0.0 00000000 00000000 1 [ ]
+400 0 80 "" 249.0146 636.72 0.0 00000000 00000000 1 [ ]
+401 0 80 "" 249.5645 549.80 0.0 00000000 00000000 1 [ ]
+402 0 80 "" 250.1250 560.55 0.0 00000000 00000000 1 [ ]
+403 0 80 "" 250.7148 589.84 0.0 00000000 00000000 1 [ ]
+404 0 80 "" 251.2920 577.15 0.0 00000000 00000000 1 [ ]
+405 0 80 "" 251.8379 545.90 0.0 00000000 00000000 1 [ ]
+406 0 80 "" 252.4150 577.15 0.0 00000000 00000000 1 [ ]
+407 0 80 "" 253.0381 623.05 0.0 00000000 00000000 1 [ ]
+408 0 80 "" 253.5645 526.37 0.0 00000000 00000000 1 [ ]
+409 0 80 "" 254.1582 593.75 0.0 00000000 00000000 1 [ ]
+410 0 80 "" 254.7383 580.08 0.0 00000000 00000000 1 [ ]
+411 0 80 "" 255.3418 603.52 0.0 00000000 00000000 1 [ ]
+412 0 80 "" 255.9180 576.17 0.0 00000000 00000000 1 [ ]
+413 0 80 "" 256.4746 556.64 0.0 00000000 00000000 1 [ ]
+414 0 70 "" 257.0449 570.31 0.0 00000000 00000000 1 [ ]
+415 0 80 "" 257.6113 566.41 0.0 00000000 00000000 1 [ ]
+416 0 80 "" 258.2080 596.68 0.0 00000000 00000000 1 [ ]
+417 0 70 "" 258.7578 549.80 0.0 00000000 00000000 1 [ ]
+418 0 80 "" 259.3545 596.68 0.0 00000000 00000000 1 [ ]
+419 0 80 "" 259.9814 626.95 0.0 00000000 00000000 1 [ ]
+420 0 80 "" 260.5713 589.84 0.0 00000000 00000000 1 [ ]
+421 0 80 "" 261.1543 583.01 0.0 00000000 00000000 1 [ ]
+422 0 70 "" 261.7744 620.12 0.0 00000000 00000000 1 [ ]
+423 0 80 "" 262.3984 624.02 0.0 00000000 00000000 1 [ ]
+424 0 80 "" 263.0244 625.98 0.0 00000000 00000000 1 [ ]
+425 0 70 "" 263.6611 636.72 0.0 00000000 00000000 1 [ ]
+426 0 80 "" 264.1943 533.20 0.0 00000000 00000000 1 [ ]
+427 0 70 "" 264.7314 537.11 0.0 00000000 00000000 1 [ ]
+428 0 80 "" 265.2783 546.88 0.0 00000000 00000000 1 [ ]
+429 0 80 "" 265.8516 573.24 0.0 00000000 00000000 1 [ ]
+430 0 80 "" 266.4443 592.77 0.0 00000000 00000000 1 [ ]
+431 0 80 "" 266.9941 549.80 0.0 00000000 00000000 1 [ ]
+432 0 80 "" 267.6377 643.55 0.0 00000000 00000000 1 [ ]
+433 0 70 "" 268.2549 617.19 0.0 00000000 00000000 1 [ ]
+434 0 80 "" 268.8613 606.45 0.0 00000000 00000000 1 [ ]
+435 0 70 "" 269.4443 583.01 0.0 00000000 00000000 1 [ ]
+436 0 80 "" 269.9941 549.80 0.0 00000000 00000000 1 [ ]
+437 0 80 "" 270.5908 596.68 0.0 00000000 00000000 1 [ ]
+438 0 80 "" 271.2109 620.12 0.0 00000000 00000000 1 [ ]
+439 0 80 "" 271.7510 540.04 0.0 00000000 00000000 1 [ ]
+440 0 80 "" 272.2949 543.95 0.0 00000000 00000000 1 [ ]
+441 0 80 "" 272.9414 646.48 0.0 00000000 00000000 1 [ ]
+442 0 80 "" 273.5312 589.84 0.0 00000000 00000000 1 [ ]
+443 0 80 "" 274.0840 552.73 0.0 00000000 00000000 1 [ ]
+444 0 80 "" 274.6514 567.38 0.0 00000000 00000000 1 [ ]
+445 0 80 "" 275.2373 585.94 0.0 00000000 00000000 1 [ ]
+446 0 70 "" 275.8145 577.15 0.0 00000000 00000000 1 [ ]
+447 0 80 "" 276.4209 606.45 0.0 00000000 00000000 1 [ ]
+448 0 80 "" 277.0479 626.95 0.0 00000000 00000000 1 [ ]
+449 0 80 "" 277.6572 609.38 0.0 00000000 00000000 1 [ ]
+450 0 80 "" 278.2578 600.59 0.0 00000000 00000000 1 [ ]
+451 0 70 "" 278.8672 609.38 0.0 00000000 00000000 1 [ ]
+452 0 80 "" 279.4512 583.98 0.0 00000000 00000000 1 [ ]
+453 0 70 "" 280.0244 573.24 0.0 00000000 00000000 1 [ ]
+454 0 80 "" 280.6514 626.95 0.0 00000000 00000000 1 [ ]
+455 0 70 "" 281.2744 623.05 0.0 00000000 00000000 1 [ ]
+456 0 80 "" 281.9180 643.55 0.0 00000000 00000000 1 [ ]
+457 0 70 "" 282.4805 562.50 0.0 00000000 00000000 1 [ ]
+458 0 80 "" 283.0674 586.91 0.0 00000000 00000000 1 [ ]
+459 0 80 "" 283.6973 629.88 0.0 00000000 00000000 1 [ ]
+460 0 80 "" 284.3037 606.45 0.0 00000000 00000000 1 [ ]
+461 0 80 "" 284.9238 620.12 0.0 00000000 00000000 1 [ ]
+462 0 80 "" 285.5273 603.52 0.0 00000000 00000000 1 [ ]
+463 0 80 "" 286.1172 589.84 0.0 00000000 00000000 1 [ ]
+464 0 80 "" 286.7246 607.42 0.0 00000000 00000000 1 [ ]
+465 0 80 "" 287.3477 623.05 0.0 00000000 00000000 1 [ ]
+466 0 80 "" 287.8877 540.04 0.0 00000000 00000000 1 [ ]
+467 0 80 "" 288.4346 546.88 0.0 00000000 00000000 1 [ ]
+468 0 80 "" 288.9941 559.57 0.0 00000000 00000000 1 [ ]
+469 0 70 "" 289.5938 599.61 0.0 00000000 00000000 1 [ ]
+470 0 80 "" 290.2275 633.79 0.0 00000000 00000000 1 [ ]
+471 0 80 "" 290.8174 589.84 0.0 00000000 00000000 1 [ ]
+472 0 80 "" 291.3945 577.15 0.0 00000000 00000000 1 [ ]
+473 0 80 "" 291.9902 595.70 0.0 00000000 00000000 1 [ ]
+474 0 80 "" 292.5742 583.98 0.0 00000000 00000000 1 [ ]
+475 0 80 "" 293.1904 616.21 0.0 00000000 00000000 1 [ ]
+476 0 80 "" 293.8008 610.35 0.0 00000000 00000000 1 [ ]
+477 0 80 "" 294.4209 620.12 0.0 00000000 00000000 1 [ ]
+478 0 70 "" 295.0469 625.98 0.0 00000000 00000000 1 [ ]
+479 0 80 "" 295.6143 567.38 0.0 00000000 00000000 1 [ ]
+480 0 70 "" 296.1709 556.64 0.0 00000000 00000000 1 [ ]
+481 0 80 "" 296.7939 623.05 0.0 00000000 00000000 1 [ ]
+482 0 80 "" 297.4238 629.88 0.0 00000000 00000000 1 [ ]
+483 0 80 "" 297.9873 563.48 0.0 00000000 00000000 1 [ ]
+484 0 70 "" 298.5977 610.35 0.0 00000000 00000000 1 [ ]
+485 0 80 "" 299.2305 632.81 0.0 00000000 00000000 1 [ ]
+486 0 70 "" 299.7705 540.04 0.0 00000000 00000000 1 [ ]
+487 0 80 "" 300.3672 596.68 0.0 00000000 00000000 1 [ ]
+488 0 80 "" 300.9434 576.17 0.0 00000000 00000000 1 [ ]
+489 0 80 "" 301.5010 557.62 0.0 00000000 00000000 1 [ ]
+490 0 70 "" 302.0508 549.80 0.0 00000000 00000000 1 [ ]
+491 0 80 "" 302.5908 540.04 0.0 00000000 00000000 1 [ ]
+492 0 70 "" 303.1973 606.45 0.0 00000000 00000000 1 [ ]
+493 0 80 "" 303.8271 629.88 0.0 00000000 00000000 1 [ ]
+494 0 80 "" 304.4434 616.21 0.0 00000000 00000000 1 [ ]
+495 0 70 "" 304.9902 546.88 0.0 00000000 00000000 1 [ ]
+496 0 80 "" 305.5605 570.31 0.0 00000000 00000000 1 [ ]
+497 0 80 "" 306.1436 583.01 0.0 00000000 00000000 1 [ ]
+498 0 80 "" 306.6807 537.11 0.0 00000000 00000000 1 [ ]
+499 0 80 "" 307.2539 573.24 0.0 00000000 00000000 1 [ ]
+500 0 80 "" 307.8467 592.77 0.0 00000000 00000000 1 [ ]
+501 0 80 "" 308.4102 563.48 0.0 00000000 00000000 1 [ ]
+502 0 80 "" 309.0137 603.52 0.0 00000000 00000000 1 [ ]
+503 0 80 "" 309.5938 580.08 0.0 00000000 00000000 1 [ ]
+504 0 80 "" 310.1465 552.73 0.0 00000000 00000000 1 [ ]
+505 0 80 "" 310.6768 530.27 0.0 00000000 00000000 1 [ ]
+506 0 70 "" 311.2471 570.31 0.0 00000000 00000000 1 [ ]
+507 0 80 "" 311.8672 620.12 0.0 00000000 00000000 1 [ ]
+508 0 80 "" 312.4199 552.73 0.0 00000000 00000000 1 [ ]
+509 0 70 "" 312.9873 567.38 0.0 00000000 00000000 1 [ ]
+510 0 80 "" 313.6006 613.28 0.0 00000000 00000000 1 [ ]
+511 0 80 "" 314.2100 609.38 0.0 00000000 00000000 1 [ ]
+512 0 80 "" 314.7773 567.38 0.0 00000000 00000000 1 [ ]
+513 0 70 "" 315.3340 556.64 0.0 00000000 00000000 1 [ ]
+514 0 80 "" 315.9199 585.94 0.0 00000000 00000000 1 [ ]
+515 0 80 "" 316.4600 540.04 0.0 00000000 00000000 1 [ ]
+516 0 80 "" 317.0166 556.64 0.0 00000000 00000000 1 [ ]
+517 0 80 "" 317.6465 629.88 0.0 00000000 00000000 1 [ ]
+518 0 80 "" 318.2471 600.59 0.0 00000000 00000000 1 [ ]
+519 0 80 "" 318.8203 573.24 0.0 00000000 00000000 1 [ ]
+520 0 80 "" 319.4131 592.77 0.0 00000000 00000000 1 [ ]
+521 0 80 "" 320.0098 596.68 0.0 00000000 00000000 1 [ ]
+522 0 80 "" 320.6035 593.75 0.0 00000000 00000000 1 [ ]
+523 0 80 "" 321.1738 570.31 0.0 00000000 00000000 1 [ ]
+524 0 70 "" 321.8037 629.88 0.0 00000000 00000000 1 [ ]
+525 0 80 "" 322.3633 559.57 0.0 00000000 00000000 1 [ ]
+526 0 80 "" 322.9834 620.12 0.0 00000000 00000000 1 [ ]
+527 0 80 "" 323.5898 606.45 0.0 00000000 00000000 1 [ ]
+528 0 80 "" 324.1934 603.52 0.0 00000000 00000000 1 [ ]
+529 0 80 "" 324.7598 566.41 0.0 00000000 00000000 1 [ ]
+530 0 80 "" 325.3867 626.95 0.0 00000000 00000000 1 [ ]
+531 0 80 "" 325.9697 583.01 0.0 00000000 00000000 1 [ ]
+532 0 80 "" 326.5635 593.75 0.0 00000000 00000000 1 [ ]
+533 0 80 "" 327.1270 563.48 0.0 00000000 00000000 1 [ ]
+534 0 80 "" 327.7002 573.24 0.0 00000000 00000000 1 [ ]
+535 0 80 "" 328.2568 556.64 0.0 00000000 00000000 1 [ ]
+536 0 70 "" 328.8301 573.24 0.0 00000000 00000000 1 [ ]
+537 0 80 "" 329.3799 549.80 0.0 00000000 00000000 1 [ ]
+538 0 80 "" 329.9531 573.24 0.0 00000000 00000000 1 [ ]
+539 0 70 "" 330.5996 646.48 0.0 00000000 00000000 1 [ ]
+540 0 80 "" 331.1836 583.98 0.0 00000000 00000000 1 [ ]
+541 0 70 "" 331.7598 576.17 0.0 00000000 00000000 1 [ ]
+542 0 80 "" 332.3428 583.01 0.0 00000000 00000000 1 [ ]
+543 0 80 "" 332.9365 593.75 0.0 00000000 00000000 1 [ ]
+544 0 80 "" 333.5303 593.75 0.0 00000000 00000000 1 [ ]
+545 0 80 "" 334.1436 613.28 0.0 00000000 00000000 1 [ ]
+546 0 70 "" 334.7363 592.77 0.0 00000000 00000000 1 [ ]
+547 0 80 "" 335.3496 613.28 0.0 00000000 00000000 1 [ ]
+548 0 80 "" 335.9268 577.15 0.0 00000000 00000000 1 [ ]
+549 0 80 "" 336.5068 580.08 0.0 00000000 00000000 1 [ ]
+550 0 80 "" 337.1094 602.54 0.0 00000000 00000000 1 [ ]
+551 0 80 "" 337.6797 570.31 0.0 00000000 00000000 1 [ ]
+552 0 80 "" 338.2832 603.52 0.0 00000000 00000000 1 [ ]
+553 0 80 "" 338.9062 623.05 0.0 00000000 00000000 1 [ ]
+554 0 80 "" 339.5361 629.88 0.0 00000000 00000000 1 [ ]
+555 0 80 "" 340.1465 610.35 0.0 00000000 00000000 1 [ ]
+556 0 80 "" 340.7363 589.84 0.0 00000000 00000000 1 [ ]
+557 0 80 "" 341.2930 556.64 0.0 00000000 00000000 1 [ ]
+558 0 80 "" 341.8730 580.08 0.0 00000000 00000000 1 [ ]
+559 0 80 "" 342.4531 580.08 0.0 00000000 00000000 1 [ ]
+560 0 80 "" 343.0000 546.88 0.0 00000000 00000000 1 [ ]
+561 0 80 "" 343.6367 636.72 0.0 00000000 00000000 1 [ ]
+562 0 80 "" 344.2334 596.68 0.0 00000000 00000000 1 [ ]
+563 0 70 "" 344.8594 625.98 0.0 00000000 00000000 1 [ ]
+564 0 80 "" 345.4697 610.35 0.0 00000000 00000000 1 [ ]
+565 0 80 "" 346.0928 623.05 0.0 00000000 00000000 1 [ ]
+566 0 70 "" 346.7031 610.35 0.0 00000000 00000000 1 [ ]
+567 0 80 "" 347.3066 603.52 0.0 00000000 00000000 1 [ ]
+568 0 80 "" 347.8594 552.73 0.0 00000000 00000000 1 [ ]
+569 0 70 "" 348.4727 613.28 0.0 00000000 00000000 1 [ ]
+570 0 80 "" 349.0830 610.35 0.0 00000000 00000000 1 [ ]
+571 0 80 "" 349.6924 609.38 0.0 00000000 00000000 1 [ ]
+572 0 80 "" 350.2725 580.08 0.0 00000000 00000000 1 [ ]
+573 0 80 "" 350.8965 624.02 0.0 00000000 00000000 1 [ ]
+574 0 80 "" 351.5225 625.98 0.0 00000000 00000000 1 [ ]
+575 0 80 "" 352.1260 603.52 0.0 00000000 00000000 1 [ ]
+576 0 80 "" 352.7393 613.28 0.0 00000000 00000000 1 [ ]
+577 0 80 "" 353.3564 617.19 0.0 00000000 00000000 1 [ ]
+578 0 80 "" 353.9932 636.72 0.0 00000000 00000000 1 [ ]
+579 0 80 "" 354.6025 609.38 0.0 00000000 00000000 1 [ ]
+580 0 80 "" 355.1963 593.75 0.0 00000000 00000000 1 [ ]
+581 0 80 "" 355.7529 556.64 0.0 00000000 00000000 1 [ ]
+582 0 80 "" 356.3125 559.57 0.0 00000000 00000000 1 [ ]
+583 0 80 "" 356.9355 623.05 0.0 00000000 00000000 1 [ ]
+584 0 80 "" 357.4795 543.95 0.0 00000000 00000000 1 [ ]
+585 0 80 "" 358.0293 549.80 0.0 00000000 00000000 1 [ ]
+586 0 80 "" 358.5693 540.04 0.0 00000000 00000000 1 [ ]
+587 0 70 "" 359.1592 589.84 0.0 00000000 00000000 1 [ ]
+588 0 80 "" 359.7021 542.97 0.0 00000000 00000000 1 [ ]
+589 0 70 "" 360.2959 593.75 0.0 00000000 00000000 1 [ ]
+590 0 80 "" 360.8496 553.71 0.0 00000000 00000000 1 [ ]
+591 0 80 "" 361.4395 589.84 0.0 00000000 00000000 1 [ ]
+592 0 70 "" 362.0029 563.48 0.0 00000000 00000000 1 [ ]
+593 0 80 "" 362.6357 632.81 0.0 00000000 00000000 1 [ ]
+594 0 80 "" 363.1855 549.80 0.0 00000000 00000000 1 [ ]
+595 0 80 "" 363.7988 613.28 0.0 00000000 00000000 1 [ ]
+596 0 70 "" 364.3457 546.88 0.0 00000000 00000000 1 [ ]
+597 0 80 "" 364.9395 593.75 0.0 00000000 00000000 1 [ ]
+598 0 80 "" 365.5156 576.17 0.0 00000000 00000000 1 [ ]
+599 0 80 "" 366.1426 626.95 0.0 00000000 00000000 1 [ ]
+600 0 70 "" 366.7129 570.31 0.0 00000000 00000000 1 [ ]
+601 0 80 "" 367.3154 602.54 0.0 00000000 00000000 1 [ ]
+602 0 80 "" 367.9492 633.79 0.0 00000000 00000000 1 [ ]
+603 0 80 "" 368.5762 626.95 0.0 00000000 00000000 1 [ ]
+604 0 80 "" 369.1729 596.68 0.0 00000000 00000000 1 [ ]
+605 0 80 "" 369.7061 533.20 0.0 00000000 00000000 1 [ ]
+606 0 80 "" 370.2490 542.97 0.0 00000000 00000000 1 [ ]
+607 0 80 "" 370.7959 546.88 0.0 00000000 00000000 1 [ ]
+608 0 70 "" 371.4326 636.72 0.0 00000000 00000000 1 [ ]
+609 0 80 "" 372.0557 623.05 0.0 00000000 00000000 1 [ ]
+610 0 70 "" 372.6455 589.84 0.0 00000000 00000000 1 [ ]
+611 0 80 "" 373.1787 533.20 0.0 00000000 00000000 1 [ ]
+612 0 80 "" 373.7793 600.59 0.0 00000000 00000000 1 [ ]
+613 0 80 "" 374.3555 576.17 0.0 00000000 00000000 1 [ ]
+614 0 80 "" 374.9756 620.12 0.0 00000000 00000000 1 [ ]
+615 0 80 "" 375.5654 589.84 0.0 00000000 00000000 1 [ ]
+616 0 80 "" 376.1455 580.08 0.0 00000000 00000000 1 [ ]
+617 0 80 "" 376.7520 606.45 0.0 00000000 00000000 1 [ ]
+618 0 80 "" 377.2959 543.95 0.0 00000000 00000000 1 [ ]
+619 0 80 "" 377.8389 542.97 0.0 00000000 00000000 1 [ ]
+620 0 80 "" 378.4756 636.72 0.0 00000000 00000000 1 [ ]
+621 0 80 "" 379.1191 643.55 0.0 00000000 00000000 1 [ ]
+622 0 70 "" 379.7188 599.61 0.0 00000000 00000000 1 [ ]
+623 0 80 "" 380.3389 620.12 0.0 00000000 00000000 1 [ ]
+624 0 80 "" 380.9355 596.68 0.0 00000000 00000000 1 [ ]
+625 0 80 "" 381.5283 592.77 0.0 00000000 00000000 1 [ ]
+626 0 80 "" 382.1221 593.75 0.0 00000000 00000000 1 [ ]
+627 0 80 "" 382.7285 606.45 0.0 00000000 00000000 1 [ ]
+628 0 80 "" 383.3389 610.35 0.0 00000000 00000000 1 [ ]
+629 0 70 "" 383.9287 589.84 0.0 00000000 00000000 1 [ ]
+630 0 80 "" 384.4951 566.41 0.0 00000000 00000000 1 [ ]
+631 0 80 "" 385.0918 596.68 0.0 00000000 00000000 1 [ ]
+632 0 80 "" 385.7256 633.79 0.0 00000000 00000000 1 [ ]
+633 0 80 "" 386.3516 625.98 0.0 00000000 00000000 1 [ ]
+634 0 80 "" 386.9385 586.91 0.0 00000000 00000000 1 [ ]
+635 0 70 "" 387.5586 620.12 0.0 00000000 00000000 1 [ ]
+636 0 80 "" 388.1953 636.72 0.0 00000000 00000000 1 [ ]
+637 0 80 "" 388.7822 586.91 0.0 00000000 00000000 1 [ ]
+638 0 80 "" 389.4189 636.72 0.0 00000000 00000000 1 [ ]
+639 0 70 "" 389.9648 545.90 0.0 00000000 00000000 1 [ ]
+640 0 80 "" 390.5850 620.12 0.0 00000000 00000000 1 [ ]
+641 0 80 "" 391.1621 577.15 0.0 00000000 00000000 1 [ ]
+642 0 70 "" 391.7891 626.95 0.0 00000000 00000000 1 [ ]
+643 0 80 "" 392.4053 616.21 0.0 00000000 00000000 1 [ ]
+644 0 70 "" 392.9717 566.41 0.0 00000000 00000000 1 [ ]
+645 0 80 "" 393.5254 553.71 0.0 00000000 00000000 1 [ ]
+646 0 70 "" 394.1387 613.28 0.0 00000000 00000000 1 [ ]
+647 0 80 "" 394.7217 583.01 0.0 00000000 00000000 1 [ ]
+648 0 80 "" 395.2783 556.64 0.0 00000000 00000000 1 [ ]
+649 0 80 "" 395.8281 549.80 0.0 00000000 00000000 1 [ ]
+650 0 70 "" 396.4082 580.08 0.0 00000000 00000000 1 [ ]
+651 0 80 "" 396.9854 577.15 0.0 00000000 00000000 1 [ ]
+652 0 80 "" 397.6221 636.72 0.0 00000000 00000000 1 [ ]
+653 0 80 "" 398.1680 545.90 0.0 00000000 00000000 1 [ ]
+654 0 80 "" 398.7285 560.55 0.0 00000000 00000000 1 [ ]
+655 0 80 "" 399.2920 563.48 0.0 00000000 00000000 1 [ ]
+656 0 80 "" 399.9082 616.21 0.0 00000000 00000000 1 [ ]
+657 0 80 "" 400.5381 629.88 0.0 00000000 00000000 1 [ ]
+658 0 80 "" 401.1582 620.12 0.0 00000000 00000000 1 [ ]
+659 0 80 "" 401.7314 573.24 0.0 00000000 00000000 1 [ ]
+660 0 80 "" 402.3516 620.12 0.0 00000000 00000000 1 [ ]
+661 0 80 "" 402.9648 613.28 0.0 00000000 00000000 1 [ ]
+662 0 80 "" 403.5820 617.19 0.0 00000000 00000000 1 [ ]
+663 0 80 "" 404.1816 599.61 0.0 00000000 00000000 1 [ ]
+664 0 80 "" 404.7783 596.68 0.0 00000000 00000000 1 [ ]
+665 0 70 "" 405.3418 563.48 0.0 00000000 00000000 1 [ ]
+666 0 80 "" 405.9414 599.61 0.0 00000000 00000000 1 [ ]
+667 0 80 "" 406.5020 560.55 0.0 00000000 00000000 1 [ ]
+668 0 80 "" 407.1182 616.21 0.0 00000000 00000000 1 [ ]
+669 0 70 "" 407.7178 599.61 0.0 00000000 00000000 1 [ ]
+670 0 80 "" 408.2744 556.64 0.0 00000000 00000000 1 [ ]
+671 0 80 "" 408.8750 600.59 0.0 00000000 00000000 1 [ ]
+672 0 80 "" 409.4678 592.77 0.0 00000000 00000000 1 [ ]
+673 0 80 "" 410.0283 560.55 0.0 00000000 00000000 1 [ ]
+674 0 80 "" 410.6211 592.77 0.0 00000000 00000000 1 [ ]
+675 0 80 "" 411.1816 560.55 0.0 00000000 00000000 1 [ ]
+676 0 80 "" 411.7520 570.31 0.0 00000000 00000000 1 [ ]
+677 0 80 "" 412.2910 539.06 0.0 00000000 00000000 1 [ ]
+678 0 70 "" 412.8516 560.55 0.0 00000000 00000000 1 [ ]
+679 0 80 "" 413.4248 573.24 0.0 00000000 00000000 1 [ ]
+680 0 80 "" 413.9746 549.80 0.0 00000000 00000000 1 [ ]
+681 0 80 "" 414.5811 606.45 0.0 00000000 00000000 1 [ ]
+682 0 80 "" 415.2178 636.72 0.0 00000000 00000000 1 [ ]
+683 0 80 "" 415.7881 570.31 0.0 00000000 00000000 1 [ ]
+684 0 80 "" 416.4111 623.05 0.0 00000000 00000000 1 [ ]
+685 0 80 "" 416.9785 567.38 0.0 00000000 00000000 1 [ ]
+686 0 80 "" 417.5684 589.84 0.0 00000000 00000000 1 [ ]
+687 0 80 "" 418.1113 542.97 0.0 00000000 00000000 1 [ ]
+688 0 70 "" 418.7217 610.35 0.0 00000000 00000000 1 [ ]
+689 0 80 "" 419.3047 583.01 0.0 00000000 00000000 1 [ ]
+690 0 80 "" 419.8984 593.75 0.0 00000000 00000000 1 [ ]
+691 0 70 "" 420.5117 613.28 0.0 00000000 00000000 1 [ ]
+692 0 80 "" 421.0615 549.80 0.0 00000000 00000000 1 [ ]
+693 0 70 "" 421.6846 623.05 0.0 00000000 00000000 1 [ ]
+694 0 80 "" 422.2480 563.48 0.0 00000000 00000000 1 [ ]
+695 0 70 "" 422.8115 563.48 0.0 00000000 00000000 1 [ ]
+696 0 80 "" 423.3975 585.94 0.0 00000000 00000000 1 [ ]
+697 0 70 "" 423.9580 560.55 0.0 00000000 00000000 1 [ ]
+698 0 80 "" 424.5713 613.28 0.0 00000000 00000000 1 [ ]
+699 0 80 "" 425.1982 626.95 0.0 00000000 00000000 1 [ ]
+700 0 70 "" 425.7676 569.34 0.0 00000000 00000000 1 [ ]
+701 0 80 "" 426.3877 620.12 0.0 00000000 00000000 1 [ ]
+702 0 80 "" 426.9980 610.35 0.0 00000000 00000000 1 [ ]
+703 0 80 "" 427.5576 559.57 0.0 00000000 00000000 1 [ ]
+704 0 80 "" 428.1377 580.08 0.0 00000000 00000000 1 [ ]
+705 0 80 "" 428.7480 610.35 0.0 00000000 00000000 1 [ ]
+706 0 80 "" 429.3242 576.17 0.0 00000000 00000000 1 [ ]
+707 0 80 "" 429.9414 617.19 0.0 00000000 00000000 1 [ ]
+708 0 80 "" 430.5674 625.98 0.0 00000000 00000000 1 [ ]
+709 0 80 "" 431.1377 570.31 0.0 00000000 00000000 1 [ ]
+710 0 80 "" 431.7646 626.95 0.0 00000000 00000000 1 [ ]
+711 0 80 "" 432.3877 623.05 0.0 00000000 00000000 1 [ ]
+712 0 80 "" 432.9443 556.64 0.0 00000000 00000000 1 [ ]
+713 0 70 "" 433.5312 586.91 0.0 00000000 00000000 1 [ ]
+714 0 80 "" 434.1113 580.08 0.0 00000000 00000000 1 [ ]
+715 0 80 "" 434.7373 625.98 0.0 00000000 00000000 1 [ ]
+716 0 70 "" 435.3076 570.31 0.0 00000000 00000000 1 [ ]
+717 0 80 "" 435.8848 577.15 0.0 00000000 00000000 1 [ ]
+718 0 70 "" 436.4512 566.41 0.0 00000000 00000000 1 [ ]
+719 0 80 "" 437.0146 563.48 0.0 00000000 00000000 1 [ ]
+720 0 80 "" 437.6113 596.68 0.0 00000000 00000000 1 [ ]
+721 0 80 "" 438.1572 545.90 0.0 00000000 00000000 1 [ ]
+722 0 70 "" 438.7979 640.62 0.0 00000000 00000000 1 [ ]
+723 0 80 "" 439.3477 549.80 0.0 00000000 00000000 1 [ ]
+724 0 80 "" 439.8975 549.80 0.0 00000000 00000000 1 [ ]
+725 0 70 "" 440.5381 640.62 0.0 00000000 00000000 1 [ ]
+726 0 80 "" 441.1475 609.38 0.0 00000000 00000000 1 [ ]
+727 0 80 "" 441.7812 633.79 0.0 00000000 00000000 1 [ ]
+728 0 80 "" 442.3711 589.84 0.0 00000000 00000000 1 [ ]
+729 0 70 "" 442.9277 556.64 0.0 00000000 00000000 1 [ ]
+730 0 80 "" 443.4873 559.57 0.0 00000000 00000000 1 [ ]
+731 0 80 "" 444.0771 589.84 0.0 00000000 00000000 1 [ ]
+732 0 80 "" 444.6504 573.24 0.0 00000000 00000000 1 [ ]
+733 0 70 "" 445.2578 607.42 0.0 00000000 00000000 1 [ ]
+734 0 80 "" 445.8574 599.61 0.0 00000000 00000000 1 [ ]
+735 0 70 "" 446.4678 610.35 0.0 00000000 00000000 1 [ ]
+736 0 80 "" 447.0205 552.73 0.0 00000000 00000000 1 [ ]
+737 0 80 "" 447.5605 540.04 0.0 00000000 00000000 1 [ ]
+738 0 80 "" 448.1172 556.64 0.0 00000000 00000000 1 [ ]
+739 0 80 "" 448.6777 560.55 0.0 00000000 00000000 1 [ ]
+740 0 70 "" 449.3242 646.48 0.0 00000000 00000000 1 [ ]
+741 0 80 "" 449.9404 616.21 0.0 00000000 00000000 1 [ ]
+742 0 80 "" 450.5537 613.28 0.0 00000000 00000000 1 [ ]
+743 0 80 "" 451.1436 589.84 0.0 00000000 00000000 1 [ ]
+744 0 80 "" 451.6973 553.71 0.0 00000000 00000000 1 [ ]
+745 0 70 "" 452.2910 593.75 0.0 00000000 00000000 1 [ ]
+746 0 80 "" 452.8271 536.13 0.0 00000000 00000000 1 [ ]
+747 0 80 "" 453.4307 603.52 0.0 00000000 00000000 1 [ ]
+748 0 80 "" 453.9736 542.97 0.0 00000000 00000000 1 [ ]
+749 0 80 "" 454.5508 577.15 0.0 00000000 00000000 1 [ ]
+750 0 80 "" 455.1738 623.05 0.0 00000000 00000000 1 [ ]
+751 0 80 "" 455.7910 617.19 0.0 00000000 00000000 1 [ ]
+752 0 80 "" 456.3242 533.20 0.0 00000000 00000000 1 [ ]
+753 0 80 "" 456.8975 573.24 0.0 00000000 00000000 1 [ ]
+754 0 80 "" 457.5039 606.45 0.0 00000000 00000000 1 [ ]
+755 0 80 "" 458.1270 623.05 0.0 00000000 00000000 1 [ ]
+756 0 70 "" 458.6934 566.41 0.0 00000000 00000000 1 [ ]
+757 0 80 "" 459.2969 603.52 0.0 00000000 00000000 1 [ ]
+758 0 80 "" 459.8740 577.15 0.0 00000000 00000000 1 [ ]
+759 0 80 "" 460.4072 533.20 0.0 00000000 00000000 1 [ ]
+760 0 70 "" 460.9570 549.80 0.0 00000000 00000000 1 [ ]
+761 0 80 "" 461.5605 603.52 0.0 00000000 00000000 1 [ ]
+762 0 70 "" 462.1572 596.68 0.0 00000000 00000000 1 [ ]
+763 0 80 "" 462.7969 639.65 0.0 00000000 00000000 1 [ ]
+764 0 80 "" 463.3633 566.41 0.0 00000000 00000000 1 [ ]
+765 0 80 "" 463.9404 577.15 0.0 00000000 00000000 1 [ ]
+766 0 80 "" 464.4873 546.88 0.0 00000000 00000000 1 [ ]
+767 0 80 "" 465.0469 559.57 0.0 00000000 00000000 1 [ ]
+768 0 80 "" 465.6533 606.45 0.0 00000000 00000000 1 [ ]
+769 0 80 "" 466.2568 603.52 0.0 00000000 00000000 1 [ ]
+770 0 70 "" 466.8672 610.35 0.0 00000000 00000000 1 [ ]
+771 0 80 "" 467.5039 636.72 0.0 00000000 00000000 1 [ ]
+772 0 70 "" 468.0605 556.64 0.0 00000000 00000000 1 [ ]
+773 0 80 "" 468.6807 620.12 0.0 00000000 00000000 1 [ ]
+774 0 80 "" 469.2705 589.84 0.0 00000000 00000000 1 [ ]
+775 0 80 "" 469.8369 566.41 0.0 00000000 00000000 1 [ ]
+776 0 70 "" 470.4404 603.52 0.0 00000000 00000000 1 [ ]
+777 0 80 "" 471.0000 559.57 0.0 00000000 00000000 1 [ ]
+778 0 70 "" 471.6104 610.35 0.0 00000000 00000000 1 [ ]
+779 0 80 "" 472.1533 542.97 0.0 00000000 00000000 1 [ ]
+780 0 70 "" 472.6865 533.20 0.0 00000000 00000000 1 [ ]
+781 0 80 "" 473.2334 546.88 0.0 00000000 00000000 1 [ ]
+782 0 70 "" 473.7969 563.48 0.0 00000000 00000000 1 [ ]
+783 0 80 "" 474.4033 606.45 0.0 00000000 00000000 1 [ ]
+784 0 80 "" 475.0039 600.59 0.0 00000000 00000000 1 [ ]
+785 0 70 "" 475.6133 609.38 0.0 00000000 00000000 1 [ ]
+786 0 80 "" 476.2305 617.19 0.0 00000000 00000000 1 [ ]
+787 0 80 "" 476.8633 632.81 0.0 00000000 00000000 1 [ ]
+788 0 80 "" 477.5000 636.72 0.0 00000000 00000000 1 [ ]
+789 0 80 "" 478.0771 577.15 0.0 00000000 00000000 1 [ ]
+790 0 80 "" 478.6934 616.21 0.0 00000000 00000000 1 [ ]
+791 0 80 "" 479.2969 603.52 0.0 00000000 00000000 1 [ ]
+792 0 80 "" 479.8867 589.84 0.0 00000000 00000000 1 [ ]
+793 0 80 "" 480.5166 629.88 0.0 00000000 00000000 1 [ ]
+794 0 80 "" 481.1035 586.91 0.0 00000000 00000000 1 [ ]
+795 0 80 "" 481.6904 586.91 0.0 00000000 00000000 1 [ ]
+796 0 80 "" 482.2236 533.20 0.0 00000000 00000000 1 [ ]
+797 0 80 "" 482.7803 556.64 0.0 00000000 00000000 1 [ ]
+798 0 80 "" 483.3369 556.64 0.0 00000000 00000000 1 [ ]
+799 0 80 "" 483.9336 596.68 0.0 00000000 00000000 1 [ ]
+800 0 80 "" 484.5264 592.77 0.0 00000000 00000000 1 [ ]
+801 0 80 "" 485.0664 540.04 0.0 00000000 00000000 1 [ ]
+802 0 80 "" 485.6768 610.35 0.0 00000000 00000000 1 [ ]
+803 0 80 "" 486.3262 649.41 0.0 00000000 00000000 1 [ ]
+804 0 70 "" 486.8701 543.95 0.0 00000000 00000000 1 [ ]
+805 0 80 "" 487.4795 609.38 0.0 00000000 00000000 1 [ ]
+806 0 80 "" 488.0400 560.55 0.0 00000000 00000000 1 [ ]
+807 0 80 "" 488.6729 632.81 0.0 00000000 00000000 1 [ ]
+808 0 70 "" 489.2402 567.38 0.0 00000000 00000000 1 [ ]
+809 0 80 "" 489.7861 545.90 0.0 00000000 00000000 1 [ ]
+810 0 70 "" 490.3633 577.15 0.0 00000000 00000000 1 [ ]
+811 0 80 "" 490.9961 632.81 0.0 00000000 00000000 1 [ ]
+812 0 70 "" 491.5693 573.24 0.0 00000000 00000000 1 [ ]
+813 0 80 "" 492.1396 570.31 0.0 00000000 00000000 1 [ ]
+814 0 80 "" 492.7529 613.28 0.0 00000000 00000000 1 [ ]
+815 0 70 "" 493.3135 560.55 0.0 00000000 00000000 1 [ ]
+816 0 80 "" 493.8936 580.08 0.0 00000000 00000000 1 [ ]
+817 0 80 "" 494.4600 566.41 0.0 00000000 00000000 1 [ ]
+818 0 70 "" 495.0830 623.05 0.0 00000000 00000000 1 [ ]
+819 0 80 "" 495.6826 599.61 0.0 00000000 00000000 1 [ ]
+820 0 80 "" 496.2900 607.42 0.0 00000000 00000000 1 [ ]
+821 0 70 "" 496.8594 569.34 0.0 00000000 00000000 1 [ ]
+822 0 80 "" 497.5059 646.48 0.0 00000000 00000000 1 [ ]
+823 0 80 "" 498.0566 550.78 0.0 00000000 00000000 1 [ ]
+824 0 80 "" 498.6631 606.45 0.0 00000000 00000000 1 [ ]
+825 0 80 "" 499.2998 636.72 0.0 00000000 00000000 1 [ ]
+826 0 70 "" 499.8564 556.64 0.0 00000000 00000000 1 [ ]
+827 0 80 "" 500.4893 632.81 0.0 00000000 00000000 1 [ ]
+828 0 80 "" 501.0566 567.38 0.0 00000000 00000000 1 [ ]
+829 0 70 "" 501.5967 540.04 0.0 00000000 00000000 1 [ ]
+830 0 80 "" 502.1826 585.94 0.0 00000000 00000000 1 [ ]
+831 0 80 "" 502.7861 603.52 0.0 00000000 00000000 1 [ ]
+832 0 70 "" 503.3857 599.61 0.0 00000000 00000000 1 [ ]
+833 0 80 "" 504.0098 624.02 0.0 00000000 00000000 1 [ ]
+834 0 80 "" 504.5732 563.48 0.0 00000000 00000000 1 [ ]
+835 0 80 "" 505.1328 559.57 0.0 00000000 00000000 1 [ ]
+836 0 70 "" 505.6924 559.57 0.0 00000000 00000000 1 [ ]
+837 0 80 "" 506.2861 593.75 0.0 00000000 00000000 1 [ ]
+838 0 80 "" 506.9092 623.05 0.0 00000000 00000000 1 [ ]
+839 0 80 "" 507.4561 546.88 0.0 00000000 00000000 1 [ ]
+840 0 80 "" 508.0557 599.61 0.0 00000000 00000000 1 [ ]
+841 0 80 "" 508.5957 540.04 0.0 00000000 00000000 1 [ ]
+842 0 70 "" 509.1865 590.82 0.0 00000000 00000000 1 [ ]
+843 0 80 "" 509.8125 625.98 0.0 00000000 00000000 1 [ ]
+844 0 70 "" 510.4160 603.52 0.0 00000000 00000000 1 [ ]
+845 0 80 "" 510.9961 580.08 0.0 00000000 00000000 1 [ ]
+846 0 80 "" 511.5498 553.71 0.0 00000000 00000000 1 [ ]
+847 0 70 "" 512.1631 613.28 0.0 00000000 00000000 1 [ ]
+848 0 80 "" 512.7764 613.28 0.0 00000000 00000000 1 [ ]
+849 0 70 "" 513.3662 589.84 0.0 00000000 00000000 1 [ ]
+850 0 80 "" 513.9824 616.21 0.0 00000000 00000000 1 [ ]
+851 0 80 "" 514.5488 566.41 0.0 00000000 00000000 1 [ ]
+852 0 70 "" 515.1162 567.38 0.0 00000000 00000000 1 [ ]
+853 0 80 "" 515.7295 613.28 0.0 00000000 00000000 1 [ ]
+854 0 70 "" 516.3330 603.52 0.0 00000000 00000000 1 [ ]
+855 0 80 "" 516.9092 576.17 0.0 00000000 00000000 1 [ ]
+856 0 80 "" 517.5195 610.35 0.0 00000000 00000000 1 [ ]
+857 0 80 "" 518.1328 613.28 0.0 00000000 00000000 1 [ ]
+858 0 80 "" 518.7588 625.98 0.0 00000000 00000000 1 [ ]
+859 0 80 "" 519.3691 610.35 0.0 00000000 00000000 1 [ ]
+860 0 70 "" 519.9062 537.11 0.0 00000000 00000000 1 [ ]
+861 0 80 "" 520.4395 533.20 0.0 00000000 00000000 1 [ ]
+862 0 80 "" 521.0654 625.98 0.0 00000000 00000000 1 [ ]
+863 0 70 "" 521.6025 537.11 0.0 00000000 00000000 1 [ ]
+864 0 80 "" 522.1855 583.01 0.0 00000000 00000000 1 [ ]
+865 0 80 "" 522.7920 606.45 0.0 00000000 00000000 1 [ ]
+866 0 70 "" 523.3691 577.15 0.0 00000000 00000000 1 [ ]
+867 0 80 "" 523.9688 599.61 0.0 00000000 00000000 1 [ ]
+868 0 70 "" 524.5625 593.75 0.0 00000000 00000000 1 [ ]
+869 0 80 "" 525.1729 610.35 0.0 00000000 00000000 1 [ ]
+870 0 70 "" 525.7461 573.24 0.0 00000000 00000000 1 [ ]
+871 0 80 "" 526.2920 545.90 0.0 00000000 00000000 1 [ ]
+872 0 80 "" 526.9229 630.86 0.0 00000000 00000000 1 [ ]
+873 0 80 "" 527.5293 606.45 0.0 00000000 00000000 1 [ ]
+874 0 80 "" 528.1328 603.52 0.0 00000000 00000000 1 [ ]
+875 0 80 "" 528.7119 579.10 0.0 00000000 00000000 1 [ ]
+876 0 80 "" 529.3428 630.86 0.0 00000000 00000000 1 [ ]
+877 0 80 "" 529.9053 562.50 0.0 00000000 00000000 1 [ ]
+878 0 80 "" 530.5059 600.59 0.0 00000000 00000000 1 [ ]
+879 0 80 "" 531.0586 552.73 0.0 00000000 00000000 1 [ ]
+880 0 70 "" 531.6758 617.19 0.0 00000000 00000000 1 [ ]
+881 0 80 "" 532.2188 542.97 0.0 00000000 00000000 1 [ ]
+882 0 80 "" 532.8193 600.59 0.0 00000000 00000000 1 [ ]
+883 0 80 "" 533.3555 536.13 0.0 00000000 00000000 1 [ ]
+884 0 80 "" 533.8818 526.37 0.0 00000000 00000000 1 [ ]
+885 0 80 "" 534.4658 583.98 0.0 00000000 00000000 1 [ ]
+886 0 80 "" 535.0322 566.41 0.0 00000000 00000000 1 [ ]
+887 0 80 "" 535.6055 573.24 0.0 00000000 00000000 1 [ ]
+888 0 80 "" 536.2393 633.79 0.0 00000000 00000000 1 [ ]
+889 0 80 "" 536.8252 585.94 0.0 00000000 00000000 1 [ ]
+890 0 70 "" 537.4092 583.98 0.0 00000000 00000000 1 [ ]
+891 0 80 "" 538.0459 636.72 0.0 00000000 00000000 1 [ ]
+892 0 80 "" 538.5918 545.90 0.0 00000000 00000000 1 [ ]
+893 0 80 "" 539.1426 550.78 0.0 00000000 00000000 1 [ ]
+894 0 80 "" 539.7324 589.84 0.0 00000000 00000000 1 [ ]
+895 0 80 "" 540.3584 625.98 0.0 00000000 00000000 1 [ ]
+896 0 70 "" 540.9756 617.19 0.0 00000000 00000000 1 [ ]
+897 0 80 "" 541.5518 576.17 0.0 00000000 00000000 1 [ ]
+898 0 80 "" 542.0791 527.34 0.0 00000000 00000000 1 [ ]
+899 0 80 "" 542.6152 536.13 0.0 00000000 00000000 1 [ ]
+900 0 80 "" 543.2021 586.91 0.0 00000000 00000000 1 [ ]
+901 0 70 "" 543.7852 583.01 0.0 00000000 00000000 1 [ ]
+902 0 80 "" 544.3555 570.31 0.0 00000000 00000000 1 [ ]
+903 0 80 "" 544.9053 549.80 0.0 00000000 00000000 1 [ ]
+904 0 70 "" 545.5254 620.12 0.0 00000000 00000000 1 [ ]
+905 0 80 "" 546.1484 623.05 0.0 00000000 00000000 1 [ ]
+906 0 80 "" 546.7490 600.59 0.0 00000000 00000000 1 [ ]
+907 0 80 "" 547.3818 632.81 0.0 00000000 00000000 1 [ ]
+908 0 80 "" 547.9756 593.75 0.0 00000000 00000000 1 [ ]
+909 0 80 "" 548.5586 583.01 0.0 00000000 00000000 1 [ ]
+910 0 80 "" 549.1123 553.71 0.0 00000000 00000000 1 [ ]
+911 0 70 "" 549.6689 556.64 0.0 00000000 00000000 1 [ ]
+912 0 80 "" 550.2920 623.05 0.0 00000000 00000000 1 [ ]
+913 0 80 "" 550.8584 566.41 0.0 00000000 00000000 1 [ ]
+914 0 80 "" 551.4287 570.31 0.0 00000000 00000000 1 [ ]
+915 0 70 "" 552.0088 580.08 0.0 00000000 00000000 1 [ ]
+916 0 80 "" 552.6484 639.65 0.0 00000000 00000000 1 [ ]
+917 0 80 "" 553.2451 596.68 0.0 00000000 00000000 1 [ ]
+918 0 80 "" 553.8682 623.05 0.0 00000000 00000000 1 [ ]
+919 0 80 "" 554.4453 577.15 0.0 00000000 00000000 1 [ ]
+920 0 80 "" 555.0420 596.68 0.0 00000000 00000000 1 [ ]
+921 0 80 "" 555.5752 533.20 0.0 00000000 00000000 1 [ ]
+922 0 80 "" 556.1748 599.61 0.0 00000000 00000000 1 [ ]
+923 0 70 "" 556.7881 613.28 0.0 00000000 00000000 1 [ ]
+924 0 80 "" 557.3848 596.68 0.0 00000000 00000000 1 [ ]
+925 0 80 "" 557.9648 580.08 0.0 00000000 00000000 1 [ ]
+926 0 70 "" 558.5420 577.15 0.0 00000000 00000000 1 [ ]
+927 0 80 "" 559.1387 596.68 0.0 00000000 00000000 1 [ ]
+928 0 70 "" 559.6914 552.73 0.0 00000000 00000000 1 [ ]
+929 0 80 "" 560.2451 553.71 0.0 00000000 00000000 1 [ ]
+930 0 70 "" 560.8086 563.48 0.0 00000000 00000000 1 [ ]
+931 0 80 "" 561.3516 542.97 0.0 00000000 00000000 1 [ ]
+932 0 80 "" 562.0049 653.32 0.0 00000000 00000000 1 [ ]
+933 0 80 "" 562.5820 577.15 0.0 00000000 00000000 1 [ ]
+934 0 80 "" 563.1650 583.01 0.0 00000000 00000000 1 [ ]
+935 0 80 "" 563.7783 613.28 0.0 00000000 00000000 1 [ ]
+936 0 80 "" 564.4150 636.72 0.0 00000000 00000000 1 [ ]
+937 0 70 "" 565.0283 613.28 0.0 00000000 00000000 1 [ ]
+938 0 80 "" 565.6514 623.05 0.0 00000000 00000000 1 [ ]
+939 0 80 "" 566.1953 543.95 0.0 00000000 00000000 1 [ ]
+940 0 70 "" 566.7852 589.84 0.0 00000000 00000000 1 [ ]
+941 0 80 "" 567.3320 546.88 0.0 00000000 00000000 1 [ ]
+942 0 80 "" 567.8750 542.97 0.0 00000000 00000000 1 [ ]
+943 0 80 "" 568.4150 540.04 0.0 00000000 00000000 1 [ ]
+944 0 70 "" 568.9580 542.97 0.0 00000000 00000000 1 [ ]
+945 0 80 "" 569.5146 556.64 0.0 00000000 00000000 1 [ ]
+946 0 80 "" 570.1445 629.88 0.0 00000000 00000000 1 [ ]
+947 0 80 "" 570.7412 596.68 0.0 00000000 00000000 1 [ ]
+948 0 80 "" 571.3379 596.68 0.0 00000000 00000000 1 [ ]
+949 0 80 "" 571.9551 617.19 0.0 00000000 00000000 1 [ ]
+950 0 80 "" 572.5576 602.54 0.0 00000000 00000000 1 [ ]
+951 0 80 "" 573.1514 593.75 0.0 00000000 00000000 1 [ ]
+952 0 80 "" 573.7451 593.75 0.0 00000000 00000000 1 [ ]
+953 0 70 "" 574.2881 542.97 0.0 00000000 00000000 1 [ ]
+954 0 80 "" 574.8682 580.08 0.0 00000000 00000000 1 [ ]
+955 0 70 "" 575.4883 620.12 0.0 00000000 00000000 1 [ ]
+956 0 80 "" 576.0811 592.77 0.0 00000000 00000000 1 [ ]
+957 0 80 "" 576.6211 540.04 0.0 00000000 00000000 1 [ ]
+958 0 70 "" 577.1680 546.88 0.0 00000000 00000000 1 [ ]
+959 0 80 "" 577.7148 546.88 0.0 00000000 00000000 1 [ ]
+960 0 80 "" 578.3145 599.61 0.0 00000000 00000000 1 [ ]
+961 0 80 "" 578.8613 546.88 0.0 00000000 00000000 1 [ ]
+962 0 80 "" 579.4912 629.88 0.0 00000000 00000000 1 [ ]
+963 0 80 "" 580.0547 563.48 0.0 00000000 00000000 1 [ ]
+964 0 70 "" 580.6777 623.05 0.0 00000000 00000000 1 [ ]
+965 0 80 "" 581.2842 606.45 0.0 00000000 00000000 1 [ ]
+966 0 80 "" 581.8779 593.75 0.0 00000000 00000000 1 [ ]
+967 0 80 "" 582.4277 549.80 0.0 00000000 00000000 1 [ ]
+968 0 80 "" 583.0078 580.08 0.0 00000000 00000000 1 [ ]
+969 0 70 "" 583.5713 563.48 0.0 00000000 00000000 1 [ ]
+970 0 80 "" 584.1143 542.97 0.0 00000000 00000000 1 [ ]
+971 0 80 "" 584.7109 596.68 0.0 00000000 00000000 1 [ ]
+972 0 70 "" 585.3311 620.12 0.0 00000000 00000000 1 [ ]
+973 0 80 "" 585.9414 610.35 0.0 00000000 00000000 1 [ ]
+974 0 80 "" 586.5146 573.24 0.0 00000000 00000000 1 [ ]
+975 0 70 "" 587.1074 592.77 0.0 00000000 00000000 1 [ ]
+976 0 80 "" 587.6875 580.08 0.0 00000000 00000000 1 [ ]
+977 0 80 "" 588.2715 583.98 0.0 00000000 00000000 1 [ ]
+978 0 80 "" 588.8379 566.41 0.0 00000000 00000000 1 [ ]
+979 0 80 "" 589.3848 546.88 0.0 00000000 00000000 1 [ ]
+980 0 80 "" 589.9814 596.68 0.0 00000000 00000000 1 [ ]
+981 0 80 "" 590.5742 592.77 0.0 00000000 00000000 1 [ ]
+982 0 80 "" 591.1914 617.19 0.0 00000000 00000000 1 [ ]
+983 0 80 "" 591.8008 609.38 0.0 00000000 00000000 1 [ ]
+984 0 80 "" 592.3877 586.91 0.0 00000000 00000000 1 [ ]
+985 0 80 "" 593.0205 632.81 0.0 00000000 00000000 1 [ ]
+986 0 80 "" 593.6309 610.35 0.0 00000000 00000000 1 [ ]
+987 0 80 "" 594.2539 623.05 0.0 00000000 00000000 1 [ ]
+988 0 80 "" 594.8174 563.48 0.0 00000000 00000000 1 [ ]
+989 0 70 "" 595.4346 617.19 0.0 00000000 00000000 1 [ ]
+990 0 80 "" 596.0439 609.38 0.0 00000000 00000000 1 [ ]
+991 0 80 "" 596.6074 563.48 0.0 00000000 00000000 1 [ ]
+992 0 80 "" 597.1777 570.31 0.0 00000000 00000000 1 [ ]
+993 0 80 "" 597.7441 566.41 0.0 00000000 00000000 1 [ ]
+994 0 80 "" 598.3047 560.55 0.0 00000000 00000000 1 [ ]
+995 0 70 "" 598.9072 602.54 0.0 00000000 00000000 1 [ ]
+996 0 80 "" 599.5371 629.88 0.0 00000000 00000000 1 [ ]
+997 0 80 "" 600.1104 573.24 0.0 00000000 00000000 1 [ ]
+998 0 80 "" 600.6943 583.98 0.0 00000000 00000000 1 [ ]
+999 0 80 "" 601.3145 620.12 0.0 00000000 00000000 1 [ ]
+1000 0 80 "" 601.9375 623.05 0.0 00000000 00000000 1 [ ]
+1001 0 70 "" 602.5039 566.41 0.0 00000000 00000000 1 [ ]
+1002 0 1 "" 605.8389 3334.96 0.0 00000000 00000000 1 [ ]
diff --git a/studio_functions/Functions/EStudio/EEG Tab/EStudio_EEG_Tab.m b/studio_functions/Functions/EStudio/EEG Tab/EStudio_EEG_Tab.m
new file mode 100755
index 00000000..65b63746
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/EStudio_EEG_Tab.m
@@ -0,0 +1,172 @@
+%%This function is to create EEG Tab
+
+
+% Author: Guanghui Zhang & Steve J. Luck
+% Center for Mind and Brain
+% University of California, Davis
+% Davis, CA
+% Aug. 2023
+
+
+
+function EStudio_gui_erp_totl = EStudio_EEG_Tab(EStudio_gui_erp_totl,ColorB_def)
+
+if isempty(ColorB_def)
+ ColorB_def = [0.7020 0.77 0.85];
+end
+
+%% Arrange the main interface for ERP panel (Tab3)
+EStudio_gui_erp_totl.eegViewBox = uix.VBox('Parent', EStudio_gui_erp_totl.tabEEG,'BackgroundColor',ColorB_def);
+EStudio_gui_erp_totl.eegViewPanel = uix.BoxPanel('Parent', EStudio_gui_erp_totl.eegViewBox,'TitleColor',ColorB_def,'ForegroundColor','k');%
+EStudio_gui_erp_totl.eegViewContainer = uicontainer('Parent', EStudio_gui_erp_totl.eegViewPanel);
+
+EStudio_gui_erp_totl.eegpanelscroll = uix.ScrollingPanel('Parent', EStudio_gui_erp_totl.tabEEG);
+set(EStudio_gui_erp_totl.eegpanelscroll,'BackgroundColor',ColorB_def);
+% + Adjust the main layout
+set( EStudio_gui_erp_totl.tabEEG, 'Widths', [-4, 300]); % Viewpanel and settings panel
+
+%%-------------------------function panels---------------------------------
+EStudio_gui_erp_totl.eegpanel_fonts = f_get_default_fontsize();
+
+EStudio_gui_erp_totl.eegsettingLayout = uiextras.VBox('Parent', EStudio_gui_erp_totl.eegpanelscroll,'BackgroundColor',ColorB_def);
+
+% + Create the settings window panels for ERP panel
+EStudio_gui_erp_totl.eegpanel{1} = f_EEG_eeg_sets_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(1) = 300;
+EStudio_gui_erp_totl.eegpanel{2} = f_EEG_IC_channel_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(2) = 320;
+EStudio_gui_erp_totl.eegpanel{3} = f_EEG_Plot_setting_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(3) = 290;
+EStudio_gui_erp_totl.eegpanel{4} = f_EEG_edit_channel_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(4) = 170;
+disp('EEG Tab: Launching EEGsets, Channel and IC Selection, Plot Settings, Edit/Delete Channels & Locations,...');
+EStudio_gui_erp_totl.eegpanel{5} = f_EEG_interpolate_chan_epoch_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(5) = 290;
+EStudio_gui_erp_totl.eegpanel{6} = f_EEG_chanoperation_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(6) = 330;
+EStudio_gui_erp_totl.eegpanel{7} = f_EEG_informtion_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(7) = 410;
+EStudio_gui_erp_totl.eegpanel{8} = f_EEG_resample_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(8) = 215;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'Interpolate Channels, Channel Operations, EEG & Bin Information, Sampling Rate & Epoch,...']);
+EStudio_gui_erp_totl.eegpanel{9} = f_EEG_events_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(9) = 430;
+EStudio_gui_erp_totl.eegpanel{10} = f_EEG_filtering_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(10) = 245;
+EStudio_gui_erp_totl.eegpanel{11} = f_EEG_eeglabtool_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(11) = 210;
+EStudio_gui_erp_totl.eegpanel{12} = f_EEG_eeglabica_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(12) = 250;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'EventList, Filtering, EEGLAB Tools (only for one selected dataset), EEGLAB ICA (only for one selected dataset),...']);
+EStudio_gui_erp_totl.eegpanel{13} = f_EEG_event2bin_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(13) = 200;
+EStudio_gui_erp_totl.eegpanel{14} = f_EEG_binepoch_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(14) = 160;
+EStudio_gui_erp_totl.eegpanel{15} = f_EEG_arf_det_segmt_conus_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(15) = 290;
+EStudio_gui_erp_totl.eegpanel{16} = f_EEG_arf_det_conus_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(16) = 470;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'Assign Events to Bins (BINLISTER), Extract Bin-Based Epochs (Continuous EEG), Delete Time Segments (Continuous EEG), Reject Artifactual Time Segments (Continuous EEG),...']);
+EStudio_gui_erp_totl.eegpanel{17} = f_EEG_shift_eventcode_conus_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(17) = 200;
+EStudio_gui_erp_totl.eegpanel{18} = f_EEG_dq_fre_conus_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(18) = 290;
+EStudio_gui_erp_totl.eegpanel{19} = f_EEG_arf_det_epoch_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(19) = 380;
+EStudio_gui_erp_totl.eegpanel{20} = f_EEG_arf_sumop_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(20) = 160;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'Shift Event Codes (Continuous EEG), Spectral Data Quality (Continuous EEG), Artifact Detection (Epoched EEG), Artifact Info & Tools (Epoched EEG),...']);
+EStudio_gui_erp_totl.eegpanel{21} = f_EEG_baselinecorr_detrend_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(21) = 220;
+EStudio_gui_erp_totl.eegpanel{22} = f_EEG_dq_epoch_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(22) = 240;
+EStudio_gui_erp_totl.eegpanel{23} = f_EEG_avg_erp_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(23) = 300;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'Baseline Correction & Linear Detrend (Epoched EEG), Compute Data Quality Metrics (Epoched EEG), Compute Averaged ERPs (Epoched EEG),...']);
+EStudio_gui_erp_totl.eegpanel{24} = f_EEG_CSD_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(24) = 190;
+EStudio_gui_erp_totl.eegpanel{25} = f_EEG_utilities_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(25) = 190;
+EStudio_gui_erp_totl.eegpanel{26} = f_EEG_history_GUI(EStudio_gui_erp_totl.eegsettingLayout,EStudio_gui_erp_totl.eegpanel_fonts);
+EStudio_gui_erp_totl.eegpanelSizes(26) = 300;
+disp([32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,...
+ 'Convert Voltage to CSD, EEG Utilities, and History panels.']);
+
+set(EStudio_gui_erp_totl.eegsettingLayout, 'Heights', EStudio_gui_erp_totl.eegpanelSizes);
+EStudio_gui_erp_totl.eegpanelscroll.Heights = sum(EStudio_gui_erp_totl.eegpanelSizes);
+
+%% Hook up the minimize callback and IsMinimized
+set( EStudio_gui_erp_totl.eegpanel{1}, 'MinimizeFcn', {@nMinimize, 1} );
+set( EStudio_gui_erp_totl.eegpanel{2}, 'MinimizeFcn', {@nMinimize, 2} );
+set( EStudio_gui_erp_totl.eegpanel{3}, 'MinimizeFcn', {@nMinimize, 3} );
+set( EStudio_gui_erp_totl.eegpanel{4}, 'MinimizeFcn', {@nMinimize, 4} );
+set( EStudio_gui_erp_totl.eegpanel{5}, 'MinimizeFcn', {@nMinimize, 5} );
+set( EStudio_gui_erp_totl.eegpanel{6}, 'MinimizeFcn', {@nMinimize, 6} );
+set( EStudio_gui_erp_totl.eegpanel{7}, 'MinimizeFcn', {@nMinimize, 7} );
+set( EStudio_gui_erp_totl.eegpanel{8}, 'MinimizeFcn', {@nMinimize, 8} );
+set( EStudio_gui_erp_totl.eegpanel{9}, 'MinimizeFcn', {@nMinimize, 9} );
+set( EStudio_gui_erp_totl.eegpanel{10}, 'MinimizeFcn', {@nMinimize, 10} );
+set( EStudio_gui_erp_totl.eegpanel{11}, 'MinimizeFcn', {@nMinimize, 11} );
+set( EStudio_gui_erp_totl.eegpanel{12}, 'MinimizeFcn', {@nMinimize, 12} );
+set( EStudio_gui_erp_totl.eegpanel{13}, 'MinimizeFcn', {@nMinimize, 13} );
+set( EStudio_gui_erp_totl.eegpanel{14}, 'MinimizeFcn', {@nMinimize, 14} );
+set( EStudio_gui_erp_totl.eegpanel{15}, 'MinimizeFcn', {@nMinimize, 15} );
+set( EStudio_gui_erp_totl.eegpanel{16}, 'MinimizeFcn', {@nMinimize, 16} );
+set( EStudio_gui_erp_totl.eegpanel{17}, 'MinimizeFcn', {@nMinimize, 17} );
+set( EStudio_gui_erp_totl.eegpanel{18}, 'MinimizeFcn', {@nMinimize, 18} );
+set( EStudio_gui_erp_totl.eegpanel{19}, 'MinimizeFcn', {@nMinimize, 19} );
+set( EStudio_gui_erp_totl.eegpanel{20}, 'MinimizeFcn', {@nMinimize, 20} );
+set( EStudio_gui_erp_totl.eegpanel{21}, 'MinimizeFcn', {@nMinimize, 21} );
+set( EStudio_gui_erp_totl.eegpanel{22}, 'MinimizeFcn', {@nMinimize, 22} );
+set( EStudio_gui_erp_totl.eegpanel{23}, 'MinimizeFcn', {@nMinimize, 23} );
+set( EStudio_gui_erp_totl.eegpanel{24}, 'MinimizeFcn', {@nMinimize, 24} );
+set( EStudio_gui_erp_totl.eegpanel{25}, 'MinimizeFcn', {@nMinimize, 25} );
+set( EStudio_gui_erp_totl.eegpanel{26}, 'MinimizeFcn', {@nMinimize, 26} );
+%%shrinking Panels 4-26 to just their title-bar
+whichpanel = [4:26];
+for Numofpanel = 1:length(whichpanel)
+ minned = EStudio_gui_erp_totl.eegpanel{whichpanel(Numofpanel)}.IsMinimized;
+ szs = get( EStudio_gui_erp_totl.eegsettingLayout, 'Sizes' );
+ if minned
+ set( EStudio_gui_erp_totl.eegpanel{whichpanel(Numofpanel)}, 'IsMinimized', false);
+ szs(whichpanel(Numofpanel)) = EStudio_gui_erp_totl.eegpanelSizes(whichpanel(Numofpanel));
+ else
+ set( EStudio_gui_erp_totl.eegpanel{whichpanel(Numofpanel)}, 'IsMinimized', true);
+ szs(whichpanel(Numofpanel)) = 25;
+ end
+ set( EStudio_gui_erp_totl.eegsettingLayout, 'Sizes', szs );
+ EStudio_gui_erp_totl.eegpanelscroll.Heights = sum(szs);
+end %% End for shrinking panels 4-23
+
+%% + Create the view
+peeg = EStudio_gui_erp_totl.eegViewContainer;
+EStudio_gui_erp_totl.eegViewAxes = uiextras.HBox( 'Parent', peeg,'BackgroundColor',ColorB_def);
+end
+
+
+function nMinimize( eventSource, eventData, whichpanel ) %#ok
+global EStudio_gui_erp_totl;
+
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+minned = EStudio_gui_erp_totl.eegpanel{whichpanel}.IsMinimized;
+szs = get( EStudio_gui_erp_totl.eegsettingLayout, 'Sizes' );
+if minned
+ set( EStudio_gui_erp_totl.eegpanel{whichpanel}, 'IsMinimized', false);
+ szs(whichpanel) = EStudio_gui_erp_totl.eegpanelSizes(whichpanel);
+else
+ set( EStudio_gui_erp_totl.eegpanel{whichpanel}, 'IsMinimized', true);
+ szs(whichpanel) = 25;
+end
+set( EStudio_gui_erp_totl.eegsettingLayout, 'Sizes', szs ,'BackgroundColor',ColorB_def);
+EStudio_gui_erp_totl.eegpanelscroll.Heights = sum(szs);
+set(EStudio_gui_erp_totl.eegpanelscroll,'BackgroundColor',ColorB_def);
+end % nMinimize
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_check_eegtab_panelchanges.m b/studio_functions/Functions/EStudio/EEG Tab/f_check_eegtab_panelchanges.m
new file mode 100755
index 00000000..9463d918
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_check_eegtab_panelchanges.m
@@ -0,0 +1,181 @@
+function [messgStr,eegpanelIndex]= f_check_eegtab_panelchanges()
+
+messgStr = '';
+eegpanelIndex = 0;
+
+MyViewer_eegset = estudioworkingmemory('EEGTab_eegset');
+if ~isempty(MyViewer_eegset) && MyViewer_eegset==1
+ messgStr = char( 'Changes on "EEGsets" have not been applied');
+ eegpanelIndex =100;
+ return;
+end
+
+
+MyViewer_chanic = estudioworkingmemory('EEGTab_chanic');
+if ~isempty(MyViewer_chanic) && MyViewer_chanic==1
+ messgStr = char( 'Changes on "Channel and IC Selection" have not been applied');
+ eegpanelIndex =1;
+ return;
+end
+
+
+MyViewer_plotset = estudioworkingmemory('EEGTab_plotset');
+if ~isempty(MyViewer_plotset) && MyViewer_plotset==1
+ messgStr = char( 'Changes on "Plot Settings" have not been applied');
+ eegpanelIndex =2;
+ return;
+end
+
+%%filtering
+MyViewer_filter = estudioworkingmemory('EEGTab_filter');
+if ~isempty(MyViewer_filter) && MyViewer_filter==1
+ messgStr = char( 'Changes on "Filtering" have not been applied');
+ eegpanelIndex =3;
+ return;
+end
+
+%%Channel operations
+MyViewer_chanop = estudioworkingmemory('EEGTab_chanop');
+if ~isempty(MyViewer_chanop) && MyViewer_chanop==1
+ messgStr = char( 'Changes on "Channel Operations" have not been applied');
+ eegpanelIndex =4;
+ return;
+end
+
+%%Assign events to bins
+MyViewer_event2bin = estudioworkingmemory('EEGTab_event2bin');
+if ~isempty(MyViewer_event2bin) && MyViewer_event2bin==1
+ messgStr = char( 'Changes on "Assign Events to Bins (BINLISTER)" have not been applied');
+ eegpanelIndex =5;
+ return;
+end
+
+
+%%Bin-based epoch
+MyViewer_binepoch = estudioworkingmemory('EEGTab_binepoch');
+if ~isempty(MyViewer_binepoch) && MyViewer_binepoch==1
+ messgStr = char( 'Changes on "Extract Bin-Based Epochs (Continuous EEG)" have not been applied');
+ eegpanelIndex =6;
+ return;
+end
+
+
+%%edit chan
+%%Bin-based epoch
+MyViewer_editchan = estudioworkingmemory('EEGTab_editchan');
+if ~isempty(MyViewer_editchan) && MyViewer_editchan==1
+ messgStr = char( 'Changes on "Edit Channel Info" have not been applied');
+ eegpanelIndex =7;
+ return;
+end
+
+
+
+%%interpolate
+MyViewer_interpolatechan = estudioworkingmemory('EEGTab_interpolated_chan_epoch');
+if ~isempty(MyViewer_interpolatechan) && MyViewer_interpolatechan==1
+ messgStr = char( 'Changes on "Interpolate Channels" have not been applied');
+ eegpanelIndex =8;
+ return;
+end
+
+%%detect artifact for epoched EEG
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_detect_arts_epoch');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Artifact Detection (Epoched EEG)" have not been applied');
+ eegpanelIndex =9;
+ return;
+end
+
+
+
+%%detect artifact for continuous EEG
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_detect_arts_conus');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Delete Time Segments (Continuous EEG)" have not been applied');
+ eegpanelIndex =10;
+ return;
+end
+
+
+%%delete time segements
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_detect_segmt_conus');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Reject Artifactual Time Segments (Continuous EEG)" have not been applied');
+ eegpanelIndex =11;
+ return;
+end
+
+
+
+%%Shift Event Codes for Continuous EEG
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_shiftcodes_conus');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Shift Event Codes (Continuous EEG)" have not been applied');
+ eegpanelIndex =12;
+ return;
+end
+
+
+
+%%Remove response mistakes for Continuous EEG
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_rmresposmistak_conus');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Remove Response Errors (Continuous EEG)" have not been applied');
+ eegpanelIndex =13;
+ return;
+end
+
+
+%%spectral data quality
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_dq_fre_conus');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Spectral Data Quality (Continuous EEG)" have not been applied');
+ eegpanelIndex =14;
+ return;
+end
+
+
+%%linear detrend
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_baseline_detrend');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Baseline Correction & Linear Detrend (Epoched EEG)" have not been applied');
+ eegpanelIndex =15;
+ return;
+end
+
+%%data quality for epoched eeg
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_dq_epoch');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Data Quality Metrics (Epoched EEG)" have not been applied');
+ eegpanelIndex =16;
+ return;
+end
+
+%%compute averaged ERP
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_avg_erp');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Compute Averaged ERPs (Epoched EEG)" have not been applied');
+ eegpanelIndex =17;
+ return;
+end
+
+%%compute averaged ERP
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_resample');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Sampling Rate & Epoch" have not been applied');
+ eegpanelIndex =18;
+ return;
+end
+
+
+
+MyViewer_detectartepoch = estudioworkingmemory('EEGTab_csd');
+if ~isempty(MyViewer_detectartepoch) && MyViewer_detectartepoch==1
+ messgStr = char( 'Changes on "Convert voltage to CSD" have not been applied');
+ eegpanelIndex =19;
+ return;
+end
+
+
+return;
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_eeg_read_chan_IC_names.m b/studio_functions/Functions/EStudio/EEG Tab/f_eeg_read_chan_IC_names.m
new file mode 100755
index 00000000..69856d17
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_eeg_read_chan_IC_names.m
@@ -0,0 +1,57 @@
+
+
+
+function [AllStr,chanName,ICName] = f_eeg_read_chan_IC_names(chanlocs,ChanArray,ICArray,channeLabel)
+chanName = '';
+ICName = '';
+AllStr = '';
+if isempty(chanlocs) && isempty(ChanArray)
+ return;
+end
+
+if ~isempty(ChanArray)
+ if ~isempty(chanlocs) && channeLabel==1
+ if any(ChanArray(:)>length(chanlocs) )
+ ChanArray = [1:length(chanlocs)];
+ end
+ chanlocs = chanlocs(ChanArray);
+ tmplocs = readlocs(chanlocs);
+ chanName = { tmplocs.labels };
+ for ii = 1:length(chanName)
+ chanName{1,ii}= sprintf(chanName{1,ii},'_','\_');
+ chanName{1,ii} = strcat(num2str(ChanArray(ii)),'.',32,chanName{1,ii});
+ end
+ elseif (isempty(chanlocs) || channeLabel==0) && ~isempty(ChanArray)
+ count = 0;
+ for ii = ChanArray
+ count = count +1;
+ chanName{count,1} = ['Chan',32,num2str(ii)];
+ end
+ end
+end
+AllStr = chanName;
+chanName = char(chanName);
+%%IC names
+if isempty(ICArray)
+ AllStr = char(AllStr);
+ return;
+end
+count = 0;
+for ii = ICArray
+ count = count +1;
+ ICName{count,1} = ['IC',32,num2str(ii)];
+end
+
+if isempty(AllStr)
+ AllStr = char(ICName);
+else
+ count = 0;
+ for ii = ICArray
+ count = count +1;
+ AllStr{length(AllStr)+1} = ['IC',32,num2str(ii)];
+ end
+
+end
+AllStr = char(AllStr);
+ICName = char(ICName);
+end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/f_get_default_fontsize.m b/studio_functions/Functions/EStudio/EEG Tab/f_get_default_fontsize.m
old mode 100644
new mode 100755
similarity index 54%
rename from studio_functions/Functions/EStudio/f_get_default_fontsize.m
rename to studio_functions/Functions/EStudio/EEG Tab/f_get_default_fontsize.m
index bb0af327..3e611376
--- a/studio_functions/Functions/EStudio/f_get_default_fontsize.m
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_get_default_fontsize.m
@@ -1,5 +1,10 @@
+%%This function is to set the default fontsize for ERP wave viewer on different platforms
-
+%Author: Guanghui ZHANG && Steve Luck
+%Center for Mind and Brain
+%University of California, Davis
+%Davis, CA, USA
+% 2023
function FonsizeDefault = f_get_default_fontsize()
@@ -9,7 +14,7 @@
FonsizeDefault = 12;
elseif isunix
% Code to run on Linux platform
- FonsizeDefault = 9;
+ FonsizeDefault = 8.5;
elseif ispc
% Code to run on Windows platform
FonsizeDefault = 9;
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_ploteeg.m b/studio_functions/Functions/EStudio/EEG Tab/f_ploteeg.m
new file mode 100644
index 00000000..0050aaa3
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_ploteeg.m
@@ -0,0 +1,71 @@
+
+%%This function is to manually detect segememnts with artifats for
+%%continuous or epoched EEG
+
+
+% FORMAT : [EEG, eegcom] = f_ploteeg(EEG,mflag)
+
+%INPUTS:
+%
+% EEG - structure array of EEG structures (EEGsets)
+% mflag - flag value between 1 to 8 to be marked when an artifact is
+% found.(1 value) for epoched EEG
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Apr. 2024
+
+
+
+
+function [EEG, eegcom] = f_ploteeg(EEG,mflag)
+eegcom = '';
+if nargin < 1
+ help f_ploteeg
+ return
+end
+
+if nargin < 2
+ mflag=1;
+end
+
+
+if isempty(EEG)
+ msgboxText = 'Cannot handle an empty EEGset';
+ title = 'ERPLAB: f_ploteeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(EEG(1).data)
+ msgboxText = 'Cannot handle an empty EEGset';
+ title = 'ERPLAB: f_ploteeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+if length(EEG)>1
+ msgboxText = 'Cannot handle multiple eegsets!';
+ title = 'ERPLAB: f_ploteeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+app = feval('EEG_select_segement_artifact_GUI',EEG,1,mflag);
+waitfor(app,'Finishbutton',1);
+try
+ EEG = app.Output; %NO you don't want to output EEG with edited channel locations, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.1); %wait for app to leave
+catch
+ EEG = [];
+ return;
+end
+
+
+eegcom = '[EEG, eegcom] = f_ploteeg(EEG);';
+end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_ploteegwave.m b/studio_functions/Functions/EStudio/EEG Tab/f_ploteegwave.m
new file mode 100644
index 00000000..8eb1f9d3
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_ploteegwave.m
@@ -0,0 +1,952 @@
+%%This is subfunction of the pop_ploteegset.m that is used to plot EEG wave
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% August 2023
+
+
+function errmeg = f_ploteegwave(EEG,ChanArray,ICArray,Winlength,...
+ AmpScale,ChanLabel,Submean,EventOnset,StackFlag,NormFlag,Startimes,...
+ AmpIC,bufftobo,FigOutpos,FigureName)
+
+errmeg = [];
+
+if nargin<1
+ help f_ploteegwave;
+ return
+end
+
+if isempty(EEG)
+ errmeg = 'EEG is empty';
+ return;
+end
+%%selected channels
+nbchan = EEG.nbchan;
+if nargin<2
+ ChanArray = 1:nbchan;
+end
+if ~isempty(ChanArray) &&( min(ChanArray(:)) >nbchan || max(ChanArray(:))> nbchan|| min(ChanArray(:))<=0)
+ ChanArray = 1:nbchan;
+end
+
+%%selected ICs
+if nargin<3
+ ICArray = [];
+end
+if isempty(EEG.icachansind)
+ ICArray = [];
+else
+ nIC = numel(EEG.icachansind);
+ if ~isempty(ICArray)
+ if min(ICArray(:))>nIC || max(ICArray(:)) > nIC || min(ICArray(:))<=0
+ ICArray = [];
+ end
+ end
+end
+
+
+%%Time range that is to display (1s or 5s)?
+if nargin<4
+ Winlength=5;
+end
+if isempty(Winlength) || numel(Winlength)~=1 || min(Winlength(:))<=0
+ Winlength=5;
+end
+
+%%Vertical scale?
+if nargin<5
+ AmpScale = 50;
+end
+if isempty(AmpScale) || numel(AmpScale)~=1 || AmpScale==0
+ AmpScale = 50;
+end
+OldAmpScale = AmpScale;
+
+%%channe labels (name or number)
+if nargin<6
+ ChanLabel = 1;
+end
+if ~isempty(ChanLabel) && numel(ChanLabel)~=1
+ ChanLabel = ChanLabel(1);
+end
+if isempty(ChanLabel) || numel(ChanLabel)~=1 || (ChanLabel~=0 && ChanLabel~=1)
+ ChanLabel = 1;
+end
+
+%%remove DC?
+if nargin<7
+ Submean = 0;
+end
+if ~isempty(Submean) && numel(Submean)~=1
+ Submean = Submean(1);
+end
+if isempty(Submean) || numel(Submean)~=1 || (Submean~=0 && Submean~=1)
+ Submean = 0;
+end
+
+
+%%Display events?
+if nargin<8
+ EventOnset = 1;
+end
+if ~isempty(EventOnset) && numel(EventOnset)~=1
+ EventOnset = EventOnset(1);
+end
+if isempty(EventOnset) || numel(EventOnset)~=1 || (EventOnset~=0 && EventOnset~=1)
+ EventOnset = 1;
+end
+
+
+%%Stack?
+if nargin<9
+ StackFlag = 0;
+end
+if ~isempty(StackFlag) && numel(StackFlag)~=1
+ StackFlag = StackFlag(1);
+end
+if isempty(StackFlag) || numel(StackFlag)~=1 || (StackFlag~=0&&StackFlag~=1)
+ StackFlag = 0;
+end
+
+%%Norm?
+if nargin<10
+ NormFlag = 0;
+end
+if ~isempty(NormFlag) && numel(NormFlag)~=1
+ NormFlag = NormFlag(1);
+end
+if isempty(NormFlag) ||numel(NormFlag)~=1 || (NormFlag~=0 && NormFlag~=1)
+ NormFlag = 0;
+end
+
+%%start time for the displayed data
+if nargin < 11
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+[ChanNum,Allsamples,tmpnb] = size(EEG.data);
+Allsamples = Allsamples*tmpnb;
+if ndims(EEG.data) > 2
+ multiplier = size(EEG.data,2);
+else
+ multiplier = EEG.srate;
+end
+
+if isempty(Startimes) || Startimes<0 || Startimes>(ceil((Allsamples-1)/multiplier)-Winlength)
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+
+%%VERTICAL SCALE for ICs
+if nargin<12
+ AmpIC = 20;
+end
+
+if isempty(AmpIC) || numel(AmpIC)~=1 || AmpIC<=0
+ AmpIC = 20;
+end
+OldAmpIC = AmpIC;
+
+
+%%buffer at top and bottom
+if nargin<13
+ bufftobo = 100;
+end
+if isempty(bufftobo) || numel(bufftobo)~=1 || any(bufftobo(:)<=0)
+ bufftobo = 100;
+end
+
+
+
+
+if nargin <14
+ FigOutpos = [];
+end
+if numel(FigOutpos)~=2
+ FigOutpos = [];
+end
+
+if nargin<15
+ FigureName = '';
+end
+
+if isempty(FigureName)
+ FigureName ='none';
+end
+
+if isempty(EEG.setname) || strcmp(EEG.setname,'')
+ EEG.setname = 'still_not_saved!';
+end
+if isempty(EEG.setname)
+ fname = 'none';
+else
+ [pathstr, fname, ext] = fileparts(EEG.setname);
+end
+
+% FigbgColor = [1 1 1];
+extfig ='';
+[pathstrfig, FigureName, extfig] = fileparts(FigureName) ;
+
+if isempty(FigureName)
+ fig_gui= figure('Name',['<< ' fname ' >> '],...
+ 'NumberTitle','on','color',[1 1 1]);
+ % fig_gui_wave = subplot(Numrows+1,1,[2:Numrows+1]);
+ hbig= axes('Parent',fig_gui,'Box','on','FontWeight','normal', 'XTick', [], 'YTick', []);
+ hold on
+end
+
+if ~isempty(FigureName)
+ fig_gui= figure('Name',['<< ' FigureName ' >> '],...
+ 'NumberTitle','on','color',[1 1 1]);
+ hbig= axes('Parent',fig_gui,'Color','none','Box','on','FontWeight','normal', 'XTick', [], 'YTick', []);
+ hold on;
+end
+% drawnow;
+try
+ Pos = hbig.Position;
+ hbig.Position = [Pos(1)*0.5,Pos(2)*0.95,Pos(3)*1.15,Pos(4)*0.95];
+ outerpos = fig_gui.OuterPosition;
+ higpos = hbig.Position;
+ set(fig_gui,'outerposition',[1,1,(1.1/higpos(3))*FigOutpos(1) (1.1/higpos(4))*FigOutpos(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
+
+
+%%determine the time range that will be dispalyed
+lowlim = round(Startimes*multiplier+1);
+highlim = round(min((Startimes+Winlength)*multiplier+1,Allsamples));
+
+
+%%--------------------prepare event array if any --------------------------
+Events = EEG.event;
+if ~isempty(Events)
+ if ~isfield(Events, 'type') || ~isfield(Events, 'latency'), Events = []; end
+end
+if ~isempty(Events)
+ if ischar(Events(1).type)
+ [Eventtypes tmpind indexcolor] = unique_bc({Events.type}); % indexcolor countinas the event type
+ else [Eventtypes tmpind indexcolor] = unique_bc([ Events.type ]);
+ end
+ Eventcolors = { 'r', [0 0.8 0], 'm', 'c', 'k', 'b', [0 0.8 0] };
+ Eventstyle = { '-' '-' '-' '-' '-' '-' '-' '--' '--' '--' '--' '--' '--' '--'};
+ Eventwidths = [ 2.5 1 ];
+ Eventtypecolors = Eventcolors(mod([1:length(Eventtypes)]-1 ,length(Eventcolors))+1);
+ Eventcolors = Eventcolors(mod(indexcolor-1 ,length(Eventcolors))+1);
+ Eventtypestyle = Eventstyle (mod([1:length(Eventtypes)]-1 ,length(Eventstyle))+1);
+ Eventstyle = Eventstyle (mod(indexcolor-1 ,length(Eventstyle))+1);
+
+ % for width, only boundary events have width 2 (for the line)
+ % -----------------------------------------------------------
+ indexwidth = ones(1,length(Eventtypes))*2;
+ if iscell(Eventtypes)
+ for index = 1:length(Eventtypes)
+ if strcmpi(Eventtypes{index}, 'boundary'), indexwidth(index) = 1; end
+ end
+ else
+ % if option_boundary99
+ % indexwidth = [ Eventtypes == -99 ];
+ % end
+ end
+ Eventtypewidths = Eventwidths (mod(indexwidth([1:length(Eventtypes)])-1 ,length(Eventwidths))+1);
+ Eventwidths = Eventwidths (mod(indexwidth(indexcolor)-1 ,length(Eventwidths))+1);
+
+ % latency and duration of events
+ % ------------------------------
+ Eventlatencies = [ Events.latency ]+1;
+ if isfield(Events, 'duration')
+ durations = { Events.duration };
+ durations(cellfun(@isempty, durations)) = { NaN };
+ Eventlatencyend = Eventlatencies + [durations{:}]+1;
+ else Eventlatencyend = [];
+ end
+ % EventOnset = 1;
+end
+
+if isempty(Events)
+ EventOnset = 0;
+end
+
+chanNum = numel(ChanArray);
+
+%%-------------------------------IC and original data----------------------
+dataica = []; chaNum = 0;
+if ~isempty(ICArray)
+ ICdispFlag=1;
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray)%%pop_eegplot from eeglab
+ tmpdata = eeg_getdatact(EEG, 'component', [1:size(EEG.icaweights,1)]);
+ try
+ dataica = tmpdata(ICArray,:);
+ catch
+ dataica = tmpdata(:,:);
+ ICArray = [1:size(tmpdata,1)];
+ end
+ end
+else
+ ICdispFlag=0;
+end
+
+if ~isempty(ChanArray)
+ EEGdispFlag=1;
+ dataeeg = EEG.data(ChanArray,:);
+ chaNum = numel(ChanArray);
+else
+ dataeeg =[];
+ EEGdispFlag=0;
+ chaNum = 0;
+end
+
+%%---------------------------Normalize-------------------------------------
+if NormFlag==1
+ %%Norm for origanal
+ % data2 = [];
+ if ~isempty(dataeeg)
+ datastd = std(dataeeg(:,1:min(1000,Allsamples)),[],2);%
+ for i = 1:size(dataeeg,1)
+ dataeeg(i,:,:) = dataeeg(i,:,:)/datastd(i);
+ % if ~isempty(data2)
+ % data2(i,:,:) = data2(i,:,:)*datastd(i);
+ % end
+ end
+ end
+
+ %%norm for IC data
+ if ~isempty(dataica)
+ dataicstd = std(dataica(:,1:min(1000,Allsamples)),[],2);
+ for i = 1:size(dataica,1)
+ dataica(i,:,:) = dataica(i,:,:)/dataicstd(i);
+ % if ~isempty(data2)
+ % data2(i,:,:) = data2(i,:,:)*dataicstd(i);
+ % end
+ end
+ end
+end
+
+% Removing DC for IC data?
+% -------------------------
+meandataica =[];ICNum = 0;
+if ICdispFlag==1
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray) && ~isempty(dataica)%%pop_eegplot from eeglab
+ switch Submean % subtract the mean ?
+ case 1
+ meandataica = mean(dataica(:,lowlim:highlim)');
+ if any(isnan(meandataica))
+ meandataica = nan_mean(dataica(:,lowlim:highlim)');
+ end
+ otherwise, meandataica = zeros(1,numel(ICArray));
+ end
+ end
+ ICNum = numel(ICArray);
+else
+ ICNum = 0;
+end
+
+% Removing DC for original data?
+% -------------------------
+meandata = [];
+if EEGdispFlag==1 && ~isempty(dataeeg)
+ switch Submean % subtract the mean ?
+ case 1
+ meandata = mean(dataeeg(:,lowlim:highlim)');
+ if any(isnan(meandata))
+ meandata = nan_mean(dataeeg(:,lowlim:highlim)');
+ end
+ otherwise, meandata = zeros(1,numel(ChanArray));
+ end
+end
+
+PlotNum = chaNum+ICNum;
+if chaNum==0 && ICNum==0
+ Ampscold = 0*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = 0*[1:PlotNum]';
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = 0;
+ ylims = [0 (PlotNum+1)*AmpScale];
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+elseif ICNum==0 && chaNum~=0
+ Ampscold = AmpScale*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = ((Ampscold(end)+AmpScale)/2)*ones(1,PlotNum)';
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = AmpScale;
+ ylims = [AmpScale*(100-bufftobo)/100 PlotNum*AmpScale+AmpScale*bufftobo/100];
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+elseif ICNum~=0 && chaNum==0
+ Ampscold = AmpIC*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = ((Ampscold(end)+AmpIC)/2)*ones(1,PlotNum)';
+ else
+ Ampsc = Ampscold;
+ end
+ ylims = [AmpIC*(100-bufftobo)/100 PlotNum*AmpIC+AmpIC*bufftobo/100];
+ AmpScaleold = AmpIC;
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+ AmpICNew = AmpIC;
+elseif ICNum~=0 && chaNum~=0
+ AmpICNew = (AmpScale*chaNum+AmpScale/2)/ICNum;
+ Ampscold1 = AmpICNew*[1:ICNum]';
+ Ampscold2 = Ampscold1(end)+AmpScale/2+AmpScale*[1:chaNum]';
+ Ampscold = [Ampscold1;Ampscold2];
+ if StackFlag==1
+ Ampsc = [(Ampscold1(end)/2)*ones(ICNum,1);((Ampscold2(end)+AmpScale+Ampscold2(1)+AmpIC)/2)*ones(chaNum,1)];
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = AmpScale;
+ ylims = [AmpICNew*(100-bufftobo)/100 Ampscold(end)+AmpScale*bufftobo/100];
+ data = [dataeeg;(AmpICNew/AmpIC)*dataica];
+ meandata = [meandata,(AmpICNew/AmpIC)*meandataica];
+end
+
+
+Colorgbwave = [];
+%%set the wave color for each channel
+if ~isempty(data)
+ ColorNamergb = roundn([255 0 7;186 85 255;255 192 0;0 238 237;0 78 255;0 197 0]/255,-3);
+ Colorgb_chan = [];
+ if ~isempty(ChanArray)
+ chanNum = numel(ChanArray);
+ if chanNum<=6
+ Colorgb_chan = ColorNamergb(1:chanNum,:);
+ else
+ jj = floor(chanNum/6);
+ Colorgb_chan = [];
+ for ii = 1:jj
+ Colorgb_chan = [Colorgb_chan; ColorNamergb];
+ end
+ if jj*6~=chanNum
+ Colorgb_chan = [Colorgb_chan; ColorNamergb(1:chanNum-jj*6,:)];
+ end
+ end
+ end
+
+ %%colors for ICs
+ % Coloricrgb = roundn([211,211,211;169,169,16;128,128,128]/255,-3);three levels for gray
+ Coloricrgb = roundn([180 0 0;127 68 127;228 88 44;15 175 175;0 0 0;9 158 74]/255,-3);
+ Colorgb_IC = [];
+ if ~isempty(ICArray)
+ ICNum = numel(ICArray);
+ if ICNum<7
+ Colorgb_IC = Coloricrgb(1:ICNum,:);
+ else
+ jj = floor(ICNum/6);
+ for ii = 1:jj
+ Colorgb_IC = [Colorgb_IC; Coloricrgb];
+ end
+
+ if jj*6~=ICNum
+ Colorgb_IC = [Colorgb_IC; Coloricrgb(1:ICNum-jj*6,:)];
+ end
+
+ end
+ end
+ Colorgbwave = [Colorgb_chan;Colorgb_IC];
+end
+
+
+PlotNum =0;
+if ICdispFlag==1 && EEGdispFlag==1
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray)
+ PlotNum = chanNum +numel(ICArray);
+ else
+ PlotNum = chanNum;
+ end
+elseif ICdispFlag==0 && EEGdispFlag==1
+ PlotNum = chanNum;
+elseif ICdispFlag==1 && EEGdispFlag==0
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray)
+ PlotNum = numel(ICArray);
+ end
+end
+%%
+EventOnsetdur =1;
+Trialstag = size(EEG.data,2);
+GapSize = ceil(numel([lowlim:highlim])/40);
+if GapSize<=2
+ GapSize=5;
+end
+% -------------------------------------------------------------------------
+% -------------------------draw events if any------------------------------
+% -------------------------------------------------------------------------
+
+FonsizeDefault = f_get_default_fontsize();
+if isempty(FonsizeDefault) || numel(FonsizeDefault)~=1|| any(FonsizeDefault(:)<=0)
+ FonsizeDefault=10;
+end
+
+if EventOnset==1 && ~isempty(data)
+ MAXEVENTSTRING = 75;
+ if MAXEVENTSTRING<0
+ MAXEVENTSTRING = 0;
+ elseif MAXEVENTSTRING>75
+ MAXEVENTSTRING=75;
+ end
+ % AXES_POSITION = [0.0964286 0.15 0.842 0.75-(MAXEVENTSTRING-5)/100];
+ %
+
+ % find event to plot
+ % ------------------
+ event2plot = find ( Eventlatencies >=lowlim & Eventlatencies <= highlim );
+ if ~isempty(Eventlatencyend)
+ event2plot2 = find ( Eventlatencyend >= lowlim & Eventlatencyend <= highlim );
+ event2plot3 = find ( Eventlatencies < lowlim & Eventlatencyend > highlim );
+ event2plot = setdiff(union(event2plot, event2plot2), event2plot3);
+ end
+ for index = 1:length(event2plot)
+ %Just repeat for the first one
+ if index == 1
+ EVENTFONT = [' \fontsize{',num2str(FonsizeDefault),'} '];
+ end
+
+ % draw latency line
+ % -----------------
+ if ndims(EEG.data)==2
+ tmplat = Eventlatencies(event2plot(index))-lowlim-1;
+ else
+ % -----------------
+ tmptaglat = [lowlim:highlim];
+ tmpind = find(mod(tmptaglat-1,Trialstag) == 0);
+ tmpind = setdiff(tmpind,[1,numel(tmptaglat)]);
+ alltaglat = setdiff(tmptaglat(tmpind),[1,tmptaglat(end)]);
+ %%add gap between epochs if any
+ if ~isempty(tmpind) && ~isempty(alltaglat) %%two or multiple epochs were displayed
+ if length(alltaglat)==1
+ if Eventlatencies(event2plot(index)) >= alltaglat
+ Singlat = Eventlatencies(event2plot(index))+GapSize;
+ else
+ Singlat = Eventlatencies(event2plot(index));
+ end
+ else
+ if Eventlatencies(event2plot(index)) < alltaglat(1)%%check the first epoch
+ Singlat = Eventlatencies(event2plot(index));
+ else%%the other epochs
+ for ii = 2:length(alltaglat)
+ if Eventlatencies(event2plot(index)) >= alltaglat(ii-1) && Eventlatencies(event2plot(index)) < alltaglat(ii)
+ Singlat = Eventlatencies(event2plot(index))+GapSize*(ii-1);
+ break;
+ elseif Eventlatencies(event2plot(index)) >= alltaglat(end) %%check the last epoch
+ Singlat = Eventlatencies(event2plot(index))+GapSize*length(alltaglat);
+ break;
+ end
+ end
+ end
+ end
+ tmplat = Singlat-lowlim;%%adjust the latency if any
+ else%%within one epoch
+ tmplat = Eventlatencies(event2plot(index))-lowlim;%-1;
+ end
+
+ end
+ tmph = plot(hbig, [ tmplat tmplat ], ylims, 'color', Eventcolors{ event2plot(index) }, ...
+ 'linestyle', Eventstyle { event2plot(index) }, ...
+ 'linewidth', Eventwidths( event2plot(index) ) );
+
+ % schtefan: add Event types text above event latency line
+ % -------------------------------------------------------
+ evntxt = strrep(num2str(Events(event2plot(index)).type),'_','-');
+ if length(evntxt)>MAXEVENTSTRING, evntxt = [ evntxt(1:MAXEVENTSTRING-1) '...' ]; end % truncate
+ try,
+ if tmplat>=0
+ tmph2 = text(hbig, [tmplat], ylims(2)-0.005, [EVENTFONT evntxt], ...
+ 'color', Eventcolors{ event2plot(index) }, ...
+ 'horizontalalignment', 'left',...
+ 'rotation',90,'FontSize',FonsizeDefault);
+ end
+ catch, end
+
+ % draw duration is not 0
+ % ----------------------
+ % if EventOnsetdur && ~isempty(Eventlatencyend) ...
+ % && Eventwidths( event2plot(index) ) ~= 2.5 % do not plot length of boundary events
+ % tmplatend = Eventlatencyend(event2plot(index))-lowlim-1;
+ % if tmplatend ~= 0
+ % tmplim = ylims;
+ % tmpcol = Eventcolors{ event2plot(index) };
+ % h = patch(hbig, [ tmplat tmplatend tmplatend tmplat ], ...
+ % [ tmplim(1) tmplim(1) tmplim(2) tmplim(2) ], ...
+ % tmpcol ); % this argument is color
+ % set(h, 'EdgeColor', 'none')
+ % end
+ % end
+ end
+else % JavierLC
+ MAXEVENTSTRING = 10; % default
+ % AXES_POSITION = [0.0964286 0.15 0.842 0.75-(MAXEVENTSTRING-5)/100];
+end
+
+
+if StackFlag==1
+ AmpScale=0;
+end
+DEFAULT_GRID_SPACING =Winlength/5;
+
+% -------------------------------------------------------------------------
+% -----------------draw EEG wave if any------------------------------------
+% -------------------------------------------------------------------------
+leftintv = [];
+%%Plot continuous EEG
+tmpcolor = [ 0 0 0.4 ];
+if EEG.trials==1
+ if ~isempty(data) && PlotNum~=0
+
+ for ii = size(data,1):-1:1
+ try
+ plot(hbig, (data(ii,lowlim:highlim)+ Ampsc(size(data,1)-ii+1)-meandata(ii))' , ...
+ 'color', Colorgbwave(ii,:), 'clipping','on','LineWidth',0.5);%%
+ catch
+ plot(hbig, (data(ii,lowlim:highlim)+ Ampsc(size(data,1)-ii+1)-meandata(ii))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',0.5);%%
+ end
+ end
+ set(hbig,'TickDir', 'in','LineWidth',1);
+ %%xtick
+ AmpScale = OldAmpScale;
+ set(hbig, 'Xlim',[1 Winlength*multiplier+1],...
+ 'XTick',[1:multiplier*DEFAULT_GRID_SPACING:Winlength*multiplier+1]);
+ set(hbig, 'XTickLabel', num2str((Startimes:DEFAULT_GRID_SPACING:Startimes+Winlength)'),'FontSize',FonsizeDefault);
+ %%
+ %%-----------------plot scale------------------
+ leftintv = Winlength*multiplier+1;
+ else
+ set(hbig, 'XTick', [], 'YTick', [],'Box','off', 'Color','none','xcolor','none','ycolor','none');
+ end
+end
+
+%%------------------------------plot single-trial EEG----------------------
+%%Thanks for the eeglab developers so that we can borrow their codes
+isfreq = 0;
+Limits = [EEG.times(1),EEG.times(end)];
+Srate = EEG.srate;
+Freqlimits = [];
+if EEG.trials>1
+ if ~isempty(data) && PlotNum~=0
+
+ % plot trial limits
+ % -----------------
+ tmptag = [lowlim:highlim];
+ tmpind = find(mod(tmptag-1,Trialstag) == 0);
+ % for index = tmpind
+ % plot(ax0, [tmptag(index)-lowlim tmptag(index)-lowlim], [0 1], 'b--');
+ % end
+ alltag = tmptag(tmpind);
+ if isempty(tmpind)
+ epochNum = 0;
+ else
+ epochNum = numel(setdiff(tmpind,[0 1 numel(tmptag)]));
+ end
+ % compute epoch number
+ % --------------
+ alltag1 = alltag;
+ if ~isempty(tmpind)
+ tagnum = (alltag1-1)/Trialstag+1;
+ for ii = 1:numel(tmpind)
+ alltag1(ii) = alltag1(ii)+(ii-1)*GapSize;
+ end
+ % set(hbig1,'XTickLabel', tagnum,'YTickLabel', [],...
+ % 'Xlim',[1 (Winlength*multiplier+epochNum*GapSize)],...
+ % 'XTick',alltag-lowlim+Trialstag/2, 'YTick',[],'xaxislocation', 'top');
+ for ii = 1:numel(tagnum)
+ text(hbig, [alltag1(ii)-lowlim+Trialstag/2],ylims(2)+1.1, [32,num2str(tagnum(ii))], ...
+ 'color', 'k','FontSize',FonsizeDefault, ...
+ 'horizontalalignment', 'left','rotation',90); %%
+ set(hbig,'Xlim',[1 (Winlength*multiplier+epochNum*GapSize)]);
+ end
+ end
+
+ %%add the gap between epochs if any
+ Epochintv = [];
+
+ if ~isempty(tmpind)
+ if (numel(tmpind)==1 && tmpind(end) == numel(tmptag)) || (numel(tmpind)==1 && tmpind(1) == 1)
+ dataplot = data(:,lowlim:highlim);
+ Epochintv(1,1) =1;
+ Epochintv(1,2) =numel(lowlim:highlim);
+ else
+ tmpind = unique(setdiff([0,tmpind, numel(tmptag)],1));
+ dataplotold = data(:,lowlim:highlim);
+ dataplot_new = [];
+ for ii = 2:numel(tmpind)
+ GapLeft = tmpind(ii-1)+1;
+ GapRight = tmpind(ii);
+ if GapLeft<1
+ GapLeft =1;
+ end
+ if GapRight > numel(tmptag)
+ GapRight = numel(tmptag);
+ end
+ dataplot_new = [dataplot_new,dataplotold(:,GapLeft:GapRight),nan(size(dataplotold,1),GapSize)];
+ Epochintv(ii-1,1) = GapLeft+(ii-2)*GapSize;
+ Epochintv(ii-1,2) = GapRight+(ii-2)*GapSize;
+ end
+ if ~isempty(dataplot_new)
+ dataplot = dataplot_new;
+ else
+ dataplot = dataplotold;
+ end
+ end
+ end
+
+ %%-----------plot background color for trias with artifact---------
+ %%highlight waves with labels
+ Value_adjust = floor(Startimes+1);
+ if Value_adjust<1
+ Value_adjust=1;
+ end
+ tagnum = unique([Value_adjust,tagnum]);
+
+ try trialsMakrs = EEG.reject.rejmanual(tagnum);catch trialsMakrs = zeros(1,numel(tagnum)) ; end
+ try trialsMakrschan = EEG.reject.rejmanualE(:,tagnum);catch trialsMakrschan = zeros(EEG.nbchan,numel(tagnum)) ; end
+ tmpcolsbgc = [1 1 0.783];
+ if ~isempty(Epochintv) %%&& chaNum~=0
+ for jj = 1:size(Epochintv,1)
+ [xpos,~]=find(trialsMakrschan(:,jj)==1);
+ if jj<= numel(trialsMakrs) && ~isempty(xpos)
+ if trialsMakrs(jj)==1
+ patch(hbig,[Epochintv(jj,1),Epochintv(jj,2),Epochintv(jj,2),Epochintv(jj,1)],...
+ [ylims(1),ylims(1),ylims(end),ylims(end)],tmpcolsbgc,'EdgeColor','none','FaceAlpha',.5);
+ %%highlight the wave if the channels that were
+ %%marked as artifacts
+ if chaNum~=0
+ ChanArray = reshape(ChanArray,1,numel(ChanArray));
+ [~,ypos1]=find(ChanArray==xpos);
+ if ~isempty(ypos1)
+ for kk = 1:numel(ypos1)
+ dataChan = nan(1,size(dataplot,2));
+ dataChan (Epochintv(jj,1):Epochintv(jj,2)) = dataplot(ypos1(kk),Epochintv(jj,1):Epochintv(jj,2));
+ dataChan1= nan(1,size(dataplot,2));
+ dataChan1 (1,Epochintv(jj,1):Epochintv(jj,1)) = dataplot(ypos1(kk),Epochintv(jj,1):Epochintv(jj,1));
+ try
+ plot(hbig, (dataChan+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))', ...
+ 'color', Colorgbwave(ypos1(kk),:), 'clipping','on','LineWidth',1.5);%%
+ plot(hbig, (dataChan1+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))' , ...
+ 'color', Colorgbwave(ypos1(kk),:), 'clipping','on','LineWidth',1.5,'Marker' ,'s','MarkerSize',8,...
+ 'MarkerEdgeColor',Colorgbwave(ypos1(kk),:),'MarkerFaceColor',Colorgbwave(ypos1(kk),:));%%
+ catch
+ plot(hbig, (dataChan+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',1.5);%%
+ plot(hbig, (dataChan1+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',1.5,'Marker' ,'s','MarkerSize',8,...
+ 'MarkerEdgeColor',Colorgbwave(ypos1(kk),:),'MarkerFaceColor',Colorgbwave(ypos1(kk),:));%%
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ for ii = size(dataplot,1):-1:1
+ try
+ plot(hbig, (dataplot(ii,:)+ Ampsc(size(dataplot,1)-ii+1)-meandata(ii))', ...
+ 'color', Colorgbwave(ii,:), 'clipping','on','LineWidth',0.5);%%
+ catch
+ plot(hbig, (dataplot(ii,:)+ Ampsc(size(dataplot,1)-ii+1)-meandata(ii))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',0.5);%%
+ end
+ end
+
+ %------------------------Xticks------------------------------------
+ tagpos = [];
+ tagtext = [];
+ if ~isempty(alltag)
+ alltag = [alltag(1)-Trialstag alltag alltag(end)+Trialstag]; % add border trial limits
+ else
+ alltag = [ floor(lowlim/Trialstag)*Trialstag ceil(highlim/Trialstag)*Trialstag ]+1;
+ end
+
+ nbdiv = 20/Winlength; % approximative number of divisions
+ divpossible = [ 100000./[1 2 4 5] 10000./[1 2 4 5] 1000./[1 2 4 5] 100./[1 2 4 5 10 20]]; % possible increments
+ [tmp indexdiv] = min(abs(nbdiv*divpossible-(Limits(2)-Limits(1)))); % closest possible increment
+ incrementpoint = divpossible(indexdiv)/1000*Srate;
+
+ % tag zero below is an offset used to be sure that 0 is included
+ % in the absicia of the data epochs
+ if Limits(2) < 0, tagzerooffset = (Limits(2)-Limits(1))/1000*Srate+1;
+ else tagzerooffset = -Limits(1)/1000*Srate;
+ end
+ if tagzerooffset < 0, tagzerooffset = 0; end
+
+ for i=1:length(alltag)-1
+ if ~isempty(tagpos) && tagpos(end)-alltag(i)<2*incrementpoint/3
+ tagpos = tagpos(1:end-1);
+ end
+ if ~isempty(Freqlimits)
+ tagpos = [ tagpos linspace(alltag(i),alltag(i+1)-1, nbdiv) ];
+ else
+ if tagzerooffset ~= 0
+ tmptagpos = [alltag(i)+tagzerooffset:-incrementpoint:alltag(i)];
+ else
+ tmptagpos = [];
+ end
+ tagpos = [ tagpos [tmptagpos(end:-1:2) alltag(i)+tagzerooffset:incrementpoint:(alltag(i+1)-1)]];
+ end
+ end
+
+ % find corresponding epochs
+ % -------------------------
+ if ~isfreq
+ tmplimit = Limits;
+ tpmorder = 1E-3;
+ else
+ tmplimit =Freqlimits;
+ tpmorder = 1;
+ end
+ tagtext = eeg_point2lat(tagpos, floor((tagpos)/Trialstag)+1, Srate, tmplimit,tpmorder);
+
+ %%adjust xticks
+ EpochFlag = floor((tagpos)/Trialstag)+1;%%
+
+ EpochFlag = reshape(EpochFlag,1,numel(EpochFlag));
+ xtickstr = tagpos-lowlim+1;
+ [xpos,ypos] = find(xtickstr>0);
+ if ~isempty(ypos)
+ EpochFlag =EpochFlag(ypos);
+ xtickstr = xtickstr(ypos);
+ tagtext = tagtext(ypos);
+ end
+
+ EpochFlagunique =unique(setdiff(EpochFlag,0));
+ if numel(EpochFlagunique)~=1
+ for ii = 2:numel(EpochFlagunique)
+ [xpos,ypos]= find(EpochFlag==EpochFlagunique(ii));
+ if ~isempty(ypos)
+ xtickstr(ypos) = xtickstr(ypos)+(EpochFlagunique(ii)-EpochFlagunique(1))*GapSize;%*(1000/Srate);
+ end
+ end
+ end
+ set(hbig,'XTickLabel', tagtext,...
+ 'Xlim',[1 (Winlength*multiplier+epochNum*GapSize)],...
+ 'XTick',xtickstr,...
+ 'FontWeight','normal',...
+ 'xaxislocation', 'bottom','FontSize',FonsizeDefault);
+ XTickLabel = cellstr(hbig.XTickLabel);
+ for Numofxtick = 1:length(XTickLabel)
+ if strcmpi(XTickLabel{Numofxtick,:},'-0')
+ XTickLabel{Numofxtick} = '0';
+ end
+ end
+ set(hbig,'XTickLabel',XTickLabel);
+ %%
+ %%-----------------plot scale------------------
+ leftintv = (Winlength*multiplier+epochNum*GapSize);
+ else
+ set(hbig, 'XTick', [], 'YTick', [],'Box','off', 'Color','none','xcolor','none','ycolor','none');
+ end
+end
+
+%%
+%%-----------------plot y scale------------------
+if ~isempty(data) && PlotNum~=0 && ~isempty(leftintv)
+ ytick_bottom = hbig.TickLength(1)*diff(hbig.XLim);
+ leftintv = leftintv+ytick_bottom*2.5;
+ rightintv = leftintv;
+ if ICdispFlag~=0
+ line(hbig,[leftintv,rightintv],[ylims(1) AmpICNew+ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ line(hbig,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(1) ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ line(hbig,[leftintv-ytick_bottom,rightintv+ytick_bottom],[AmpICNew+ylims(1) AmpICNew+ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ text(hbig,leftintv,((ylims(2)-ylims(1))/43+AmpICNew+ylims(1)), [num2str(AmpIC),32,'\muV'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ text(hbig,leftintv,((ylims(2)-ylims(1))/20+AmpICNew+ylims(1)), ['ICs'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ end
+ if EEGdispFlag~=0
+ line(hbig,[leftintv,rightintv],[ylims(end)-OldAmpScale ylims(end)],'color','k','LineWidth',1, 'clipping','off');
+ line(hbig,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(end)-OldAmpScale ylims(end)-OldAmpScale],'color','k','LineWidth',1, 'clipping','off');
+ line(hbig,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(end) ylims(end)],'color','k','LineWidth',1, 'clipping','off');
+ text(hbig,leftintv,(ylims(2)-ylims(1))/43+ylims(end), [num2str(OldAmpScale),32,'\muV'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ text(hbig,leftintv,(ylims(2)-ylims(1))/20+ylims(end), ['Chans'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ end
+
+
+ %%ytick ticklabels
+ if chaNum==0
+ ChanArray = [];
+ end
+ set(hbig, 'ylim',[ylims(1) ylims(end)],'YTick',[ylims(1) Ampscold']);
+ [YLabels,chaName,ICName] = f_eeg_read_chan_IC_names(EEG.chanlocs,ChanArray,ICArray,ChanLabel);
+ YLabels = flipud(char(YLabels,''));
+ set(hbig,'YTickLabel',cellstr(YLabels),...
+ 'TickLength',[.005 .005],...
+ 'Color','none',...
+ 'XColor','k',...
+ 'YColor','k',...
+ 'FontWeight','normal',...
+ 'TickDir', 'in',...
+ 'LineWidth',0.5,'FontSize',FonsizeDefault);%%,'HorizontalAlignment','center'
+ count=0;
+ for ii = length(hbig.YTickLabel):-1:2
+ count = count+1;
+ hbig.YTickLabel{ii} = ['\color[rgb]{',num2str(Colorgbwave(count,:)),'}', strrep(hbig.YTickLabel{ii},'_','\_')];
+ end
+end
+
+set(gcf,'color',[1 1 1]);
+prePaperType = get(fig_gui,'PaperType');
+prePaperUnits = get(fig_gui,'PaperUnits');
+preUnits = get(fig_gui,'Units');
+prePaperPosition = get(fig_gui,'PaperPosition');
+prePaperSize = get(fig_gui,'PaperSize');
+% Make changing paper type possible
+set(fig_gui,'PaperType','');
+
+% Set units to all be the same
+set(fig_gui,'PaperUnits','inches');
+set(fig_gui,'Units','inches');
+% Set the page size and position to match the figure's dimensions
+paperPosition = get(fig_gui,'PaperPosition');
+position = get(fig_gui,'Position');
+set(fig_gui,'PaperPosition',[0,0,position(3:4)]);
+set(fig_gui,'PaperSize',position(3:4));
+
+%%save figure with different formats
+if ~isempty(extfig)
+ [C_style,IA_style] = ismember_bc2(extfig,{'.pdf','.svg','.jpg','.png','.tif','.bmp','.eps'});
+ figFileName = fullfile(pathstrfig,FigureName);
+ try
+ switch IA_style
+ case 1
+ print(fig_gui,'-dpdf',figFileName);
+ case 2
+ print(fig_gui,'-dsvg',figFileName);
+ case 3
+ print(fig_gui,'-djpeg',figFileName);
+ case 4
+ print(fig_gui,'-dpng',figFileName);
+
+ case 5
+ print(fig_gui,'-dtiff',figFileName);
+ case 6
+ print(fig_gui,'-dbmp',figFileName);
+ case 7
+ print(fig_gui,'-depsc',figFileName);
+ otherwise
+ print(fig_gui,'-dpdf',figFileName);
+ end
+ catch
+ print(fig_gui,'-dpdf',figFileName);
+ end
+end
+return;
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_preparms_eegwaviewer.m b/studio_functions/Functions/EStudio/EEG Tab/f_preparms_eegwaviewer.m
new file mode 100755
index 00000000..d1ede027
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_preparms_eegwaviewer.m
@@ -0,0 +1,269 @@
+%%this function is used to call back the parameters for plotting EEG wave
+
+% *** This function is part of EStudio Toolbox ***
+% Author: Guanghui Zhang & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% 2023 && 2024
+
+function OutputViewerpareeg = f_preparms_eegwaviewer(EEG,matlabfig,History,figureName)
+
+OutputViewerpareeg = '';
+if nargin<1
+ help f_preparms_eegwaviewer();
+ return
+end
+if isempty(EEG)
+ disp('f_preparms_eegwaviewer(): EEG is empty');
+ return;
+end
+
+if nargin<3
+ History = 'gui';
+end
+
+if nargin <2
+ matlabfig=1;
+end
+if nargin <4
+ figureName = '';
+end
+
+%%channel array and IC array
+%channels
+ChanArray = estudioworkingmemory('EEG_ChanArray');
+nbchan = EEG.nbchan;
+if isempty(ChanArray) || any(ChanArray(:)>nbchan) || any(ChanArray(:)<=0)
+ ChanArray = 1:nbchan;
+ estudioworkingmemory('EEG_ChanArray',ChanArray);
+end
+
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+ChanArray = reshape(ChanArray,1,[]);
+try
+ chanOrder = EEG_plotset{10};
+ if chanOrder==2
+ if isfield(EEG,'chanlocs') && ~isempty(EEG.chanlocs)
+ chanindexnew = f_estudio_chan_frontback_left_right(EEG.chanlocs(ChanArray));
+ if ~isempty(chanindexnew)
+ ChanArray = ChanArray(chanindexnew);
+ end
+ end
+ elseif chanOrder==3
+ [eloc, labels, theta, radius, indices] = readlocs(EEG.chanlocs);
+ chanorders = EEG_plotset{11};
+ chanorderindex = chanorders{1};
+ chanorderindex1 = unique(chanorderindex,'stable');
+ chanorderlabels = chanorders{2};
+ [C,IA]= ismember_bc2(chanorderlabels,labels);
+ Chanlanelsinst = labels(ChanArray);
+ if ~any(IA==0) && numel(chanorderindex1) == length(labels)
+ [C,IA1]= ismember_bc2(Chanlanelsinst,chanorderlabels);
+ [C,IA2]= ismember_bc2(Chanlanelsinst,labels);
+ ChanArray = IA1(IA2);
+ end
+ end
+catch
+end
+
+
+%%ICs
+ICArray = estudioworkingmemory('EEG_ICArray');
+if isempty(EEG.icachansind)
+ ICArray = [];
+ estudioworkingmemory('EEG_ICArray',[]);
+else
+ nIC = numel(EEG.icachansind);
+ if isempty(ICArray) || any(ICArray(:)>nIC) || any(ICArray(:)<=0)
+ ICArray = [];
+ estudioworkingmemory('EEG_ICArray',ICArray);
+ end
+end
+
+%%Plot setting
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+if isempty(EEG_plotset)
+ EEGdisp = 1;
+ ICdisp = 0;
+ Winlength = 5;%%in second
+ AmpScale = 50;
+ ChanLabel = 1;
+ Submean=0;
+ EventOnset = 1;
+ StackFlag = 0;
+ NormFlag = 0;
+ AmpScale_ic=20;
+ buffer_topo_bottom = 100;
+else
+ %%diaply original data?
+ try
+ EEGdisp = EEG_plotset{1};
+ catch
+ EEGdisp = 1;
+ end
+ if isempty(EEGdisp) || (EEGdisp~=0 && EEGdisp~=1)
+ EEGdisp = 1;
+ end
+
+ %%display ICs?
+ try
+ ICdisp = EEG_plotset{2};
+ catch
+ ICdisp = 0;
+ end
+ if isempty(ICdisp) || (ICdisp~=0 && ICdisp~=1)
+ ICdisp = 0;
+ end
+
+ %%Time range?
+ try
+ Winlength = EEG_plotset{3};
+ catch
+ Winlength = 5;
+ end
+ if isempty(Winlength) || numel(Winlength)~=1 || min(Winlength(:))<=0
+ Winlength=5;
+ end
+
+
+ %%Vertical scale for original data?
+ try
+ AmpScale = EEG_plotset{4};
+ catch
+ AmpScale = 50;
+ end
+ if isempty(AmpScale) || numel(AmpScale)~=1 || AmpScale<=0
+ AmpScale = 50;
+ end
+
+ %%Vertical scale for IC data?
+ try
+ AmpScale_ic = EEG_plotset{5};
+ catch
+ AmpScale_ic = 20;
+ end
+ if isempty(AmpScale_ic) || numel(AmpScale_ic)~=1 || AmpScale_ic<=0
+ AmpScale_ic = 20;
+ end
+
+ %%Channel labels? (1 is name, 0 is number)
+ try
+ ChanLabel = EEG_plotset{5};
+ catch
+ ChanLabel = 1;
+ end
+ if isempty(ChanLabel) || numel(ChanLabel)~=1 || (ChanLabel~=0 && ChanLabel~=1)
+ ChanLabel = 1;
+ end
+
+ %%Remove DC? (1 is "Yes", 0 is "no")
+ try
+ Submean = EEG_plotset{6};
+ catch
+ Submean = 0;
+ end
+ if isempty(Submean) || numel(Submean)~=1 || (Submean~=0 && Submean~=1)
+ Submean = 0;
+ end
+
+ %%Display events?
+ try
+ EventOnset = EEG_plotset{7};
+ catch
+ EventOnset = 1;
+ end
+ if isempty(EventOnset) || numel(EventOnset)~=1 || (EventOnset~=0 && EventOnset~=1)
+ EventOnset = 1;
+ end
+
+
+ %%Stack?
+ try
+ StackFlag = EEG_plotset{8};
+ catch
+ StackFlag = 0;
+ end
+ if isempty(StackFlag) || numel(StackFlag)~=1 || (StackFlag~=0&&StackFlag~=1)
+ StackFlag = 0;
+ end
+
+ %%Norm?
+ try
+ NormFlag = EEG_plotset{9};
+ catch
+ NormFlag = 0;
+ end
+ if isempty(NormFlag) ||numel(NormFlag)~=1 || (NormFlag~=0 && NormFlag~=1)
+ NormFlag = 0;
+ end
+
+ %%buffer at top and bottom
+ try
+ buffer_topo_bottom = EEG_plotset{12};
+ catch
+ buffer_topo_bottom=100;
+ end
+ if isempty(buffer_topo_bottom) || numel(buffer_topo_bottom)~=1 || any(buffer_topo_bottom(:)<=0)
+ buffer_topo_bottom=100;
+ end
+end
+
+
+%%Start time to display
+Startimes = estudioworkingmemory('Startimes');
+[chaNum,sampleNum,trialNum]=size(EEG.data);
+Frames = sampleNum*trialNum;
+if EEG.trials>1 % time in second or in trials
+ multiplier = size(EEG.data,2);
+else
+ multiplier = EEG.srate;
+end
+
+StartimesMax = max(0,ceil((Frames-1)/multiplier)-Winlength);
+if ndims(EEG.data)==3
+ Startimes=Startimes-1;
+end
+if isempty(Startimes) || numel(Startimes)~=1 || Startimes<0 ||Startimes>StartimesMax
+ Startimes=0;
+ estudioworkingmemory('Startimes',Startimes);
+end
+
+figSize = estudioworkingmemory('egfigsize');
+if isempty(figSize)
+ figSize = [];
+end
+if ICdisp==0
+ ICArray = [];
+end
+if isempty(ICArray)
+ ICdisp=0;
+end
+
+
+if matlabfig==1
+ if EEGdisp==0
+ ChanArray = [];
+ end
+ [EEG, eegcom] = pop_ploteegset(EEG,'ChanArray',ChanArray,'ICArray',ICArray,'Winlength',Winlength,'bufftobo',buffer_topo_bottom,...
+ 'Ampchan',AmpScale,'ChanLabel',ChanLabel,'Submean',Submean,'EventOnset',EventOnset,'Ampic',AmpScale_ic,...
+ 'StackFlag',StackFlag,'NormFlag',NormFlag,'Startimes',Startimes,'figureName',figureName,'figSize',figSize,'History',History);
+else
+ OutputViewerpareeg{1} = ChanArray;
+ OutputViewerpareeg{2} = ICArray;
+ OutputViewerpareeg{3} =EEGdisp;
+ OutputViewerpareeg{4} =ICdisp;
+ OutputViewerpareeg{5} =Winlength;
+ OutputViewerpareeg{6} =AmpScale;
+ OutputViewerpareeg{7} =ChanLabel;
+ OutputViewerpareeg{8} =Submean;
+ OutputViewerpareeg{9} = EventOnset;
+ OutputViewerpareeg{10} =StackFlag;
+ OutputViewerpareeg{11} =NormFlag;
+ OutputViewerpareeg{12} =Startimes;
+ OutputViewerpareeg{13} = AmpScale_ic;
+ OutputViewerpareeg{14} = buffer_topo_bottom;
+ OutputViewerpareeg{15} = figSize;
+end
+
+end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/f_redrawEEG_Wave_Viewer.m b/studio_functions/Functions/EStudio/EEG Tab/f_redrawEEG_Wave_Viewer.m
new file mode 100644
index 00000000..82dae362
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/f_redrawEEG_Wave_Viewer.m
@@ -0,0 +1,1984 @@
+%PURPOSE : Plot EEG waves within one axes as EEGLAB
+
+% Author: Guanghui Zhang & Steve J. Luck
+% Center for Mind and Brain
+% University of California, Davis
+% Davis, CA
+% 2023
+
+
+
+function f_redrawEEG_Wave_Viewer(Axesreset)
+
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+addlistener(observe_EEGDAT,'eeg_panel_change_message',@eeg_panel_change_message);
+addlistener(observe_EEGDAT,'count_current_eeg_change',@count_current_eeg_change);
+
+
+if nargin>2
+ help f_redrawEEG_Wave_Viewer;
+ return;
+end
+if nargin<1
+ Axesreset=0;
+end
+
+if isempty(observe_EEGDAT.EEG)
+ Startimes = 0;
+else
+ Startimes= estudioworkingmemory('Startimes');
+ if isempty(Startimes) || min(Startimes)<0
+ Startimes = 0;
+ end
+ EEG_plotset = estudioworkingmemory('EEG_plotset');
+ try
+ Winlength = EEG_plotset{3};
+ catch
+ Winlength = 5;
+ end
+
+ [chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+ Frames = sampleNum*trialNum;
+ if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier = size(observe_EEGDAT.EEG.data,2);
+ else
+ multiplier = observe_EEGDAT.EEG.srate;
+ end
+ if isempty(Winlength)|| Winlength<0 || (Winlength>floor(Frames/observe_EEGDAT.EEG.srate))
+ Winlength = 5;
+ end
+ StartimesMax = max(0,ceil((Frames-1)/multiplier)-Winlength);
+ if observe_EEGDAT.EEG.trials>1
+ StartimesMax =StartimesMax+1;
+ end
+ if Startimes > StartimesMax
+ Startimes = StartimesMax;
+ end
+end
+if ~isempty(observe_EEGDAT.EEG)
+ if observe_EEGDAT.EEG.trials>1 && Startimes ==0%%for epoched EEG, it should be from the first epoch
+ Startimes=1;
+ end
+end
+estudioworkingmemory('Startimes',Startimes);
+
+%%Selected EEGsets from memory file
+EEGset_selected = estudioworkingmemory('EEGArray');
+if ~isempty(observe_EEGDAT.ALLEEG) && ~isempty(observe_EEGDAT.EEG)
+ if isempty(EEGset_selected) || min(EEGset_selected(:)) > length(observe_EEGDAT.ALLEEG) || max(EEGset_selected(:))>length(observe_EEGDAT.ALLEEG)
+ EEGset_selected = length(observe_EEGDAT.ALLEEG) ;
+ estudioworkingmemory('EEGArray',EEGset_selected);
+ observe_EEGDAT.CURRENTSET = EEGset_selected;
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(EEGset_selected);
+ assignin('base','EEG',observe_EEGDAT.EEG);
+ assignin('base','ALLEEG', observe_EEGDAT.ALLEEG);
+ assignin('base','CURRENTSET', observe_EEGDAT.CURRENTSET);
+ end
+ [xpos,ypos] = find(EEGset_selected==observe_EEGDAT.CURRENTSET);
+ if ~isempty(ypos)
+ pagecurrentNum = ypos;
+ pageNum = numel(EEGset_selected);
+ PageStr = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET).setname;
+ else
+ pageNum=1;
+ pagecurrentNum=1;
+ PageStr = observe_EEGDAT.EEG.setname;
+ end
+ Enableflag = 'on';
+else
+ pageNum=1;
+ pagecurrentNum=1;
+ PageStr = 'No EEG was loaded';
+ Enableflag = 'off';
+end
+
+EEG_autoplot = EStudio_gui_erp_totl.EEG_autoplot;
+
+EStudio_gui_erp_totl.eegpageinfo_text.String=['Page',32,num2str(pagecurrentNum),'/',num2str(pageNum),':',PageStr];
+EStudio_gui_erp_totl.eegpageinfo_minus.Callback=@page_minus;
+set(EStudio_gui_erp_totl.eegpageinfo_edit,'String',num2str(pagecurrentNum),'Enable','on');
+if EEG_autoplot ==0
+ EStudio_gui_erp_totl.eegpageinfo_text.String='Plotting is disabled, to enable it, please go to "Plotting Options" at the bottom of the plotting area to active it.';
+ Enableflag = 'off';
+end
+EStudio_gui_erp_totl.eegpageinfo_edit.Callback=@page_edit;
+EStudio_gui_erp_totl.eegpageinfo_plus.Callback=@page_plus;
+if pageNum ==1
+ Enable_minus = 'off';
+ Enable_plus = 'off';
+ Enable_plus_BackgroundColor = [1 1 1];
+ Enable_minus_BackgroundColor = [0 0 0];
+else
+ if pagecurrentNum ==1
+ Enable_minus = 'off';
+ Enable_plus = 'on';
+ Enable_plus_BackgroundColor = [0 1 0];
+ Enable_minus_BackgroundColor = [0 0 0];
+ elseif pagecurrentNum == pageNum
+ Enable_minus = 'on';
+ Enable_plus = 'off';
+ Enable_plus_BackgroundColor = [0 0 0];
+ Enable_minus_BackgroundColor = [0 1 0];
+ else
+ Enable_minus = 'on';
+ Enable_plus = 'on';
+ Enable_plus_BackgroundColor = [0 1 0];
+ Enable_minus_BackgroundColor = [0 1 0];
+ end
+end
+
+if ~isempty(observe_EEGDAT.ALLEEG) && ~isempty(observe_EEGDAT.EEG) && EEG_autoplot==0
+ Enable_minus = 'off';
+ Enable_plus = 'off';
+ EStudio_gui_erp_totl.eegpageinfo_edit.Enable = 'off';
+end
+
+%%----Processing for label ICs or using IClabel
+EEGUpdate = estudioworkingmemory('EEGUpdate');
+if isempty(EEGUpdate) || numel(EEGUpdate)~=1 || (EEGUpdate~=0 && EEGUpdate~=1)
+ EEGUpdate = 0; estudioworkingmemory('EEGUpdate',0);
+end
+if EEGUpdate==1
+ Enableflag = 'off';
+ Enable_minus = 'off';
+ Enable_plus = 'off';
+ EStudio_gui_erp_totl.eegpageinfo_edit.Enable = 'off';
+end
+
+
+EStudio_gui_erp_totl.eegpageinfo_minus.Enable = Enable_minus;
+EStudio_gui_erp_totl.eegpageinfo_plus.Enable = Enable_plus;
+EStudio_gui_erp_totl.eegpageinfo_plus.ForegroundColor = Enable_plus_BackgroundColor;
+EStudio_gui_erp_totl.eegpageinfo_minus.ForegroundColor = Enable_minus_BackgroundColor;
+set(EStudio_gui_erp_totl.eegpageinfo_box, 'Sizes', [-1 70 50 70] );
+set(EStudio_gui_erp_totl.eeg_zoom_in_large,'Callback',@zoomin_large,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_in_fivesmall,'Callback',@zoomin_fivesmall,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_in_small,'Callback',@zoomin_small,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_edit,'String',num2str(Startimes),'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_edit,'Callback',@zoomedit,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_out_small,'Callback',@zoomout_small,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_out_fivelarge,'Callback',@zoomout_fivelarge,'Enable',Enableflag);
+set(EStudio_gui_erp_totl.eeg_zoom_out_large,'Callback',@zoomout_large,'Enable',Enableflag);
+if ~isempty(observe_EEGDAT.ALLEEG) && ~isempty(observe_EEGDAT.EEG)
+ set(EStudio_gui_erp_totl.popmemu_eeg,'Callback',@popmemu_eeg,'Enable','on','String',...
+ {'Plotting Options','Automatic Plotting','Window Size','Show Command','Save Figure as','Create Static/Exportable Plot'});
+else
+ set(EStudio_gui_erp_totl.popmemu_eeg,'Callback',@popmemu_eeg,'Enable','on','String',{'Plotting Options','Automatic Plotting','Window Size'});
+end
+popmemu_eeg = EStudio_gui_erp_totl.popmemu_eeg.String;
+if EEG_autoplot==1
+ popmemu_eeg{2} = 'Automatic Plotting: On';
+else
+ popmemu_eeg{2} = 'Automatic Plotting: Off';
+end
+EStudio_gui_erp_totl.popmemu_eeg.String=popmemu_eeg;
+
+
+set(EStudio_gui_erp_totl.eeg_reset,'Callback',@eeg_paras_reset,'Enable','on');
+set(EStudio_gui_erp_totl.eeg_plot_button_title, 'Sizes', [10 40 40 40 40 40 40 40 -1 150 50 5]);
+
+if ~isempty(observe_EEGDAT.ALLEEG) && ~isempty(observe_EEGDAT.EEG) && EEG_autoplot==1
+ EEG = observe_EEGDAT.EEG;
+ OutputViewereegpar = f_preparms_eegwaviewer(EEG,0);
+ % %%Plot the eeg waves
+ if ~isempty(OutputViewereegpar)
+ EStudio_gui_erp_totl = f_plotviewereegwave(EEG,OutputViewereegpar{1},OutputViewereegpar{2},...
+ OutputViewereegpar{3},OutputViewereegpar{4},OutputViewereegpar{5},...
+ OutputViewereegpar{6},OutputViewereegpar{7},OutputViewereegpar{8},...
+ OutputViewereegpar{9},OutputViewereegpar{10},OutputViewereegpar{11},...
+ OutputViewereegpar{12},OutputViewereegpar{13},OutputViewereegpar{14},EStudio_gui_erp_totl,Axesreset);
+ else
+ return;
+ end
+end
+
+if isempty(observe_EEGDAT.EEG) || EEG_autoplot==0
+ EStudio_gui_erp_totl.myeegviewer = axes('Parent', EStudio_gui_erp_totl.eegViewAxes,'Color','none','Box','on','FontWeight','normal');
+ hold(EStudio_gui_erp_totl.myeegviewer,'on');
+ set(EStudio_gui_erp_totl.myeegviewer, 'XTick', [], 'YTick', [],'Box','off', 'Color','none','xcolor','none','ycolor','none');
+else
+end
+EStudio_gui_erp_totl.eegplotgrid.Heights(1) = 30; % set the first element (pageinfo) to 30px high
+EStudio_gui_erp_totl.eegplotgrid.Heights(3) = 5;
+EStudio_gui_erp_totl.eegplotgrid.Heights(4) = 30; % set the second element (x axis) to 30px high
+EStudio_gui_erp_totl.eegplotgrid.Heights(5) = 30; % set the second element (x axis) to 30px high
+end % redrawDemo
+
+%%-------------------------------------------------------------------------
+%%-----------------------------Subfunctions--------------------------------
+%%-------------------------------------------------------------------------
+
+function popmemu_eeg(Source,~)
+global EStudio_gui_erp_totl;
+Value = Source.Value;
+if Value==2
+ app = feval('EStudio_plot_set_waves',EStudio_gui_erp_totl.EEG_autoplot,1);
+ waitfor(app,'Finishbutton',1);
+ try
+ plotSet = app.output; %NO you don't want to output EEG with edited channel locations, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.01); %wait for app to leave
+ catch
+ return;
+ end
+ if isempty(plotSet)||numel(plotSet)~=1 || (plotSet~=0&&plotSet~=1)
+ plotSet=1;
+ end
+ popmemu_eegString = EStudio_gui_erp_totl.popmemu_eeg.String;
+ if plotSet==1
+ popmemu_eegString{2} = 'Automatic Plotting: On';
+ else
+ popmemu_eegString{2} = 'Automatic Plotting: Off';
+ end
+ EStudio_gui_erp_totl.popmemu_eeg.String=popmemu_eegString;
+ EStudio_gui_erp_totl.EEG_autoplot = plotSet;
+ f_redrawEEG_Wave_Viewer();
+elseif Value==3
+ EStudiowinsize();
+elseif Value==4
+ Show_command();
+elseif Value==5
+ figure_saveas();
+elseif Value==6
+ figure_out();
+end
+Source.Value=1;
+end
+
+
+%%--------------------Setting for EStudio window size----------------------
+function EStudiowinsize(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+try
+ ScreenPos= EStudio_gui_erp_totl.ScreenPos;
+catch
+ ScreenPos = get( 0, 'Screensize' );
+end
+try
+ New_pos = EStudio_gui_erp_totl.Window.Position;
+catch
+ return;
+end
+try
+ New_posin = estudioworkingmemory('EStudioScreenPos');
+catch
+ New_posin = [75,75];
+end
+if isempty(New_posin) ||numel(New_posin)~=2
+ New_posin = [75,75];
+end
+New_posin(2) = abs(New_posin(2));
+
+app = feval('EStudio_pos_gui',New_posin);
+waitfor(app,'Finishbutton',1);
+try
+ New_pos1 = app.output; %NO you don't want to output EEG with edited channel locations, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.01); %wait for app to leave
+catch
+ return;
+end
+try New_pos1(2) = abs(New_pos1(2));catch; end;
+
+if isempty(New_pos1) || numel(New_pos1)~=2
+ estudioworkingmemory('f_EEG_proces_messg',['The defined Window Size for EStudio is invalid and it must be two numbers']);
+ observe_EEGDAT.eeg_panel_message =4;
+ return;
+end
+estudioworkingmemory('EStudioScreenPos',New_pos1);
+try
+ POS4 = (New_pos1(2)-New_posin(2))/100;
+ new_pos =[New_pos(1),New_pos(2)-ScreenPos(4)*POS4,ScreenPos(3)*New_pos1(1)/100,ScreenPos(4)*New_pos1(2)/100];
+ if new_pos(2) < -abs(new_pos(4))%%if
+
+ end
+ set(EStudio_gui_erp_totl.Window, 'Position', new_pos);
+catch
+ estudioworkingmemory('f_EEG_proces_messg',['The defined Window Size for EStudio is invalid and it must be two numbers']);
+ observe_EEGDAT.eeg_panel_message =4;
+ set(EStudio_gui_erp_totl.Window, 'Position', [0 0 0.75*ScreenPos(3) 0.75*ScreenPos(4)]);
+ estudioworkingmemory('EStudioScreenPos',[75 75]);
+end
+f_redrawEEG_Wave_Viewer();
+f_redrawERP();
+EStudio_gui_erp_totl.context_tabs.TabSize = (new_pos(3)-20)/2;
+end
+
+
+%%------------------set to 0----------------------------------------
+function zoomin_large(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ Startimes =1;
+else
+ Startimes = 0;
+end
+EStudio_gui_erp_totl.eeg_zoom_edit.String =num2str(Startimes);
+estudioworkingmemory('Startimes',Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+%%reduce the start time of the displayed EEG
+function zoomin_fivesmall(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier_winleg = observe_EEGDAT.EEG.srate;
+end
+if isempty(Winlength)|| Winlength<0 || Winlength>floor(Frames/multiplier_winleg)
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+Startimesdef = str2num(EStudio_gui_erp_totl.eeg_zoom_edit.String);
+if ~isempty(Startimesdef) && isnumeric(Startimesdef) && numel(Startimesdef)==1 && Startimesdef>=0
+else
+ Startimesdef = 0;
+ EStudio_gui_erp_totl.eeg_zoom_edit.String = '0';
+end
+
+Startimes = Startimesdef-fastif(Winlength>=5, round(5*Winlength), 5*Winlength);
+if Startimes<0
+ if observe_EEGDAT.EEG.trials>1
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+
+estudioworkingmemory('Startimes',Startimes);
+EStudio_gui_erp_totl.eeg_zoom_edit.String =num2str(Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+%%prev time period
+function zoomin_small(~,~)
+
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier_winleg = observe_EEGDAT.EEG.srate;
+end
+if isempty(Winlength)|| Winlength<0 || Winlength>floor(Frames/multiplier_winleg)
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+Startimesdef = str2num(EStudio_gui_erp_totl.eeg_zoom_edit.String);
+if ~isempty(Startimesdef) && isnumeric(Startimesdef) && numel(Startimesdef)==1 && Startimesdef>=0
+else
+ Startimesdef = 0;
+ EStudio_gui_erp_totl.eeg_zoom_edit.String = '0';
+end
+
+Startimes = Startimesdef-fastif(Winlength>=5, round(Winlength), Winlength);
+if Startimes<0
+ if observe_EEGDAT.EEG.trials>1
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+
+estudioworkingmemory('Startimes',Startimes);
+EStudio_gui_erp_totl.eeg_zoom_edit.String =num2str(Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+%%Editing the start the time for the displayed EEG data
+function zoomedit(Source,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+if isempty(observe_EEGDAT.EEG)
+ Source.String ='0';
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+
+Startimes = str2num(EStudio_gui_erp_totl.eeg_zoom_edit.String);
+if isempty(Startimes)
+ Startimes = 0;
+ Source.String = '0';
+ MessageViewer= char(strcat('Start time for the displayed EEG should be a number'));
+ estudioworkingmemory('f_EEG_proces_messg',MessageViewer);
+ observe_EEGDAT.eeg_panel_message=4;
+end
+if numel(Startimes)~=1
+ Startimes = Startimes(1);
+end
+
+
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier = size(observe_EEGDAT.EEG.data,2);
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier = observe_EEGDAT.EEG.srate;
+ multiplier_winleg = observe_EEGDAT.EEG.srate;
+end
+
+if isempty(Winlength)|| Winlength<0 || (Winlength>floor(Frames/multiplier_winleg))
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+if ndims(observe_EEGDAT.EEG.data) ==3
+ Startimes = Startimes-1;
+end
+Startimes = max(0,min(Startimes,ceil((Frames-1)/multiplier)-Winlength));
+if ndims(observe_EEGDAT.EEG.data) ==3
+ Startimes = Startimes+1;
+end
+Source.String = num2str(Startimes);
+
+
+estudioworkingmemory('Startimes',Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+
+
+%%-------------------% > add one second for displayed EEG------------------
+function zoomout_small(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier = size(observe_EEGDAT.EEG.data,2);
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier = observe_EEGDAT.EEG.srate;
+ multiplier_winleg = multiplier;
+end
+
+if isempty(Winlength)|| Winlength<0 || Winlength>floor(Frames/multiplier_winleg)
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+Startimesdef = str2num(EStudio_gui_erp_totl.eeg_zoom_edit.String);
+if ~isempty(Startimesdef) && isnumeric(Startimesdef) && numel(Startimesdef)==1 && Startimesdef>=0
+else
+ Startimesdef = 0;
+end
+
+Startimes = Startimesdef+fastif(Winlength>=5, round(Winlength), Winlength); %%> add one second
+if Startimes<0
+ Startimes=0;
+end
+
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+
+if isempty(Winlength)|| Winlength<0 || (Winlength>floor(Frames/multiplier_winleg))
+ Winlength = floor(Frames/multiplier_winleg);
+ EEG_plotset{3} = floor(Frames/multiplier_winleg);
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+StartimesMax = max(0,ceil((Frames-1)/multiplier)-Winlength);
+if ndims(observe_EEGDAT.EEG.data)==3
+ StartimesMax = StartimesMax+1;
+end
+if Startimes>StartimesMax
+ Startimes=StartimesMax;
+end
+EStudio_gui_erp_totl.eeg_zoom_edit.String = num2str(Startimes);
+
+estudioworkingmemory('Startimes',Startimes);
+f_redrawEEG_Wave_Viewer(1);
+
+end
+
+
+function zoomout_fivelarge(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier = size(observe_EEGDAT.EEG.data,2);
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier = observe_EEGDAT.EEG.srate;
+ multiplier_winleg = multiplier;
+end
+
+if isempty(Winlength)|| Winlength<0 || Winlength>floor(Frames/multiplier_winleg)
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+Startimesdef = str2num(EStudio_gui_erp_totl.eeg_zoom_edit.String);
+if ~isempty(Startimesdef) && isnumeric(Startimesdef) && numel(Startimesdef)==1 && Startimesdef>=0
+else
+ Startimesdef = 0;
+end
+
+Startimes = Startimesdef+fastif(Winlength>=5, round(5*Winlength), 5*Winlength); %%> add one second
+if Startimes<0
+ Startimes=0;
+end
+
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+
+if isempty(Winlength)|| Winlength<0 || (Winlength>floor(Frames/multiplier_winleg))
+ Winlength = floor(Frames/multiplier_winleg);
+ EEG_plotset{3} = floor(Frames/multiplier_winleg);
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+StartimesMax = max(0,ceil((Frames-1)/multiplier)-Winlength);
+if ndims(observe_EEGDAT.EEG.data)==3
+ StartimesMax = StartimesMax+1;
+end
+if Startimes>StartimesMax
+ Startimes=StartimesMax;
+end
+EStudio_gui_erp_totl.eeg_zoom_edit.String = num2str(Startimes);
+
+estudioworkingmemory('Startimes',Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+
+
+function zoomout_large(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;%%Global variable
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+EStudio_gui_erp_totl.eegProcess_messg.String = '';
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;
+EEG_plotset = estudioworkingmemory('EEG_plotset');
+try
+ Winlength = EEG_plotset{3};
+catch
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+[chaNum,sampleNum,trialNum]=size(observe_EEGDAT.EEG.data);
+Frames = sampleNum*trialNum;
+if observe_EEGDAT.EEG.trials>1 % time in second or in trials
+ multiplier = size(observe_EEGDAT.EEG.data,2);
+ multiplier_winleg = size(observe_EEGDAT.EEG.data,2);
+else
+ multiplier = observe_EEGDAT.EEG.srate;
+ multiplier_winleg = multiplier;
+end
+
+if isempty(Winlength)|| Winlength<0 || (Winlength>floor(Frames/multiplier_winleg))
+ Winlength = 5;
+ EEG_plotset{3} = 5;
+end
+estudioworkingmemory('EEG_plotset',EEG_plotset);
+StartimesMax = max(0,ceil((Frames-1)/multiplier)-Winlength);
+if ndims(observe_EEGDAT.EEG.data)==3
+ StartimesMax = StartimesMax+1;
+end
+Startimes = StartimesMax;
+
+
+estudioworkingmemory('Startimes',Startimes);
+
+EStudio_gui_erp_totl.eeg_zoom_edit.String =num2str(Startimes);
+f_redrawEEG_Wave_Viewer(1);
+end
+
+
+%%-------------------------------Page Editor-------------------------------
+function page_edit(Source,~)
+global observe_EEGDAT;
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+
+Pagecurrent = str2num(Source.String);
+
+EEGset_selected = estudioworkingmemory('EEGArray');
+if isempty(EEGset_selected)
+ EEGset_selected=observe_EEGDAT.CURRENTSET;
+ estudioworkingmemory('EEGArray',EEGset_selected);
+end
+
+pageNum = numel(EEGset_selected);
+if ~isempty(Pagecurrent) && numel(Pagecurrent)~=1 %%if two or more numbers are entered
+ Pagecurrent =Pagecurrent(1);
+end
+
+if ~isempty(Pagecurrent) && Pagecurrent>0 && Pagecurrent<= pageNum%%
+ Source.String = num2str(Pagecurrent);
+ observe_EEGDAT.CURRENTSET = EEGset_selected(Pagecurrent);
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET);
+ estudioworkingmemory('Startimes',0);
+ f_redrawEEG_Wave_Viewer();
+ observe_EEGDAT.count_current_eeg=2;
+end
+end
+
+
+
+
+%------------------Display the waveform for proir ERPset--------------------
+function page_minus(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+Pagecurrent = str2num(EStudio_gui_erp_totl.eegpageinfo_edit.String);
+EEGset_selected = estudioworkingmemory('EEGArray');
+if isempty(EEGset_selected)
+ EEGset_selected=observe_EEGDAT.CURRENTSET;
+ estudioworkingmemory('EEGArray',EEGset_selected);
+end
+
+pageNum = numel(EEGset_selected);
+if ~isempty(Pagecurrent) && numel(Pagecurrent)~=1 %%if two or more numbers are entered
+ Pagecurrent =Pagecurrent(1);
+elseif isempty(Pagecurrent)
+ [xpos, ypos] = find(EEGset_selected==observe_EEGDAT.CURRENTSET);
+ if isempty(ypos)
+ Pagecurrent=1;
+ observe_EEGDAT.CURRENTSET = EEGset_selected(1);
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET);
+ else
+ Pagecurrent = ypos;
+ end
+end
+Pagecurrent = Pagecurrent-1;
+if Pagecurrent>0 && Pagecurrent<=pageNum
+ EStudio_gui_erp_totl.eegpageinfo_edit.String = num2str(Pagecurrent);
+ observe_EEGDAT.CURRENTSET = EEGset_selected(Pagecurrent);
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET);
+ estudioworkingmemory('Startimes',0);
+ f_redrawEEG_Wave_Viewer(1);
+ observe_EEGDAT.count_current_eeg=2;
+else
+ return;
+end
+end
+
+
+%------------------Display the waveform for next ERPset--------------------
+function page_plus(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+Pagecurrent = str2num(EStudio_gui_erp_totl.eegpageinfo_edit.String);
+EEGset_selected = estudioworkingmemory('EEGArray');
+if isempty(EEGset_selected)
+ EEGset_selected=observe_EEGDAT.CURRENTSET;
+ estudioworkingmemory('EEGArray',EEGset_selected);
+end
+
+pageNum = numel(EEGset_selected);
+if ~isempty(Pagecurrent) && numel(Pagecurrent)~=1 %%if two or more numbers are entered
+ Pagecurrent =Pagecurrent(1);
+elseif isempty(Pagecurrent)
+ [xpos, ypos] = find(EEGset_selected==observe_EEGDAT.CURRENTSET);
+ if isempty(ypos)
+ Pagecurrent=1;
+ observe_EEGDAT.CURRENTSET = EEGset_selected(1);
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET);
+ observe_EEGDAT.count_current_eeg =2;
+ f_redrawEEG_Wave_Viewer();
+ return;
+ else
+ Pagecurrent = ypos;
+ end
+end
+Pagecurrent = Pagecurrent+1;
+if Pagecurrent>0 && Pagecurrent<=pageNum
+ EStudio_gui_erp_totl.eegpageinfo_edit.String = num2str(Pagecurrent);
+ observe_EEGDAT.CURRENTSET = EEGset_selected(Pagecurrent);
+ observe_EEGDAT.EEG = observe_EEGDAT.ALLEEG(observe_EEGDAT.CURRENTSET);
+ estudioworkingmemory('Startimes',0);
+ f_redrawEEG_Wave_Viewer(1);
+ observe_EEGDAT.count_current_eeg=2;
+else
+ return;
+end
+end
+
+
+
+
+function Show_command(~,~)
+global observe_EEGDAT;
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+MessageViewer= char(strcat('Show Command'));
+estudioworkingmemory('f_EEG_proces_messg',MessageViewer);
+try
+ observe_EEGDAT.eeg_panel_message=1;
+ OutputViewereegpar = f_preparms_eegwaviewer(observe_EEGDAT.EEG,1,'command');
+ observe_EEGDAT.eeg_panel_message=2;
+catch
+ observe_EEGDAT.eeg_panel_message=3;
+end
+end
+
+
+
+%%-------------------------Save figure as----------------------------------
+function figure_saveas(~,~)
+global observe_EEGDAT;
+% addlistener(observe_EEGDAT,'Messg_EEG_change',@Messg_EEG_change);
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+MessageViewer= char(strcat('Save Figure As'));
+estudioworkingmemory('f_EEG_proces_messg',MessageViewer);
+
+pathstr = pwd;
+[~, namedef, ~] = fileparts(observe_EEGDAT.EEG.setname);
+[figurename, erppathname, indxs] = uiputfile({'*.pdf';'*.svg';'*.jpg';'*.png';'*.tif';'*.bmp';'*.eps'},...
+ 'Save as',[fullfile(pathstr,namedef)]);
+
+if isequal(figurename,0)
+ % observe_EEGDAT.eeg_panel_message=3;
+ return
+end
+
+History = 'off';
+[pathstr, figurename1, ext] = fileparts(figurename) ;
+
+if isempty(ext)
+ figurename = fullfile(erppathname,char(strcat(figurename,'.pdf')));
+else
+ figurename = fullfile(erppathname,figurename);
+end
+
+observe_EEGDAT.eeg_panel_message=1;
+OutputViewereegpar = f_preparms_eegwaviewer(observe_EEGDAT.EEG,1,History,figurename);
+observe_EEGDAT.eeg_panel_message=2;
+
+end
+
+
+%%------------------------Reset parameters---------------------------------
+function eeg_paras_reset(~,~)
+global observe_EEGDAT;
+global observe_ERPDAT;
+global EStudio_gui_erp_totl;
+
+estudioworkingmemory('EEGUpdate',0);
+observe_EEGDAT.count_current_eeg =1;
+
+estudioworkingmemory('ViewerFlag', 0);
+observe_ERPDAT.Count_currentERP=1;
+
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+
+estudioworkingmemory('f_EEG_proces_messg','Reset parameters for EEG panels');
+app = feval('estudio_reset_paras',[1 0 0 0]);
+waitfor(app,'Finishbutton',1);
+reset_paras = [0 0 0 0];
+try
+ reset_paras = app.output; %NO you don't want to output EEG with edited channel locations, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.1); %wait for app to leave
+catch
+ return;
+end
+if isempty(reset_paras)
+ return;
+end
+EStudio_gui_erp_totl.ERP_autoplot=1;
+EStudio_gui_erp_totl.EEG_autoplot = 1;
+
+observe_EEGDAT.eeg_panel_message=1;
+if reset_paras(2)==1
+ EStudio_gui_erp_totl.clear_alleeg = 1;
+else
+ EStudio_gui_erp_totl.clear_alleeg = 0;
+end
+
+if reset_paras(1)==1
+ observe_EEGDAT.Reset_eeg_paras_panel=1;
+ if EStudio_gui_erp_totl.clear_alleeg == 0
+ f_redrawEEG_Wave_Viewer();
+ else
+ observe_EEGDAT.ALLEEG = [];
+ observe_EEGDAT.EEG = [];
+ observe_EEGDAT.CURRENTSET = 0;
+ estudioworkingmemory('EEGArray',1);
+ observe_EEGDAT.count_current_eeg =1;
+ end
+else
+ if EStudio_gui_erp_totl.clear_alleeg == 1
+ observe_EEGDAT.ALLEEG = [];
+ observe_EEGDAT.EEG = [];
+ observe_EEGDAT.CURRENTSET = 0;
+ estudioworkingmemory('EEGArray',1);
+ observe_EEGDAT.count_current_eeg =1;
+ end
+end
+observe_EEGDAT.eeg_panel_message=2;
+%%---------------- -------------erp tab------------------------------------
+if reset_paras(4)==1
+ EStudio_gui_erp_totl.clear_allerp = 1;
+else
+ EStudio_gui_erp_totl.clear_allerp = 0;
+end
+
+if reset_paras(3)==1
+ observe_ERPDAT.Reset_erp_paras_panel = 1;
+ if EStudio_gui_erp_totl.clear_allerp == 0
+ f_redrawERP();
+ else
+ observe_ERPDAT.ALLERP = [];
+ observe_ERPDAT.ERP = [];
+ observe_ERPDAT.CURRENTERP = 1;
+ estudioworkingmemory('selectederpstudio',1);
+ observe_ERPDAT.Count_currentERP = 1;
+ end
+else
+ if EStudio_gui_erp_totl.clear_allerp == 1
+
+ observe_ERPDAT.ALLERP = [];
+ observe_ERPDAT.ERP = [];
+ observe_ERPDAT.CURRENTERP = 1;
+ estudioworkingmemory('selectederpstudio',1);
+ observe_ERPDAT.Count_currentERP = 1;
+ end
+end
+
+end
+
+
+
+%%-----------------Pop figure---------------------------------------------
+function figure_out(~,~)
+global observe_EEGDAT;
+
+if isempty(observe_EEGDAT.EEG)
+ return;
+end
+
+%%first check if the changed parameters have been applied in any panels
+[messgStr,eegpanelIndex] = f_check_eegtab_panelchanges();
+if ~isempty(messgStr)
+ observe_EEGDAT.eeg_two_panels = observe_EEGDAT.eeg_two_panels+1;
+end
+
+
+MessageViewer= char(strcat('Create Static/Exportable Plot'));
+estudioworkingmemory('f_EEG_proces_messg',MessageViewer);
+try
+ figurename = observe_EEGDAT.EEG.setname;
+catch
+ figurename = '';
+end
+History = 'off';
+observe_EEGDAT.eeg_panel_message=1;
+OutputViewereegpar = f_preparms_eegwaviewer(observe_EEGDAT.EEG,1,History,figurename);
+observe_EEGDAT.eeg_panel_message=2;
+end
+
+
+% %%------------------------Message panel------------------------------------
+function eeg_panel_change_message(~,~)
+global observe_EEGDAT;
+global EStudio_gui_erp_totl;
+% addlistener(observe_EEGDAT,'count_current_eeg_change',@count_current_eeg_change);
+
+if isempty(observe_EEGDAT.EEG) || isempty(observe_EEGDAT.ALLEEG)
+ return;
+end
+FonsizeDefault = f_get_default_fontsize();
+try
+ [version reldate,ColorB_def,ColorF_def,errorColorF_def] = geterplabstudiodef;%%Get background color
+catch
+ ColorB_def = [0.7020 0.77 0.85];
+end
+if isempty(ColorB_def) || numel(ColorB_def)~=3 || min(ColorB_def(:))<0 || max(ColorB_def(:))>1
+ ColorB_def = [0.7020 0.77 0.85];
+end
+Processed_Method=estudioworkingmemory('f_EEG_proces_messg');
+EEGMessagepre = estudioworkingmemory('f_EEG_proces_messg_pre');
+if isempty(EEGMessagepre)
+ EEGMessagepre = {'',0};
+end
+try
+ if strcmpi(EEGMessagepre{1},Processed_Method) && observe_EEGDAT.eeg_panel_message == EEGMessagepre{2}
+ return;
+ end
+catch
+end
+estudioworkingmemory('f_EEG_proces_messg_pre',{Processed_Method,observe_EEGDAT.eeg_panel_message});
+
+
+EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = [0.95 0.95 0.95];
+EStudio_gui_erp_totl.eegProcess_messg.FontSize = FonsizeDefault;
+
+if observe_EEGDAT.eeg_panel_message==1
+ EStudio_gui_erp_totl.eegProcess_messg.String = strcat('1- ',Processed_Method,': Running....');
+ EStudio_gui_erp_totl.eegProcess_messg.ForegroundColor = [0 0 0];
+ pause(0.1);
+elseif observe_EEGDAT.eeg_panel_message==2
+ EStudio_gui_erp_totl.eegProcess_messg.String = strcat('2- ',Processed_Method,': Complete');
+ EStudio_gui_erp_totl.eegProcess_messg.ForegroundColor = [0 0.5 0];
+ pause(0.1);
+elseif observe_EEGDAT.eeg_panel_message==3
+ if ~strcmp(EStudio_gui_erp_totl.eegProcess_messg.String,strcat('3- ',Processed_Method,': Error (see Command Window)'))
+ fprintf([Processed_Method,32,32,32,datestr(datetime('now')),'\n.']);
+ end
+ EStudio_gui_erp_totl.eegProcess_messg.String = strcat('3- ',Processed_Method,': Error (see Command Window)');
+ EStudio_gui_erp_totl.eegProcess_messg.ForegroundColor = [1 0 0];
+else
+ if ~strcmpi(EStudio_gui_erp_totl.eegProcess_messg.String,strcat('Warning:',32,Processed_Method,32,'(see Command Window).'))
+ fprintf([Processed_Method,32,32,32,datestr(datetime('now')),'\n.']);
+ end
+ EStudio_gui_erp_totl.eegProcess_messg.String = strcat('Warning:',32,Processed_Method,32,'(see Command Window).');
+
+ pause(0.1);
+ EStudio_gui_erp_totl.eegProcess_messg.ForegroundColor = [1 0.65 0];
+end
+if observe_EEGDAT.eeg_panel_message==2 || observe_EEGDAT.eeg_panel_message==3
+ pause(0.01);
+ EStudio_gui_erp_totl.eegProcess_messg.String = '';
+ EStudio_gui_erp_totl.eegProcess_messg.BackgroundColor = ColorB_def;%[0.95 0.95 0.95];
+end
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%-------------------------------Plot eeg waves--------------------------%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function [EStudio_gui_erp_totl,errmeg] = f_plotviewereegwave(EEG,ChanArray,ICArray,EEGdispFlag,ICdispFlag,Winlength,...
+ AmpScale,ChanLabel,Submean,EventOnset,StackFlag,NormFlag,Startimes,AmpIC,bufftobo,EStudio_gui_erp_totl,Axesreset)
+
+if nargin<17
+ Axesreset=0;
+end
+
+if isempty(Axesreset) || numel(Axesreset)~=1 || (Axesreset~=0 && Axesreset~=1)
+ Axesreset=0;
+end
+
+if Axesreset ==1%%Speed up the execute time
+ cla(EStudio_gui_erp_totl.myeegviewer,'reset');
+ set(EStudio_gui_erp_totl.myeegviewer,'Box','on');
+else
+ EStudio_gui_erp_totl.myeegviewer = axes('Parent', EStudio_gui_erp_totl.eegViewAxes,'Color','none','Box','on','FontWeight','normal');
+ Pos = EStudio_gui_erp_totl.myeegviewer.Position;
+ EStudio_gui_erp_totl.myeegviewer.Position = [Pos(1)*0.5,Pos(2)*0.5,Pos(3)*1.15,Pos(4)*1.05];%%x,y,width,height
+ estudioworkingmemory('egfigsize',[EStudio_gui_erp_totl.myeegviewer.Position(3),EStudio_gui_erp_totl.myeegviewer.Position(4)]);
+end
+
+hold(EStudio_gui_erp_totl.myeegviewer,'on');
+
+myeegviewer = EStudio_gui_erp_totl.myeegviewer;
+
+
+errmeg = [];
+if nargin<1
+ help f_plotviewereegwave;
+ return
+end
+
+if isempty(EEG)
+ errmeg = 'EEG is empty';
+ return;
+end
+
+
+%%selected channels
+nbchan = EEG.nbchan;
+if nargin<2
+ ChanArray = 1:nbchan;
+end
+if isempty(ChanArray) || min(ChanArray(:)) >nbchan || max(ChanArray(:))> nbchan|| min(ChanArray(:))<=0
+ ChanArray = 1:nbchan;
+end
+
+%%selected ICs
+if nargin<3
+ ICArray = [];
+end
+if isempty(EEG.icachansind)
+ ICArray = [];
+else
+ nIC = numel(EEG.icachansind);
+ if isempty(ICArray) || min(ICArray(:))>nIC || max(ICArray(:)) > nIC || min(ICArray(:))<=0
+ ICArray = 1:nIC;
+ end
+end
+
+%%display EEG?
+if nargin<4
+ EEGdispFlag=1;
+end
+if isempty(EEGdispFlag) || (EEGdispFlag~=0 && EEGdispFlag~=1)
+ EEGdispFlag = 1;
+end
+
+%%Dispaly ICs?
+if nargin<5
+ ICdispFlag=0;
+end
+if isempty(ICdispFlag) || (ICdispFlag~=0 && ICdispFlag~=1)
+ ICdispFlag = 0;
+end
+if ICdispFlag==0
+ ICArray = [];
+end
+
+%%Time range that is to display (1s or 5s)?
+if nargin<6
+ Winlength=5;
+end
+if isempty(Winlength) || numel(Winlength)~=1 || min(Winlength(:))<=0
+ Winlength=5;
+end
+
+%%Vertical scale?
+if nargin<7
+ AmpScale = 50;
+end
+if isempty(AmpScale) || numel(AmpScale)~=1 || AmpScale<=0
+ AmpScale = 50;
+end
+OldAmpScale = AmpScale;
+
+%%channe labels (name or number)
+if nargin<8
+ ChanLabel = 1;
+end
+if isempty(ChanLabel) || numel(ChanLabel)~=1 || (ChanLabel~=0 && ChanLabel~=1)
+ ChanLabel = 1;
+end
+
+%%remove DC?
+if nargin<9
+ Submean = 0;
+end
+if isempty(Submean) || numel(Submean)~=1 || (Submean~=0 && Submean~=1)
+ Submean = 1;
+end
+
+
+%%Display events?
+if nargin<10
+ EventOnset = 1;
+end
+if isempty(EventOnset) || numel(EventOnset)~=1 || (EventOnset~=0 && EventOnset~=1)
+ EventOnset = 1;
+end
+
+
+%%Stack?
+if nargin<11
+ StackFlag = 0;
+end
+if isempty(StackFlag) || numel(StackFlag)~=1 || (StackFlag~=0&&StackFlag~=1)
+ StackFlag = 0;
+end
+
+%%Norm?
+if nargin<12
+ NormFlag = 0;
+end
+if isempty(NormFlag) ||numel(NormFlag)~=1 || (NormFlag~=0 && NormFlag~=1)
+ NormFlag = 0;
+end
+
+% Startimes =20;
+%%start time for the displayed data
+if nargin < 13
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+
+%%VERTICAL SCALE for ICs
+if nargin<14
+ AmpIC = 20;
+end
+
+if isempty(AmpIC) || numel(AmpIC)~=1 || AmpIC<=0
+ AmpIC = 20;
+end
+OldAmpIC = AmpIC;
+
+%%buffer at top and bottom
+if nargin<15
+ bufftobo = 100;
+end
+if isempty(bufftobo) || numel(bufftobo)~=1 || any(bufftobo(:)<=0)
+ bufftobo = 100;
+end
+
+
+[ChanNum,Allsamples,tmpnb] = size(EEG.data);
+Allsamples = Allsamples*tmpnb;
+if ndims(EEG.data) > 2
+ multiplier = size(EEG.data,2);
+else
+ multiplier = EEG.srate;
+end
+
+if isempty(Startimes) || Startimes<0 || Startimes>(ceil((Allsamples-1)/multiplier)-Winlength)
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+end
+
+%%determine the time range that will be dispalyed
+lowlim = round(Startimes*multiplier+1);
+highlim = round(min((Startimes+Winlength)*multiplier+1,Allsamples));
+
+
+%%--------------------prepare event array if any --------------------------
+Events = EEG.event;
+if ~isempty(Events)
+ if ~isfield(Events, 'type') || ~isfield(Events, 'latency'), Events = []; end
+end
+if ~isempty(Events)
+ if ischar(Events(1).type)
+ [Eventtypes tmpind indexcolor] = unique_bc({Events.type}); % indexcolor countinas the event type
+ else [Eventtypes tmpind indexcolor] = unique_bc([ Events.type ]);
+ end
+ Eventcolors = { 'r', [0 0.8 0], 'm', 'c', 'k', 'b', [0 0.8 0] };
+ Eventstyle = { '-' '-' '-' '-' '-' '-' '-' '--' '--' '--' '--' '--' '--' '--'};
+ Eventwidths = [ 2.5 1 ];
+ Eventtypecolors = Eventcolors(mod([1:length(Eventtypes)]-1 ,length(Eventcolors))+1);
+ Eventcolors = Eventcolors(mod(indexcolor-1 ,length(Eventcolors))+1);
+ Eventtypestyle = Eventstyle (mod([1:length(Eventtypes)]-1 ,length(Eventstyle))+1);
+ Eventstyle = Eventstyle (mod(indexcolor-1 ,length(Eventstyle))+1);
+
+ % for width, only boundary events have width 2 (for the line)
+ % -----------------------------------------------------------
+ indexwidth = ones(1,length(Eventtypes))*2;
+ if iscell(Eventtypes)
+ for index = 1:length(Eventtypes)
+ if strcmpi(Eventtypes{index}, 'boundary'), indexwidth(index) = 1; end
+ end
+ else
+ end
+ Eventtypewidths = Eventwidths (mod(indexwidth([1:length(Eventtypes)])-1 ,length(Eventwidths))+1);
+ Eventwidths = Eventwidths (mod(indexwidth(indexcolor)-1 ,length(Eventwidths))+1);
+
+ % latency and duration of events
+ % ------------------------------
+ Eventlatencies = [ Events.latency ]+1;
+ if isfield(Events, 'duration')
+ durations = { Events.duration };
+ durations(cellfun(@isempty, durations)) = { NaN };
+ Eventlatencyend = Eventlatencies + [durations{:}]+1;
+ else Eventlatencyend = [];
+ end
+ % EventOnset = 1;
+end
+
+if isempty(Events)
+ EventOnset = 0;
+end
+
+chanNum = numel(ChanArray);
+
+
+%%-------------------------------IC and original data----------------------
+dataica = [];chaNum=0;
+if ~isempty(EEG.icaweights) && ~isempty(ICArray)%%pop_eegplot from eeglab
+ tmpdata = eeg_getdatact(EEG, 'component', [1:size(EEG.icaweights,1)]);
+ try
+ dataica = tmpdata(ICArray,:);
+ catch
+ dataica = tmpdata(:,:);
+ ICArray = [1:size(tmpdata,1)];
+ end
+end
+
+if EEGdispFlag==1
+ dataeeg = EEG.data(ChanArray,:);
+ chaNum = numel(ChanArray);
+else
+ dataeeg =[];
+ chaNum = 0;
+end
+
+%%---------------------------Normalize-------------------------------------
+if NormFlag==1
+ %%Norm for origanal
+ % data2 = [];
+ if ~isempty(dataeeg)
+ datastd = std(dataeeg(:,1:min(1000,Allsamples)),[],2);%
+ for i = 1:size(dataeeg,1)
+ dataeeg(i,:,:) = dataeeg(i,:,:)/datastd(i);
+ % if ~isempty(data2)
+ % data2(i,:,:) = data2(i,:,:)*datastd(i);
+ % end
+ end
+ end
+
+ %%norm for IC data
+ if ~isempty(dataica)
+ dataicstd = std(dataica(:,1:min(1000,Allsamples)),[],2);
+ for i = 1:size(dataica,1)
+ dataica(i,:,:) = dataica(i,:,:)/dataicstd(i);
+ % if ~isempty(data2)
+ % data2(i,:,:) = data2(i,:,:)*dataicstd(i);
+ % end
+ end
+ end
+end
+
+% Removing DC for IC data?
+% -------------------------
+meandataica =[];ICNum=0;
+if ICdispFlag==1
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray) && ~isempty(dataica)%%pop_eegplot from eeglab
+ switch Submean % subtract the mean ?
+ case 1
+ meandataica = mean(dataica(:,lowlim:highlim)');
+ if any(isnan(meandataica))
+ meandataica = nan_mean(dataica(:,lowlim:highlim)');
+ end
+ otherwise, meandataica = zeros(1,numel(ICArray));
+ end
+ end
+ ICNum = numel(ICArray);
+else
+ ICNum = 0;
+end
+
+% Removing DC for original data?
+% -------------------------
+meandata = [];
+if EEGdispFlag==1 && ~isempty(dataeeg)
+ switch Submean % subtract the mean ?
+ case 1
+ meandata = mean(dataeeg(:,lowlim:highlim)');
+ if any(isnan(meandata))
+ meandata = nan_mean(dataeeg(:,lowlim:highlim)');
+ end
+ otherwise, meandata = zeros(1,numel(ChanArray));
+ end
+end
+
+
+PlotNum = chaNum+ICNum;
+if chaNum==0 && ICNum==0
+ Ampscold = 0*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = 0*[1:PlotNum]';
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = 0;
+ ylims = [0 (PlotNum+1)*AmpScale];
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+elseif ICNum==0 && chaNum~=0
+ Ampscold = AmpScale*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = ((Ampscold(end)+AmpScale)/2)*ones(1,PlotNum)';
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = AmpScale;
+ ylims = [AmpScale*(100-bufftobo)/100 PlotNum*AmpScale+AmpScale*bufftobo/100];
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+elseif ICNum~=0 && chaNum==0
+ Ampscold = AmpIC*[1:PlotNum]';
+ if StackFlag==1
+ Ampsc = ((Ampscold(end)+AmpIC)/2)*ones(1,PlotNum)';
+ else
+ Ampsc = Ampscold;
+ end
+ ylims = [AmpIC*(100-bufftobo)/100 PlotNum*AmpIC+AmpIC*bufftobo/100];
+ AmpScaleold = AmpIC;
+ data = [dataeeg;dataica];
+ meandata = [meandata,meandataica];
+ AmpICNew = AmpIC;
+elseif ICNum~=0 && chaNum~=0
+ AmpICNew = (AmpScale*chaNum+AmpScale/2)/ICNum;
+ Ampscold1 = AmpICNew*[1:ICNum]';
+ Ampscold2 = Ampscold1(end)+AmpScale/2+AmpScale*[1:chaNum]';
+ Ampscold = [Ampscold1;Ampscold2];
+ if StackFlag==1
+ Ampsc = [(Ampscold1(end)/2)*ones(ICNum,1);((Ampscold2(end)+AmpScale+Ampscold2(1)+AmpIC)/2)*ones(chaNum,1)];
+ else
+ Ampsc = Ampscold;
+ end
+ AmpScaleold = AmpScale;
+ ylims = [AmpICNew*(100-bufftobo)/100 Ampscold(end)+AmpScale*bufftobo/100];
+ data = [dataeeg;(AmpICNew/AmpIC)*dataica];
+ meandata = [meandata,(AmpICNew/AmpIC)*meandataica];
+end
+
+
+Colorgbwave = [];
+%%set the wave color for each channel
+if ~isempty(data)
+ ColorNamergb = roundn([255 0 7;186 85 255;255 192 0;0 238 237;0 78 255;0 197 0]/255,-3);
+ Colorgb_chan = [];
+ if ~isempty(dataeeg)
+ chanNum = numel(ChanArray);
+ if chanNum<=6
+ Colorgb_chan = ColorNamergb(1:chanNum,:);
+ else
+ jj = floor(chanNum/6);
+ Colorgb_chan = [];
+ for ii = 1:jj
+ Colorgb_chan = [Colorgb_chan; ColorNamergb];
+ end
+ if jj*6~=chanNum
+ Colorgb_chan = [Colorgb_chan; ColorNamergb(1:chanNum-jj*6,:)];
+ end
+ end
+ end
+
+ %%colors for ICs
+ % Coloricrgb = roundn([211,211,211;169,169,16;128,128,128]/255,-3);
+ Coloricrgb = roundn([180 0 0;127 68 127;228 88 44;15 175 175;0 0 0;9 158 74]/255,-3);
+ Colorgb_IC = [];
+ if ~isempty(ICArray)
+ ICNum = numel(ICArray);
+ if ICNum<7
+ Colorgb_IC = Coloricrgb(1:ICNum,:);
+ else
+ jj = floor(ICNum/6);
+ for ii = 1:jj
+ Colorgb_IC = [Colorgb_IC; Coloricrgb];
+ end
+
+ if jj*6~=ICNum
+ Colorgb_IC = [Colorgb_IC; Coloricrgb(1:ICNum-jj*6,:)];
+ end
+
+ end
+ end
+ Colorgbwave = [Colorgb_chan;Colorgb_IC];
+end
+
+
+PlotNum =0;
+if ICdispFlag==1 && EEGdispFlag==1
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray)
+ PlotNum = chanNum +numel(ICArray);
+ else
+ PlotNum = chanNum;
+ end
+elseif ICdispFlag==0 && EEGdispFlag==1
+ PlotNum = chanNum;
+elseif ICdispFlag==1 && EEGdispFlag==0
+ if ~isempty(EEG.icaweights) && ~isempty(ICArray)
+ PlotNum = numel(ICArray);
+ end
+end
+%%
+EventOnsetdur =1;
+Trialstag = size(EEG.data,2);
+GapSize = ceil(numel([lowlim:highlim])/40);
+if GapSize<=2
+ GapSize=5;
+end
+% -------------------------------------------------------------------------
+% -------------------------draw events if any------------------------------
+% -------------------------------------------------------------------------
+% ylims = [0 (PlotNum+1)*AmpScale];
+
+FonsizeDefault = f_get_default_fontsize();
+if isempty(FonsizeDefault) || numel(FonsizeDefault)~=1|| any(FonsizeDefault(:)<=0)
+ FonsizeDefault=10;
+end
+
+if EventOnset==1 && ~isempty(data) && PlotNum~=0
+ MAXEVENTSTRING = 75;
+ if MAXEVENTSTRING<0
+ MAXEVENTSTRING = 0;
+ elseif MAXEVENTSTRING>75
+ MAXEVENTSTRING=75;
+ end
+ % AXES_POSITION = [0.0964286 0.15 0.842 0.75-(MAXEVENTSTRING-5)/100];
+ %
+
+ % find event to plot
+ % ------------------
+ event2plot = find ( Eventlatencies >=lowlim & Eventlatencies <= highlim );
+ if ~isempty(Eventlatencyend)
+ event2plot2 = find ( Eventlatencyend >= lowlim & Eventlatencyend <= highlim );
+ event2plot3 = find ( Eventlatencies < lowlim & Eventlatencyend > highlim );
+ event2plot = setdiff(union(event2plot, event2plot2), event2plot3);
+ end
+ for index = 1:length(event2plot)
+ %Just repeat for the first one
+ if index == 1
+ EVENTFONT = [' \fontsize{',num2str(FonsizeDefault),'} '];
+ end
+
+ % draw latency line
+ % -----------------
+ if ndims(EEG.data)==2
+ tmplat = Eventlatencies(event2plot(index))-lowlim-1;
+ else
+ % -----------------
+ tmptaglat = [lowlim:highlim];
+ tmpind = find(mod(tmptaglat-1,Trialstag) == 0);
+ tmpind = setdiff(tmpind,[1,numel(tmptaglat)]);
+ alltaglat = setdiff(tmptaglat(tmpind),[1,tmptaglat(end)]);
+ %%add gap between epochs if any
+ if ~isempty(tmpind) && ~isempty(alltaglat) %%two or multiple epochs were displayed
+ if length(alltaglat)==1
+ if Eventlatencies(event2plot(index)) >= alltaglat
+ Singlat = Eventlatencies(event2plot(index))+GapSize;
+ else
+ Singlat = Eventlatencies(event2plot(index));
+ end
+ else
+ if Eventlatencies(event2plot(index)) < alltaglat(1)%%check the first epoch
+ Singlat = Eventlatencies(event2plot(index));
+ else%%the other epochs
+ for ii = 2:length(alltaglat)
+ if Eventlatencies(event2plot(index)) >= alltaglat(ii-1) && Eventlatencies(event2plot(index)) < alltaglat(ii)
+ Singlat = Eventlatencies(event2plot(index))+GapSize*(ii-1);
+ break;
+ elseif Eventlatencies(event2plot(index)) >= alltaglat(end) %%check the last epoch
+ Singlat = Eventlatencies(event2plot(index))+GapSize*length(alltaglat);
+ break;
+ end
+ end
+ end
+ end
+ tmplat = Singlat-lowlim;%%adjust the latency if any
+ else%%within one epoch
+ tmplat = Eventlatencies(event2plot(index))-lowlim;%-1;
+ end
+ end
+ tmph = plot(myeegviewer, [ tmplat tmplat ], ylims, 'color', Eventcolors{ event2plot(index) }, ...
+ 'linestyle', Eventstyle { event2plot(index) }, ...
+ 'linewidth', Eventwidths( event2plot(index) ) );
+
+ % schtefan: add Event types text above event latency line
+ % -------------------------------------------------------
+ evntxt = strrep(num2str(Events(event2plot(index)).type),'_','-');
+ if length(evntxt)>MAXEVENTSTRING, evntxt = [ evntxt(1:MAXEVENTSTRING-1) '...' ]; end % truncate
+ try,
+ if tmplat>=0
+ tmph2 = text(myeegviewer, [tmplat], ylims(2)-0.005, [EVENTFONT evntxt], ...
+ 'color', Eventcolors{ event2plot(index) }, ...
+ 'horizontalalignment', 'left',...
+ 'rotation',90,'FontSize',FonsizeDefault);
+ end
+ catch, end
+
+ % draw duration is not 0
+ % ----------------------
+ % if EventOnsetdur && ~isempty(Eventlatencyend) ...
+ % && Eventwidths( event2plot(index) ) ~= 2.5 % do not plot length of boundary events
+ % tmplatend = Eventlatencyend(event2plot(index))-lowlim-1;
+ % if tmplatend ~= 0
+ % tmplim = ylims;
+ % tmpcol = Eventcolors{ event2plot(index) };
+ % h = patch(myeegviewer, [ tmplat tmplatend tmplatend tmplat ], ...
+ % [ tmplim(1) tmplim(1) tmplim(2) tmplim(2) ], ...
+ % tmpcol ); % this argument is color
+ % set(h, 'EdgeColor', 'none')
+ % end
+ % end
+ end
+else % JavierLC
+ MAXEVENTSTRING = 10; % default
+ % AXES_POSITION = [0.0964286 0.15 0.842 0.75-(MAXEVENTSTRING-5)/100];
+end
+
+
+DEFAULT_GRID_SPACING =Winlength/5;
+
+% if StackFlag==1
+% AmpScale=0;
+% end
+
+% Ampsc = AmpScale*[1:PlotNum]';
+% -------------------------------------------------------------------------
+% -----------------draw EEG wave if any------------------------------------
+% -------------------------------------------------------------------------
+leftintv = [];
+%%Plot continuous EEG
+tmpcolor = [ 0 0 0.4 ];
+if ndims(EEG.data)==2
+ if ~isempty(data) && PlotNum~=0
+
+ for ii = size(data,1):-1:1
+ try
+ plot(myeegviewer, (data(ii,lowlim:highlim)+ Ampsc(size(data,1)-ii+1)-meandata(ii))' , ...
+ 'color', Colorgbwave(ii,:), 'clipping','on','LineWidth',0.75);%%
+ catch
+ plot(myeegviewer, (data(ii,lowlim:highlim)+ Ampsc(size(data,1)-ii+1)-meandata(ii))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',0.75);%%
+ end
+ end
+ set(myeegviewer,'TickDir', 'in','LineWidth',1);
+ %%xtick
+ set(myeegviewer, 'Xlim',[1 Winlength*multiplier+1],...
+ 'XTick',[1:multiplier*DEFAULT_GRID_SPACING:Winlength*multiplier+1]);
+ set(myeegviewer, 'XTickLabel', num2str((Startimes:DEFAULT_GRID_SPACING:Startimes+Winlength)'));
+
+ %%
+ %%-----------------plot scale------------------
+ leftintv = Winlength*multiplier+1;
+ else
+ set(myeegviewer, 'XTick', [], 'YTick', [],'Box','off', 'Color','none','xcolor','none','ycolor','none');
+ end
+end
+
+%%------------------------------plot single-trial EEG----------------------
+%%Thanks for the eeglab developers so that we can borrow their codes
+isfreq = 0;
+Limits = [EEG.times(1),EEG.times(end)];
+Srate = EEG.srate;
+Freqlimits = [];
+if EEG.trials>1
+ if ~isempty(data) && PlotNum~=0
+ % plot trial limits
+ % -----------------
+ tmptag = [lowlim:highlim];
+ tmpind = find(mod(tmptag-1,Trialstag) == 0);
+ % for index = tmpind
+ % plot(ax0, [tmptag(index)-lowlim tmptag(index)-lowlim], [0 1], 'b--');
+ % end
+ alltag = tmptag(tmpind);
+ if isempty(tmpind)
+ epochNum = 0;
+ else
+ epochNum = numel(setdiff(tmpind,[0 1 numel(tmptag)]));
+ end
+ % compute epoch number
+ % --------------
+ alltag1 = alltag;
+ if ~isempty(tmpind)
+ tagnum = (alltag1-1)/Trialstag+1;
+ for ii = 1:numel(tmpind)
+ alltag1(ii) = alltag1(ii)+(ii-1)*GapSize;
+ end
+ for ii = 1:numel(tagnum)
+ text(myeegviewer, [alltag1(ii)-lowlim+Trialstag/2],ylims(2)+1.1, [32,num2str(tagnum(ii))], ...
+ 'color', 'k','FontSize',FonsizeDefault, ...
+ 'horizontalalignment', 'left','rotation',90); %%
+ set(myeegviewer,'Xlim',[1 (Winlength*multiplier+epochNum*GapSize)]);
+ end
+ end
+
+ %%add the gap between epochs if any
+ Epochintv = [];
+
+ if ~isempty(tmpind)
+ if (numel(tmpind)==1 && tmpind(end) == numel(tmptag)) || (numel(tmpind)==1 && tmpind(1) == 1)
+ dataplot = data(:,lowlim:highlim);
+ Epochintv(1,1) =1;
+ Epochintv(1,2) =numel(lowlim:highlim);
+ else
+ tmpind = unique(setdiff([0,tmpind, numel(tmptag)],1));
+ dataplotold = data(:,lowlim:highlim);
+ dataplot_new = [];
+ for ii = 2:numel(tmpind)
+ GapLeft = tmpind(ii-1)+1;
+ GapRight = tmpind(ii);
+ if GapLeft<1
+ GapLeft =1;
+ end
+ if GapRight > numel(tmptag)
+ GapRight = numel(tmptag);
+ end
+ dataplot_new = [dataplot_new,dataplotold(:,GapLeft:GapRight),nan(size(dataplotold,1),GapSize)];
+ Epochintv(ii-1,1) = GapLeft+(ii-2)*GapSize;
+ Epochintv(ii-1,2) = GapRight+(ii-2)*GapSize;
+ end
+ if ~isempty(dataplot_new)
+ dataplot = dataplot_new;
+ else
+ dataplot = dataplotold;
+ end
+ end
+ end
+
+ %%-----------plot background color for trias with artifact---------
+ %%highlight waves with labels
+ Value_adjust = floor(Startimes+1);
+ if Value_adjust<1
+ Value_adjust=1;
+ end
+ tagnum = unique([Value_adjust,tagnum]);
+
+ try trialsMakrs = EEG.reject.rejmanual(tagnum);catch trialsMakrs = zeros(1,numel(tagnum)) ; end
+ try trialsMakrschan = EEG.reject.rejmanualE(:,tagnum);catch trialsMakrschan = zeros(EEG.nbchan,numel(tagnum)) ; end
+ tmpcolsbgc = [1 1 0.783];
+ if ~isempty(Epochintv)
+ for jj = 1:size(Epochintv,1)
+ [xpos,~]=find(trialsMakrschan(:,jj)==1);
+ if jj<= numel(trialsMakrs) && ~isempty(xpos)
+ if trialsMakrs(jj)==1
+ patch(myeegviewer,[Epochintv(jj,1),Epochintv(jj,2),Epochintv(jj,2),Epochintv(jj,1)],...
+ [ylims(1),ylims(1),ylims(end),ylims(end)],tmpcolsbgc,'EdgeColor','none','FaceAlpha',.5);
+ %%highlight the wave if the channels exist
+ if chaNum~=0
+ ChanArray = reshape(ChanArray,1,numel(ChanArray));
+ [~,ypos1]=find(ChanArray==xpos);
+ if ~isempty(ypos1)
+ for kk = 1:numel(ypos1)
+ dataChan = nan(1,size(dataplot,2));
+ dataChan (1,Epochintv(jj,1):Epochintv(jj,2)) = dataplot(ypos1(kk),Epochintv(jj,1):Epochintv(jj,2));
+ dataChan1= nan(1,size(dataplot,2));
+ dataChan1 (1,Epochintv(jj,1):Epochintv(jj,1)) = dataplot(ypos1(kk),Epochintv(jj,1):Epochintv(jj,1));
+ try
+ plot(myeegviewer, (dataChan+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))' , ...
+ 'color', Colorgbwave(ypos1(kk),:), 'clipping','on','LineWidth',1.5);%%
+
+ plot(myeegviewer, (dataChan1+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))' , ...
+ 'color', Colorgbwave(ypos1(kk),:), 'clipping','on','LineWidth',1.5,'Marker' ,'s','MarkerSize',8,...
+ 'MarkerEdgeColor',Colorgbwave(ypos1(kk),:),'MarkerFaceColor',Colorgbwave(ypos1(kk),:));%%
+ catch
+ plot(myeegviewer, (dataChan+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',1.5);%%
+ plot(myeegviewer, (dataChan1+ Ampsc(size(dataplot,1)-ypos1(kk)+1)-meandata(ypos1(kk)))', ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',1.5,'Marker' ,'s','MarkerSize',8,...
+ 'MarkerEdgeColor',Colorgbwave(ypos1(kk),:),'MarkerFaceColor',Colorgbwave(ypos1(kk),:));%%
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ %%
+ for ii = size(dataplot,1):-1:1
+ try
+ plot(myeegviewer, (dataplot(ii,:)+ Ampsc(size(dataplot,1)-ii+1)-meandata(ii))' + (PlotNum+1)*(OldAmpScale-AmpScale)/2, ...
+ 'color', Colorgbwave(ii,:), 'clipping','on','LineWidth',0.75);%%
+ catch
+ plot(myeegviewer, (dataplot(ii,:)+ Ampsc(size(dataplot,1)-ii+1)-meandata(ii))' + (PlotNum+1)*(OldAmpScale-AmpScale)/2, ...
+ 'color', tmpcolor, 'clipping','on','LineWidth',0.75);%%
+ end
+ end
+
+ %------------------------Xticks------------------------------------
+ tagpos = [];
+ tagtext = [];
+ if ~isempty(alltag)
+ alltag = [alltag(1)-Trialstag alltag alltag(end)+Trialstag]; % add border trial limits
+ else
+ alltag = [ floor(lowlim/Trialstag)*Trialstag ceil(highlim/Trialstag)*Trialstag ]+1;
+ end
+
+ nbdiv = 20/Winlength; % approximative number of divisions
+ divpossible = [ 100000./[1 2 4 5] 10000./[1 2 4 5] 1000./[1 2 4 5] 100./[1 2 4 5 10 20]]; % possible increments
+ [tmp indexdiv] = min(abs(nbdiv*divpossible-(Limits(2)-Limits(1)))); % closest possible increment
+ incrementpoint = divpossible(indexdiv)/1000*Srate;
+
+ % tag zero below is an offset used to be sure that 0 is included
+ % in the absicia of the data epochs
+ if Limits(2) < 0, tagzerooffset = (Limits(2)-Limits(1))/1000*Srate+1;
+ else tagzerooffset = -Limits(1)/1000*Srate;
+ end
+ if tagzerooffset < 0, tagzerooffset = 0; end
+
+ for i=1:length(alltag)-1
+ if ~isempty(tagpos) && tagpos(end)-alltag(i)<2*incrementpoint/3
+ tagpos = tagpos(1:end-1);
+ end
+ if ~isempty(Freqlimits)
+ tagpos = [ tagpos linspace(alltag(i),alltag(i+1)-1, nbdiv) ];
+ else
+ if tagzerooffset ~= 0
+ tmptagpos = [alltag(i)+tagzerooffset:-incrementpoint:alltag(i)];
+ else
+ tmptagpos = [];
+ end
+ tagpos = [ tagpos [tmptagpos(end:-1:2) alltag(i)+tagzerooffset:incrementpoint:(alltag(i+1)-1)]];
+ end
+ end
+
+ % find corresponding epochs
+ % -------------------------
+ if ~isfreq
+ tmplimit = Limits;
+ tpmorder = 1E-3;
+ else
+ tmplimit =Freqlimits;
+ tpmorder = 1;
+ end
+ tagtext = eeg_point2lat(tagpos, floor((tagpos)/Trialstag)+1, Srate, tmplimit,tpmorder);
+
+ %%adjust xticks
+ EpochFlag = floor((tagpos)/Trialstag)+1;%%
+
+ EpochFlag = reshape(EpochFlag,1,numel(EpochFlag));
+ xtickstr = tagpos-lowlim+1;
+ [xpos,ypos] = find(xtickstr>0);
+ if ~isempty(ypos)
+ EpochFlag =EpochFlag(ypos);
+ xtickstr = xtickstr(ypos);
+ tagtext = tagtext(ypos);
+ end
+
+ EpochFlagunique =unique(setdiff(EpochFlag,0));
+ if numel(EpochFlagunique)~=1
+ for ii = 2:numel(EpochFlagunique)
+ [xpos,ypos]= find(EpochFlag==EpochFlagunique(ii));
+ if ~isempty(ypos)
+ xtickstr(ypos) = xtickstr(ypos)+(EpochFlagunique(ii)-EpochFlagunique(1))*GapSize;%*(1000/Srate);
+ end
+ end
+ end
+ set(myeegviewer, 'Xlim',[1 (Winlength*multiplier+epochNum*GapSize)],...
+ 'XTick',xtickstr,...
+ 'XTickLabel', tagtext,...
+ 'FontWeight','normal',...
+ 'xaxislocation', 'bottom','FontSize',FonsizeDefault);
+ XTickLabel = cellstr(myeegviewer.XTickLabel);
+ for Numofxtick = 1:length(XTickLabel)
+ if strcmpi(XTickLabel{Numofxtick,:},'-0')
+ XTickLabel{Numofxtick} = '0';
+ end
+ end
+ set(myeegviewer,'XTickLabel',XTickLabel);
+ %%
+ %%-----------------plot scale------------------
+ leftintv = (Winlength*multiplier+epochNum*GapSize);
+ else
+ set(myeegviewer, 'XTick', [], 'YTick', [],'Box','off', 'Color','none','xcolor','none','ycolor','none');
+ end
+end
+
+
+%%
+%%----------------------------plot y scale---------------------------------
+if ~isempty(data) && PlotNum~=0 && ~isempty(leftintv)
+ ytick_bottom = myeegviewer.TickLength(1)*diff(myeegviewer.XLim);
+ % xtick_bottom = myeegviewer.TickLength(1)*diff(myeegviewer.YLim);
+ leftintv = leftintv+ytick_bottom*2.5;
+ rightintv = leftintv;
+ if ICdispFlag~=0
+ line(myeegviewer,[leftintv,rightintv],[ylims(1) AmpICNew+ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ line(myeegviewer,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(1) ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ line(myeegviewer,[leftintv-ytick_bottom,rightintv+ytick_bottom],[AmpICNew+ylims(1) AmpICNew+ylims(1)],'color','k','LineWidth',1, 'clipping','off');
+ text(myeegviewer,leftintv,((ylims(2)-ylims(1))/43+AmpICNew+ylims(1)), [num2str(AmpIC),32,'\muV'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ text(myeegviewer,leftintv,((ylims(2)-ylims(1))/20+AmpICNew+ylims(1)), ['ICs'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ end
+ if EEGdispFlag~=0
+ line(myeegviewer,[leftintv,rightintv],[ylims(end)-AmpScale ylims(end)],'color','k','LineWidth',1, 'clipping','off');
+ line(myeegviewer,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(end)-AmpScale ylims(end)-AmpScale],'color','k','LineWidth',1, 'clipping','off');
+ line(myeegviewer,[leftintv-ytick_bottom,rightintv+ytick_bottom],[ylims(end) ylims(end)],'color','k','LineWidth',1, 'clipping','off');
+ text(myeegviewer,leftintv,(ylims(2)-ylims(1))/43+ylims(end), [num2str(AmpScale),32,'\muV'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ text(myeegviewer,leftintv,(ylims(2)-ylims(1))/20+ylims(end), ['Chans'],'HorizontalAlignment', 'center','FontSize',FonsizeDefault);
+ end
+end
+
+%%---------------------------ytick ticklabels------------------------------
+if ~isempty(data) && PlotNum~=0
+ if chaNum==0
+ ChanArray = [];
+ end
+ set(myeegviewer, 'ylim',[ylims(1) ylims(end)],'YTick',[ylims(1) Ampscold']);
+ [YLabels,chaName,ICName] = f_eeg_read_chan_IC_names(EEG.chanlocs,ChanArray,ICArray,ChanLabel);
+ YLabels = flipud(char(YLabels,''));
+ set(myeegviewer,'YTickLabel',cellstr(YLabels),...
+ 'TickLength',[.005 .005],...
+ 'Color','none',...
+ 'XColor','k',...
+ 'YColor','k',...
+ 'FontWeight','normal',...
+ 'TickDir', 'in',...
+ 'LineWidth',0.5,'FontSize',FonsizeDefault);%%,'HorizontalAlignment','center'
+ count=0;
+ for ii = length(myeegviewer.YTickLabel):-1:2
+ count = count+1;
+ Cellsing = strrep(myeegviewer.YTickLabel{ii},'_','\_');
+ myeegviewer.YTickLabel{ii} = strcat('\color[rgb]{',num2str(Colorgbwave(count,:)),'}', Cellsing);
+ end
+end
+end
+
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_duplicateeg.m b/studio_functions/Functions/EStudio/EEG Tab/pop_duplicateeg.m
new file mode 100644
index 00000000..ba0b1454
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_duplicateeg.m
@@ -0,0 +1,193 @@
+% PURPOSE: pop_duplicateeg.m
+% duplicate ERPset
+%
+
+% FORMAT:
+% [EEG, erpcom] = pop_duplicateeg( EEG, 'ChanArray',ChanArray,...
+% 'Saveas', 'off', 'History', 'gui');
+
+% Inputs:
+%
+%EEG -EEG structure
+%ChanArray -index(es) of channels
+
+
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Dec. 2024
+
+
+
+
+function [EEG, erpcom] = pop_duplicateeg(EEG, varargin)
+erpcom = '';
+
+if nargin < 1
+ help pop_duplicateeg
+ return
+end
+if isempty(EEG)
+ msgboxText = 'Cannot duplicate an empty EEGset';
+ title = 'ERPLAB: pop_duplicateeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(EEG(1).data)
+ msgboxText = 'Cannot duplicate an empty EEGset';
+ title = 'ERPLAB: pop_duplicateeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+if length(EEG)>1
+ msgboxText = 'Cannot duplicate multiple EEGsets!';
+ title = 'ERPLAB: pop_duplicateeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if nargin==1
+ def = erpworkingmemory('pop_duplicateeg');
+ if isempty(def)
+ def = {[]};
+ end
+ ChanArray =def{1};
+
+ def = f_ERP_duplicate(EEG,ChanArray);
+ if isempty(def)
+ return;
+ end
+ ChanArray = def{1};
+ erpworkingmemory('pop_duplicateeg',def);
+ %
+ % Somersault
+ %
+ [EEG, erpcom] = pop_duplicateeg( EEG, 'ChanArray',ChanArray,...
+ 'Saveas', 'off', 'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('EEG');
+% option(s)
+p.addParamValue('ChanArray', [],@isnumeric);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(EEG, varargin{:});
+
+ChanArray = p.Results.ChanArray;
+if isempty(ChanArray) || any(ChanArray(:)>EEG.nbchan) || any(ChanArray(:)<=0)
+ ChanArray = [[1:EEG.nbchan]];
+end
+
+
+if ~isempty(ChanArray)
+ EEG.saved = 'no';
+ EEG.filepath = '';
+ chanDelete = setdiff([1:EEG.nbchan],ChanArray);
+ if ~isempty(chanDelete)
+ count = 0;
+ for ii = chanDelete
+ count = count+1;
+ ChanArrayStr{count} = EEG.chanlocs(ii).labels;
+ end
+ EEG = pop_select( EEG, 'rmchannel', ChanArrayStr);
+ % EEG = eeg_checkset(EEG);
+ end
+end
+
+
+
+if strcmpi(p.Results.Saveas,'on')
+ 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
+
+EEG.saved = 'no';
+
+%
+% History
+%
+
+skipfields = {'EEG', 'Saveas','History'};
+fn = fieldnames(p.Results);
+erpcom = sprintf( '%s = pop_duplicateeg( %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);
+
+%
+% Save ERPset from GUI
+%
+if issaveas
+ [EEG, ~] = pop_saveset( EEG, 'filename',EEG.filename,'filepath',EEG.filepath);
+end
+
+
+
+% get history from script. EEG
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ EEG = eegh(erpcom, EEG);
+ case 3
+ % implicit
+ otherwise %off or none
+ erpcom = '';
+ return
+end
+return
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_editdatachanlocs.m b/studio_functions/Functions/EStudio/EEG Tab/pop_editdatachanlocs.m
new file mode 100644
index 00000000..5a763221
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_editdatachanlocs.m
@@ -0,0 +1,267 @@
+% PURPOSE: pop_editdatachanlocs.m is to edit the channel locations
+%
+%
+
+% FORMAT :
+%
+% pop_editdatachanlocs(ALLEEG, CURRENTSET, parameters);
+%
+
+% ALLEEG - structure array of ALLEEG/ERP structures
+% CURRENTSET - Index for current EEGset/ERPset
+
+
+
+% The available parameters are as follows:
+%
+%ChanArray -index(es) for the selected channels
+%Chanlocs - channel locations for the selected channels
+
+
+
+%%Output
+%%EEG -EEG/ERP structure with the changed chan locations of the selected channels
+
+
+%%Example:
+%EEG = pop_editdatachanlocs( ALLEEG, 2, 'ChanArray', [1 2 3], 'Chanlocs', chanlocs, 'History', 'implicit' );
+
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Sep. 2023
+
+
+
+function [EEG,eegcom] = pop_editdatachanlocs(ALLEEG,CURRENTSET,varargin)
+
+eegcom = '';
+if nargin < 1
+ help pop_editdatachanlocs
+ return;
+end
+
+if isempty(ALLEEG)%%
+ beep;
+ disp('ALLEEG is empty');
+ return;
+end
+
+if nargin< 3
+ %%Do we need to create a GUI that the user can use it to define the
+ %%desired parameters?
+
+ if nargin< 2 || isempty(CURRENTSET) || numel(CURRENTSET)~=1 || CURRENTSET>length(ALLEEG) || CURRENTSET<=0
+ CURRENTSET = length(ALLEEG);
+ end
+ EEG = ALLEEG(CURRENTSET);
+ if ~isfield(EEG,'chanlocs')
+ beep;
+ disp('The current dataset donot have chanlocs field');
+ return;
+ end
+ chanlocs = EEG.chanlocs;
+ if ~isfield(chanlocs,'labels')
+ beep;
+ disp('There is no labels for chanlocs for the current dataset');
+ return;
+ end
+
+ ChanArray = [1:length(EEG.chanlocs)];
+
+
+ titleName= ['Dataset',32,num2str(CURRENTSET),': Add/Edit Channel locations'];
+ EEGIN = EEG;
+ EEGIN.chanlocs = EEG.chanlocs(ChanArray);
+ app = feval('f_editchan_gui',EEGIN,titleName);
+ waitfor(app,'Finishbutton',1);
+ try
+ EEGINOUT = app.output; %NO you don't want to output EEG with edited channel locations, 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(EEGINOUT)
+ disp('User selected Cancel')
+ return
+ end
+
+ Chanlocs = EEGINOUT.chanlocs;
+ %%add suffix
+ try
+ ALLEEG(CURRENTSET).setname = [ALLEEG(CURRENTSET).setname,'_editchan'];
+ catch
+ ALLEEG(CURRENTSET).erpname = [ALLEEG(CURRENTSET).erpname,'_editchan'];
+ end
+ [EEG, eegcom] = pop_editdatachanlocs(ALLEEG,CURRENTSET,'ChanArray',ChanArray,'Chanlocs',Chanlocs,'History', 'gui');
+ pause(0.1);
+ return;
+end
+
+
+%
+% Parsing inputs
+%
+% colordef = getcolorcellerps; %{'k' 'r' 'b' 'g' 'c' 'm' 'y' 'w'};% default colors
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+p.addRequired('CURRENTSET');
+
+%Option(s)
+p.addParamValue('ChanArray',[],@isnumeric);
+p.addParamValue('Chanlocs','', @isstruct);
+
+p.addParamValue('History', '', @ischar); % history from scripting
+
+p.parse(ALLEEG,CURRENTSET,varargin{:});
+
+p_Results = p.Results;
+
+if strcmpi(p_Results.History,'command')
+ shist = 4;%%Show Maltab command only and donot plot the wave
+elseif 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(ALLEEG)%%
+ beep;
+ disp('ALLEEG is empty');
+ return;
+end
+
+
+if isempty(CURRENTSET) || numel(CURRENTSET)~=1 || CURRENTSET>length(ALLEEG) || CURRENTSET<=0
+ CURRENTSET = length(ALLEEG);
+end
+
+EEG = ALLEEG(CURRENTSET);
+if ~isfield(EEG,'chanlocs')
+ beep;
+ disp('The current dataset donot have chanlocs field');
+ return;
+end
+chanlocs = EEG.chanlocs;
+if ~isfield(chanlocs,'labels')
+ beep;
+ disp('There is no labels for chanlocs for the current dataset');
+ return;
+end
+
+
+%%channel array
+qchanArray = p_Results.ChanArray;
+nbchan = length(EEG.chanlocs);
+if isempty(qchanArray) || min(qchanArray(:))>nbchan || max(qchanArray(:))>nbchan || min(qchanArray(:))<=0
+ qchanArray = [1:nbchan];
+end
+
+
+
+%%IC array (the default is empty, that is, donot display ICs)
+qChanlocsnew = p_Results.Chanlocs;
+if isempty(qChanlocsnew)
+ disp('Chanlocs is empty');
+ return;
+end
+
+%
+%%adjust the number of channels and channel names
+for Numofchan = 1:numel(qchanArray)
+ try
+ qChanlocsnew(Numofchan) = qChanlocsnew(Numofchan);
+ catch
+ qChanlocsnew(Numofchan) = EEG.chanlocs(qchanArray(Numofchan));
+ fprintf(2,['\n Warning: Location for channel ',32,num2str(qchanArray(Numofchan)),32,'was not defined, we threfore used its original one.\n']);
+ end
+end
+
+
+%%--------------change the channel names-----------------------------------
+for Numofchan = 1:numel(qchanArray)
+ fprintf(['Chan',32,num2str(qchanArray(Numofchan)),': Location was edited.\n']);
+ EEG.chanlocs(qchanArray(Numofchan)) = qChanlocsnew(Numofchan);
+end
+
+
+
+%%history
+fn = fieldnames(p.Results);
+skipfields = {'ALLEEG','CURRENTSET'};
+if isfield(EEG,'datatype') && strcmpi(EEG.datatype,'ERP')
+ eegcom = sprintf( 'ERP = pop_editdatachanlocs( %s %s', 'ALLERP,',num2str(CURRENTSET));
+else
+eegcom = sprintf( 'EEG = pop_editdatachanlocs( %s %s', 'ALLEEG,',num2str(CURRENTSET));
+end
+for q=1:length(fn)
+ fn2com = fn{q}; % inputname
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com); % input value
+ if ~isempty(fn2res)
+ if isstruct(fn2res)
+ eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, fn2com);
+ elseif iscell(fn2res)
+ nn = length(fn2res);
+ eegcom = sprintf( '%s, ''%s'', {''%s'' ', eegcom, fn2com, fn2res{1});
+ for ff=2:nn
+ eegcom = sprintf( '%s, ''%s'' ', eegcom, fn2res{ff});
+ end
+ eegcom = sprintf( '%s}', eegcom);
+ elseif isnumeric(fn2res)
+
+ if size(fn2res,1)==1
+ fn2res_trans = char(num2str(fn2res));
+ else
+ fn2res_trans = vect2colon(fn2res);
+ end
+ fn2res = fn2res_trans;
+ eegcom = sprintf( '%s, ''%s'', [%s', eegcom,fn2com,fn2res);
+ eegcom = sprintf( '%s]', eegcom);
+ else
+ % if ~ismember_bc2(fn2com,{'xscale','yscale'})
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ % else
+ % xyscalestr = sprintf('[ %.1f %.1f %s ]', fn2res(1), fn2res(2), vect2colon(fn2res(3:end),'Delimiter','off'));
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, xyscalestr);
+ % end
+ end
+ end
+ end
+end
+
+eegcom = sprintf( '%s );', eegcom);
+% get history from script. ERP
+% shist = 1;
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(eegcom);
+ case 2 % from script
+ for i=1:length(ALLEEG)
+ ALLEEG(i) = erphistory(ALLEEG(i), [], eegcom, 1);
+ end
+ case 3
+ % implicit
+ case 4
+ displayEquiComERP(eegcom);
+
+ otherwise %off or none
+ eegcom = '';
+ return
+end
+
+return;
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_ar_summary.m b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_ar_summary.m
new file mode 100644
index 00000000..7e705d42
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_ar_summary.m
@@ -0,0 +1,48 @@
+%%This function is to display the summary of trial information
+%
+% FORMAT :
+%
+% pop_eeg_ar_summary(ALLEEG,EEGArray);
+%
+% ALLEEG - structure array of EEG structures
+% EEGArray -index of eegsets
+
+
+
+
+% *** This function is part of ERPLAB Studio Toolbox ***
+% Author: Guanghui Zhang & Steven Luck
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Apr. 2024
+
+
+
+function eegcom = pop_eeg_ar_summary(ALLEEG,EEGArray)
+
+eegcom = '';
+if nargin < 1 || nargin >2
+ help pop_eeg_ar_summary
+ return
+end
+if nargin < 2
+ EEGArray = [1:length(ALLEEG)];
+end
+if isempty(EEGArray) || any(EEGArray(:)>length(ALLEEG)) || any(EEGArray(:)<1)
+ EEGArray = [1:length(ALLEEG)];
+end
+if isempty(ALLEEG)
+ msgboxText = ['ALLEEG is empty.'];
+ title = 'ERPLAB Studio: pop_eeg_ar_summary() inputs';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+if ~isempty(EEGArray)
+ app = feval('EEG_trial_rejection_sumr',ALLEEG(EEGArray),1);
+ waitfor(app,'Finishbutton',1);
+end
+EEGArraystr= vect2colon(EEGArray);
+eegcom = sprintf('eegcom = pop_eeg_ar_summary(ALLEEG,%s);',EEGArraystr);
+end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_eventlist_view.m b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_eventlist_view.m
new file mode 100644
index 00000000..973c23ff
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_eventlist_view.m
@@ -0,0 +1,144 @@
+% PURPOSE: pop_eeg_eventlist_view.m
+% display eventlist
+
+% FORMAT:
+% [ALLEEG, erpcom] = pop_eeg_eventlist_view( ALLEEG, 'EEGArray',EEGArray,...
+% 'Saveas', 'off', 'History', 'gui');
+
+% Inputs:
+%
+%ALLEEG -ALLEEG structure
+%EEGArray -index(es) of eegsets
+
+
+
+% *** This function is part of ALLEEGLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% May 2024
+
+
+
+
+function [ALLEEG, erpcom] = pop_eeg_eventlist_view(ALLEEG, varargin)
+erpcom = '';
+
+if nargin < 1
+ help pop_eeg_eventlist_view
+ return
+end
+if isempty(ALLEEG)
+ msgboxText = 'Cannot handle an empty EEGset';
+ title = 'ERPLAB: pop_eeg_eventlist_view() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(ALLEEG(1))
+ msgboxText = 'Cannot handle an empty EEGset';
+ title = 'ERPLAB: pop_eeg_eventlist_view() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+if nargin==1
+ EEGArray = [1:length(ALLEEG)];
+ [ALLEEG, erpcom] = pop_eeg_eventlist_view( ALLEEG, 'EEGArray',EEGArray,...
+ 'Saveas', 'off', 'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+% option(s)
+p.addParamValue('EEGArray', [],@isnumeric);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLEEG, varargin{:});
+
+
+EEGArray = p.Results.EEGArray;
+
+if isempty(EEGArray) || any(EEGArray(:)>length(ALLEEG)) || any(EEGArray(:)<1)
+ EEGArray = [1:length(ALLEEG)];
+end
+
+feval("EEG_evenlist_gui",ALLEEG(EEGArray));
+
+if strcmpi(p.Results.Saveas,'on')
+ 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
+
+
+
+
+%
+% History
+%
+
+skipfields = {'ALLEEG', 'Saveas','History'};
+fn = fieldnames(p.Results);
+erpcom = sprintf( '%s = pop_eeg_eventlist_view( %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') && ~strcmpi(fn2res,'no')
+ erpcom = sprintf( '%s, ''%s'', ''%s''', erpcom, fn2com, fn2res);
+ end
+ else
+ erpcom = sprintf( '%s, ''%s'', %s', erpcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ end
+ end
+ end
+end
+erpcom = sprintf( '%s );', erpcom);
+
+%
+% Save ALLEEGset from GUI
+%
+if issaveas
+ for ii = 1:length(ALLEEG)
+ [ALLEEG(ii), ~] = pop_saveset( ALLEEG(ii), 'filename',ALLEEG(ii).filename,'filepath',[ALLEEG(ii).filepath,filesep]);
+ end
+end
+
+
+% get history from script. ALLEEG
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ for ii = 1:length(EEGArray)
+ ALLEEG(EEGArray(ii)) = eegh(erpcom, ALLEEG(EEGArray(ii)));
+ end
+ case 3
+ % implicit
+ otherwise %off or none
+ erpcom = '';
+ return
+end
+return
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_save_trial_information.m b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_save_trial_information.m
new file mode 100644
index 00000000..83975938
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_eeg_save_trial_information.m
@@ -0,0 +1,287 @@
+%write trial information to .text or .xls file
+
+
+
+function eegcom = pop_eeg_save_trial_information(ALLEEG, varargin)
+
+eegcom = '';
+if nargin<1
+ help pop_eeg_save_trial_information
+ return
+end
+
+if nargin==1
+ if isempty(ALLEEG)
+ msgboxText = ['pop_eeg_save_trial_information: ALLEEG is empty!'];
+ titlNamerro = 'Error for pop_eeg_save_trial_information';
+ estudio_warning(msgboxText,titlNamerro);
+ return;
+ end
+ EEGArray = [1:length(ALLEEG)];
+ binArray = [1:ALLEEG(1).EVENTLIST.nbin];
+
+ eegcom = pop_eeg_save_trial_information(ALLEEG, 'EEGArray',EEGArray,'binArray',binArray,'History', 'gui');
+ pause(0.01);
+ return
+end
+
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+
+p.addParamValue('EEGArray', [], @isnumeric); %
+p.addParamValue('binArray', [], @isnumeric);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLEEG, varargin{:});
+p_Results = p.Results;
+
+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
+
+
+BackERPLABcolor = [1 0.9 0.3]; % ERPLAB main window background
+question = 'In order to see your summary, What would you like to do?';
+title = 'Artifact detection summary';
+oldcolor = get(0,'DefaultUicontrolBackgroundColor');
+set(0,'DefaultUicontrolBackgroundColor',BackERPLABcolor)
+button = questdlg(question, title,'Save in a .txt file','Save in a .xls file', 'Cancel','Cancel');
+set(0,'DefaultUicontrolBackgroundColor',oldcolor);
+
+if strcmpi(button,'Save in a .txt file')
+ write_spreadsheet=1;
+ formatname = {'*.txt'};
+elseif strcmpi(button,'Save in a .xls file')
+ write_spreadsheet=2;
+ formatname = {'*.xls';'*.xlsx'};
+else
+ return;
+end
+
+ERPtooltype = erpgettoolversion('tooltype');
+if strcmpi(ERPtooltype,'EStudio')
+ pathstr= estudioworkingmemory('EEG_save_folder');
+ if isempty(pathstr)
+ pathstr = pwd;
+ end
+else
+ pathstr = pwd;
+end
+
+namedef ='EEG_Trial_information';
+[erpfilename, erppathname, indxs] = uiputfile(formatname, ...
+ ['Export trial informationb for epoched EEG'],...
+ fullfile(pathstr,namedef));
+if isequal(erpfilename,0)
+ return
+end
+if isequal(erpfilename,0)
+ return
+end
+
+[pathstr, erpfilename, ext] = fileparts(erpfilename) ;
+if write_spreadsheet==1
+ ext = '.txt';
+else
+ if indxs==1
+ ext = '.xls';
+ elseif indxs==2
+ ext = '.xlsx';
+ else
+ ext = '.xls';
+ end
+end
+
+erpFilename = char(strcat(erppathname,erpfilename,ext));
+
+delete(erpFilename);%%delete the exist file
+
+qEEGArray = p_Results.EEGArray;
+EEGArray = qEEGArray;
+if isempty(qEEGArray) || any(qEEGArray(:)>length(ALLEEG)) || any(qEEGArray(:)<1)
+ qEEGArray = 1:length(ALLEEG);
+end
+
+qbinArray = p_Results.binArray;
+binArray = qbinArray;
+
+for Numoferp = 1:numel(qEEGArray)
+
+ EEG = ALLEEG(qEEGArray(Numoferp));
+ [EEG, tprej, acce, rej, histoflags, com] = pop_summary_AR_eeg_detection(EEG, 'none');
+ ERP = pop_averager(EEG, 'Criterion', 'good', 'DSindex', 1, 'SEM', 'off');
+
+ if isempty(qbinArray) || any(qbinArray(:)>ERP.nbin) || any(qbinArray(:)<1)
+ qbinArray = [1:ERP.nbin];
+ end
+ %%txt file
+ if write_spreadsheet==1
+ if Numoferp==1
+ fileID = fopen(erpFilename,'w+');
+ end
+ fprintf(fileID,'%s\n','*');
+ fprintf(fileID,'%s\n','**');
+ columName1{1,1} = ['Name:',32,EEG.setname];
+ fprintf(fileID,'%s\n\n\n',columName1{1,:});
+
+ %%Table title
+ formatSpec2 =['%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\n'];
+ columName2 = {'Bin', 'Total trials','Included trials', 'Rejected trials', 'Invalid trials','F2','F3','F4','F5','F6','F7','F8'};
+ fprintf(fileID,formatSpec2,columName2{1,:});
+ for ii = 1:length(qbinArray)
+ try
+ data{1,1} = [num2str(qbinArray(ii)),'.',ERP.bindescr{qbinArray(ii)}];
+ data{1,2} = [num2str(ERP.ntrials.accepted(qbinArray(ii))+ERP.ntrials.rejected(qbinArray(ii))+ERP.ntrials.invalid(qbinArray(ii)))];
+ data{1,3} = [num2str(ERP.ntrials.accepted(qbinArray(ii)))];
+ data{1,4} = [num2str(ERP.ntrials.rejected(qbinArray(ii)))];
+ data{1,5} = [num2str(ERP.ntrials.invalid(qbinArray(ii)))];
+ data{1,6} = [num2str(histoflags(ii,2))];%%F2
+ data{1,7} = [num2str(histoflags(ii,3))];%%F3
+ data{1,8} = [num2str(histoflags(ii,4))];
+ data{1,9} = [num2str(histoflags(ii,5))];
+ data{1,10} = [num2str(histoflags(ii,6))];
+ data{1,11} = [num2str(histoflags(ii,7))];
+ data{1,12} = [num2str(histoflags(ii,8))];
+ catch
+ data{1,1} = '';
+ data{1,3} = '';
+ data{1,4} = '';
+ data{1,5} = '';
+ data{1,6} = '';%%F2
+ data{1,7} = '';%%F3
+ data{1,8} = '';
+ data{1,9} = '';
+ data{1,10} = '';
+ data{1,11} = '';
+ data{1,12} = '';
+ end
+ fprintf(fileID,formatSpec2,data{1,:});
+ end
+
+ if Numoferp~=length(ALLEEG)
+ data1{1,1} = '';
+ data1{1,2} = '';
+ data1{1,3} = '';
+ data1{1,4} = '';
+ data1{1,5} = '';
+ data1{1,6} = '';%%F2
+ data1{1,7} = '';%%F3
+ data1{1,8} = '';
+ data1{1,9} = '';
+ data1{1,10} = '';
+ data1{1,11} = '';
+ data1{1,12} = '';
+ formatSpec3 =['%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t',32,'%s\t','%s\n\n\n\n\n\n'];
+ fprintf(fileID,formatSpec3,data1{1,:});
+ end
+ end
+
+ %%xls file
+ if write_spreadsheet==2
+ data = [];
+ binname = '';
+ columName2 = {ERP.erpname,'Total trials','Included trials', 'Rejected trials', 'Invalid trials','F2','F3','F4','F5','F6','F7','F8'};
+ for ii = 1:length(qbinArray)
+ try
+ data(ii,1) = [ERP.ntrials.accepted(qbinArray(ii))+ERP.ntrials.rejected(qbinArray(ii))+ERP.ntrials.invalid(qbinArray(ii))];
+ data(ii,2) = [ERP.ntrials.accepted(qbinArray(ii))];
+ data(ii,3) = [ERP.ntrials.rejected(qbinArray(ii))];
+ data(ii,4) = [ERP.ntrials.invalid(qbinArray(ii))];
+ data(ii,5) = histoflags(ii,2);%%F2
+ data(ii,6) = histoflags(ii,3);%%F3
+ data(ii,7) = histoflags(ii,4);
+ data(ii,8) = histoflags(ii,5);
+ data(ii,9) = histoflags(ii,6);
+ data(ii,10) = histoflags(ii,7);
+ data(ii,11) = histoflags(ii,8);
+ catch
+ data(ii,1) = [];
+ data(ii,2) = [];
+ data(ii,3) = [];
+ data(ii,4) = [];
+ data(ii,5) = [];%%F2
+ data(ii,6) = [];%%F3
+ data(ii,7) = [];
+ data(ii,8) = [];
+ data(ii,9) = [];
+ data(ii,10) = [];
+ data(ii,11) = [];
+ end
+ try
+ binname{ii,1} = ERP.bindescr{qbinArray(ii)};
+ catch
+ binname{ii,1} = 'none';
+ end
+ end
+ if Numoferp==1
+ end
+ sheet_label_T = table(columName2);
+ sheetname = char(EEG.setname);
+ if length(sheetname)>31
+ sheetname = sheetname(1:31);
+ end
+ writetable(sheet_label_T,erpFilename,'Sheet',Numoferp,'Range','A1','WriteVariableNames',false,'Sheet',sheetname,"AutoFitWidth",false);
+ xls_d = table(binname,data);
+ writetable(xls_d,erpFilename,'Sheet',Numoferp,'Range','A2','WriteVariableNames',false,'Sheet',sheetname,"AutoFitWidth",false); % write data
+ end
+end
+
+if write_spreadsheet==1
+ fclose(fileID);
+end
+disp(['A new file for trial information was created at ' erpFilename ''])
+
+
+skipfields = {'ALLEEG', 'History'};
+
+if isempty(EEGArray)
+ skipfields = [skipfields,{'EEGArray'}];
+end
+
+if isempty(binArray)
+ skipfields = [skipfields,{'binArray'}];
+end
+
+fn = fieldnames(p.Results);
+eegcom = sprintf( 'eegcom = pop_eeg_save_trial_information( %s', 'ALLEEG');
+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') && ~strcmpi(fn2res,'no')
+ eegcom = sprintf( '%s, ''%s'', ''%s''', eegcom, fn2com, fn2res);
+ end
+ else
+ eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ end
+ end
+ end
+end
+eegcom = sprintf( '%s );', eegcom);
+
+% get history from script. ERP
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(eegcom);
+ case 2 % from script
+ for i=1:length(ALLEEG)
+ ALLEEG(i)= eegh(eegcom, ALLEEG(i));
+ end
+ case 3
+
+ otherwise %off or none
+ eegcom = '';
+ return
+end
+
+end
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_ploteegset.m b/studio_functions/Functions/EStudio/EEG Tab/pop_ploteegset.m
new file mode 100644
index 00000000..ad9e04d5
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_ploteegset.m
@@ -0,0 +1,405 @@
+% PURPOSE: pop_ploteegset.m
+% plot continuous/epoched EEG waves
+%
+
+
+%%FORMAT:
+% [EEG, eegcom] = pop_ploteegset(EEG,'ChanArray',ChanArray,'ICArray',ICArray,'Winlength',Winlength,...
+% 'Ampchan',Ampchan,'ChanLabel',ChanLabel,'Submean',Submean,'EventOnset',EventOnset,...
+% 'StackFlag',StackFlag,'NormFlag',NormFlag,'Startimes',Startimes,'figureName',figureName,'figSize',figSize,'History', 'gui');
+
+
+% Inputs:
+%
+%EEG -EEGSET
+%ChanArray -index(es) of channel(s) to plot ( 5 10 11 ...)
+%ICArray -index(es) of IC(s) to plot (1 2 5 3...). Please set
+% empty if you donot want to display ICs
+%Winlength -the length of time-wondow to display the wave e.g.,
+% 5s for continuous EEG; For epoched EEG, it is the
+% number of epochs, e.g., 5 epochs
+%Ampchan -Verticl amplitude scales for chans e.g., 50
+%ChanLabel -display channel names or numbers. 1 is name and 0 is
+% number
+%Submean -remove DC? 1 (yes) or 0 (no)
+%EventOnset -display events? 1(yes) or 0 (no)
+%StackFlag -stack the waves for different channels or ics. 1 or 0
+%NormFlag -normalize the data? 1 or 0
+%Startimes -the start time for the dispalyed data e.g.,from 2nd s
+%figureName - figure name
+%figSize -width and height for the figure e.g., [1800 900]
+
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% August 2023
+
+
+
+
+function [EEG,eegcom] = pop_ploteegset(EEG,varargin)
+
+eegcom = '';
+if nargin < 1
+ help pop_ploteegset
+ return;
+end
+
+if isempty(EEG)%%
+ beep;
+ disp('EEG is empty');
+ return;
+end
+
+if nargin==1
+ %%Do we need to create a GUI that the user can use it to define the
+ %%desired parameters?
+
+ %%channels that will be plotted
+ nbchan = EEG.nbchan;
+ ChanArray = 1:nbchan;
+
+ %%display ICs
+ ICArray = [];
+
+ %%window length for displayed EEG
+ Winlength=5;
+
+ %%vertical voltage
+ Ampchan = 50;
+ Ampic = 20;%%vertical voltage for ICs
+ bufftobo = 100;%%buffer at top and bottom
+ %%channel name (1) or number (0)
+ ChanLabel = 1;
+
+ %%remove DC for the displayed EEG?
+ Submean = 0;
+
+ %%Display events if any?
+ EventOnset = 1;
+
+ %%Stack on/off?
+ StackFlag = 0;
+
+ %%Norm on/off?
+ NormFlag = 0;
+
+ %%start time for displayed EEG data
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+
+ [ChanNum,Allsamples,tmpnb] = size(EEG.data);
+ Allsamples = Allsamples*tmpnb;
+ if ndims(EEG.data) > 2
+ multiplier = size(EEG.data,2);
+ else
+ multiplier = EEG.srate;
+ end
+
+ if isempty(Startimes) || Startimes<0 || Startimes>(ceil((Allsamples-1)/multiplier)-Winlength)
+ if ndims(EEG.data) ==3
+ Startimes=1;
+ else
+ Startimes=0;
+ end
+ end
+
+ %%figure name if any
+ figureName = EEG.setname;
+ %%Figure position
+ figSize = [];
+
+ [EEG, eegcom] = pop_ploteegset(EEG,'ChanArray',ChanArray,'ICArray',ICArray,'Winlength',Winlength,'bufftobo',bufftobo,...
+ 'Ampchan',Ampchan,'Ampic',Ampic,'ChanLabel',ChanLabel,'Submean',Submean,'EventOnset',EventOnset,...
+ 'StackFlag',StackFlag,'NormFlag',NormFlag,'Startimes',Startimes,'figureName',figureName,'figSize',figSize,'History', 'gui');
+ pause(0.1);
+ return;
+end
+
+%
+% Parsing inputs
+%
+% colordef = getcolorcellerps; %{'k' 'r' 'b' 'g' 'c' 'm' 'y' 'w'};% default colors
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('EEG');
+
+%Option(s)
+p.addParamValue('ChanArray',[],@isnumeric);
+p.addParamValue('ICArray',[], @isnumeric);
+p.addParamValue('Winlength',[], @isnumeric);
+p.addParamValue('Ampchan',[], @isnumeric);
+p.addParamValue('Ampic',[], @isnumeric);
+p.addParamValue('bufftobo',[], @isnumeric);
+p.addParamValue('ChanLabel',[], @isnumeric);
+p.addParamValue('Submean',[], @isnumeric);
+p.addParamValue('EventOnset',[], @isnumeric);
+p.addParamValue('StackFlag',[], @isnumeric);
+p.addParamValue('NormFlag',[], @isnumeric);
+p.addParamValue('Startimes',[], @isnumeric);
+p.addParamValue('figureName','', @ischar);
+p.addParamValue('figSize',[], @isnumeric);
+
+p.addParamValue('ErrorMsg', '', @ischar);
+p.addParamValue('History', '', @ischar); % history from scripting
+
+
+p.parse(EEG,varargin{:});
+
+p_Results = p.Results;
+
+if strcmpi(p_Results.History,'command')
+ shist = 4;%%Show Maltab command only and donot plot the wave
+elseif 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.ErrorMsg,'popup')
+ errormsgtype = 1; % open popup window
+else
+ errormsgtype = 0; % error in red at command window
+end
+
+if isempty(EEG)%%
+ beep;
+ disp('EEG is empty');
+ return;
+end
+
+
+%%channel array
+qchanArray = p_Results.ChanArray;
+nbchan = EEG.nbchan;
+if ~isempty(qchanArray)
+ if min(qchanArray(:))>nbchan || max(qchanArray(:))>nbchan || min(qchanArray(:))<=0
+ qchanArray = [1:nbchan];
+ end
+end
+
+%%IC array (the default is empty, that is, donot display ICs)
+qICArray = p_Results.ICArray;
+if isempty(EEG.icachansind)
+ qICArray = [];
+else
+ if ~isempty(qICArray) && (min(qICArray(:))> numel(EEG.icachansind) || max(qICArray(:))> numel(EEG.icachansind) || min(qICArray(:))<=0)
+ qICArray = [];
+ end
+end
+
+
+%%the window length
+qWinlength = p_Results.Winlength;
+if ~isempty(qWinlength) && numel(qWinlength)~=1
+ qWinlength = qWinlength(1);
+end
+if isempty(qWinlength) || numel(qWinlength)~=1 || min(qWinlength(:))<=0
+ qWinlength=5;
+end
+
+%%vertical amplitude scale for chans
+qAmpchan = p_Results.Ampchan;
+if ~isempty(qAmpchan) && numel(qAmpchan)~=1
+ qAmpchan = qAmpchan(1);
+end
+if isempty(qAmpchan)|| qAmpchan<=0
+ qAmpchan = 50;
+end
+
+
+%%vertical amplitude scale for ics
+qAmpic = p_Results.Ampic;
+if ~isempty(qAmpic) && numel(qAmpic)~=1
+ qAmpic = qAmpic(1);
+end
+if isempty(qAmpic)|| qAmpic<=0
+ qAmpic = 10;
+end
+
+%%buffer at top and bottom
+qbufftobo = p_Results.bufftobo;
+if isempty(qbufftobo) || numel(qbufftobo)~=1 || any(qbufftobo(:)<=0)
+ qbufftobo = 100;
+end
+
+
+
+%%channel with names (1) or numbers(0)
+qChanLabel = p_Results.ChanLabel;
+if ~isempty(qChanLabel) && numel(qChanLabel)~=1
+ qChanLabel = qChanLabel(1);
+end
+if isempty(qChanLabel) || (qChanLabel~=0 && qChanLabel~=1)
+ qChanLabel =1;
+end
+
+
+%%remove DCs from the displayed EEG data?
+qSubmean = p_Results.Submean;
+if ~isempty(qSubmean) && numel(qSubmean)~=1
+ qSubmean = qSubmean(1);
+end
+if isempty(qSubmean) || (qSubmean~=0 && qSubmean~=1)
+ qSubmean=0;
+end
+
+
+%%event onset or offset if any?
+qEventOnset = p_Results.EventOnset;
+if ~isempty(qEventOnset) && numel(qEventOnset)~=1
+ qEventOnset = qEventOnset(1);
+end
+if isempty(qEventOnset) || (qEventOnset~=0 && qEventOnset~=1)
+ qEventOnset =1;
+end
+
+%%stack on/off?
+qStackFlag = p_Results.StackFlag;
+if ~isempty(qStackFlag) && numel(qStackFlag)~=1
+ qStackFlag = qStackFlag(1);
+end
+if isempty(qStackFlag) || (qStackFlag~=0 && qStackFlag~=1)
+ qStackFlag =1;
+end
+
+%%normalization?
+qNormFlag = p_Results.NormFlag;
+if ~isempty(qNormFlag) && numel(qNormFlag)~=1
+ qNormFlag = qNormFlag(1);
+end
+if isempty(qNormFlag) || (qNormFlag~=0 && qNormFlag~=1)
+ qNormFlag =1;
+end
+
+
+%%start time of the displayed EEG
+qStartimes = p_Results.Startimes;
+if ~isempty(qStartimes) && numel(qStartimes)~=1
+ qStartimes = qStartimes(1);
+end
+[ChanNum,Allsamples,tmpnb] = size(EEG.data);
+Allsamples = Allsamples*tmpnb;
+if ndims(EEG.data) > 2
+ multiplier = size(EEG.data,2);
+else
+ multiplier = EEG.srate;
+end
+
+if isempty(qStartimes) || qStartimes<0 || qStartimes>(ceil((Allsamples-1)/multiplier)-qWinlength)
+ if ndims(EEG.data) ==3
+ qStartimes=1;
+ else
+ qStartimes=0;
+ end
+end
+
+
+%%figure name
+qfigureName = p_Results.figureName;
+if isempty(qfigureName)
+ qfigureName =EEG.setname;
+end
+
+%%figure position
+qfigSize = p_Results.figSize;
+if ~isempty(qfigSize) && numel(qfigSize)~=2
+ qfigSize = [];
+end
+
+%%%%%%%%%%%%%%%
+% insert the function that is to plot the EEG
+if ~isempty(qfigureName) && shist~=4
+ f_ploteegwave(EEG,qchanArray,qICArray,qWinlength,...
+ qAmpchan,qChanLabel,qSubmean,qEventOnset,qStackFlag,qNormFlag,qStartimes,...
+ qAmpic,qbufftobo,qfigSize,qfigureName) ;
+
+end
+
+%%history
+fn = fieldnames(p.Results);
+skipfields = {'EEG'};
+eegcom = sprintf( 'EEG = pop_ploteegset( %s', 'EEG');
+
+for q=1:length(fn)
+ fn2com = fn{q}; % inputname
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com); % input value
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if strcmpi(fn2com,'History') && strcmpi(fn2res,'command')
+ fn2res = 'gui';
+ end
+ if ~strcmpi(fn2res,'off')
+ eegcom = sprintf( '%s, ''%s'', ''%s''', eegcom, fn2com, fn2res);
+ end
+ elseif iscell(fn2res)
+ nn = length(fn2res);
+ eegcom = sprintf( '%s, ''%s'', {''%s'' ', eegcom, fn2com, fn2res{1});
+ for ff=2:nn
+ eegcom = sprintf( '%s, ''%s'' ', eegcom, fn2res{ff});
+ end
+ eegcom = sprintf( '%s}', eegcom);
+ elseif isnumeric(fn2res)
+ if ~ismember_bc2(fn2com,{'LineColor','GridSpace','GridposArray'})
+ eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ else
+ if size(fn2res,1)==1
+ fn2res_trans = char(num2str(fn2res));
+ else
+ fn2res_trans = char(num2str(fn2res(1,:)));
+ for ii = 2:size(fn2res,1)
+ fn2res_trans = char(strcat(fn2res_trans,';',num2str(fn2res(ii,:))));
+ end
+ end
+ fn2res = fn2res_trans;
+ eegcom = sprintf( '%s, ''%s'', [%s', eegcom,fn2com,fn2res);
+ eegcom = sprintf( '%s]', eegcom);
+ end
+
+ else
+ % if ~ismember_bc2(fn2com,{'xscale','yscale'})
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ % else
+ % xyscalestr = sprintf('[ %.1f %.1f %s ]', fn2res(1), fn2res(2), vect2colon(fn2res(3:end),'Delimiter','off'));
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, xyscalestr);
+ % end
+ end
+ end
+ end
+end
+
+
+eegcom = sprintf( '%s );', eegcom);
+% get history from script. ERP
+% shist = 1;
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(eegcom);
+ case 2 % from script
+ EEG = eegh(eegcom, EEG);
+ case 3
+ % implicit
+ case 4
+ displayEquiComERP(eegcom);
+ otherwise %off or none
+ eegcom = '';
+ return
+end
+
+
+
+return;
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_rename2chan.m b/studio_functions/Functions/EStudio/EEG Tab/pop_rename2chan.m
new file mode 100644
index 00000000..ade149fc
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_rename2chan.m
@@ -0,0 +1,272 @@
+% PURPOSE: pop_rename2chan.m is to change the channel names
+%
+%
+
+% FORMAT :
+%
+% pop_rename2chan(ALLEEG, CURRENTSET, parameters);
+%
+
+% ALLEEG - structure array of EEG structures
+% CURRENTSET - Index for current EEGset
+
+
+
+% The available parameters are as follows:
+%
+%ChanArray -index(es) for the selected channels
+%Chanlabels - new names for the selected channels
+
+
+
+%%Output
+%%EEG -EEG structure with the changed names of the selected channels
+
+
+%%Example:
+%EEG = pop_rename2chan( ALLEEG, 2, 'ChanArray', [1 2 3], 'Chanlabels', {'FP1-1' , 'F3-2' , 'F7-3' }, 'History', 'implicit' );
+
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Sep. 2023
+
+
+
+function [EEG,eegcom] = pop_rename2chan(ALLEEG,CURRENTSET,varargin)
+
+eegcom = '';
+if nargin < 1
+ help pop_rename2chan
+ return;
+end
+
+if isempty(ALLEEG)%%
+ beep;
+ disp('ALLEEG is empty');
+ return;
+end
+
+if nargin< 3
+ %%Do we need to create a GUI that the user can use it to define the
+ %%desired parameters?
+
+ if nargin< 2 || isempty(CURRENTSET) || numel(CURRENTSET)~=1 || CURRENTSET>length(ALLEEG) || CURRENTSET<=0
+ CURRENTSET = length(ALLEEG);
+ end
+ EEG = ALLEEG(CURRENTSET);
+ if ~isfield(EEG,'chanlocs')
+ beep;
+ disp('The current dataset donot have chanlocs field');
+ return;
+ end
+ chanlocs = EEG.chanlocs;
+ if ~isfield(chanlocs,'labels')
+ beep;
+ disp('There is no labels for chanlocs for the current dataset');
+ return;
+ end
+
+ ChanArray = [1:length(EEG.chanlocs)];
+ [eloc, Chanlabelsold, theta, radius, indices] = readlocs( chanlocs);
+
+
+ def = erpworkingmemory('pop_rename2chan');
+ if isempty(def)
+ def = Chanlabelsold;
+ end
+ erplab_studio_default_values;
+ version = erplabstudiover;
+ titleName= ['Dataset',32,num2str(CURRENTSET),': ERPLAB',32,num2str(version), 32,'Change Channel Name'];
+ Chanlabelsnew= f_change_chan_name_GUI(Chanlabelsold,def,titleName);
+
+ if isempty(Chanlabelsnew)
+ return
+ end
+ erpworkingmemory('pop_rename2chan',Chanlabelsnew);
+ %%add suffix
+ try
+ ALLEEG(CURRENTSET).setname = [ALLEEG(CURRENTSET).setname,'_rnchan'];
+ catch
+ ALLEEG(CURRENTSET).erpname = [ALLEEG(CURRENTSET).erpname,'_rnchan'];
+ end
+ [EEG, eegcom] = pop_rename2chan(ALLEEG,CURRENTSET,'ChanArray',ChanArray,'Chanlabels',Chanlabelsnew,'History', 'gui');
+ pause(0.1);
+ return;
+end
+
+
+%
+% Parsing inputs
+%
+% colordef = getcolorcellerps; %{'k' 'r' 'b' 'g' 'c' 'm' 'y' 'w'};% default colors
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+p.addRequired('CURRENTSET');
+
+%Option(s)
+p.addParamValue('ChanArray',[],@isnumeric);
+p.addParamValue('Chanlabels','', @iscell);
+
+p.addParamValue('History', '', @ischar); % history from scripting
+
+p.parse(ALLEEG,CURRENTSET,varargin{:});
+
+p_Results = p.Results;
+
+if strcmpi(p_Results.History,'command')
+ shist = 4;%%Show Maltab command only and donot plot the wave
+elseif 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(ALLEEG)%%
+ beep;
+ disp('ALLEEG is empty');
+ return;
+end
+
+
+if isempty(CURRENTSET) || numel(CURRENTSET)~=1 || CURRENTSET>length(ALLEEG) || CURRENTSET<=0
+ CURRENTSET = length(ALLEEG);
+end
+
+EEG = ALLEEG(CURRENTSET);
+if ~isfield(EEG,'chanlocs')
+ beep;
+ disp('The current dataset donot have chanlocs field');
+ return;
+end
+chanlocs = EEG.chanlocs;
+if ~isfield(chanlocs,'labels')
+ beep;
+ disp('There is no labels for chanlocs for the current dataset');
+ return;
+end
+
+
+%%channel array
+qchanArray = p_Results.ChanArray;
+nbchan = length(EEG.chanlocs);
+if isempty(qchanArray) || min(qchanArray(:))>nbchan || max(qchanArray(:))>nbchan || min(qchanArray(:))<=0
+ qchanArray = [1:nbchan];
+end
+
+
+
+%%IC array (the default is empty, that is, donot display ICs)
+qChanlabelsnew = p_Results.Chanlabels;
+if isempty(qChanlabelsnew)
+ disp('Chanlabels is empty');
+ return;
+end
+
+%
+%%adjust the number of channels and channel names
+for Numofchan = 1:numel(qchanArray)
+ try
+ if isempty(char(qChanlabelsnew{Numofchan}))
+ qChanlabelsnew{Numofchan,1} = EEG.chanlocs(qchanArray(Numofchan)).labels;
+ fprintf(2,['\n Warning: name for channel ',32,num2str(qchanArray(Numofchan)),32,' was empty, we threfore used its original name',32,qChanlabelsnew{Numofchan,1},'.\n']);
+ else
+ qChanlabelsnew{Numofchan,1} = char(qChanlabelsnew{Numofchan});
+ end
+ catch
+ qChanlabelsnew{Numofchan,1} = EEG.chanlocs(qchanArray(Numofchan)).labels;
+ fprintf(2,['\n Warning: name for channel ',32,num2str(qchanArray(Numofchan)),32,'was not defined, we threfore used its original name',32,qChanlabelsnew{Numofchan,1},'.\n']);
+ end
+end
+
+
+%%--------------change the channel names-----------------------------------
+for Numofchan = 1:numel(qchanArray)
+ fprintf(['Chan',32,num2str(qchanArray(Numofchan)),':',32,EEG.chanlocs(qchanArray(Numofchan)).labels,32,'was changed to',32,qChanlabelsnew{Numofchan,1},'.\n']);
+ EEG.chanlocs(qchanArray(Numofchan)).labels = char(qChanlabelsnew{Numofchan,1});
+end
+
+
+
+%%history
+fn = fieldnames(p.Results);
+skipfields = {'ALLEEG','CURRENTSET'};
+if isfield(EEG,'datatype') && strcmpi(EEG.datatype,'ERP')
+ eegcom = sprintf( 'ERP = pop_rename2chan( %s %s', 'ALLERP,',num2str(CURRENTSET));
+else
+eegcom = sprintf( 'EEG = pop_rename2chan( %s %s', 'ALLEEG,',num2str(CURRENTSET));
+end
+for q=1:length(fn)
+ fn2com = fn{q}; % inputname
+ if ~ismember_bc2(fn2com, skipfields)
+ fn2res = p.Results.(fn2com); % input value
+ if ~isempty(fn2res)
+ if ischar(fn2res)
+ if ~strcmpi(fn2res,'off')
+ eegcom = sprintf( '%s, ''%s'', ''%s''', eegcom, fn2com, fn2res);
+ end
+ elseif iscell(fn2res)
+ nn = length(fn2res);
+ eegcom = sprintf( '%s, ''%s'', {''%s'' ', eegcom, fn2com, fn2res{1});
+ for ff=2:nn
+ eegcom = sprintf( '%s, ''%s'' ', eegcom, fn2res{ff});
+ end
+ eegcom = sprintf( '%s}', eegcom);
+ elseif isnumeric(fn2res)
+
+ if size(fn2res,1)==1
+ fn2res_trans = char(num2str(fn2res));
+ else
+ fn2res_trans = char(num2str(fn2res(1,:)));
+ for ii = 2:size(fn2res,1)
+ fn2res_trans = char(strcat(fn2res_trans,';',num2str(fn2res(ii,:))));
+ end
+ end
+ fn2res = fn2res_trans;
+ eegcom = sprintf( '%s, ''%s'', [%s', eegcom,fn2com,fn2res);
+ eegcom = sprintf( '%s]', eegcom);
+ else
+ % if ~ismember_bc2(fn2com,{'xscale','yscale'})
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, vect2colon(fn2res,'Repeat','on'));
+ % else
+ % xyscalestr = sprintf('[ %.1f %.1f %s ]', fn2res(1), fn2res(2), vect2colon(fn2res(3:end),'Delimiter','off'));
+ % eegcom = sprintf( '%s, ''%s'', %s', eegcom, fn2com, xyscalestr);
+ % end
+ end
+ end
+ end
+end
+
+eegcom = sprintf( '%s );', eegcom);
+% get history from script. ERP
+% shist = 1;
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(eegcom);
+ case 2 % from script
+ for i=1:length(ALLEEG)
+ ALLEEG(i) = erphistory(ALLEEG(i), [], eegcom, 1);
+ end
+ case 3
+ % implicit
+ case 4
+ displayEquiComERP(eegcom);
+
+ otherwise %off or none
+ eegcom = '';
+ return
+end
+
+return;
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_renameeg.m b/studio_functions/Functions/EStudio/EEG Tab/pop_renameeg.m
new file mode 100644
index 00000000..b011f3ce
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_renameeg.m
@@ -0,0 +1,180 @@
+% PURPOSE: pop_renameeg.m
+% rename ALLEEGset
+%
+
+% FORMAT:
+% [ALLEEG, erpcom] = pop_renameeg( ALLEEG, 'eegnames',eegnames,...
+% 'Saveas', 'off', 'History', 'gui');
+
+% Inputs:
+%
+%ALLEEG -ALLEEG structure
+%eegnames -strings for erpsets
+
+
+
+% *** This function is part of ALLEEGLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Dec. 2024
+
+
+
+
+function [ALLEEG, erpcom] = pop_renameeg(ALLEEG, varargin)
+erpcom = '';
+
+if nargin < 1
+ help pop_renameeg
+ return
+end
+if isempty(ALLEEG)
+ msgboxText = 'Cannot rename an empty EEGset';
+ title = 'ERPLAB: pop_renameeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(ALLEEG(1).data)
+ msgboxText = 'Cannot rename an empty EEGset';
+ title = 'ERPLAB: pop_renameeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+
+if nargin==1
+
+ app = feval('EEG_Tab_rename_gui',ALLEEG,1:length(ALLEEG));
+ waitfor(app,'Finishbutton',1);
+ try
+ eegnames = app.Output; %NO you don't want to output EEG with edited channel locations, you want to output the parameters to run decoding
+ app.delete; %delete app from view
+ pause(0.1); %wait for app to leave
+ catch
+ return;
+ end
+ if isempty(eegnames)
+ return;
+ end
+ %
+ % Somersault
+ %
+ [ALLEEG, erpcom] = pop_renameeg( ALLEEG, 'eegnames',eegnames,...
+ 'Saveas', 'off', 'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+% option(s)
+p.addParamValue('eegnames', '',@iscell);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLEEG, varargin{:});
+
+
+eegnames = p.Results.eegnames;
+if ischar(eegnames) && numel(ALLEEG)==1
+ ALLEEG.erpname = eegnames;
+ ALLEEG.saved = 'no';
+elseif iscell(eegnames)
+ for Numoferp = 1:numel(ALLEEG)
+ newName = eegnames{Numoferp};
+ [~, newName, ~] = fileparts(newName) ;
+ if ~isempty(newName)
+ ALLEEG(Numoferp).setname = newName;
+ ALLEEG(Numoferp).saved = 'no';
+ else
+ ALLEEG(Numoferp).saved = 'no';
+ end
+ end
+end
+
+
+
+if strcmpi(p.Results.Saveas,'on')
+ 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
+
+
+
+
+%
+% History
+%
+
+skipfields = {'ALLEEG', 'Saveas','History'};
+fn = fieldnames(p.Results);
+erpcom = sprintf( '%s = pop_renameeg( %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{1});
+ end
+ else
+ if iscell(fn2res)
+ nn = length(fn2res);
+ erpcom = sprintf( '%s, ''%s'', {''%s'' ', erpcom, fn2com, fn2res{1});
+ for ff=2:nn
+ erpcom = sprintf( '%s, ''%s'' ', erpcom, fn2res{ff});
+ end
+ erpcom = sprintf( '%s}', erpcom);
+ end
+
+ end
+ end
+ end
+end
+erpcom = sprintf( '%s );', erpcom);
+
+%
+% Save ALLEEGset from GUI
+%
+if issaveas
+ for ii = 1:length(ALLEEG)
+ [ALLEEG(ii), ~] = pop_saveset( ALLEEG(ii), 'filename',ALLEEG(ii).filename,'filepath',[ALLEEG(ii).filepath,filesep]);
+ end
+end
+
+
+
+% get history from script. ALLEEG
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ for ii = 1:length(ALLEEG)
+ ALLEEG(ii) = eegh(erpcom, ALLEEG(ii));
+ end
+ case 3
+ % implicit
+ otherwise %off or none
+ erpcom = '';
+ return
+end
+return
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_resampleeg.m b/studio_functions/Functions/EStudio/EEG Tab/pop_resampleeg.m
new file mode 100644
index 00000000..2774884a
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_resampleeg.m
@@ -0,0 +1,306 @@
+% PURPOSE: pop_resampleeg.m
+% resample ERPsets
+%
+
+% FORMAT:
+% [EEG, LASTCOM] = pop_resamplerp( EEG, 'Freq2resamp',Freq2resamp, 'TimeRange',TimeRange,...
+% 'Saveas', 'off', 'History', 'gui');
+
+% Inputs:
+%
+%EEG -EEG structure
+%Freq2resamp -new sampling rate e.g., 200 Hz
+%TimeRange -new time range e.g., [-300 900]ms
+
+
+%%We used some functions from EEGlab in this routine
+
+
+% *** This function is part of ERPLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Mar. 2024
+
+function [EEG, LASTCOM] = pop_resampleeg(EEG, varargin)
+LASTCOM = '';
+
+if nargin < 1
+ help pop_resampleeg
+ return
+end
+if isempty(EEG)
+ msgboxText = 'Cannot resample an empty eegset';
+ title = 'ERPLAB: pop_resampleeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(EEG(1).data)
+ msgboxText = 'Cannot resample an empty EEGset';
+ title = 'ERPLAB: pop_resampleeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+if EEG(1).trials==1
+ msgboxText = 'Cannot resample continous EEGset';
+ title = 'ERPLAB: pop_resampleeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+if nargin==1
+
+ Freq2resamp = EEG.srate;
+ TimeRange = [EEG.times(1),EEG.times(end)];
+ %
+ % Somersault
+ %
+ [EEG, LASTCOM] = pop_resampleeg( EEG, 'Freq2resamp',Freq2resamp, 'TimeRange',TimeRange,...
+ 'Saveas', 'off', 'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('EEG');
+% option(s)
+p.addParamValue('Freq2resamp', [],@isnumeric);
+p.addParamValue('TimeRange', [], @isnumeric);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(EEG, varargin{:});
+
+Freq2resamp = p.Results.Freq2resamp;
+if isempty(Freq2resamp) || numel(Freq2resamp)~=1 || any(Freq2resamp<=0)
+ Freq2resamp = EEG.srate;
+end
+
+TimeRange= p.Results.TimeRange;
+TimeRange = unique(TimeRange);
+if isempty(TimeRange) || numel(TimeRange)~=2 || TimeRange(1)>=EEG.times(end) || TimeRange(2)<=EEG.times(1)
+ TimeRange = [EEG.times(1),EEG.times(end)];
+end
+if TimeRange(1)>=0
+ msgboxText = ['The left number of the new time range should be smaller than 0'];
+ title = 'ERPLAB: pop_resampleeg() inputs';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+if TimeRange(2)<=0
+ msgboxText = ['The right number of the new time range should be larger than 0'];
+ title = 'ERPLAB: pop_resampleeg() inputs';
+ errorfound(sprintf(msgboxText), title);
+ return
+end
+
+
+latency0_old = 1-(EEG.xmin*EEG.srate); % time 0 point
+alllatencies_old = linspace( latency0_old, EEG.pnts*(EEG.trials-1)+latency0_old, EEG.trials);
+
+
+%%-------------------------adjust the left edge----------------------------
+if roundn(TimeRange(1),-2)>= roundn(EEG.times(1),-2)
+ [xxx, latsamp, latdiffms] = closest(EEG.times, TimeRange(1));
+ EEG.times = EEG.times(latsamp:end);
+ EEG.xmin = EEG.times(1)/1000;
+ EEG.data = EEG.data(:,latsamp:end,:);
+else
+ TimesNew = EEG.times;
+ timeint = 1000/EEG.srate;
+ count=0;
+ for ii=1:10000
+ timeStart = TimesNew(1)-timeint;
+ if timeStart>=TimeRange(1)
+ count = count+1;
+ TimesNew = [timeStart,TimesNew];
+ else
+ break;
+ end
+ end
+ if count~=0
+ EEG.times = TimesNew;
+ EEG.xmin = EEG.times(1)/1000;
+ datadd= zeros(size(EEG.data,1),count);
+ for ii = 1:size(EEG.data,3)
+ newdata(:,:,ii) = [datadd,squeeze(EEG.data(:,:,ii))];
+ end
+ EEG.data = newdata;
+ end
+end
+%%-------------------------adjust the right edge---------------------------
+if roundn(TimeRange(2),-2)<= roundn(EEG.times(end),-2)
+ [xxx, latsamp, latdiffms] = closest(EEG.times, TimeRange(2));
+ EEG.times = EEG.times(1:latsamp);
+ EEG.xmax = EEG.times(end)/1000;
+ EEG.data = EEG.data(:,1:latsamp,:);
+else
+ TimesNew = EEG.times;
+ timeint = 1000/EEG.srate;
+ count=0;
+ for ii=1:10000
+ timend = TimesNew(end)+timeint;
+ if timend<=TimeRange(2)
+ count = count+1;
+ TimesNew = [TimesNew,timend];
+ else
+ break;
+ end
+ end
+ if count~=0
+ newdata = [];
+ EEG.times = TimesNew;
+ EEG.xmax = EEG.times(end)/1000;
+ datadd= zeros(size(EEG.data,1),count);
+ for ii = 1:size(EEG.data,3)
+ newdata(:,:,ii) = [squeeze(EEG.data(:,:,ii)),datadd];
+ end
+ EEG.data = newdata;
+ end
+end
+
+count = 0;
+check_left = [];
+for ii = 1:numel(EEG.times)
+ if roundn(EEG.times(ii),-2)< roundn(TimeRange(1),-2) || roundn(EEG.times(ii),-2)> roundn(TimeRange(2),-2)
+ count = count+1;
+ check_left(count) = ii;
+ end
+end
+EEG.data(:,check_left,:) =[];
+EEG.times(check_left) = [];
+EEG.pnts = size(EEG.data,2);
+EEG.xmax = EEG.times(end)/1000;
+EEG.xmin = EEG.times(1)/1000;
+
+
+%%Adjust events
+latency0_new = 1-(EEG.xmin*EEG.srate); % time 0 point
+alllatencies_new = linspace( latency0_new, EEG.pnts*(EEG.trials-1)+latency0_new, EEG.trials);
+Latency_all = [];
+for Numofevent = 1:length( EEG.event)
+ epochindex(Numofevent,1) = EEG.event(Numofevent).epoch;
+ Latency_all(Numofevent,1) = EEG.event(Numofevent).latency;
+end
+%%adjust event latency
+count = 0;
+eventrm = [];
+for Numoftrial = 1:EEG.trials
+ [xpos,ypos]= find(epochindex==Numoftrial);
+ count1= 0;
+ eventrm_epoch = [];
+ Latency_single= Latency_all(xpos);
+ Latency_single = Latency_single-alllatencies_old(Numoftrial);
+ for ii = 1:numel(xpos)
+ EEG.event(xpos(ii)).latency = Latency_single(ii)+alllatencies_new(Numoftrial);%%update latency for each epoch
+ if (EEG.event(xpos(ii)).latency-alllatencies_new(Numoftrial))<(1-latency0_new) || (EEG.event(xpos(ii)).latency-alllatencies_new(Numoftrial))>(numel(EEG.times)-latency0_new)
+ count = count+1;
+ eventrm(count) = xpos(ii);%%remove event exceeds the epoch
+ end
+ end
+end
+EEG.event(eventrm) = [];
+EEG.urevent = [];
+EEG = eeg_checkset(EEG, 'eventconsistency');
+% EEG = eeg_checkset(EEG,'epochconsist');
+%%resampling data based on eeglab routine
+if EEG.srate~=Freq2resamp
+ setnameold = EEG.setname;
+ EEG = pop_resample( EEG, Freq2resamp);
+ EEG.setname = setnameold;
+end
+EEG = eeg_checkset(EEG);
+
+if strcmpi(p.Results.Saveas,'on')
+ 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
+EEG.saved = 'no';
+EEG = eeg_checkset(EEG);
+%
+% History
+%
+%
+% Completion statement
+%
+% msg2end
+
+%
+% History
+%
+
+skipfields = {'EEG', 'Saveas','History'};
+fn = fieldnames(p.Results);
+LASTCOM = sprintf( '%s = pop_resampleeg( %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')
+ LASTCOM = sprintf( '%s, ''%s'', ''%s''', LASTCOM, 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
+ LASTCOM = sprintf( ['%s, ''%s'', ' fnformat], LASTCOM, fn2com, fn2resstr);
+ end
+ else
+ LASTCOM = sprintf( ['%s, ''%s'', ' fnformat], LASTCOM, fn2com, fn2resstr);
+ end
+ end
+ end
+ end
+end
+LASTCOM = sprintf( '%s );', LASTCOM);
+
+% Save ERPset from GUI
+%
+if issaveas
+ [EEG, LASTCOM1] = pop_saveset(EEG,'filename', EEG.filename, 'filepath',EEG.filepath,'check','on');
+ EEG = eegh(LASTCOM1, EEG);
+end
+
+% get history from script. ERP
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(LASTCOM);
+ case 2 % from script
+ EEG = eegh(LASTCOM, EEG);
+ case 3
+ % implicit
+ otherwise %off or none
+ LASTCOM = '';
+ return
+end
+return
\ No newline at end of file
diff --git a/studio_functions/Functions/EStudio/EEG Tab/pop_suffixeeg.m b/studio_functions/Functions/EStudio/EEG Tab/pop_suffixeeg.m
new file mode 100644
index 00000000..27efe298
--- /dev/null
+++ b/studio_functions/Functions/EStudio/EEG Tab/pop_suffixeeg.m
@@ -0,0 +1,165 @@
+% PURPOSE: pop_suffixeeg.m
+% add suffix to ALLEEG names
+%
+
+% FORMAT:
+% [ALLEEG, erpcom] = pop_suffixeeg( ALLEEG, 'suffixstr',suffixstr,...
+% 'Saveas', 'off', 'History', 'gui');
+
+% Inputs:
+%
+%ALLEEG -ALLEEG structure
+%suffixstr -strings for erpsets
+
+
+
+% *** This function is part of ALLEEGLAB Studio ***
+% Author: Guanghui Zhang & Steven Luck
+% ghzhang@ucdavis.edu, sjluck@ucdavis.edu
+% Center for Mind and Brain
+% University of California, Davis,
+% Davis, CA
+% Dec. 2024
+
+
+
+
+function [ALLEEG, erpcom] = pop_suffixeeg(ALLEEG, varargin)
+erpcom = '';
+
+if nargin < 1
+ help pop_suffixeeg
+ return
+end
+if isempty(ALLEEG)
+ msgboxText = 'Cannot rename an empty EEGset';
+ title = 'ERPLAB: pop_suffixeeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+if isempty(ALLEEG(1).data)
+ msgboxText = 'Cannot rename an empty EEGset';
+ title = 'ERPLAB: pop_suffixeeg() error';
+ errorfound(msgboxText, title);
+ return
+end
+
+
+if nargin==1
+
+ suffixstr = f_EEG_suffix_gui('Suffix');
+
+ if isempty(suffixstr)
+ return;
+ end
+ %
+ % Somersault
+ %
+ [ALLEEG, erpcom] = pop_suffixeeg( ALLEEG, 'suffixstr',suffixstr,...
+ 'Saveas', 'off', 'History', 'gui');
+ return
+end
+
+%
+% Parsing inputs
+%
+p = inputParser;
+p.FunctionName = mfilename;
+p.CaseSensitive = false;
+p.addRequired('ALLEEG');
+% option(s)
+p.addParamValue('suffixstr', '',@ischar);
+p.addParamValue('Saveas', 'off', @ischar);
+p.addParamValue('History', 'script', @ischar); % history from scripting
+
+p.parse(ALLEEG, varargin{:});
+
+
+
+suffixstr = p.Results.suffixstr;
+
+for Numoferp = 1:numel(ALLEEG)
+ ALLEEG(Numoferp).setname = [ALLEEG(Numoferp).setname,'_',suffixstr];
+ ALLEEG(Numoferp).saved = 'no';
+
+end
+
+
+
+
+if strcmpi(p.Results.Saveas,'on')
+ 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
+
+
+
+
+%
+% History
+%
+
+skipfields = {'ALLEEG', 'Saveas','History'};
+fn = fieldnames(p.Results);
+erpcom = sprintf( '%s = pop_suffixeeg( %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)
+ nn = length(fn2res);
+ erpcom = sprintf( '%s, ''%s'', {''%s'' ', erpcom, fn2com, fn2res{1});
+ for ff=2:nn
+ erpcom = sprintf( '%s, ''%s'' ', erpcom, fn2res{ff});
+ end
+ erpcom = sprintf( '%s}', erpcom);
+ end
+
+ end
+ end
+ end
+end
+erpcom = sprintf( '%s );', erpcom);
+
+%
+% Save ALLEEGset from GUI
+%
+if issaveas
+ for ii = 1:length(ALLEEG)
+ [ALLEEG(ii), ~] = pop_saveset( ALLEEG(ii), 'filename',ALLEEG(ii).filename,'filepath',[ALLEEG(ii).filepath,filesep]);
+ end
+end
+
+
+
+% get history from script. ALLEEG
+switch shist
+ case 1 % from GUI
+ displayEquiComERP(erpcom);
+ case 2 % from script
+ for ii = 1:length(ALLEEG)
+ ALLEEG(ii) = eegh(erpcom, ALLEEG(ii));
+ end
+ case 3
+ % implicit
+ otherwise %off or none
+ erpcom = '';
+ return
+end
+return
\ No newline at end of file
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 2404bd3a..0024cd83 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
@@ -1,7 +1,6 @@
-
-% New ERP viewer GUI Layout - Simple ERP viewer 0.014
+% New ERP viewer GUI Layout
%
-% Author: Guanghui Zhang & Steve J. Luck & Andrew Stewart
+% Author: Guanghui Zhang & Steve J. Luck
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
@@ -36,14 +35,20 @@
function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Parameterfile)
tic;%
-disp(' ERP Waveform Viewer is launching...');
+disp('ERP Waveform Viewer is launching. Please be patient...');
+EStudioversion = geterplabeversion;
global viewer_ERPDAT;
global gui_erp_waviewer;
ERPtooltype = erpgettoolversion('tooltype');
-% global observe_ERPDAT;
-% if ~strcmpi(ERPtooltype,'EStudio')
+
+%%try to close existing Viewer
+try
+ close(gui_erp_waviewer.Window);%%close previous GUI if exists
+catch
+end
+
viewer_ERPDAT = v_ERPDAT;
% end
% addlistener(observe_ERPDAT,'erpschange',@allErpChanged);
@@ -58,21 +63,6 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
observe_ERPDAT.Count_currentERP = 0;
observe_ERPDAT.Process_messg = 0;
end
-try
- close(EStudio_gui_erp_totl.Window);
-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
@@ -81,10 +71,15 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
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')
+ mshock = 0;
+ if iserpmem==0
+ p1 = which('o_ERPDAT');
+ p1 = p1(1:findstr(p1,'o_ERPDAT.m')-1);
+ save(fullfile(p1,'memoryerpstudio.erpm'),'EStudioversion')
+ end
end
@@ -167,23 +162,13 @@ 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);
-% addlistener(viewer_ERPDAT,'v_messg_change',@V_messg_change);
-% addlistener(viewer_ERPDAT,'count_legend_change',@count_legend_change);
-% addlistener(viewer_ERPDAT,'page_xyaxis_change',@page_xyaxis_change);
-% % end
-
+estudioworkingmemory('ERPLAB_ERPWaviewer',0);%%Update the Viewer based on the changes in ERPLAB
viewer_ERPDAT.Count_currentERP = 0;
% viewer_ERPDAT.Process_messg = 0;%0 is the default means there is no message for processing procedure;
%1 means the processign procedure is running
%2 means the processign procedure is done
%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.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
@@ -199,8 +184,7 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
try
test = uix.HBoxFlex();
catch
- beep;
- disp('The GUI Layout Toolbox might not be installed. Quitting')
+ disp('The GUI Layout Toolbox might not be included. Please download it from:https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox')
return
end
@@ -214,38 +198,43 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
estudioworkingmemory('MyViewer_linelegend',0);
estudioworkingmemory('MyViewer_other',0);
-ERPwaviewer.ALLERP =ALLERP;
-ERPwaviewer.ERP = ALLERP(selectedERP_index(end));
-ERPwaviewer.CURRENTERP =selectedERP_index(end);
-ERPwaviewer.SelectERPIdx =selectedERP_index;
-ERPwaviewer.bin = binArray;
-ERPwaviewer.chan = chanArray;
-ERPwaviewer.binchan_op = 1;%% 1. Auto; 2.Custom
-
-ERPwaviewer.plot_org.Grid = 1; %1.Channels; 2.Bins; 3. ERPsets; 4. None
-ERPwaviewer.plot_org.Overlay = 2; %1.Channels; 2.Bins; 3. ERPsets; 4. None
-ERPwaviewer.plot_org.Pages = 3; %1.Channels; 2.Bins; 3. ERPsets; 4. None
-ERPwaviewer.plot_org.gridlayout.op = 1; %1.Auto; 2. Custom
-ERPwaviewer.plot_org.gridlayout.data = [];
-ERPwaviewer.Lines = [];
-ERPwaviewer.Legend = [];
-ERPwaviewer.xaxis = [];
-ERPwaviewer.yaxis = [];
-ERPwaviewer.polarity = [];
-ERPwaviewer.SEM = [];
-ERPwaviewer.PageIndex = 1;
-ERPwaviewer.baselinecorr = 'none';
-ERPwaviewer.chanbinsetlabel = [];
-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
+gui_erp_waviewer.ERPwaviewer.ALLERP =ALLERP;
+gui_erp_waviewer.ERPwaviewer.ERP = ALLERP(selectedERP_index(end));
try
- close(gui_erp_waviewer.Window);%%close previous GUI if exists
+ CURRENTERP = evalin('base','CURRENTERP');
catch
+ CURRENTERP = numel(selectedERP_index);
+end
+gui_erp_waviewer.ERPwaviewer.CURRENTERP =CURRENTERP;
+[xpos,ypos] = find(selectedERP_index==CURRENTERP);
+if ~isempty(ypos)
+ gui_erp_waviewer.ERPwaviewer.PageIndex =ypos;
+else
+ gui_erp_waviewer.ERPwaviewer.PageIndex=numel(selectedERP_index);
end
+gui_erp_waviewer.ERPwaviewer.SelectERPIdx =selectedERP_index;
+gui_erp_waviewer.ERPwaviewer.bin = binArray;
+gui_erp_waviewer.ERPwaviewer.chan = chanArray;
+gui_erp_waviewer.ERPwaviewer.binchan_op = 1;%% 1. Auto; 2.Custom
+
+gui_erp_waviewer.ERPwaviewer.plot_org.Grid = 1; %1.Channels; 2.Bins; 3. ERPsets; 4. None
+gui_erp_waviewer.ERPwaviewer.plot_org.Overlay = 2; %1.Channels; 2.Bins; 3. ERPsets; 4. None
+gui_erp_waviewer.ERPwaviewer.plot_org.Pages = 3; %1.Channels; 2.Bins; 3. ERPsets; 4. None
+gui_erp_waviewer.ERPwaviewer.plot_org.gridlayout.op = 1; %1.Auto; 2. Custom
+gui_erp_waviewer.ERPwaviewer.plot_org.gridlayout.data = [];
+gui_erp_waviewer.ERPwaviewer.Lines = [];
+gui_erp_waviewer.ERPwaviewer.Legend = [];
+gui_erp_waviewer.ERPwaviewer.xaxis = [];
+gui_erp_waviewer.ERPwaviewer.yaxis = [];
+gui_erp_waviewer.ERPwaviewer.polarity = [];
+gui_erp_waviewer.ERPwaviewer.SEM = [];
+gui_erp_waviewer.ERPwaviewer.baselinecorr = 'none';
+gui_erp_waviewer.ERPwaviewer.chanbinsetlabel = [];
+gui_erp_waviewer.ERPwaviewer.figbackgdcolor = [1 1 1];
+gui_erp_waviewer.ERPwaviewer.figname = 'My Viewer';
+gui_erp_waviewer.ERPwaviewer.FigOutpos=[];
+%
+% estudioworkingmemory('zoomSpace',0);%%sett for zoom in and zoom out
createInterface_ERPWave_viewer(ERPtooltype);
@@ -263,23 +252,19 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
set(0,'DefaultUicontrolBackgroundColor',oldcolor);
if strcmpi(button,'Yes')
- ERPwaviewerdef = evalin('base','ALLERPwaviewer');
- Parameterfile.ALLERP= ERPwaviewerdef.ALLERP;
- Parameterfile.ERP = ERPwaviewerdef.ERP;
+ Parameterfile.ALLERP= gui_erp_waviewer.ERPwaviewer.ALLERP;
+ Parameterfile.ERP = gui_erp_waviewer.ERPwaviewer.ERP;
else
if strcmpi(button,'No')
- beep;
viewer_ERPDAT.Process_messg =3;
fprintf(2,'\n\n My viewer > ERPLAB_ERP_Viewer: \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 > ERPLAB_ERP_Viewer: \n User selected cancel.\n\n');
end
return;
end
end
- assignin('base','ALLERPwaviewer',Parameterfile);
viewer_ERPDAT.loadproper_count = 1;
f_redrawERP_viewer_test();
end
@@ -287,58 +272,56 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
fprintf([32,'It took',32,num2str(timeElapsed),'s to launch ERP Waveform Viewer.\n\n']);
function createInterface_ERPWave_viewer(ERPtooltype);
+ try
+ erplabstudiover = num2str(geterplabeversion);
+ catch
+ erplabstudiover = '??';
+ end
+
if strcmpi(ERPtooltype,'EStudio')
- try
- [version reldate] = geterplabstudioversion;
- erplabstudiover = version;
- catch
- erplabstudiover = '??';
- end
-
currvers = ['ERPLAB Studio ' erplabstudiover,'- My Viewer'];
else
- try
- [version reldate] = geterplabversion;
- erplabstudiover = version;
- catch
- erplabstudiover = '??';
- end
-
currvers = ['ERPLAB ' erplabstudiover,'- My Viewer'];
end
estudioworkingmemory('viewername','My Viewer');
try
[version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
catch
- ColorBviewer_def = [0.7765,0.7294,0.8627];
+ ColorBviewer_def = [0.8 0.8 0.9];
end
- % gui_erp_waviewer = struct();
- % First, let's start the window
+
gui_erp_waviewer.Window = figure( 'Name', currvers, ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'none', ...
- 'HandleVisibility', 'off', 'tag', 'rollover');
+ 'HandleVisibility', 'on',...
+ 'tag', 'rollover',...
+ 'DockControls','off');%%donot allow to dock
ScreenPos = [];
-
- new_pos= erpworkingmemory('ERPWaveScreenPos');
- if isempty(new_pos)
- new_pos = [0.01,0.01,75,75];
- erpworkingmemory('ERPWaveScreenPos',new_pos);
+ new_pos= estudioworkingmemory('ERPWaviewerScreenPos');
+ if isempty(new_pos) || numel(new_pos)~=2
+ new_pos = [75,75];
+ estudioworkingmemory('ERPWaviewerScreenPos',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];
+ gui_erp_waviewer.monitor_size = ScreenPos;%%save monitor size
+ gui_erp_waviewer.screen_pos = new_pos;%%GUI size
+ if ~isempty(new_pos(2)) && new_pos(2) >100
+ POS4 = (100-new_pos(2))/100;
+ new_pos =[0,ScreenPos(4)*POS4,ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100];
+ else
+ new_pos =[0,0,ScreenPos(3)*new_pos(1)/100,ScreenPos(4)*new_pos(2)/100];
+ end
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);
+% gui_erp_waviewer.help = uimenu( gui_erp_waviewer.Window, 'Label', 'Help', 'Callback', @onhelp);
%%-----------Setting------------------------------------------------
%% Create tabs
@@ -357,37 +340,26 @@ function ERPLAB_ERP_Viewer(ALLERP,selectedERP_index,binArray,chanArray,Paramete
set(gui_erp_waviewer.panelscroll,'BackgroundColor',ColorBviewer_def);
% + Adjust the main layout
set( gui_erp_waviewer.tabERP, 'Widths', [-4, 270]); % Viewpanel and settings panel
-
-
gui_erp_waviewer.panel_fonts = f_get_default_fontsize(); %% get the default fontsize based on the different plat form, e.g., Mac
-
gui_erp_waviewer.settingLayout = uiextras.VBox('Parent', gui_erp_waviewer.panelscroll,'BackgroundColor',ColorBviewer_def);
% + 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) = 255;
-
+ gui_erp_waviewer.panelSizes(1) = 360;
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;
-
gui_erp_waviewer.panel{3} = f_ERP_timeampscal_waveviewer_GUI(gui_erp_waviewer.settingLayout,gui_erp_waviewer.panel_fonts);
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) = 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) = 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) = 130;
-
+ gui_erp_waviewer.panelSizes(8) = 140;
set(gui_erp_waviewer.settingLayout, 'Heights', gui_erp_waviewer.panelSizes);
gui_erp_waviewer.panelscroll.Heights = sum(gui_erp_waviewer.panelSizes);
@@ -417,16 +389,11 @@ 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);
- gui_erp_waviewer.Resize=1;
+ gui_erp_waviewer.Resize=0;
end % createInterface_ERPWave_viewer
function nMinimize( eventSource, eventData, whichpanel) %#ok
- try
- [version reldate,ColorB_def,ColorF_def,errorColorF_def,ColorBviewer_def] = geterplabstudiodef;
- catch
- ColorBviewer_def = [0.7020 0.77 0.85];
- end
minned = gui_erp_waviewer.panel{whichpanel}.IsMinimized;
szs = get( gui_erp_waviewer.settingLayout, 'Sizes' );
if minned
@@ -436,9 +403,8 @@ function nMinimize( eventSource, eventData, whichpanel) %#ok
set( gui_erp_waviewer.panel{whichpanel}, 'IsMinimized', true);
szs(whichpanel) = 25;
end
- set( gui_erp_waviewer.settingLayout, 'Sizes', szs ,'BackgroundColor',ColorBviewer_def);
+ set( gui_erp_waviewer.settingLayout, 'Sizes', szs);
gui_erp_waviewer.panelscroll.Heights = sum(szs);
- set(gui_erp_waviewer.panelscroll,'BackgroundColor',ColorBviewer_def);
end % nMinimize
@@ -454,7 +420,6 @@ function onExit(~,~)
if strcmpi(button1,'Yes')
try
close(gui_erp_waviewer.Window);
- clear ALLERPwaviewer;
catch
return;
end
@@ -468,17 +433,13 @@ 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
-%%%%%%%%%%%%%%%%%%%%%%%
-end % end of the function
\ No newline at end of file
+%%---------------------ERPLAB VERSION--------------------------------------
+function erplabver1 = geterplabeversion
+erplab_default_values;
+erplabver1 = str2num(erplabver);
+estudioworkingmemory('erplabver', erplabver);
+end
\ 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
old mode 100644
new mode 100755
index d5671987..bb4964d2
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
old mode 100644
new mode 100755
index 01dafaad..451d0805
--- 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
@@ -53,31 +53,10 @@ function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
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} = '';
-% else
-% GridinforDatadef{Numofrows,Numofcolumns} = char(plotArray{count});
-% end
-% end
-% end
try
GridinforData = varargin{2};
@@ -87,37 +66,7 @@ function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
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
-
-% 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
%
@@ -127,25 +76,11 @@ function ERP_layoutstringGUI_OpeningFcn(hObject, eventdata, handles, varargin)
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);
@@ -471,47 +406,6 @@ function text_rownum_Callback(hObject, eventdata, 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) ['
',text,'
'];
@@ -525,49 +419,6 @@ function text_rownum_Callback(hObject, eventdata, handles)
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},'
GUI Layout Toolbox is a layout manager for creating MATLAB graphical user
interfaces that resize gracefully. The classes supplied can be used in
@@ -46,7 +46,7 @@