Skip to content

Commit 7378c4a

Browse files
committed
seperate each package and add them if unzip and add them if needed
1 parent f0607b9 commit 7378c4a

20 files changed

+215
-274
lines changed

.gitignore

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
./~/
2-
matlab_scripts/eeglab*
3-
matlab_scripts/inexact*
4-
matlab_scripts/VisLab-EEG-Clean-Tools*
5-
matlab_scripts/EEG-Clean-Tools-master*
6-
matlab_scripts/__MACOSX/
7-
matlab_scripts/asr*
8-
matlab_scripts/artifact_subspace_reconstruction*
9-
matlab_scripts/MARA-master/
2+
matlab_scripts/*
3+
!matlab_scripts/*.zip
104
state.mat
115
*_state.mat
126
*.m~

RunAutomagic.m

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
%% This script starts automagic and unzips required libraries
2-
3-
% unzip EEGLAB once
4-
eeglabdir = dir('./matlab_scripts/eeglab13_6_5b/');
5-
if isempty(eeglabdir)
6-
unzip('./matlab_scripts/eeglab13_6_5b.zip','./matlab_scripts/');
7-
end
8-
9-
% Unzip inexact ALM once
10-
eeglabdir = dir('./matlab_scripts/inexact_alm_rpca/');
11-
if isempty(eeglabdir)
12-
unzip('./matlab_scripts/inexact_alm_rpca.zip','./matlab_scripts/');
13-
end
14-
15-
addpath(genpath('.'))
16-
mainGUI
1+
%% This script starts Automagic
2+
run gui/mainGUI
173

gui/mainGUI.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ function mainGUI_OpeningFcn(hObject, eventdata, handles, varargin)
8989
% Add project paths
9090
% Checks 'project.m' as an example of a file in /src. Could be any other file
9191
% in /src
92-
if( ~exist('Subject.m', 'file'))
92+
addpath(genpath(('./')));
93+
if( ~exist('Subject.m', 'file'))
9394
addpath('../src/');
9495
addpath('../preprocessing/');
9596
end
9697

97-
9898
% Set Constant Values
9999
handles.CGV = ConstantGlobalValues;
100100

matlab_scripts/MARA-master.zip

7.73 MB
Binary file not shown.
497 KB
Binary file not shown.

matlab_scripts/clean_rawdata0.32.zip

111 KB
Binary file not shown.

matlab_scripts/eeglab13_6_5b.zip

-452 KB
Binary file not shown.

matlab_scripts/eeglab14_1_2b.zip

32.4 MB
Binary file not shown.

preprocessing/PreprocessingConstants.m

+26-2
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@
2222
'NOTCH_OTHER', [], ...
2323
'RUN_MESSAGE', 'Perform Filtering...')
2424

25+
EEGLabCsts = struct('ZIP', 'eeglab14_1_2b.zip')
26+
2527
CRDCsts = struct('URL', 'http://sccn.ucsd.edu/eeglab/plugins/clean_rawdata0.32.zip', ...
26-
'ZIP', 'clean_rawdata.zip', ...
28+
'ZIP', 'clean_rawdata0.32.zip', ...
2729
'RUN_MESSAGE', 'Finding bad channels...');
2830

2931
PrepCsts = struct('URL', 'https://github.com/VisLab/EEG-Clean-Tools/archive/master.zip', ...
30-
'ZIP', 'EEG-Clean-Tools.zip')
32+
'ZIP', 'VisLab-EEG-Clean-Tools.zip')
3133

3234
RPCACsts = struct(...
3335
'URL', 'http://perception.csl.illinois.edu/matrix-rank/Files/inexact_alm_rpca.zip', ...
3436
'ZIP', 'inexact_alm_rpca.zip', ...
3537
'RUN_MESSAGE', 'Performing Robust PCA (this may take a while...)');
3638

3739
MARACsts = struct(...
40+
'ZIP', 'MARA-master.zip', ...
3841
'REQ_CHAN_LABELS', {{'C3','C4','Cz','F3','F4','F7','F8',...
3942
'Fp1','Fp2','Fz','LM','NAS','O1','O2','Oz','P3','P4','P7'...
4043
,'P8','Pz','RM','T7','T8'}}, ...
@@ -54,4 +57,25 @@
5457
Settings = struct('pathToSteps', '/allSteps');
5558

5659
end
60+
61+
methods(Static)
62+
function path = LIBRARY_PATH()
63+
if ispc
64+
slash = '\';
65+
home = [getenv('HOMEDRIVE') getenv('HOMEPATH')];
66+
else
67+
slash = '/';
68+
home = getenv('HOME');
69+
end
70+
71+
name = 'matlab_scripts';
72+
if exist(name, 'dir')
73+
path = ['matlab_scripts' slash];
74+
elseif exist('preprocessing', 'dir')
75+
path = ['..' slash 'matlab_scripts' slash];
76+
else
77+
path = [home slash 'matlab_scripts' slash];
78+
end
79+
end
80+
end
5781
end

preprocessing/addCRD.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function addCRD()
2+
% addCRD Unzip and add the CRD package
3+
%
4+
% Copyright (C) 2017 Amirreza Bahreini, [email protected]
5+
%
6+
% This program is free software: you can redistribute it and/or modify
7+
% it under the terms of the GNU General Public License as published by
8+
% the Free Software Foundation, either version 3 of the License, or
9+
% (at your option) any later version.
10+
%
11+
% This program is distributed in the hope that it will be useful,
12+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
% GNU General Public License for more details.
15+
%
16+
% You should have received a copy of the GNU General Public License
17+
% along with this program. If not, see <http://www.gnu.org/licenses/>
18+
CSTS = PreprocessingConstants;
19+
ZIPName = CSTS.CRDCsts.ZIP;
20+
libraryPath = CSTS.LIBRARY_PATH;
21+
22+
parts = strsplit(ZIPName, '.zip');
23+
folderName = parts{1};
24+
25+
folderName = [libraryPath folderName];
26+
ZIPName = [libraryPath ZIPName];
27+
28+
if ~ exist(folderName, 'dir')
29+
unzip(ZIPName, folderName);
30+
end
31+
addpath(genpath(folderName));
32+
fprintf('clean_rawdata() package successfully unzipped. Continuing preprocessing....\n');
33+
34+
end

preprocessing/addEEGLab.m

+16-11
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,25 @@
2222
%
2323
% You should have received a copy of the GNU General Public License
2424
% along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
CSTS = PreprocessingConstants;
26+
ZIPName = CSTS.EEGLabCsts.ZIP;
27+
libraryPath = CSTS.LIBRARY_PATH;
2528

29+
parts = strsplit(ZIPName, '.zip');
30+
folderName = parts{1};
2631

27-
% System dependence:
28-
if(ispc)
29-
slash = '\';
30-
else
31-
slash = '/';
32+
folderName = [libraryPath folderName];
33+
ZIPName = [libraryPath ZIPName];
34+
35+
if ~ exist(folderName, 'dir')
36+
unzip(ZIPName, libraryPath);
3237
end
38+
eeglab_paths = genpath(folderName);
3339

34-
matlab_paths = genpath(['..' slash 'matlab_scripts' slash]);
3540
if(ispc)
36-
parts = strsplit(matlab_paths, ';');
41+
parts = strsplit(eeglab_paths, ';');
3742
else
38-
parts = strsplit(matlab_paths, ':');
43+
parts = strsplit(eeglab_paths, ':');
3944
end
4045

4146
% Exclude paths which create conflicts
@@ -46,10 +51,10 @@
4651
Index = not(~contains(parts, 'dpss'));
4752
parts(Index) = [];
4853
if(ispc)
49-
matlab_paths = strjoin(parts, ';');
54+
eeglab_paths = strjoin(parts, ';');
5055
else
51-
matlab_paths = strjoin(parts, ':');
56+
eeglab_paths = strjoin(parts, ':');
5257
end
53-
addpath(matlab_paths);
58+
addpath(eeglab_paths);
5459

5560
end

preprocessing/addMARA.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function addMARA()
2+
% addMARA Unzip and add the MARA package
3+
%
4+
% Copyright (C) 2017 Amirreza Bahreini, [email protected]
5+
%
6+
% This program is free software: you can redistribute it and/or modify
7+
% it under the terms of the GNU General Public License as published by
8+
% the Free Software Foundation, either version 3 of the License, or
9+
% (at your option) any later version.
10+
%
11+
% This program is distributed in the hope that it will be useful,
12+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
% GNU General Public License for more details.
15+
%
16+
% You should have received a copy of the GNU General Public License
17+
% along with this program. If not, see <http://www.gnu.org/licenses/>
18+
CSTS = PreprocessingConstants;
19+
ZIPName = CSTS.MARACsts.ZIP;
20+
libraryPath = CSTS.LIBRARY_PATH;
21+
22+
parts = strsplit(ZIPName, '.zip');
23+
folderName = parts{1};
24+
25+
folderName = [libraryPath folderName];
26+
ZIPName = [libraryPath ZIPName];
27+
28+
if ~ exist(folderName, 'dir')
29+
unzip(ZIPName, libraryPath);
30+
end
31+
addpath(genpath(folderName));
32+
fprintf('MARA package successfully unzipped. Continuing preprocessing....\n');
33+
34+
end

preprocessing/addPREP.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function addPREP()
2+
% addPREP Unzip and add the PREP package
3+
%
4+
% Copyright (C) 2017 Amirreza Bahreini, [email protected]
5+
%
6+
% This program is free software: you can redistribute it and/or modify
7+
% it under the terms of the GNU General Public License as published by
8+
% the Free Software Foundation, either version 3 of the License, or
9+
% (at your option) any later version.
10+
%
11+
% This program is distributed in the hope that it will be useful,
12+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
% GNU General Public License for more details.
15+
%
16+
% You should have received a copy of the GNU General Public License
17+
% along with this program. If not, see <http://www.gnu.org/licenses/>
18+
CSTS = PreprocessingConstants;
19+
ZIPName = CSTS.PrepCsts.ZIP;
20+
libraryPath = CSTS.LIBRARY_PATH;
21+
22+
parts = strsplit(ZIPName, '.zip');
23+
folderName = parts{1};
24+
25+
folderName = [libraryPath folderName];
26+
ZIPName = [libraryPath ZIPName];
27+
28+
if ~ exist(folderName, 'dir')
29+
unzip(ZIPName, libraryPath);
30+
end
31+
addpath(genpath(folderName));
32+
fprintf('PREP package successfully unzipped. Continuing preprocessing....\n');
33+
34+
end

preprocessing/downloadAndAddPaths.m preprocessing/addPaths.m

+27-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
function parts = downloadAndAddPaths(varargin)
2-
% downloadAndAddPaths Add path and download required packages
3-
% If a required package is not in the path, it adds or downloads them to
4-
% the path.
1+
function parts = addPaths(varargin)
2+
% addPaths Unzip and add required paths
3+
% If a required package is not in the path, it adds them to the path.
54
% A very naive approach is taken to see if the library is in path or not:
65
% simply check if one of their files exists or not.
76
%
8-
% parts = downloadAndAddPaths(varargin)
7+
% parts = addPaths(varargin)
98
% Where varargin is an optional parameter. When given, it should be a
10-
% struct with optional fields PrepParams and CRDParams corresponding to
11-
% PREP parameters and cleanrawdatA() parameters.
9+
% struct with optional fields PrepParams, CRDParams, RPCAParams and
10+
% MARAParams corresponding to PREP parameters, cleanrawdata() parameters,
11+
% RPCA parameters and MARA parameters.
1212
%
1313
% If varargin is ommited, default values are used. If any fields of
1414
% varargin is ommited, corresponsing default value is used. Please see
@@ -30,14 +30,21 @@
3030
%
3131
% You should have received a copy of the GNU General Public License
3232
% along with this program. If not, see <http://www.gnu.org/licenses/>.
33-
33+
CSTS = PreprocessingConstants;
3434
defaults = DefaultParameters;
3535
p = inputParser;
3636
addParameter(p,'PrepParams', defaults.PrepParams, @isstruct);
3737
addParameter(p,'CRDParams', defaults.CRDParams, @isstruct);
38+
addParameter(p,'RPCAParams', defaults.RPCAParams, @isstruct);
39+
addParameter(p,'MARAParams', defaults.MARAParams, @isstruct);
3840
parse(p, varargin{:});
3941
PrepParams = p.Results.PrepParams;
4042
CRDParams = p.Results.CRDParams;
43+
RPCAParams = p.Results.RPCAParams;
44+
MARAParams = p.Results.MARAParams;
45+
libraryPath = CSTS.LIBRARY_PATH;
46+
47+
addpath(libraryPath);
4148

4249
parts = [];
4350
if(~exist('pop_fileio', 'file'))
@@ -46,12 +53,22 @@
4653

4754
% Check and download if PREP does not exist
4855
if( ~isempty(PrepParams) && ~ exist('performReference.m', 'file'))
49-
downloadPREP();
56+
addPREP();
5057
end
5158

5259
% Check and download if cleanrawdata() does not exist
5360
if( ~isempty(CRDParams) && ~ exist('clean_artifacts.m', 'file'))
54-
downloadCRD();
61+
addCRD();
62+
end
63+
64+
% Check and download if cleanrawdata() does not exist
65+
if( ~isempty(RPCAParams) && ~ exist('inexact_alm_rpca.m', 'file'))
66+
addRPCA();
67+
end
68+
69+
% Check and download if cleanrawdata() does not exist
70+
if( ~isempty(MARAParams) && ~ exist('MARA.m', 'file'))
71+
addMARA();
5572
end
5673

5774
end

preprocessing/addRPCA.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function addRPCA()
2+
% addRPCA Unzip and add the RPCA package
3+
%
4+
% Copyright (C) 2017 Amirreza Bahreini, [email protected]
5+
%
6+
% This program is free software: you can redistribute it and/or modify
7+
% it under the terms of the GNU General Public License as published by
8+
% the Free Software Foundation, either version 3 of the License, or
9+
% (at your option) any later version.
10+
%
11+
% This program is distributed in the hope that it will be useful,
12+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
% GNU General Public License for more details.
15+
%
16+
% You should have received a copy of the GNU General Public License
17+
% along with this program. If not, see <http://www.gnu.org/licenses/>
18+
CSTS = PreprocessingConstants;
19+
ZIPName = CSTS.RPCACsts.ZIP;
20+
libraryPath = CSTS.LIBRARY_PATH;
21+
22+
parts = strsplit(ZIPName, '.zip');
23+
folderName = parts{1};
24+
25+
folderName = [libraryPath folderName];
26+
ZIPName = [libraryPath ZIPName];
27+
28+
if ~ exist(folderName, 'dir')
29+
unzip(ZIPName, libraryPath);
30+
end
31+
addpath(genpath(folderName));
32+
fprintf('RPCA package successfully unzipped. Continuing preprocessing....\n');
33+
34+
end

0 commit comments

Comments
 (0)