braindecode 0.1.5.4__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/PKG-INFO +1 -1
  2. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/SOURCES.txt +2 -0
  3. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/PKG-INFO +1 -1
  4. Braindecode-0.1.6/braindecode/datasets/sensor_positions.py +217 -0
  5. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/util.py +95 -0
  6. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/conf.py +2 -2
  7. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/index.rst +1 -0
  8. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/Cropped_Decoding.ipynb +4 -4
  9. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/TrialWise_Decoding.ipynb +9 -4
  10. Braindecode-0.1.6/docs/notebooks/visualization/Perturbation.ipynb +1840 -0
  11. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.datasets.rst +8 -0
  12. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/setup.py +1 -1
  13. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/dependency_links.txt +0 -0
  14. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/not-zip-safe +0 -0
  15. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/requires.txt +0 -0
  16. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/Braindecode.egg-info/top_level.txt +0 -0
  17. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/LICENSE.txt +0 -0
  18. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/MANIFEST.in +0 -0
  19. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/README.rst +0 -0
  20. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/__init__.py +0 -0
  21. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datasets/__init__.py +0 -0
  22. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datasets/bbci.py +0 -0
  23. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datasets/bcic_iv_2a.py +0 -0
  24. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datasets/multiple.py +0 -0
  25. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/__init__.py +0 -0
  26. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/iterators.py +0 -0
  27. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/signal_target.py +0 -0
  28. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/signalproc.py +0 -0
  29. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/splitters.py +0 -0
  30. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/trial_segment.py +0 -0
  31. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/datautil/util.py +0 -0
  32. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/experiments/__init__.py +0 -0
  33. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/experiments/experiment.py +0 -0
  34. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/experiments/monitors.py +0 -0
  35. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/experiments/stopcriteria.py +0 -0
  36. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/mne_ext/__init__.py +0 -0
  37. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/mne_ext/signalproc.py +0 -0
  38. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/models/__init__.py +0 -0
  39. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/models/deep4.py +0 -0
  40. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/models/eegnet.py +0 -0
  41. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/models/shallow_fbcsp.py +0 -0
  42. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/models/util.py +0 -0
  43. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/__init__.py +0 -0
  44. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/constraints.py +0 -0
  45. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/functions.py +0 -0
  46. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/init.py +0 -0
  47. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/losses.py +0 -0
  48. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/modules.py +0 -0
  49. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/braindecode/torch_ext/util.py +0 -0
  50. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/Makefile +0 -0
  51. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/BBCI_Data.ipynb +0 -0
  52. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/BBCI_Data_Start_Stop.ipynb +0 -0
  53. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/BBCI_Data_Trialwise.ipynb +0 -0
  54. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/notebooks/Experiment_Class.ipynb +0 -0
  55. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.datautil.rst +0 -0
  56. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.experiments.rst +0 -0
  57. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.mne_ext.rst +0 -0
  58. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.models.rst +0 -0
  59. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.rst +0 -0
  60. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/braindecode.torch_ext.rst +0 -0
  61. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/docs/source/modules.rst +0 -0
  62. {Braindecode-0.1.5.4 → Braindecode-0.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Braindecode
3
- Version: 0.1.5.4
3
+ Version: 0.1.6
4
4
  Summary: A deep learning toolbox to decode raw time-domain EEG.
5
5
  Home-page: https://github.com/robintibor/braindecode
6
6
  Author: Robin Tibor Schirrmeister
@@ -14,6 +14,7 @@ braindecode/datasets/__init__.py
14
14
  braindecode/datasets/bbci.py
15
15
  braindecode/datasets/bcic_iv_2a.py
16
16
  braindecode/datasets/multiple.py
17
+ braindecode/datasets/sensor_positions.py
17
18
  braindecode/datautil/__init__.py
18
19
  braindecode/datautil/iterators.py
19
20
  braindecode/datautil/signal_target.py
@@ -48,6 +49,7 @@ docs/notebooks/BBCI_Data_Trialwise.ipynb
48
49
  docs/notebooks/Cropped_Decoding.ipynb
49
50
  docs/notebooks/Experiment_Class.ipynb
50
51
  docs/notebooks/TrialWise_Decoding.ipynb
52
+ docs/notebooks/visualization/Perturbation.ipynb
51
53
  docs/source/braindecode.datasets.rst
52
54
  docs/source/braindecode.datautil.rst
53
55
  docs/source/braindecode.experiments.rst
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Braindecode
3
- Version: 0.1.5.4
3
+ Version: 0.1.6
4
4
  Summary: A deep learning toolbox to decode raw time-domain EEG.
5
5
  Home-page: https://github.com/robintibor/braindecode
6
6
  Author: Robin Tibor Schirrmeister
@@ -0,0 +1,217 @@
1
+ import numpy as np
2
+ import math
3
+
4
+
5
+ CHANNEL_10_20_APPROX = ('angle',
6
+ ('Fpz',(0.000, 4.000)),
7
+ ('Fp1',(-3.500, 3.500)),
8
+ ('Fp2',(3.500, 3.500)),
9
+ ('AFp3h',(-1.000, 3.500)),
10
+ ('AFp4h',(1.000, 3.500)),
11
+ ('AF7',(-4.000, 3.000)),
12
+ ('AF3',(-2.000, 3.000)),
13
+ ('AFz',(0.000, 3.000)),
14
+ ('AF4',(2.000, 3.000)),
15
+ ('AF8',(4.000, 3.000)),
16
+ ('AFF5h',(-2.500, 2.500)),
17
+ ('AFF1',(-0.500, 2.500)),
18
+ ('AFF2',(0.500, 2.500)),
19
+ ('AFF6h',(2.500, 2.500)),
20
+ ('F7',(-4.000, 2.000)),
21
+ ('F5',(-3.000, 2.000)),
22
+ ('F3',(-2.000, 2.000)),
23
+ ('F1',(-1.000, 2.000)),
24
+ ('Fz',(0.000, 2.000)),
25
+ ('F2',(1.000, 2.000)),
26
+ ('F4',(2.000, 2.000)),
27
+ ('F6',(3.000, 2.000)),
28
+ ('F8',(4.000, 2.000)),
29
+ ('FFT7h',(-3.500, 1.500)),
30
+ ('FFC5h',(-2.500, 1.500)),
31
+ ('FFC3h',(-1.500, 1.500)),
32
+ ('FFC1h',(-0.500, 1.500)),
33
+ ('FFC2h',(0.500, 1.500)),
34
+ ('FFC4h',(1.500, 1.500)),
35
+ ('FFC6h',(2.500, 1.500)),
36
+ ('FFT8h',(3.500, 1.500)),
37
+ ('FT9',(-5.000, 1.000)),
38
+ ('FT7',(-4.000, 1.000)),
39
+ ('FC5',(-3.000, 1.000)),
40
+ ('FC3',(-2.000, 1.000)),
41
+ ('FC1',(-1.000, 1.000)),
42
+ ('FCz',(0.000, 1.000)),
43
+ ('FC2',(1.000, 1.000)),
44
+ ('FC4',(2.000, 1.000)),
45
+ ('FC6',(3.000, 1.000)),
46
+ ('FT8',(4.000, 1.000)),
47
+ ('FT10',(5.000, 1.000)),
48
+ ('FTT9h',(-4.500, 0.500)),
49
+ ('FTT7h',(-3.500, 0.500)),
50
+ ('FCC5h',(-2.500, 0.500)),
51
+ ('FCC3h',(-1.500, 0.500)),
52
+ ('FCC1h',(-0.500, 0.500)),
53
+ ('FCC2h',(0.500, 0.500)),
54
+ ('FCC4h',(1.500, 0.500)),
55
+ ('FCC6h',(2.500, 0.500)),
56
+ ('FTT8h',(3.500, 0.500)),
57
+ ('FTT10h',(4.500, 0.500)),
58
+ ('M1',(-5.000, 0.000)),
59
+ # notsure if correct:
60
+ ('T9', (-4.500, 0.000)),
61
+ ('T7',(-4.000, 0.000)),
62
+ ('C5',(-3.000, 0.000)),
63
+ ('C3',(-2.000, 0.000)),
64
+ ('C1',(-1.000, 0.000)),
65
+ ('Cz',(0.000, 0.000)),
66
+ ('C2',(1.000, 0.000)),
67
+ ('C4',(2.000, 0.000)),
68
+ ('C6',(3.000, 0.000)),
69
+ ('T8',(4.000, 0.000)),
70
+ ('T10', (4.500, 0.000)),
71
+ ('M2',(5.000, 0.000)),
72
+ ('TTP7h',(-3.500, -0.500)),
73
+ ('CCP5h',(-2.500, -0.500)),
74
+ ('CCP3h',(-1.500, -0.500)),
75
+ ('CCP1h',(-0.500, -0.500)),
76
+ ('CCP2h',(0.500, -0.500)),
77
+ ('CCP4h',(1.500, -0.500)),
78
+ ('CCP6h',(2.500, -0.500)),
79
+ ('TTP8h',(3.500, -0.500)),
80
+ ('TP7',(-4.000, -1.000)),
81
+ ('CP5',(-3.000, -1.000)),
82
+ ('CP3',(-2.000, -1.000)),
83
+ ('CP1',(-1.000, -1.000)),
84
+ ('CPz',(0.000, -1.000)),
85
+ ('CP2',(1.000, -1.000)),
86
+ ('CP4',(2.000, -1.000)),
87
+ ('CP6',(3.000, -1.000)),
88
+ ('TP8',(4.000, -1.000)),
89
+ ('TPP9h',(-4.500, -1.500)),
90
+ ('TPP7h',(-3.500, -1.500)),
91
+ ('CPP5h',(-2.500, -1.500)),
92
+ ('CPP3h',(-1.500, -1.500)),
93
+ ('CPP1h',(-0.500, -1.500)),
94
+ ('CPP2h',(0.500, -1.500)),
95
+ ('CPP4h',(1.500, -1.500)),
96
+ ('CPP6h',(2.500, -1.500)),
97
+ ('TPP8h',(3.500, -1.500)),
98
+ ('TPP10h',(4.500, -1.500)),
99
+ ('P9',(-5.000, -2.000)),
100
+ ('P7',(-4.000, -2.000)),
101
+ ('P5',(-3.000, -2.000)),
102
+ ('P3',(-2.000, -2.000)),
103
+ ('P1',(-1.000, -2.000)),
104
+ ('Pz',(0.000, -2.000)),
105
+ ('P2',(1.000, -2.000)),
106
+ ('P4',(2.000, -2.000)),
107
+ ('P6',(3.000, -2.000)),
108
+ ('P8',(4.000, -2.000)),
109
+ ('P10',(5.000, -2.000)),
110
+ ('PPO9h',(-4.500, -2.500)),
111
+ ('PPO5h',(-3.000, -2.500)),
112
+ ('PPO1',(-0.650, -2.500)),
113
+ ('PPO2',(0.650, -2.500)),
114
+ ('PPO6h',(3.000, -2.500)),
115
+ ('PPO10h',(4.500, -2.500)),
116
+ ('PO9',(-5.000, -3.000)),
117
+ ('PO7',(-4.000, -3.000)),
118
+ ('PO5',(-3.000, -3.000)),
119
+ ('PO3',(-2.000, -3.000)),
120
+ ('PO1',(-1.000, -3.000)),
121
+ ('POz',(0.000, -3.000)),
122
+ ('PO2',(1.000, -3.000)),
123
+ ('PO4',(2.000, -3.000)),
124
+ ('PO6',(3.000, -3.000)),
125
+ ('PO8',(4.000, -3.000)),
126
+ ('PO10',(5.000, -3.000)),
127
+ ('POO9h',(-4.500, -3.250)),
128
+ ('POO3h',(-2.000, -3.250)),
129
+ ('POO4h',(2.000, -3.250)),
130
+ ('POO10h',(4.500, -3.250)),
131
+ ('O1',(-2.500, -3.750)),
132
+ ('Oz',(0.000, -3.750)),
133
+ ('O2',(2.500, -3.750)),
134
+ ('OI1h',(1.500, -4.250)),
135
+ ('OI2h',(-1.500, -4.250)),
136
+ ('I1',(1.000, -4.500)),
137
+ ('Iz',(0.000, -4.500)),
138
+ ('I2',(-1.000, -4.500)),
139
+ )
140
+
141
+
142
+ def get_channelpos(channame, chan_pos_list):
143
+ if chan_pos_list[0] == 'angle':
144
+ return get_channelpos_from_angle(channame, chan_pos_list[1:])
145
+ elif chan_pos_list[0] == 'cartesian':
146
+ channame = channame.lower()
147
+ for name, coords in chan_pos_list[1:]:
148
+ if name.lower() == channame:
149
+ return coords[0], coords[1]
150
+ return None
151
+ else:
152
+ raise ValueError("Unknown first element "
153
+ "{:s} (should be type of positions)".format(
154
+ chan_pos_list[0]))
155
+
156
+
157
+ def get_channelpos_from_angle(channame, chan_pos_list=CHANNEL_10_20_APPROX):
158
+ """Return the x/y position of a channel.
159
+
160
+ This method calculates the stereographic projection of a channel
161
+ from ``CHANNEL_10_20``, suitable for a scalp plot.
162
+
163
+ Parameters
164
+ ----------
165
+ channame : str
166
+ Name of the channel, the search is case insensitive.
167
+
168
+ chan_pos_list=CHANNEL_10_20_APPROX,
169
+ interpolation='bilinear'
170
+
171
+ Returns
172
+ -------
173
+ x, y : float or None
174
+ The projected point on the plane if the point is known,
175
+ otherwise ``None``
176
+
177
+ Examples
178
+ --------
179
+
180
+ >>> plot.get_channelpos_from_angle('C2')
181
+ (0.1720792096741632, 0.0)
182
+ >>> # the channels are case insensitive
183
+ >>> plot.get_channelpos_from_angle('c2')
184
+ (0.1720792096741632, 0.0)
185
+ >>> # lookup for an invalid channel
186
+ >>> plot.get_channelpos_from_angle('foo')
187
+ None
188
+
189
+ """
190
+ channame = channame.lower()
191
+ for i in chan_pos_list:
192
+ if i[0].lower() == channame:
193
+ # convert the 90/4th angular position into x, y, z
194
+ p = i[1]
195
+ ea, eb = p[0] * (90 / 4), p[1] * (90 / 4)
196
+ ea = ea * math.pi / 180
197
+ eb = eb * math.pi / 180
198
+ x = math.sin(ea) * math.cos(eb)
199
+ y = math.sin(eb)
200
+ z = math.cos(ea) * math.cos(eb)
201
+ # Calculate the stereographic projection.
202
+ # Given a unit sphere with radius ``r = 1`` and center at
203
+ # the origin. Project the point ``p = (x, y, z)`` from the
204
+ # sphere's South pole (0, 0, -1) on a plane on the sphere's
205
+ # North pole (0, 0, 1).
206
+ #
207
+ # The formula is:
208
+ #
209
+ # P' = P * (2r / (r + z))
210
+ #
211
+ # We changed the values to move the point of projection
212
+ # further below the south pole
213
+ mu = 1 / (1.3 + z)
214
+ x *= mu
215
+ y *= mu
216
+ return x, y
217
+ return None
@@ -3,6 +3,101 @@ import errno
3
3
  import numpy as np
4
4
 
5
5
 
6
+ def corr(a, b):
7
+ """
8
+ Computes correlation only between terms of a and terms of b, not within
9
+ a and b.
10
+
11
+ Parameters
12
+ ----------
13
+ a, b: 2darray, features x samples
14
+
15
+ Returns
16
+ -------
17
+ Correlation between features in x and features in y
18
+ """
19
+ # Difference to numpy:
20
+ # Correlation only between terms of x and y
21
+ # not between x and x or y and y
22
+ this_cov = cov(a, b)
23
+ return _cov_to_corr(this_cov, a, b)
24
+
25
+
26
+ def cov(a, b):
27
+ """
28
+ Computes covariance only between terms of a and terms of b, not within
29
+ a and b.
30
+
31
+ Parameters
32
+ ----------
33
+ a, b: 2darray, features x samples
34
+
35
+ Returns
36
+ -------
37
+ Covariance between features in x and features in y
38
+ """
39
+ demeaned_a = a - np.mean(a, axis=1, keepdims=True)
40
+ demeaned_b = b - np.mean(b, axis=1, keepdims=True)
41
+ this_cov = np.dot(demeaned_a, demeaned_b.T) / (b.shape[1] - 1)
42
+ return this_cov
43
+
44
+
45
+ def _cov_to_corr(this_cov, a, b):
46
+ # computing "unbiased" corr
47
+ # ddof=1 for unbiased..
48
+ var_a = np.var(a, axis=1, ddof=1)
49
+ var_b = np.var(b, axis=1, ddof=1)
50
+ return _cov_and_var_to_corr(this_cov, var_a, var_b)
51
+
52
+
53
+ def _cov_and_var_to_corr(this_cov, var_a, var_b):
54
+ divisor = np.outer(np.sqrt(var_a), np.sqrt(var_b))
55
+ return this_cov / divisor
56
+
57
+
58
+ def wrap_reshape_apply_fn(stat_fn, a, b, axis_a, axis_b):
59
+ """
60
+ Reshape two nd-arrays into 2d-arrays, apply function and reshape
61
+ result back.
62
+ Parameters
63
+ ----------
64
+ stat_fn: function
65
+ Function to apply to 2d-arrays
66
+ a: nd-array: nd-array
67
+ b: nd-array
68
+ axis_a: int or list of int
69
+ sample axis
70
+ axis_b: int or list of int
71
+ sample axis
72
+
73
+ Returns
74
+ -------
75
+ result: nd-array
76
+ The result reshaped to remaining_dims_a + remaining_dims_b
77
+ """
78
+ if not hasattr(axis_a, '__len__'):
79
+ axis_a = [axis_a]
80
+ if not hasattr(axis_b, '__len__'):
81
+ axis_b = [axis_b]
82
+ other_axis_a = [i for i in range(a.ndim) if i not in axis_a]
83
+ other_axis_b = [i for i in range(b.ndim) if i not in axis_b]
84
+ transposed_topo_a = a.transpose(tuple(other_axis_a) + tuple(axis_a))
85
+ n_stat_axis_a = [a.shape[i] for i in axis_a]
86
+ n_other_axis_a = [a.shape[i] for i in other_axis_a]
87
+ flat_topo_a = transposed_topo_a.reshape(np.prod(n_other_axis_a),
88
+ np.prod(n_stat_axis_a))
89
+ transposed_topo_b = b.transpose(tuple(other_axis_b) + tuple(axis_b))
90
+ n_stat_axis_b = [b.shape[i] for i in axis_b]
91
+ n_other_axis_b = [b.shape[i] for i in other_axis_b]
92
+ flat_topo_b = transposed_topo_b.reshape(np.prod(n_other_axis_b),
93
+ np.prod(n_stat_axis_b))
94
+ assert np.array_equal(n_stat_axis_a, n_stat_axis_b)
95
+ stat_result = stat_fn(flat_topo_a, flat_topo_b)
96
+ topo_result = stat_result.reshape(
97
+ tuple(n_other_axis_a) + tuple(n_other_axis_b))
98
+ return topo_result
99
+
100
+
6
101
  class FuncAndArgs(object):
7
102
  """Container for a function and its arguments.
8
103
  Useful in case you want to pass a function and its arguments
@@ -108,9 +108,9 @@ author = 'Robin Tibor Schirrmeister'
108
108
  # built documents.
109
109
  #
110
110
  # The short X.Y version.
111
- version = '0.1.5'
111
+ version = '0.1.6'
112
112
  # The full version, including alpha/beta/rc tags.
113
- release = '0.1.5'
113
+ release = '0.1.6'
114
114
 
115
115
  # The language for content autogenerated by Sphinx. Refer to documentation
116
116
  # for a list of supported languages.
@@ -42,6 +42,7 @@ Tutorials
42
42
  notebooks/TrialWise_Decoding.ipynb
43
43
  notebooks/Cropped_Decoding.ipynb
44
44
  notebooks/Experiment_Class.ipynb
45
+ notebooks/visualization/Perturbation.ipynb
45
46
 
46
47
 
47
48
  API
@@ -418,10 +418,10 @@
418
418
  " for batch_X, batch_y in iterator.get_batches(train_set, shuffle=False):\n",
419
419
  " net_in = np_to_var(batch_X)\n",
420
420
  " if cuda:\n",
421
- " net_in.cuda()\n",
421
+ " net_in = net_in.cuda()\n",
422
422
  " net_target = np_to_var(batch_y)\n",
423
423
  " if cuda:\n",
424
- " net_target.cuda()\n",
424
+ " net_target = net_target.cuda()\n",
425
425
  " # Remove gradients of last backward pass from all parameters \n",
426
426
  " optimizer.zero_grad()\n",
427
427
  " outputs = model(net_in)\n",
@@ -445,10 +445,10 @@
445
445
  " for batch_X, batch_y in iterator.get_batches(dataset, shuffle=False):\n",
446
446
  " net_in = np_to_var(batch_X)\n",
447
447
  " if cuda:\n",
448
- " net_in.cuda()\n",
448
+ " net_in = net_in.cuda()\n",
449
449
  " net_target = np_to_var(batch_y)\n",
450
450
  " if cuda:\n",
451
- " net_target.cuda()\n",
451
+ " net_target = net_target.cuda()\n",
452
452
  " outputs = model(net_in)\n",
453
453
  " all_preds.append(var_to_np(outputs))\n",
454
454
  " outputs = th.mean(outputs, dim=2)[:,:,0]\n",
@@ -464,10 +464,10 @@
464
464
  " batch_y = train_set.y[i_trials]\n",
465
465
  " net_in = np_to_var(batch_X)\n",
466
466
  " if cuda:\n",
467
- " net_in.cuda()\n",
467
+ " net_in = net_in.cuda()\n",
468
468
  " net_target = np_to_var(batch_y)\n",
469
469
  " if cuda:\n",
470
- " net_target.cuda()\n",
470
+ " net_target = net_target.cuda()\n",
471
471
  " # Remove gradients of last backward pass from all parameters \n",
472
472
  " optimizer.zero_grad()\n",
473
473
  " # Compute outputs of the network\n",
@@ -487,10 +487,10 @@
487
487
  " # for such smaller datasets. Otherwise we would have to use batches.\n",
488
488
  " net_in = np_to_var(dataset.X[:,:,:,None])\n",
489
489
  " if cuda:\n",
490
- " net_in.cuda()\n",
490
+ " net_in = net_in.cuda()\n",
491
491
  " net_target = np_to_var(dataset.y)\n",
492
492
  " if cuda:\n",
493
- " net_target.cuda()\n",
493
+ " net_target = net_target.cuda()\n",
494
494
  " outputs = model(net_in)\n",
495
495
  " loss = F.nll_loss(outputs, net_target)\n",
496
496
  " print(\"{:6s} Loss: {:.5f}\".format(\n",
@@ -536,6 +536,11 @@
536
536
  },
537
537
  "outputs": [],
538
538
  "source": [
539
+ "import mne\n",
540
+ "import numpy as np\n",
541
+ "from mne.io import concatenate_raws\n",
542
+ "from braindecode.datautil.signal_target import SignalAndTarget\n",
543
+ "\n",
539
544
  "physionet_paths = [ mne.datasets.eegbci.load_data(sub_id,[4,8,12,]) for sub_id in range(1,51)]\n",
540
545
  "physionet_paths = np.concatenate(physionet_paths)\n",
541
546
  "parts = [mne.io.read_raw_edf(path, preload=True,stim_channel='auto')\n",