Skip to content

Commit

Permalink
misc: added pytest config to CI, fixed stuff that broke in refactor, …
Browse files Browse the repository at this point in the history
…updated docs
  • Loading branch information
ErikBjare committed Apr 18, 2021
1 parent 08d4164 commit 1f145ec
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 45 deletions.
4 changes: 2 additions & 2 deletions doc/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Start a jupyter notebooks session and you will be presented with the eeg-noteboo
# Imports
import os
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_n170 import n170
from eegnb.analysis.utils import load_data
Expand All @@ -126,7 +126,7 @@ Start a jupyter notebooks session and you will be presented with the eeg-noteboo
record_duration=120
# Initiate EEG device
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device=board_name)
# Create output filename
save_fn = generate_save_fn(board_name, experiment, subject)
Expand Down
12 changes: 6 additions & 6 deletions doc/getting_started/running_experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The first step is to import all of the necessary library dependencies. These are

```python
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_n170 import n170
```

Expand All @@ -94,10 +94,10 @@ record_duration = 120
save_fn = generate_save_fn(board_name, experiment, subject, session)
```

Next it is necessary to call the `eegnb.devices.eeg.EEG` class which handles all of the backend processes related to each device.
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.

```python
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device_name=board_name)
```

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.
Expand All @@ -110,7 +110,7 @@ All together the example script looks like
```python
# Imports
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_n170 import n170

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

# Setup EEG device
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device_name=board_name)

# Run stimulus presentation
n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
```
```
15 changes: 7 additions & 8 deletions doc/getting_started/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ Before getting going with running an experiment, it is important to first verify

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.

Initiating an EEG stream is a relatively easy process using the `eegnb.devices.eeg.EEG` class which abstracts the
the various devices and backends behind one easy call.
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.

```python
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice

# define the name for the board you are using and call the EEG object
eeg = EEG(device='cyton')
eeg = EEGDevice.create(device='cyton')

# start the stream
eeg.start()
```

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


## Supported Devices

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.
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.

### Interaxon Muse
**Device Names:** *'muse2016'*, *'muse2'*, and *'museS'*
Expand Down Expand Up @@ -111,10 +110,10 @@ menu pictures below.

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

# define the name for the board you are using and call the EEG object
eeg = EEG(
eeg = EEGDevice.create(
device='cyton',
serial_port='COM7'
)
Expand Down
8 changes: 8 additions & 0 deletions eegnb/devices/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ def check(self):
def test_create():
device = EEGDevice.create("synthetic")
assert device


def test_instantiate_should_fail():
# abstract base class should not be instantiated on its own
import pytest

with pytest.raises(TypeError):
EEGDevice("test") # type: ignore
17 changes: 8 additions & 9 deletions examples/visual_n170/00x__n170_run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
"""

###################################################################################################
###################################################################################################
# Setup
# ---------------------
#
# ---------------------
#
# Imports
import os
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_n170 import n170

# Define some variables
Expand All @@ -29,14 +28,14 @@
# ---------------------
#
# Start EEG device
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device_name=board_name)

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

###################################################################################################
###################################################################################################
# Run experiment
# ---------------------
#
# ---------------------
#
n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
17 changes: 8 additions & 9 deletions examples/visual_p300/00x__p300_run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
"""

###################################################################################################
###################################################################################################
# Setup
# ---------------------
#
# ---------------------
#
# Imports
import os
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_p300 import p300

# Define some variables
Expand All @@ -29,14 +28,14 @@
# ---------------------
#
# Start EEG device
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device_name=board_name)

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

###################################################################################################
###################################################################################################
# Run experiment
# ---------------------
#
# ---------------------
#
p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
21 changes: 10 additions & 11 deletions examples/visual_ssvep/00x__ssvep_run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
SSVEP run experiment
===============================
This example demonstrates the initiation of an EEG stream with eeg-notebooks, and how to run
an experiment.
This example demonstrates the initiation of an EEG stream with eeg-notebooks, and how to run
an experiment.
"""

###################################################################################################
###################################################################################################
# Setup
# ---------------------
#
# ---------------------
#
# Imports
import os
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.devices import EEGDevice
from eegnb.experiments.visual_ssvep import ssvep

# Define some variables
Expand All @@ -29,14 +28,14 @@
# ---------------------
#
# Start EEG device
eeg_device = EEG(device=board_name)
eeg_device = EEGDevice.create(device_name=board_name)

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

###################################################################################################
###################################################################################################
# Run experiment
# ---------------------
#
# ---------------------
#
ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)

0 comments on commit 1f145ec

Please sign in to comment.