Skip to content

Commit 60eaaed

Browse files
arnoarno
arno
authored and
arno
committed
Adding mecanism to choose between EEGLAB versions
1 parent 1541ef8 commit 60eaaed

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

dependencies/eeglab_10_0_1_0x/eeglab.m

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,58 @@
139139

140140
function [ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab( onearg )
141141

142+
% BCILAB specific ---------------
143+
144+
% check for duplicate versions of EEGLAB
145+
% --------------------------------------
146+
eeglabpath = mywhich('eeglab.m');
147+
eeglabpath = eeglabpath(1:end-length('eeglab.m'));
148+
dbstackval = dbstack;
149+
if nargin < 1 && length(dbstackval) < 2
150+
eeglabpath2 = '';
151+
if strcmpi(eeglabpath, pwd) || strcmpi(eeglabpath(1:end-1), pwd)
152+
cd('functions');
153+
warning('off', 'MATLAB:rmpath:DirNotFound');
154+
rmpath(eeglabpath);
155+
warning('on', 'MATLAB:rmpath:DirNotFound');
156+
eeglabpath2 = mywhich('eeglab.m');
157+
cd('..');
158+
else
159+
try, rmpath(eeglabpath); catch, end;
160+
eeglabpath2 = mywhich('eeglab.m');
161+
end;
162+
if ~isempty(eeglabpath2)
163+
eeglabpath2 = eeglabpath2(1:end-length('eeglab.m'));
164+
disp('******************************************************');
165+
disp('There are two versions of EEGLAB in your path');
166+
disp(sprintf('(1) One is at %s', eeglabpath));
167+
disp(sprintf('(2) The other one is at %s', eeglabpath2));
168+
%disp('To remove this message, simply delete or remove one of the EEGLAB version from the Matlab path');
169+
s = input('Which version do you want to use (enter "1" or "2" then press enter)? ');
170+
171+
% starting other version of eeglab
172+
if ~isempty(s) && s(1) == 2
173+
tmpp = path;
174+
indcolom = [0 find(tmpp == ':') length(tmpp)+1];
175+
for ind = 1:length(indcolom)-1
176+
currentpath = tmpp(indcolom(ind)+1:indcolom(ind+1)-1);
177+
if ~isempty(findstr('eeglab', currentpath))
178+
disp([ 'Removing path ' currentpath ]);
179+
rmpath(currentpath);
180+
end;
181+
end;
182+
cd(eeglabpath2);
183+
eeglab;
184+
return;
185+
else
186+
disp(sprintf('Using the EEGLAB version at %s', eeglabpath));
187+
end;
188+
end;
189+
addpath(eeglabpath);
190+
end;
191+
192+
% BCILAB specific ---------------
193+
142194
% add the paths
143195
% -------------
144196
warning('off', 'dispatcher:nameConflict');
@@ -162,8 +214,6 @@
162214
warning('EEGLAB subfolders not found');
163215
end;
164216
end;
165-
OPT_FOLDER = which('eeg_options');
166-
OPT_FOLDER = fileparts( OPT_FOLDER );
167217

168218
% determine file format
169219
% ---------------------
@@ -192,6 +242,8 @@
192242
myaddpath( eeglabpath, 'eeglab1020.ced', [ 'functions' filesep 'resources' ]);
193243
myaddpath( eeglabpath, 'eegplugin_dipfit', 'plugins');
194244
end;
245+
OPT_FOLDER = which('eeg_options');
246+
OPT_FOLDER = fileparts( OPT_FOLDER );
195247

196248
eeglab_options;
197249

@@ -1701,4 +1753,12 @@ function addpathexist(p)
17011753
else val = 0;
17021754
end;
17031755

1756+
1757+
function res = mywhich(varargin);
1758+
try
1759+
res = which(varargin{:});
1760+
catch
1761+
fprintf('Warning: permission error accesssing %s\n', varargin{1});
1762+
end;
1763+
17041764
function buildhelpmenu;

0 commit comments

Comments
 (0)