diff --git a/initEnv.m b/initEnv.m index febf28a..10efd18 100644 --- a/initEnv.m +++ b/initEnv.m @@ -1,18 +1,45 @@ -% -% 1 - Check if version requirements -% are satisfied and the packages are -% are installed/loaded: -% Octave > 4 -% - image -% - optim -% - struct -% - statistics -% -% MATLAB >= R2015b -% -% 2 - Add project to the O/M path - -function initEnv +function initEnv(varargin) + % + % 1 - Check if version requirements are satisfied and the packages are are installed/loaded: + % Octave > 4 + % - image + % - optim + % - struct + % - statistics + % + % MATLAB >= R2015b + % + % 2 - Add project to the O/M path + % + % USAGE:: + % + % initEnv + % initEnv('init') + % initEnv('uninit') + % + % :param action: + % :type action: string + % + % :returns: - :action: (type) (dimension) + % + % Example:: + % + + % (C) Copyright 2022 CPP_BIDS developers + + p = inputParser; + + defaultAction = 'init'; + + addOptional(p, 'action', defaultAction, @ischar); + % addParameter(p, 'verbose', true); + + parse(p, varargin{:}); + + action = p.Results.action; + % verbose = p.Results.verbose; + + % Check Matlab and Octave version octaveVersion = '4.0.3'; matlabVersion = '8.6.0'; @@ -59,7 +86,7 @@ 'Try this in your terminal:', ... ' git submodule update --recursive ']); else - addDependencies(); + addDependencies(action); end disp('Correct matlab/octave versions and added to the path!'); @@ -96,13 +123,24 @@ function tryInstallFromForge(packageName) end -function addDependencies() +function addDependencies(action) pth = fileparts(mfilename('fullpath')); - addpath(fullfile(pth, 'lib', 'CPP_BIDS')); - addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src'))); - addpath(fullfile(pth, 'subfun')); - checkCppBidsDependencies(); + switch lower(action) + + case 'init' + + run(fullfile(pth, 'lib', 'CPP_PTB', 'cpp_ptb')); + run(fullfile(pth, 'lib', 'CPP_BIDS', 'cpp_bids')); + addpath(genpath(fullfile(pth, 'src'))); + + case 'uninit' + + cpp_ptb('uninit'); + cpp_bids('uninit'); + rmpath(genpath(fullfile(pth, 'src'))); + + end end diff --git a/lib/CPP_BIDS b/lib/CPP_BIDS index f814264..3a0613e 160000 --- a/lib/CPP_BIDS +++ b/lib/CPP_BIDS @@ -1 +1 @@ -Subproject commit f814264af94fbfd5a4ef6644abd68f30f90883f2 +Subproject commit 3a0613e64b2048db0f4a8b97c26722b691e034df diff --git a/lib/CPP_PTB b/lib/CPP_PTB index 0738579..06fd8eb 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit 073857927bd9c9ebb35a0d0d9675239b135960b3 +Subproject commit 06fd8ebbae190c62ac04f4b57953b904a79ad9ef diff --git a/mainScript.m b/mainScript.m index 2f3fa11..6ab993a 100644 --- a/mainScript.m +++ b/mainScript.m @@ -11,7 +11,7 @@ end % make sure we got access to all the required functions and inputs -initEnv(); +initEnv('init'); % set and load all the parameters to run the experiment cfg = setParameters; @@ -125,6 +125,8 @@ cleanUp(); + initEnv('uninit'); + catch cleanUp();