-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathEx03_testICAmethods.m
More file actions
61 lines (50 loc) · 1.74 KB
/
Copy pathEx03_testICAmethods.m
File metadata and controls
61 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% Independent component analysis using classical methods
%
% BMI500 Course
% Lecture: An Introduction to Blind Source Separation and Independent Component Analysis
% By: R. Sameni
% Department of Biomedical Informatics, Emory University, Atlanta, GA, USA
% Fall 2020
%
% Dependency: The open-source electrophysiological toolbox (OSET):
% https://github.com/alphanumericslab/OSET.git
% OR
% https://gitlab.com/rsameni/OSET.git
%
clc
clear
close all
load EEGdata textdata data % Load a sample EEG signal
fs = 500;
x = data';
disp(textdata)
N = size(x, 1); % The number of channels
T = size(x, 2); % The number of samples per channel
% Plot the channels
PlotECG(x, 4, 'b', fs, 'Raw data channels');
% Run fastica
% Choose from two approaches symmetric or defletion
% extract few number of component, deflect is good than symmetric
approach = 'defl'; % 'symm' or 'defl'
% parameter for non-linearty
g = 'gauss'; % 'pow3', 'tanh', 'gauss', 'skew'
lastEigfastica = N; % PCA stage
numOfIC = N; % ICA stage
interactivePCA = 'off';
[s_fastica, A_fatsica, W_fatsica] = fastica (x, 'approach', approach, 'g', g, 'lastEig', lastEigfastica, 'numOfIC', numOfIC, 'interactivePCA', interactivePCA, 'verbose', 'off', 'displayMode', 'off');
% Check the covariance matrix
Cs = cov(s_fastica');
% Run JADE
lastEigJADE = N; % PCA stage
W_JADE = jadeR(x, lastEigJADE);
s_jade = W_JADE * x;
% Run SOBI
lastEigSOBI = N; % PCA stage
num_cov_matrices = 100;
[W_SOBI, s_sobi] = sobi(x, lastEigSOBI, num_cov_matrices);
% Plot the sources
PlotECG(s_fastica, 4, 'r', fs, 'Sources extracted by fatsica');
% Plot the sources
PlotECG(s_jade, 4, 'k', fs, 'Sources extracted by JADE');
% Plot the sources
PlotECG(s_sobi, 4, 'm', fs, 'Sources extracted by SOBI');