Skip to content

Commit

Permalink
Adding mecanism to choose between EEGLAB versions
Browse files Browse the repository at this point in the history
  • Loading branch information
arno authored and arno committed Nov 12, 2013
1 parent 1541ef8 commit 60eaaed
Showing 1 changed file with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions dependencies/eeglab_10_0_1_0x/eeglab.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,58 @@

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

% BCILAB specific ---------------

% check for duplicate versions of EEGLAB
% --------------------------------------
eeglabpath = mywhich('eeglab.m');
eeglabpath = eeglabpath(1:end-length('eeglab.m'));
dbstackval = dbstack;
if nargin < 1 && length(dbstackval) < 2
eeglabpath2 = '';
if strcmpi(eeglabpath, pwd) || strcmpi(eeglabpath(1:end-1), pwd)
cd('functions');
warning('off', 'MATLAB:rmpath:DirNotFound');
rmpath(eeglabpath);
warning('on', 'MATLAB:rmpath:DirNotFound');
eeglabpath2 = mywhich('eeglab.m');
cd('..');
else
try, rmpath(eeglabpath); catch, end;
eeglabpath2 = mywhich('eeglab.m');
end;
if ~isempty(eeglabpath2)
eeglabpath2 = eeglabpath2(1:end-length('eeglab.m'));
disp('******************************************************');
disp('There are two versions of EEGLAB in your path');
disp(sprintf('(1) One is at %s', eeglabpath));
disp(sprintf('(2) The other one is at %s', eeglabpath2));
%disp('To remove this message, simply delete or remove one of the EEGLAB version from the Matlab path');
s = input('Which version do you want to use (enter "1" or "2" then press enter)? ');

% starting other version of eeglab
if ~isempty(s) && s(1) == 2
tmpp = path;
indcolom = [0 find(tmpp == ':') length(tmpp)+1];
for ind = 1:length(indcolom)-1
currentpath = tmpp(indcolom(ind)+1:indcolom(ind+1)-1);
if ~isempty(findstr('eeglab', currentpath))
disp([ 'Removing path ' currentpath ]);
rmpath(currentpath);
end;
end;
cd(eeglabpath2);
eeglab;
return;
else
disp(sprintf('Using the EEGLAB version at %s', eeglabpath));
end;
end;
addpath(eeglabpath);
end;

% BCILAB specific ---------------

% add the paths
% -------------
warning('off', 'dispatcher:nameConflict');
Expand All @@ -162,8 +214,6 @@
warning('EEGLAB subfolders not found');
end;
end;
OPT_FOLDER = which('eeg_options');
OPT_FOLDER = fileparts( OPT_FOLDER );

% determine file format
% ---------------------
Expand Down Expand Up @@ -192,6 +242,8 @@
myaddpath( eeglabpath, 'eeglab1020.ced', [ 'functions' filesep 'resources' ]);
myaddpath( eeglabpath, 'eegplugin_dipfit', 'plugins');
end;
OPT_FOLDER = which('eeg_options');
OPT_FOLDER = fileparts( OPT_FOLDER );

eeglab_options;

Expand Down Expand Up @@ -1701,4 +1753,12 @@ function addpathexist(p)
else val = 0;
end;


function res = mywhich(varargin);
try
res = which(varargin{:});
catch
fprintf('Warning: permission error accesssing %s\n', varargin{1});
end;

function buildhelpmenu;

0 comments on commit 60eaaed

Please sign in to comment.