Skip to content

Classic circular shifting based c-VEP speller for MEDUSA that supports non-binary sequences

License

Notifications You must be signed in to change notification settings

medusabci/app-pary-cvep-speller

Repository files navigation

A c-VEP speller encoded with non-binary m-sequences

This app provides a BCI speller based on code-modulated visual evoked potential (c-VEP) under the circular-shifting paradigm that can encode commands using non-binary codes. The app allows to develop high-speed, reliable BCIs for communication and control by encoding the application commands using shifted versions of p-ary m-sequences. Read the description below to learn more.

Note

If you don't want to edit the paradigm, download the built app at https://medusabci.com/market/pary_cvep/

How to install

It is recommended to download the latest release of MEDUSA© and download the matching version of this app at https://medusabci.com/market/pary_cvep/. If you want to edit this paradigm via sorce code, then:

  1. Create a new app in MEDUSA© via "Developer tools/Create app"
  2. Indicate a ".cvep" extension and make sure "Empty project" is marked. Identifier and name can be freely chosen (e.g. "pary_cvep_speller" as identifier, and "P-ary c-VEP Speller" as name)
  3. After pressing OK, a new folder at "src/accounts/{username}/{identifier}" is created. Then, delete it.
  4. Clone this repository or download the source code of the release you want to install in "src/accounts/{username}/"
  5. Rename the cloned repository to match the identifier ("src/accounts/{username}/{identifier}")
  6. Done! Now you can edit the app in MEDUSA©.

What is the basis of this paradigm?

The c-VEPs are visual evoked potentials generated by looking at a flickering source that follows a pseudorandom sequence. Usually, this sequence is binary (i.e., it only has values 0 or 1), and thus the flickering is encoded with black and white flashes. This high-contrast stimuli may cause visual eyestrain for some users. However, it is possible to encode commands using non-binary codes, encoded with different shades of gray or different colors, with the objective to be more comfortable to the end user. If you want to learn more about binary-based c-VEP spellers and/or circular shifting paradigms, please check the "c-VEP speller" app: https://medusabci.com/market/cvep_speller/

Finding non-binary codes with good autocorrelation functions is not trivial, thus this app does that for you. Here, we have use different primitive polynomials over Galois Fields GF(p^r), where p is the base (i.e., number of levels or colors) and r is the order of the polynomial; to generate p-ary m-sequences. Currently, bases 2, 3, 5, 7, 11 and 13 are implemented for different orders to vary the code length. Please, refer to the basic "c-VEP speller" app if you are interested in the signal processing pipeline.

Important

If you want to know more about the paradigm, we recommend to read the following paper: Martínez-Cagigal, V., Santamaría-Vázquez, E., Pérez-Velasco, S., Marcos-Martínez, D., Moreno-Calderón, S., & Hornero, R. (2023). Non-binary m-sequences for more comfortable brain–computer interfaces based on c-VEPs. Expert Systems with Applications, 232, 120815. https://doi.org/10.1016/j.eswa.2023.120815

Relevant functionalities of the “P-ary c-VEP Speller” app

Run Settings:

  • The app has two functioning modes: “Train” and “Online”. Use “Train” to record the data for calibrating the system. Use “Online” when you already has a decoding model to select speller commands freely.
  • The number of trials and the number of cycles can be configured for the “Train” mode. See the recommendations section below to know more.
  • This app does not implement an early stopping approach, so it is required to specify the number of cycles per trial for the “Online” mode.
  • The app allows you to specify the presentation rate of the m-sequence. Use 60 Hz if you are using a standard monitor, read the recommendations section to know more.

Encoding and matrix

  • This app supports the use of p-ary m-sequences of bases 2, 3, 5, 7, 11 and 13, select the one that you want to use! The length (in bits) and the cycle duration (in seconds) of the final code is automatically shown when you select the base and the desired order.
  • Configure the number of commands in the online mode as you wish. Please note that the length of the m-sequence must be enough to encode all commands! To make sure of this, press the button “Update encoding” to check the lags associated to each command. The app will try to space the lags as much as possible.
  • Use also the "Update encoding" button to show the distribution of the lags of each command to avoid local autocorrelation maxima and minima for p-ary m-sequences. A deterministic algorithm is used to avoid these points. Make sure to check the correlation values of each command to avoid unexpected errors (if all the cells are green, everything would be fine).

Colors:

  • The colors functionality allows you to use different colors for the GUI and the encoding of the p-ary m-sequences. Try it out!

Model training:

  • Use the button “Train model” to train the decoding model. Signal processing is entirely based on the “reference processing pipeline” for c-VEP-BCIs based on circular shifting (check this out to know more).
  • Use a filter bank to improve the decoding accuracy for 120 Hz monitor rates!

Tip

C-VEPs are exogenous signals generated naturally by our brains in response to stimuli. For that reason, c-VEP-based BCIs do not require users to be trained, but just a small calibration. In calibration stage, user is asked to pay attention to a flickering command encoded with the original m-sequence. We recommend to user, at least, 100 entire cycles (i.e., a full stimulation of the m-sequence) to train the model. That is, two runs of 5 trials each, in which trials are composed of 10 cycles. It is important to avoid blinking when trials are being displayed. Users can freely blink in the inter-trial time window.

Tip

If your monitor is capable to refresh at 120 Hz, we recommend using a “Target FPS (Hz)” that matches the monitor refresh rate. Imagine that you are using a 63-bit m-sequence. For a 60 Hz presentation rate, each cycle will last 1.05 s (i.e., 63/60). You can reduce that duration by half using 120 Hz, lasting 0.525 s (i.e., 63/120). If you are using a 120 Hz presentation rate, we recommend you use more than a single filter. For instance, a filter bank composed of 3 IIR filters: (1, 60), (12, 60) and (30, 60) usually gives good results.