Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions eegnb/experiments/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@

from abc import abstractmethod
from typing import Callable
from psychopy import prefs
from psychopy.visual.rift import Rift
#change the pref libraty to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

from time import time
import random
Expand Down
27 changes: 22 additions & 5 deletions eegnb/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@
from .visual_p300.p300 import VisualP300
from .visual_ssvep.ssvep import VisualSSVEP

# PTB does not yet support macOS Apple Silicon,
# this experiment needs to run as i386 if on macOS.
import sys
from psychopy import sound, plugins, prefs
import platform
if sys.platform != 'darwin' or platform.processor() != 'arm':
from .auditory_oddball.aob import AuditoryOddball

# PTB does not yet support macOS Apple Silicon freely, need to fall back to sounddevice.
if platform.system() == 'Darwin' and platform.machine() == 'arm64':
# import psychopy_sounddevice.backend_sounddevice
plugins.scanPlugins()
success = plugins.loadPlugin('psychopy-sounddevice')
print(f"psychopy_sounddevice plugin loaded: {success}")

# Force reload sound module
import importlib
importlib.reload(sound)
# setting prefs.hardware['audio_device'] still falls back to a default device, need to use setDevice.
audio_device = prefs.hardware.get('audioDevice', 'default')
if audio_device and audio_device != 'default':
sound.setDevice(audio_device)
else:
#change the pref library to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

from .auditory_oddball.aob import AuditoryOddball
5 changes: 0 additions & 5 deletions eegnb/experiments/auditory_oddball/auditory_erp_arrayin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""Generate sound-only auditory oddball stimulus presentation.
"""

from psychopy import prefs
#change the pref libraty to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

import time
from optparse import OptionParser

Expand Down
5 changes: 0 additions & 5 deletions eegnb/experiments/visual_n170/n170.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
""" eeg-notebooks/eegnb/experiments/visual_n170/n170.py """

from psychopy import prefs
#change the pref libraty to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

import os
from time import time
from glob import glob
Expand Down
5 changes: 0 additions & 5 deletions eegnb/experiments/visual_n170/n170_fixedstimorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

"""

from psychopy import prefs
#change the pref libraty to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

from time import time
from optparse import OptionParser
import os
Expand Down
1 change: 1 addition & 0 deletions environments/eeg-expy-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- liblsl # install liblsl to prevent error on macOS and Ubuntu: "RuntimeError: LSL binary library file was not found."
- wxpython>=4.0 # install wxpython to prevent error on macOS arm64: "site-packages/wx/_core.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '__ZN10wxBoxSizer20InformFirstDirectionEiii'"
- html2text # avoid building wheel
- cffi # Fix sound ffi.callback() issue with sounddevice on macOS: https://github.com/spatialaudio/python-sounddevice/issues/397
- pip
- pip:
# Install package with only Analysis requirements
Expand Down
1 change: 1 addition & 0 deletions environments/eeg-expy-stimpres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- python>=3.8,<=3.10 # psychopy <= 3.10
- dukpy==0.2.3 # psychopy dependency, avoid failing due to building wheel on win 3.9.
- wxpython>=4.0 # install wxpython to prevent error on macOS arm64: "site-packages/wx/_core.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '__ZN10wxBoxSizer20InformFirstDirectionEiii'"
- cffi # Fix sound ffi.callback() issue with sounddevice on macOS: https://github.com/spatialaudio/python-sounddevice/issues/397
- pip
- pip:
# Install package with Analysis + Streaming requirements
Expand Down
129 changes: 129 additions & 0 deletions psychopy-sounddevice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
Empty file.
Loading
Loading