-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path05_input.py
More file actions
107 lines (91 loc) · 2.68 KB
/
05_input.py
File metadata and controls
107 lines (91 loc) · 2.68 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# %% [markdown]
# # Technical background
# - A search of features for
# - k-fold (10) evaluation with unmixed persons
# - the overall specificity and sensitivity is calculed as a __minimal__ value of 10 folds
# - NSGA-II search
# - selects the window size in the gene
#
# # Issues and weaknesses
# - How to determine, if we found a specific feature, or some recording-specific noise? control and test dataset were captured using different device
#
#
# %%
#%pip install py-paretoarchive
import pickle, gzip, json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from paretoarchive.pandas import pareto
import re
import os
import glob
from galib import DataParser
from mpl_toolkits.axes_grid1 import make_axes_locatable
# %%
d = DataParser()
data = d.get_data()
# %%
viz = data["x"][0]
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8))
cm = plt.get_cmap("inferno")
for i in range(viz.shape[0]):
ax1.plot(data["freqs"], viz[i, :], label=data["features"][i].replace("EEG ", ""), c = cm(i / viz.shape[0]))
ax1.legend(ncol=3)
ax1.set(
xlim=(0, 128),
ylim=(-180, -80),
title="(a) PSD diagram",
xlabel="Frequency [Hz]",
ylabel="Power [dB]"
)
divider = make_axes_locatable(ax2)
im = ax2.imshow(viz, aspect="auto", interpolation="none",
extent=(0, 128, 19, 0), vmin=-180, vmax=-80, rasterized=True)
cax = divider.append_axes('right', size='5%', pad=0.05)
cb = fig.colorbar(im, cax=cax, orientation='vertical')
cb.set_label("Power [dB]")
ax2.set_yticks(
np.arange(viz.shape[0]) + 0.5,
[x.replace("EEG ", "") for x in data["features"]]
)
ax2.set(
title="(b) Matrix representation",
xlabel="Frequency [Hz]",
ylabel="Channel"
)
plt.tight_layout()
plt.savefig("plt/subject.pdf")
# %%
viz = data["x"][0]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))
cm = plt.get_cmap("inferno")
for i in range(viz.shape[0]):
ax1.plot(data["freqs"], viz[i, :], label=data["features"][i].replace("EEG ", ""), c = cm(i / viz.shape[0]))
ax1.legend(ncol=2)
ax1.set(
xlim=(0, 128),
ylim=(-180, -80),
title="(a) PSD diagram",
xlabel="Frequency [Hz]",
ylabel="Power [dB]"
)
divider = make_axes_locatable(ax2)
im = ax2.imshow(viz, aspect="auto", interpolation="none",
extent=(0, 128, 19, 0), vmin=-180, vmax=-80, rasterized=True)
cax = divider.append_axes('right', size='5%', pad=0.05)
cb = fig.colorbar(im, cax=cax, orientation='vertical')
cb.set_label("Power [dB]")
ax2.set_yticks(
np.arange(viz.shape[0]) + 0.5,
[x.replace("EEG ", "") for x in data["features"]]
)
ax2.set(
title="(b) Matrix representation",
xlabel="Frequency [Hz]",
ylabel="Channel"
)
plt.tight_layout()
plt.savefig("plt/subject_line.pdf")
# %%