This code launches an ASSR experiment in PsychoPy with a GUI to adjust parameters like duration and the number of trials. In case volunteers skip certain trials when they lose focus, the code updates these trial numbers in a separate CSV. See the experiment design section for more details on it. The start and end timestamps of each trial are recorded using an LSL stream in another CSV by LSLworker.py
.
The initial GUI menu of this experiment looks as follows:
After adjusting the required parameters, the experiment begins.
Within each trial, the following events happen in order:
- Pure tone sound is played as a reference for user to memorize
- Waits for user input to proceed to dual tone sound
- Sends LSL Start Marker for the trial
- Dual tone sound is played for actual data collection (pure tone + random tone mixed)
- Sends LSL End Marker for the trial
- Asks the user if they want to skip the previous trial
- Waits for 3 seconds
- If yes, records it in a CSV (
volname_date_time.csv
) - Continues to next trial
Parallelly, the LSLworker.py
script collects the output stream and parses it to generate another CSV file showing the timestamps and the trial numbers.
Run the stimulus and integrate with LSL stream using the steps below.
Ensure you have the following installed on your machine:
- Python3
- Pip
- PsychoPy
- OpenBCI GUI
- OpenBCI_LSL-master
- pydub
If not previously installed, from a clean Ubuntu 20.04 setup, these are the commands to execute in order:
sudo apt-get install python3-pip
pip install psychopy
export PATH=/home/ubuntu/.local/bin:$PATH
Download the given wheel from here
pip install Downloads/wxPython-4.1.1-cp38-cp38-linux_x86_64.whl
sudo apt-get install libusb-1.0-0-dev portaudio19-dev libasound2-dev
pip install psychtoolbox
Download Conda from official website and run:
sha256sum Anaconda3-2021.05-Linux-x86_64.sh
bash Anaconda3-2021.05-Linux-x86_64.sh
export PATH=/home/<username>/anaconda3/bin:$PATH
(Change according to your installation)
cd ASSRExp/
conda env create -n psychopy -f psychopy-env.yml
conda activate psychopy
sudo apt-get install libwebkitgtk-1.0.0
You might need to exachange the order of above two commands if it does not work on your machine.
pip install pydub
psychopy
(After your work, close PsychoPy and deactivate)
conda deactivate
More details on installing PsychoPy on Ubuntu and other platforms can be found here.
Next, download and install OpenBCI_GUI standalone app and in its directory, run
./OpenBCI_GUI
Ensure that your dongle is attached, OpenBCI is turned on and the correct port is selected in the GUI.
Next, clone OpenBCI_LSL-master form Github
cd OpenBCI_LSL-master/
pip install -r requirements.txt
(If you get an error, run the command below. After that, remove numpy and scipy from requirements.txt manually and rerun the command above)
python -m pip install --user numpy scipy matplotlib ipython jupyter
If not previously done, ensure your path is correct:
export PATH=/home/ubuntu/.local/bin:$PATH
Go to OpenBCI_LSL-master/ and run
python openbci_lsl.py --stream
If you get any port related errors, specify it manually using:
python openbci_lsl.py [PORT] --stream
Now, clone this repository and open it on PsychoPy coder's file navigation pane.
Now, start streaming in the OpenBCI GUI, and run FinalStimulus.py
on PsychoPy coder by double clicking it to open and clicking on the green run button.
In another terminal, run:
conda activate psychopy
python LSLworker.py
Full LSL stream integration and saving skipped trials and their timestamps in a CSV. [Done]