-
Notifications
You must be signed in to change notification settings - Fork 0
/
eeg_rpsd_compare.m
56 lines (46 loc) · 1.33 KB
/
eeg_rpsd_compare.m
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
% this script compares the MATLAB and Python version of the function
clear
pyenv('Version', '/Users/arno/miniconda3/envs/p39env/bin/python');
eeglabpath = which('eeglab.m');
eeglabpath = eeglabpath(1:end-length('eeglab.m'));
fileName = fullfile(eeglabpath, 'sample_data', 'eeglab_data_epochs_ica.set');
%fileName = fullfile(pwd, 'eeglab_data_with_ica_tmp.set');
% call Python function
system(['/Users/arno/miniconda3/envs/p311env/bin/python eeg_rpsd_compare_helper.py ' fileName]);
res = load('eeg_rpsd_data.mat');
%delete('eeg_rpsd_data.mat');
% call EEGLAB function
EEG = pop_loadset(fileName);
temp2 = eeg_rpsd(EEG, 100);
%% compare the two
figure('position', [924 752 912 565])
subplot(2,2,1);
imagesc(temp2); title('MATLAB');
cl = clim;
ylabel('Component index')
title('MATLAB');
subplot(2,2,3);
imagesc(res.grid); title('Python');
xlabel('Frequency (Hz)')
ylabel('Component index')
clim(cl)
title('Python');
cbar;
subplot(2,2,2);
imagesc(temp2-res.grid);
clim(cl-mean(cl))
title('Difference');
cbar;
subplot(2,2,4);
imagesc(temp2-res.grid);
xlabel('Frequency (Hz)')
cl = clim;
clim(cl-mean(cl))
title('Magnified difference');
cbar;
setfont(gcf, 'fontsize', 20)
set(gcf, 'color', 'w')
set(gcf, 'PaperPositionMode', 'auto');
print('-djpeg', 'figures/ersp_diff.jpg')
print('-depsc', 'figures/ersp_diff.eps')
compare_variables(temp2, res.grid);