Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for VR headsets #241

Merged
merged 23 commits into from
Jun 16, 2024
Merged

Conversation

pellet
Copy link
Contributor

@pellet pellet commented Jul 6, 2023

This PR modifies the current rendering engine to allow support for using a head mounted display.
Here is a github issue explaining the change: Support for Oculus/Meta Quest VR.
PsychXR is utilized for seamlessly integrating HUD support into the existing codebase which depends on PsychoPy for presenting stimulus.

  • The core.wait calls had to be removed so that the render loop could continually update the display in relation to the current position and angle of the head.
  • The code changes are backwards compatible so that existing experiments can be ran and replicated without any change to the presented visual stimulus or eeg data.
  • More VR headsets can be supported by adding OpenXR support to PsychXR or directly into eeg-notebooks.

The new feature functionality can be tested by connecting a supported headset(eg oculus/quest) and running the N170 experiment with the parameter use_vr=True
Backwards compatibility can be tested by running any experiment without any changes needed.

@pellet pellet marked this pull request as draft October 15, 2023 02:22
@pellet pellet force-pushed the dev/n170_rift branch 2 times, most recently from 24028df to 4437cef Compare November 9, 2023 09:03
@JohnGriffiths
Copy link
Collaborator

@pellet thanks for this. I am now back from pat leave and this is high up on my priority list. I first need to get my hands on a comp with a good enough graphics card for the quest screen sharing. Once I have that I will start testing this out and feed back here.

@pellet
Copy link
Contributor Author

pellet commented Nov 23, 2023

@JohnGriffiths sounds great :) Let me know if you run into any issues with the testing and I will be happy to help out. If the changes to the rendering engine somehow break some old experiments I can leave the existing rendering code in place and separate the VR rendering code to only run with use_vr=True. I've opened an issue with PsychXR regarding setAutoDraw(True) no working, and window.getActualFrameRate() crashing. The Quest 2 does up to 120hz which is nice for the SSVEP experiment 👍🏼

@tmorshed
Copy link
Collaborator

tmorshed commented Dec 8, 2023

@pellet - getting the following error. Any thoughts?

In [1]: from psychopy import visual

In [2]: blah = visual.Rift(monoscopic=True,headlocked=True)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[2], line 1
----> 1 blah = visual.Rift(monoscopic=True,headlocked=True)

File ~\miniconda3\envs\expy-vr\lib\site-packages\psychopy\contrib\lazy_import.py:118, in ScopeReplacer.__call__(self, *args, **kwargs)
    116 def __call__(self, *args, **kwargs):
    117     obj = object.__getattribute__(self, '_resolve')()
--> 118     return obj(*args, **kwargs)

File ~\miniconda3\envs\expy-vr\lib\site-packages\psychopy\visual\rift.py:316, in Rift.__init__(self, fovType, trackingOriginType, texelsPerPixel, headLocked, highQuality, monoscopic, samples, mirrorMode, mirrorRes, warnAppFrameDropped, autoUpdateInput, legacyOpenGL, *args, **kwargs)
    312     raise RuntimeError("HMD service is not available or started, " +
    313                        "exiting.")
    315 if not libovr.isHmdConnected():
--> 316     raise RuntimeError("Cannot find any connected HMD, check " +
    317                        "connections and try again.")
    319 # create a VR session, do some initial configuration
    320 initResult = libovr.initialize()  # removed logging callback

RuntimeError: Cannot find any connected HMD, check connections and try again.

In [3]:

@tmorshed
Copy link
Collaborator

tmorshed commented Dec 8, 2023

...tracked this down a bit more...

In [15]: import psychxr.drivers.libovr as libovr
In [16]: libovr.isHmdConnected()
Out[16]: False

@pellet
Copy link
Contributor Author

pellet commented Dec 8, 2023

Yep I get this error when my headset isn't linked up and active(wearing it)

@tmorshed
Copy link
Collaborator

tmorshed commented Dec 9, 2023

The device now gets recognized if you do the in-VR setup. But that setup never seems to finish successfully. It gets stuck on a three-dot loading screen, a la
image

If you ignore the continuing screen, it seems to get detected by libovr in Python.

>>> import psychxr.drivers.libovr as libovr
>>> libovr.isHmdConnected()
True

Trying to run the experiment though, gets this error: wglDXOpenDeviceNV with minimal detail
Which seems to be a DirectX/OpenGL-related error message. Could be a driver or communication issue.

Next steps:

  • Will retry later with the other USB ports and cables to see if that solves anything.
  • Maybe using AirLink will solve the issue
  • Also, maybe using the official USB cable helps.

@JohnGriffiths JohnGriffiths marked this pull request as ready for review June 16, 2024 02:53
@JohnGriffiths
Copy link
Collaborator

I've reviewed the code and this is working nicely.

There is a build deployment failure currently which I don't understand as I don't think anything in the PR is touching CI type things.

In any case I am going to merge into `develop' and we can continue to solve any CI issues there.

@JohnGriffiths JohnGriffiths merged commit fad804b into NeuroTechX:develop Jun 16, 2024
3 of 6 checks passed
@pellet
Copy link
Contributor Author

pellet commented Jun 16, 2024

Thanks @JohnGriffiths, I'll take a look at the build issues.

@pellet pellet deleted the dev/n170_rift branch June 16, 2024 04:07
JohnGriffiths added a commit that referenced this pull request Jun 21, 2024
* example test commit (#182)

* example test commit

* example edit

* ci: run test workflow on develop branch

* ci: add develop branch to job triggers

* ci: fix syntax issue in workflow

* fix: fixed import (brainflow updated API)

* build(deps): locked pylsl==1.10.5 (#187)

* Experiment Class Refactor (update to #183), converting specific experiments to subclasses (#184)

* First commit

* Second commit

* Modifications

* Lol

* Lol

* Incorporated N170 and p300, looking good for a PR

* ssvep update

* Implementing subclasses instead of loose functions

* fix: fixed import (brainflow updated API)

* Playing around still

* Fixing import errors

* Adding abstractmethod decorators

* Still working on the import error

* Guess what's finally working

* Comments and naming ticks

* More comments

* Live coding demonstration

* ssvep adapted

* Adapting Auditory Oddball

* changing save_fn to self.save_fun

* This maybe the last big change

* utils file changed, changes work through cli

Co-authored-by: Erik Bjäreholt <[email protected]>

* Submodule added for gsoc

* Adding pipelines for cli analysis (#202)

* started pipelines function

* almost working simple function equivalents of nb scripts

* fix: fixed import (brainflow updated API)

* sqc fixes for unicorn (#176)

* Ignore pushes

* Trying to create a cli

* Stepping through the problem

* First commit

* Fixing pause in signal quality check

* Fixing Signal quality check problem

* fix the technical debt

* Save path done for automated saving pdf

* I feel amazing

* Almost through

* Update eegnb/cli/__main__.py

Co-authored-by: Erik Bjäreholt <[email protected]>

* Trying to create cli but it's being really painful

* Extra word cli error

* Changed example handling

* Pain

* Adding whole datapath

* Finally fixed cli

* hmm

* Looking good

* added hyperlink

* Having some issues with detecting css and image deltetion

* Just the css now

* Fixed the css linking problem though it's a weird soln

* Automated running, still fnames problem

* Hahahah embedded images in html

* Improving code

* Okay now

* Look at that

* Almost there just the two figures now

* Now

* Added attrdict to do with cli error

Co-authored-by: John Griffiths <[email protected]>
Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: John Griffiths <[email protected]>

* added more options for site args; improved function names; removed some redundant lines (#209)

* fix subject num parsing bug

* analysis report function improvements for openbci cyton and gtec unicorn devices

* run exp fix

* Update requirements.txt

* fixes to get docs building by github action (#210)

* fixes to get docs building by github action

* reverted some changes

* Update 01r__ssvep_viz.py

Co-authored-by: John Griffiths <[email protected]>

* Update README.rst

small commit to test doc build workflow on this branch

* removing gsoc submodule

* ci: update python to 3.8, update wxPython, update setup-python action

* ci: pin ubuntu versions to 22.04, updated wxPython urls

* ci: bumped psychopy to 2023.1.0

* build(deps): set upper supported numpy version to 1.23.x

* chore: applied no_implicit_optional

* update dependencies - for build (#220)

* major update: merging develop to master (#217)

* example test commit (#182)

* example test commit

* example edit

* ci: run test workflow on develop branch

* ci: add develop branch to job triggers

* ci: fix syntax issue in workflow

* fix: fixed import (brainflow updated API)

* build(deps): locked pylsl==1.10.5 (#187)

* Experiment Class Refactor (update to #183), converting specific experiments to subclasses (#184)

* First commit

* Second commit

* Modifications

* Lol

* Lol

* Incorporated N170 and p300, looking good for a PR

* ssvep update

* Implementing subclasses instead of loose functions

* fix: fixed import (brainflow updated API)

* Playing around still

* Fixing import errors

* Adding abstractmethod decorators

* Still working on the import error

* Guess what's finally working

* Comments and naming ticks

* More comments

* Live coding demonstration

* ssvep adapted

* Adapting Auditory Oddball

* changing save_fn to self.save_fun

* This maybe the last big change

* utils file changed, changes work through cli

Co-authored-by: Erik Bjäreholt <[email protected]>

* Submodule added for gsoc

* Adding pipelines for cli analysis (#202)

* started pipelines function

* almost working simple function equivalents of nb scripts

* fix: fixed import (brainflow updated API)

* sqc fixes for unicorn (#176)

* Ignore pushes

* Trying to create a cli

* Stepping through the problem

* First commit

* Fixing pause in signal quality check

* Fixing Signal quality check problem

* fix the technical debt

* Save path done for automated saving pdf

* I feel amazing

* Almost through

* Update eegnb/cli/__main__.py

Co-authored-by: Erik Bjäreholt <[email protected]>

* Trying to create cli but it's being really painful

* Extra word cli error

* Changed example handling

* Pain

* Adding whole datapath

* Finally fixed cli

* hmm

* Looking good

* added hyperlink

* Having some issues with detecting css and image deltetion

* Just the css now

* Fixed the css linking problem though it's a weird soln

* Automated running, still fnames problem

* Hahahah embedded images in html

* Improving code

* Okay now

* Look at that

* Almost there just the two figures now

* Now

* Added attrdict to do with cli error

Co-authored-by: John Griffiths <[email protected]>
Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: John Griffiths <[email protected]>

* added more options for site args; improved function names; removed some redundant lines (#209)

* fix subject num parsing bug

* analysis report function improvements for openbci cyton and gtec unicorn devices

* run exp fix

* Update requirements.txt

* fixes to get docs building by github action (#210)

* fixes to get docs building by github action

* reverted some changes

* Update 01r__ssvep_viz.py

Co-authored-by: John Griffiths <[email protected]>

* Update README.rst

small commit to test doc build workflow on this branch

* removing gsoc submodule

Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: Parv Agarwal <[email protected]>
Co-authored-by: Parvfect <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>

* update dependencies - seaborn

* docs/perf: reduced the imports: `cueing` example

* bug: update deprecated `plot_psd()` method

- feature of new `mne` version.
- instead of doing plot_psd() from the `mne.io.Raw` object, must do this:
	- `raw.compute_psd().plot()`
	- i.e., has to pass through a `spectrum` object

* updated deprec. `mne` function

* perf: removed importage of unused packages from example
- One of them, i.e., `collections.Iterable` is even deprecated.
- Must use `collections.abc.Iterable` instead now.
- Resulting in faster build/user run

* bugfix: `plot_conditions` - due to `sns` deprecation

* bugfix: resolved `psd_welch()` deprecation (`mne`)

---------

Co-authored-by: John Griffiths <[email protected]>
Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: Parv Agarwal <[email protected]>
Co-authored-by: Parvfect <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>
Co-authored-by: Taha Morshedzadeh <[email protected]>

* Updated psychopy (#215)

* update psychopy for psychxr compatibility

* updated n170 example to run again.

* Updated doc examples for N170, P300 and SSVEP after Experiment Class Refactor (#218)

* major update: merging develop to master (#217)

* example test commit (#182)

* example test commit

* example edit

* ci: run test workflow on develop branch

* ci: add develop branch to job triggers

* ci: fix syntax issue in workflow

* fix: fixed import (brainflow updated API)

* build(deps): locked pylsl==1.10.5 (#187)

* Experiment Class Refactor (update to #183), converting specific experiments to subclasses (#184)

* First commit

* Second commit

* Modifications

* Lol

* Lol

* Incorporated N170 and p300, looking good for a PR

* ssvep update

* Implementing subclasses instead of loose functions

* fix: fixed import (brainflow updated API)

* Playing around still

* Fixing import errors

* Adding abstractmethod decorators

* Still working on the import error

* Guess what's finally working

* Comments and naming ticks

* More comments

* Live coding demonstration

* ssvep adapted

* Adapting Auditory Oddball

* changing save_fn to self.save_fun

* This maybe the last big change

* utils file changed, changes work through cli

Co-authored-by: Erik Bjäreholt <[email protected]>

* Submodule added for gsoc

* Adding pipelines for cli analysis (#202)

* started pipelines function

* almost working simple function equivalents of nb scripts

* fix: fixed import (brainflow updated API)

* sqc fixes for unicorn (#176)

* Ignore pushes

* Trying to create a cli

* Stepping through the problem

* First commit

* Fixing pause in signal quality check

* Fixing Signal quality check problem

* fix the technical debt

* Save path done for automated saving pdf

* I feel amazing

* Almost through

* Update eegnb/cli/__main__.py

Co-authored-by: Erik Bjäreholt <[email protected]>

* Trying to create cli but it's being really painful

* Extra word cli error

* Changed example handling

* Pain

* Adding whole datapath

* Finally fixed cli

* hmm

* Looking good

* added hyperlink

* Having some issues with detecting css and image deltetion

* Just the css now

* Fixed the css linking problem though it's a weird soln

* Automated running, still fnames problem

* Hahahah embedded images in html

* Improving code

* Okay now

* Look at that

* Almost there just the two figures now

* Now

* Added attrdict to do with cli error

Co-authored-by: John Griffiths <[email protected]>
Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: John Griffiths <[email protected]>

* added more options for site args; improved function names; removed some redundant lines (#209)

* fix subject num parsing bug

* analysis report function improvements for openbci cyton and gtec unicorn devices

* run exp fix

* Update requirements.txt

* fixes to get docs building by github action (#210)

* fixes to get docs building by github action

* reverted some changes

* Update 01r__ssvep_viz.py

Co-authored-by: John Griffiths <[email protected]>

* Update README.rst

small commit to test doc build workflow on this branch

* removing gsoc submodule

Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: Parv Agarwal <[email protected]>
Co-authored-by: Parvfect <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>

* Updated doc examples

* Update 00x__n170_run_experiment.py

fix: typo in func param

---------

Co-authored-by: John Griffiths <[email protected]>
Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>
Co-authored-by: Ore O <[email protected]>

* fix error breaking n170 test (#223)

* fixed requirements.txt so 'pip install -e .' would work on windows. (#229)

* Get CI test builds working again! (#170)

* Revert "Revert PR #167: "ci: fix broken CI" (#169)"

This reverts commit 2d74871.

* Update Makefile

* fix: Update vep.py import

* Update Makefile

* Update vep.py

* fix: typo in makefile

* fix: update BaseExperiment class reference

* Update Makefile

* Update vep.py

* Update 01r__n170_viz.py

* makefile: install libnotify4

---------

Co-authored-by: Ore O <[email protected]>

* fix macos build (#245)

* Add devcontainer configuration for CPU environment

* Fixed the python version needed

* Fix plot conditions (#257)

* fixed plot_conditions functoni issues

* small change to viz n170 plotting example

* small change to viz p300 plotting example

* fixed to plotting issue

* modify plot command

* update example files

* fix condition label bug

* fix: set layout engine to fix colorbar error

---------

Co-authored-by: Ore O <[email protected]>

* Started the name switch (#251)

* started renaming from eegnb to eegexpy

* more eegnb renaming work

* more eegnb switches

* more relabelling

* ssvep renamings

* cueing eg

* update for more misc files

* more of the same

* update

* Update and rename available_notebooks.md to available_experiments.md

* Add newlogo (#260)

* Add files via upload

* Update README.rst

* added to enable eegexpy commands (#265)

* started alias of main package for imports (#266)

* Add multiple installation options (#263)

* added newly separated analysis and streaming utils files

* modified setup and requirements to allow for optional install types

* updated imports in experiment examples

* fixed some typos

* Update requirements.txt

moved click library to stim pres requirements section

* Update requirements.txt

Co-authored-by: Taha Morshedzadeh <[email protected]>

* Update Makefile

* Update docs.yml

* Update Makefile

this does a full build with all dependencies for EEG-ExPy

---------

Co-authored-by: Ore O <[email protected]>
Co-authored-by: Taha Morshedzadeh <[email protected]>

* Add support for /develop in docs site (#259)

* feat: update action to build doc page in a folder

* test: see if it works without if clause

* test: change source for docs

* Initial support for VR headsets (#241)

* fixed requirements.txt so 'pip install -e .' would work on windows.

* added support for n170 to run on rift

* altered logic to add back in jitter

* simplified logic

* made fullscreen again

* further simplified logic

* decreased font size of instructions for vr

* fixed instructions display, further simplified logic, removed logs

* made code easier to read

* reverted board back to muse

* Enable headlocking to fix jittering - cancel out any rotation and translation coming from the headset.

* fixed use_vr parameter to be set to False by default for existing experiments.

* fix macos build

* reverted unnecessary changes and made p300 experiment display correctly

* added vr support for p300 and ssvep

* fix psychxr version

* adding vr doc

* updated vr doco

---------

Co-authored-by: John Griffiths <[email protected]>

* ssaep volumefadingfixes (#81)

* fixed duration on instructions screen

* put sound object instantiation inside trials loop. fixes sound fading issue

---------

Co-authored-by: Erik Bjäreholt <[email protected]>
Co-authored-by: Parv Agarwal <[email protected]>
Co-authored-by: Parvfect <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>
Co-authored-by: Ore Ogundipe <[email protected]>
Co-authored-by: Taha Morshedzadeh <[email protected]>
Co-authored-by: Ben Pettit <[email protected]>
Co-authored-by: Taha Morshedzadeh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants