Creating & Running a Protocol
Creating your own protocol should be done by creating a asyncio
function.
To run your protocol whilst conducting an EEG recording using the IDUN Guardian Earbuds a useful function to use is:
asyncio.gather
The asyncio
module allows you to execute multiple coroutines in parallel, and wait for them to finish. It takes in one or more coroutines as arguments and returns a new coroutine that provides the results of all the coroutines.
To run your protocol alongwith a EEG recording use:
asyncio.run(main())
.
An example of this is in the record_lsl.py
script.
Example script is shown below:
async def main():
"""
This function is the main function for the script. It will start the recording and the LSL stream.
"""
await asyncio.gather(
bci.start_recording(
recording_timer=RECORDING_TIMER, led_sleep=LED_SLEEP, experiment=EXPERIMENT
),
# ENTER YOUR COROUTINE HERE),
)
asyncio.run(main())