Skip to content

Commit 1f145ec

Browse files
committed
misc: added pytest config to CI, fixed stuff that broke in refactor, updated docs
1 parent 08d4164 commit 1f145ec

File tree

7 files changed

+49
-45
lines changed

7 files changed

+49
-45
lines changed

doc/getting_started/installation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Start a jupyter notebooks session and you will be presented with the eeg-noteboo
113113
# Imports
114114
import os
115115
from eegnb import generate_save_fn
116-
from eegnb.devices.eeg import EEG
116+
from eegnb.devices import EEGDevice
117117
from eegnb.experiments.visual_n170 import n170
118118
from eegnb.analysis.utils import load_data
119119
@@ -126,7 +126,7 @@ Start a jupyter notebooks session and you will be presented with the eeg-noteboo
126126
record_duration=120
127127
128128
# Initiate EEG device
129-
eeg_device = EEG(device=board_name)
129+
eeg_device = EEGDevice.create(device=board_name)
130130
131131
# Create output filename
132132
save_fn = generate_save_fn(board_name, experiment, subject)

doc/getting_started/running_experiments.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The first step is to import all of the necessary library dependencies. These are
7777

7878
```python
7979
from eegnb import generate_save_fn
80-
from eegnb.devices.eeg import EEG
80+
from eegnb.devices import EEGDevice
8181
from eegnb.experiments.visual_n170 import n170
8282
```
8383

@@ -94,10 +94,10 @@ record_duration = 120
9494
save_fn = generate_save_fn(board_name, experiment, subject, session)
9595
```
9696

97-
Next it is necessary to call the `eegnb.devices.eeg.EEG` class which handles all of the backend processes related to each device.
97+
Next it is necessary to create an instance of the `eegnb.devices.EEGDevice` class which handles all of the backend processes related to each device.
9898

9999
```python
100-
eeg_device = EEG(device=board_name)
100+
eeg_device = EEGDevice.create(device_name=board_name)
101101
```
102102

103103
Finally, we call the `present` method of the class corresponding to our desired experiment, in this case the visual N170. We pass both the EEG device and generated save file name in order to collect and save data. The presentation can also be run without an EEG device/save file for testing and debugging.
@@ -110,7 +110,7 @@ All together the example script looks like
110110
```python
111111
# Imports
112112
from eegnb import generate_save_fn
113-
from eegnb.devices.eeg import EEG
113+
from eegnb.devices import EEGDevice
114114
from eegnb.experiments.visual_n170 import n170
115115

116116
# Define some variables
@@ -124,8 +124,8 @@ record_duration = 120
124124
save_fn = generate_save_fn(board_name, experiment, subject, session)
125125

126126
# Setup EEG device
127-
eeg_device = EEG(device=board_name)
127+
eeg_device = EEGDevice.create(device_name=board_name)
128128

129129
# Run stimulus presentation
130130
n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
131-
```
131+
```

doc/getting_started/streaming.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@ Before getting going with running an experiment, it is important to first verify
44

55
The exact steps for this vary with the device (MUSE, OpenBCI, others) and operating system (Windows, Mac, Linux) used. When using these instructions, you should make sure you are consulting the section appropriate for your combination of device and OS.
66

7-
Initiating an EEG stream is a relatively easy process using the `eegnb.devices.eeg.EEG` class which abstracts the
8-
the various devices and backends behind one easy call.
7+
Initiating an EEG stream is a relatively easy process using the `eegnb.devices.EEGDevice` class which abstracts the various devices and backends behind one easy call.
98

109
```python
11-
from eegnb.devices.eeg import EEG
10+
from eegnb.devices import EEGDevice
1211

1312
# define the name for the board you are using and call the EEG object
14-
eeg = EEG(device='cyton')
13+
eeg = EEGDevice.create(device='cyton')
1514

1615
# start the stream
1716
eeg.start()
1817
```
1918

20-
These two lines of code abstract a lot of the heavy lifting with respect to switching streaming backends for the variou support devices.
19+
These two lines of code abstract a lot of the heavy lifting with respect to switching streaming backends for the various support devices.
2120

2221

2322
## Supported Devices
2423

25-
Below is a lst of supported devices and the information needed to connect to each when running the library. Each section also provides common troubleshooting tips for each. If you encounter any errors when connecting which are not listed below please report these on the issues page.
24+
Below is a list of supported devices and the information needed to connect to each when running the library. Each section also provides common troubleshooting tips for each. If you encounter any errors when connecting which are not listed below please report these on the issues page.
2625

2726
### Interaxon Muse
2827
**Device Names:** *'muse2016'*, *'muse2'*, and *'museS'*
@@ -111,10 +110,10 @@ menu pictures below.
111110

112111
Now that we have the COM port, we can initiate the stream by passing it to the EEG device in the object call.
113112
```python
114-
from eegnb.devices.eeg import EEG
113+
from eegnb.devices import EEGDevice
115114

116115
# define the name for the board you are using and call the EEG object
117-
eeg = EEG(
116+
eeg = EEGDevice.create(
118117
device='cyton',
119118
serial_port='COM7'
120119
)

eegnb/devices/base.py

+8
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ def check(self):
9191
def test_create():
9292
device = EEGDevice.create("synthetic")
9393
assert device
94+
95+
96+
def test_instantiate_should_fail():
97+
# abstract base class should not be instantiated on its own
98+
import pytest
99+
100+
with pytest.raises(TypeError):
101+
EEGDevice("test") # type: ignore

examples/visual_n170/00x__n170_run_experiment.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
88
"""
99

10-
###################################################################################################
10+
###################################################################################################
1111
# Setup
12-
# ---------------------
13-
#
12+
# ---------------------
13+
#
1414
# Imports
15-
import os
1615
from eegnb import generate_save_fn
17-
from eegnb.devices.eeg import EEG
16+
from eegnb.devices import EEGDevice
1817
from eegnb.experiments.visual_n170 import n170
1918

2019
# Define some variables
@@ -29,14 +28,14 @@
2928
# ---------------------
3029
#
3130
# Start EEG device
32-
eeg_device = EEG(device=board_name)
31+
eeg_device = EEGDevice.create(device_name=board_name)
3332

3433
# Create save file name
3534
save_fn = generate_save_fn(board_name, experiment, subject_id, session_nb)
3635
print(save_fn)
3736

38-
###################################################################################################
37+
###################################################################################################
3938
# Run experiment
40-
# ---------------------
41-
#
39+
# ---------------------
40+
#
4241
n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)

examples/visual_p300/00x__p300_run_experiment.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
88
"""
99

10-
###################################################################################################
10+
###################################################################################################
1111
# Setup
12-
# ---------------------
13-
#
12+
# ---------------------
13+
#
1414
# Imports
15-
import os
1615
from eegnb import generate_save_fn
17-
from eegnb.devices.eeg import EEG
16+
from eegnb.devices import EEGDevice
1817
from eegnb.experiments.visual_p300 import p300
1918

2019
# Define some variables
@@ -29,14 +28,14 @@
2928
# ---------------------
3029
#
3130
# Start EEG device
32-
eeg_device = EEG(device=board_name)
31+
eeg_device = EEGDevice.create(device_name=board_name)
3332

3433
# Create save file name
3534
save_fn = generate_save_fn(board_name, experiment, subject_id, session_nb)
3635
print(save_fn)
3736

38-
###################################################################################################
37+
###################################################################################################
3938
# Run experiment
40-
# ---------------------
41-
#
39+
# ---------------------
40+
#
4241
p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)

examples/visual_ssvep/00x__ssvep_run_experiment.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
SSVEP run experiment
33
===============================
44
5-
This example demonstrates the initiation of an EEG stream with eeg-notebooks, and how to run
6-
an experiment.
5+
This example demonstrates the initiation of an EEG stream with eeg-notebooks, and how to run
6+
an experiment.
77
88
"""
99

10-
###################################################################################################
10+
###################################################################################################
1111
# Setup
12-
# ---------------------
13-
#
12+
# ---------------------
13+
#
1414
# Imports
15-
import os
1615
from eegnb import generate_save_fn
17-
from eegnb.devices.eeg import EEG
16+
from eegnb.devices import EEGDevice
1817
from eegnb.experiments.visual_ssvep import ssvep
1918

2019
# Define some variables
@@ -29,14 +28,14 @@
2928
# ---------------------
3029
#
3130
# Start EEG device
32-
eeg_device = EEG(device=board_name)
31+
eeg_device = EEGDevice.create(device_name=board_name)
3332

3433
# Create save file name
3534
save_fn = generate_save_fn(board_name, experiment, subject_id, session_nb)
3635
print(save_fn)
3736

38-
###################################################################################################
37+
###################################################################################################
3938
# Run experiment
40-
# ---------------------
41-
#
39+
# ---------------------
40+
#
4241
ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)

0 commit comments

Comments
 (0)