Skip to content

Commit

Permalink
Merge pull request #324 from tiborauer/eeglab
Browse files Browse the repository at this point in the history
ENH - EEGLAB with safe plugins
  • Loading branch information
tiborauer committed Feb 21, 2022
2 parents ba0acd9 + d942dc6 commit 85c8f9c
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions aa_tools/toolboxes/eeglabClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

properties (Access = private)
plugins = []
% tested plugin versions, will not overwrite already installed plugins
safePlugins = {...
'{"name": "clean_rawdata", "version": "2.5"}'...
}
end

properties (Access = protected, Dependent)
Expand Down Expand Up @@ -45,6 +49,7 @@
obj = obj@toolboxClass(argParse.Results.name,argParse.Results.path,argParse.Results.doAddToPath,vars);

obj.requiredPlugins = argParse.Results.requiredPlugins;
obj.safePlugins = cellfun(@jsondecode, obj.safePlugins);
end

function load(obj,keepWorkspace)
Expand All @@ -55,34 +60,21 @@ function load(obj,keepWorkspace)
if ~obj.showGUI, set(gcf,'visible','off'); end
obj.plugins = evalin('base','PLUGINLIST');

checkAMICA = false;
pllist = plugin_getweb('', obj.plugins, 'newlist');
for p = reshape(pllist,1,[])
if any(strcmp(obj.requiredPlugins, p.name)) && ~p.installed
if strcmp(p.name,'AMICA')
% p.version = '1.6'; % force the tested version - TODO: revise
% p.zip = spm_file(p.zip,'basename',['amica' p.version]);
% p.size = 1;
checkAMICA = true;
safeInf = obj.safePlugins(strcmp({obj.safePlugins.name},p.name));
if ~isempty(safeInf)
p.zip = spm_file(p.zip,'basename',[safeInf.name safeInf.version]);
p.version = safeInf.version;
p.size = 1; % force install
end
plugin_install(p.zip, p.name, p.version, p.size);
is_new_plugin = true;
end
end
if is_new_plugin, obj.load; end

if checkAMICA
[~,~,pl] = plugin_status('AMICA');
plPath = fullfile(obj.toolPath,'plugins',pl.foldername);
if isunix
fileattrib(fullfile(plPath,'amica15ex'),'+x');
fileattrib(fullfile(plPath,'amica15ub'),'+x');
% shadow amica15ex with amica15ub (N.B.: revert if you work on the Expanse Supercomputer)
movefile(fullfile(plPath,'amica15ex'),fullfile(plPath,'bcp_amica15ex'));
system(sprintf('ln -s %s %s',fullfile(plPath,'amica15ub'),fullfile(plPath,'amica15ex')));
end
end

load@toolboxClass(obj,keepWorkspace)
end

Expand Down

0 comments on commit 85c8f9c

Please sign in to comment.