A Flash Group Creation Algorithm for P300 Brain–Computer Interface Integration with Irregular Assistive Technology Keyboard Layouts
Abstract
1. Introduction
1.1. Evolution of BCI Design
1.2. AAC System Design
1.3. Design of Flash Groups

2. Methods
2.1. Design Priorities
- In an ERP-BCI, any target key (user-intended key) must be identifiable from a series of binary signals (of whether a P300 ERP is present or not). The binary series of responses to a sequence of stimuli must be able to identify every key of the keyboard uniquely. All keys of the keyboard must be interpreted (identified) from their unique binary sequence. This gives us the first and foremost design priority, identifiability (DP1: Identifiability).
- The P300 ERP, critical to BCI operation, is generated in response to a stimulus that is anticipated by the user but unpredictable [28]. The flash groups generated by the algorithm must not be easily predictable. The second design priority for the algorithm is unpredictability (DP2: Unpredictability).
- The users’ ERP responses to stimuli occur over a finite time and ERP-BCIs often analyze the EEG response in the 800 milliseconds (ms) after the presentation of the stimuli (e.g., [11,22]). If the stimulus presentation is so rapid that consecutive flashes of the same stimuli occur in a time shorter than this interval, the latter stimuli might be missed by the user. Further, ERP responses to rapid stimuli have greater temporal overlaps, which results in an inconsistent EEG waveform and amplitude [8]. To overcome this, flash groups must be presented in a way that ensures that the target-to-target interval of any key is long enough that both stimuli are perceptible. The third design priority is perceptibility (DP3: Perceptibility).
- A brute-force method for stimulus presentation is to have each key on the screen presented separately. While such a solution satisfies DP1 through DP3, as the size of keyboards grow, it takes increasingly longer times for stimulus presentation. To enhance the speed of the BCI, keys must be presented in groups and the number of such groups must be as few as possible. This gives us the fourth design priority: minimality (DP4: Minimality).
- Fazel-Rezai (2007) presents evidence that locations adjacent to the target key [29] are responsible for the majority of misclassification errors. To reduce the errors, the adjacent keys must not be part of the same stimulus. The design priority capturing this idea is anti-adjacency (DP5: Anti-adjacency).
- A deliberate effort is made to keep the stimuli consistent in size and appearance. As a principle, the size of all flash groups is roughly equal for a given keyboard. The final guideline is equality (DP6: Equality).
2.2. Interface Specifications
- Key-to-grid correspondence: In a traditional BCI keyboard, a key is uniquely determined by the row and the column it occupies on the grid. In the AAC keyboards, amalgamated keys span multiple grid locations. Since the AAC keyboards only contain rectangular keys, every key can be uniquely determined by its top-left and bottom-right grid locations. By convention, we use the top-left key number as the identifier for the key (Figure 5).
- Adjacency: In traditional BCI keyboards, two keys are adjacent if they are next to each other in the same column or row. Two keys that share a corner can be called diagonally adjacent. In AAC keyboards, where keys are not just restricted to a single row and a single column, we extend the concept of adjacency as a numeric metric. There are two basic rules for calculating the adjacency between two grid locations.
- –
- The adjacency between two grid locations is 1 if they immediately neighbor each other on the same row or the same column of the rectangular grid (side adjacency).
- –
- The adjacency between two grid locations is 0.4 if they share a corner of the rectangular grid (diagonal adjacency).
The chosen adjacency values create an algorithmic preference for diagonal adjacency over side adjacency (row or column). The value of 0.4 was chosen empirically based on the observation that a value of 0.5 resulted in occasional key placements with row and column adjacency. No other values were evaluated. With a value of 0.4 for diagonal adjacency, key placement diagonally adjacent to two other keys is preferable to a side-adjacent key placement in an adjacent row or column.The amalgamated adjacency between two keys on an AAC board is the sum of the adjacencies between pairs of the grid locations, one from each key (Figure 6). It should be noted that this definition of the metric implies that adjacency is symmetric. Further, adjacency provides a numeric objective to minimize as per design priorities (DP5: Anti-adjacency).
2.3. Algorithm Overview
- Virtual matrix dimensions—The dimensions of the two virtual matrices;
- Key order—The order in which keys are evaluated for placement in the virtual matrices;
- Board division—The method for dividing the keys between the two virtual matrices;
- Key placement—The method by which the keys are placed in the matrices;
- 1.
- Identify the location and dimensions of the keys to access.
- 2.
- Determine the size of square virtual matrices that will accommodate all the keys. Matrices should be square and approximately the same size (see Section 2.3.1).
- 3.
- Order the keys in each group for placement into the virtual matrices using switchback numbering (see Figure 8 and Section 2.3.2).
- 4.
- Divide the keys into 2 mutually exclusive groups using a checkerboard pattern (Figure 9). If the size of one of the groups exceeds the capacity of the largest virtual matrix, shift extra keys to the other group using the algorithm in Appendix B (see Figure 10 and Section 2.3.3).
- 5.
- Fill each virtual matrix according to a magic square pattern (Figure 11), using the anti-adjacency algorithm (Figure 12, Figure 13 and Figure 14) to minimize adjacency within the rows and columns of the matrix (see Section 2.3.4).
- 6.
- The rows and columns of the virtual matrices are the flash groups. Extract the row and column subgroups to create a flash group set in the order rows of matrix 1, rows of matrix 2, columns of matrix 1, columns of matrix 2.
- 7.
- Consecutive presentation of all flash groups constitutes a sequence. Between sequences, shuffle within the row and column subgroups to increase unpredictability.
2.3.1. Virtual Matrix Dimensions
- Ifthe two virtual matrices are squares with sides and n.
- Otherwise ifthe two virtual matrices are both squares with sides n.
2.3.2. Key Order
2.3.3. Board Division
2.3.4. Key Placement
- Given a virtual matrix with numbered positions, the positions (in ascending order of the position numbers given by the magic square) are filled by keys (in ascending key order). So, among the keys allocated to the virtual matrix (by board division), the key that has the lowest key order is placed in the position numbered 1, the key with the second-lowest key order is placed in the position numbered 2, and so forth. Placement is subject to an anti-adjacency check to ensure that no two keys that have an adjacency metric greater than zero will be placed in the same row or column of the virtual matrix.
- If for a given virtual matrix position, the key that is about to be placed would violate the anti-adjacency directive (that is the current key would lie in the same row or column as another key whose adjacency with the current key is greater than zero), the key is placed in a buffer queue and the next key in order is picked.
- Once a virtual matrix position is filled, a key will be chosen for the next matrix position. If the buffer queue is not empty, the key is picked from the beginning of the buffer queue instead of the key order. The same rules of anti-adjacency apply to the key (the one picked from the buffer); if placing the key violates anti-adjacency, the key is pushed to the end of the buffer and a new key is picked (from the beginning of the buffer if the buffer is not empty or the next key in order if the buffer is empty). The steps so far are illustrated in Figure 12 and Figure 13.
- Eventually, there might come a point when it is not possible to place any of the remaining keys at the current virtual matrix position that prevents adjacency violations. In such a case, the adjacency violations are calculated for all remaining keys for all remaining virtual matrix positions. That is, if a key is placed in a position, the sum of the adjacency of the key with the other keys that have already been placed in the same row or column of the position are calculated. The key–virtual matrix position combination that has the lowest adjacency metric is chosen and the key is placed in that position. The adjacency violations are recalculated for the remaining keys and the remaining positions and the key–position pair that has the lowest adjacency violation is chosen. This final step of the sub-routine is illustrated in Figure 14.
2.4. Parameter Optimization and Offline Analysis
2.5. Implementation Considerations
2.6. On-Line Performance Analysis
3. Results
On-Line Performance
4. Discussion
4.1. Evaluation of Design Priorities
4.2. Practical Considerations
4.3. Algorithm Vulnerabilities
4.4. Limitations
4.5. Conclusions and Future Work
Supplementary Materials
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
| AAC | Alternative and augmentative communication |
| BCI | Brain–computer interface |
| CBP | Checkerboard paradigm for flash group creation |
| DP | Design priority |
| EEG | Electroencephalogram |
| ERP | Event-related potential |
| ms | Milliseconds |
| MSP | Magic square paradigm for flash group creation |
| NIDCD | National Institute of Deafness and Other Communication Disorders |
| NIH | National Institutes of Health (United States) |
| RCP | Row–column paradigm for flash group creation |
| TTI | Target-to-target interval |
| UIA | User interface automation |
Appendix A. Alternate Algorithm Parameters
Appendix A.1. Alternate Key Orders




Appendix A.2. Alternate Board Divisions



Appendix A.3. Alternate Key Placements



Appendix B. Virtual Matrix Capacity Shuffle Sub-Routine
- For all keys in the over-capacity virtual matrix, calculate the sum of adjacencies with all keys in the other matrix.
- If the matrix is over-capacity by , pick the keys with the lowest adjacencies with the other matrix. Let us call this set the tentatives and let the maximum adjacency with the other matrix of the tentatives set be .
- Calculate the within-adjacency of each key in the tentatives with every other key in the tentatives. Calculate the total adjacency of every key in the tentatives as the sum of the cross-adjacency (with the other matrix) and the within-adjacency (within the tentatives set).
- Consider all remaining keys in the over-capacity matrix whose adjacency with the other matrix is less than or equal to . Let us call this set probables.
- Pick a key from the tentatives and swap it out with a key from probables. Calculate the within-adjacencies of the new key. If the total adjacency of the new key is less than the total adjacency of the key that was swapped out, retain the new member as a permanent member.
- Repeat the above step for all members of the tentatives set.
Appendix C. AAC Screens for Parameter Optimization


References
- Farwell, L.A.; Donchin, E. Talking off the top of your head: Toward a mental prosthesis utilizing event-related brain potentials. Electroencephalogr. Clin. Neurophysiol. 1988, 70, 510–523. [Google Scholar] [CrossRef]
- Sellers, E.W.; Vaughan, T.M.; Wolpaw, J.R. A brain-computer interface for long-term independent home use. Amyotroph. Lateral Scler. 2010, 11, 449–455. [Google Scholar] [CrossRef] [PubMed]
- Holz, E.M.; Botrel, L.; Kaufmann, T.; Kübler, A. Long-Term Independent Brain-Computer Interface Home Use Improves Quality of Life of a Patient in the Locked-In State: A Case Study. Arch. Phys. Med. Rehabil. 2015, 96, S16–S26. [Google Scholar] [CrossRef] [PubMed]
- Takano, K.; Komatsu, T.; Hata, N.; Nakajima, Y.; Kansaku, K. Visual stimuli for the P300 brain–computer interface: A comparison of white/gray and green/blue flicker matrices. Clin. Neurophysiol. 2009, 120, 1562–1566. [Google Scholar] [PubMed]
- Li, Y.; Nam, C.S.; Shadden, B.B.; Johnson, S.L. A P300-based brain–computer interface: Effects of interface type and screen size. Int. J. Hum.-Comput. Interact. 2010, 27, 52–68. [Google Scholar] [CrossRef]
- Guo, M.; Jin, J.; Jiao, Y.; Wang, X.; Cichockia, A. Investigation of Visual Stimulus With Various Colors and the Layout for the Oddball Paradigm in Evoked Related Potential-Based Brain–Computer Interface. Front. Comput. Neurosci. 2019, 13, 24. [Google Scholar] [CrossRef]
- Gray, H.M.; Ambady, N.; Lowenthal, W.T.; Deldin, P. P300 as an index of attention to self-relevant stimuli. J. Exp. Soc. Psychol. 2004, 40, 216–224. [Google Scholar] [CrossRef]
- Martens, S.; Hill, N.; Farquhar, J.; Schölkopf, B. Overlap and refractory effects in a brain–computer interface speller based on the visual P300 event-related potential. J. Neural Eng. 2009, 6, 026003. [Google Scholar] [CrossRef]
- Liu, Y.; Zhou, Z.; Hu, D. Comparison of stimulus types in visual P300 speller of brain-computer interfaces. In Proceedings of the 9th IEEE International Conference on Cognitive Informatics (ICCI’10), Beijing, China, 7–9 July 2010; IEEE: Piscataway, NJ, USA, 2010; pp. 273–279. [Google Scholar]
- Kaufmann, T.; Schulz, S.M.; Grünzinger, C.; Kübler, A. Flashing characters with famous faces improves ERP-based brain–computer interface performance. J. Neural Eng. 2011, 8, 056016. [Google Scholar]
- Jin, J.; Allison, B.Z.; Kaufmann, T.; Kübler, A.; Zhang, Y.; Wang, X.; Cichocki, A. The changing face of P300 BCIs: A comparison of stimulus changes in a P300 BCI involving faces, emotion, and movement. PLoS ONE 2012, 7, e49688. [Google Scholar] [CrossRef]
- Zhang, Y.; Zhao, Q.; Jin, J.; Wang, X.; Cichocki, A. A novel BCI based on ERP components sensitive to configural processing of human faces. J. Neural Eng. 2012, 9, 026018. [Google Scholar] [CrossRef] [PubMed]
- Kellicut-Jones, M.R.; Sellers, E.W. P300 brain-computer interface: Comparing faces to size matched non-face stimuli. Brain-Comput. Interfaces 2018, 5, 30–39. [Google Scholar] [CrossRef]
- Martínez-Cagigal, V.; Gomez-Pilar, J.; Alvarez, D.; Hornero, R. An asynchronous P300-based brain-computer interface web browser for severely disabled people. IEEE Trans. Neural Syst. Rehabil. Eng. 2016, 25, 1332–1342. [Google Scholar] [CrossRef]
- Yu, T.; Li, Y.; Long, J.; Gu, Z. Surfing the internet with a BCI mouse. J. Neural Eng. 2012, 9, 036012. [Google Scholar] [CrossRef] [PubMed]
- Mellinger, J.; Hinterberger, T.; Bensch, M.; Schröder, M.; Birbaumer, N. Surfing the web with electrical brain signals: The brain web surfer (BWS) for the completely paralysed. In Proceedings of the 2nd World Congress of the International Society of Physical and Rehabilitation Medicine-ISPRM, Prague, Czech Republic, 18–22 May 2003; pp. 162–165. [Google Scholar]
- Rebsamen, B.; Burdet, E.; Guan, C.; Zhang, H.; Teo, C.L.; Zeng, Q.; Laugier, C.; Ang, M.H. Controlling a wheelchair indoors using thought. IEEE Intell. Syst. 2007, 22, 18–24. [Google Scholar] [CrossRef]
- Münßinger, J.I.; Halder, S.; Kleih, S.C.; Furdea, A.; Raco, V.; Hösle, A.; Kubler, A. Brain painting: First evaluation of a new brain–computer interface application with ALS-patients and healthy volunteers. Front. Neurosci. 2010, 4, 182. [Google Scholar] [CrossRef]
- Pinegger, A.; Hiebel, H.; Wriessnegger, S.C.; Müller-Putz, G.R. Composing only by thought: Novel application of the P300 brain-computer interface. PLoS ONE 2017, 12, e0181584. [Google Scholar] [CrossRef]
- Kaplan, A.Y.; Shishkin, S.L.; Ganin, I.P.; Basyul, I.A.; Zhigalov, A.Y. Adapting the P300-based brain–computer interface for gaming: A review. IEEE Trans. Comput. Intell. AI Games 2013, 5, 141–149. [Google Scholar] [CrossRef]
- Ryan, D.B.; Frye, G.E.; Townsend, G.; Berry, D.R.; Mesa-G, S.; Gates, N.A.; Sellers, E.W. Predictive spelling with a P300-based brain-computer interface: Increasing the rate of communication. Int. J. Hum. Comput. Interact. 2011, 27, 69–85. [Google Scholar] [CrossRef] [PubMed]
- Thompson, D.E.; Gruis, K.L.; Huggins, J.E. A plug-and-play brain-computer interface to operate commercial assistive technology. Disabil. Rehabil. Assist. Technol. 2014, 9, 144–150. [Google Scholar] [CrossRef] [PubMed]
- Zickler, C.; Riccio, A.; Leotta, F.; Hillian-Tress, S.; Halder, S.; Holz, E.; Staiger-Sälzer, P.; Hoogerwerf, E.J.; Desideri, L.; Mattia, D.; et al. A Brain-Computer Interface as Input Channel for a Standard Assistive Technology Software. Clin. EEG Neurosci. 2011, 42, 236–244. [Google Scholar] [CrossRef] [PubMed]
- Baker, B. Minspeak, a semantic compaction system that makes self-expression easier for communicatively disabled individuals. Byte 1982, 7, 186–202. [Google Scholar]
- Hill, K.J. The Development of a Model for Automated Performance Measurement and the Establishment of Performance Indices for Augmented Communicators Under Two Sampling Conditions; University of Pittsburgh: Pittsburgh, PA, USA, 2001. [Google Scholar]
- Yuan, P.; Wang, Y.; Wu, W.; Xu, H.; Gao, X.; Gao, S. Study on an online collaborative BCI to accelerate response to visual targets. In Proceedings of the 2012 Annual International Conference of the IEEE Engineering in Medicine and Biology Society, San Diego, CA, USA, 28 August–1 September 2012; IEEE: Piscataway, NJ, USA, 2012; pp. 1736–1739. [Google Scholar]
- Townsend, G.; LaPallo, B.K.; Boulay, C.B.; Krusienski, D.J.; Frye, G.; Hauser, C.; Schwartz, N.E.; Vaughan, T.M.; Wolpaw, J.R.; Sellers, E.W. A novel P300-based brain–computer interface stimulus presentation paradigm: Moving beyond rows and columns. Clin. Neurophysiol. 2010, 121, 1109–1120. [Google Scholar] [CrossRef]
- Gonsalvez, C.L.; Polich, J. P300 amplitude is determined by target-to-target interval. Psychophysiology 2002, 39, 388–396. [Google Scholar] [CrossRef] [PubMed]
- Fazel-Rezai, R. Human error in P300 speller paradigm for brain-computer interface. In Proceedings of the 2007 29th Annual International Conference of the IEEE Engineering in Medicine and Biology Society, Lyon, France, 22–26 August 2007; IEEE: Piscataway, NJ, USA, 2007; pp. 2516–2519. [Google Scholar]
- Cameron, I.; Rogers, A.; Loly, P. Signatura of magic and Latin integer squares: Isentropic clans and indexing. Discuss. Math. Probab. Stat. 2012, 33, 121–149. [Google Scholar] [CrossRef][Green Version]
- Microsoft. UI Automation—win32 Apps. 2025. Available online: https://learn.microsoft.com/en-us/windows/win32/winauto/entry-uiauto-win32 (accessed on 19 March 2026).
- Schalk, G.; McFarland, D.J.; Hinterberger, T.; Birbaumer, N.; Wolpaw, J.R. BCI2000: A General-Purpose Brain-Computer Interface (BCI) System. IEEE Trans. Biomed. Eng. 2004, 51, 1034–1043. [Google Scholar] [CrossRef]
- Parberry, I. An efficient algorithm for the Knight’s tour problem. Discret. Appl. Math. 1997, 73, 251–260. [Google Scholar] [CrossRef]




















| Keyboard | Number of Selections | Number of Groups | Groups with Adjacency | Groups with Amalgamated Adjacency | Groups with Side-Adjacency | Groups with Diagonal Adjacency | Difference in Flash Group Length |
|---|---|---|---|---|---|---|---|
| Unity | 127 | 2744 | 91 | 0 | 0 | 91 | 1.3 |
| UnityKey | 93 | 2236 | 128 | 15 | 0 | 113 | 1.3 |
| PauseScr | 1040 | 24,960 | 840 | 0 | 0 | 840 | 1.3 |
| keyboard | 4518 | 97,004 | 7083 | 5 | 0 | 7078 | 2.1 |
| Total | 5778 | 126,944 | 8142 | 20 | 0 | 8122 | 1.9 |
| Design Priority | Design Mechanism | Evaluation Metric |
|---|---|---|
| DP1: Identifiability | Hidden matrices | Each key associated with unique set of flash groups |
| DP2: Unpredictability | Shuffle of flash groups between sequences | Variance of target-to-target interval |
| DP3: Perceptibility | Ordering of groups by rows and columns of hidden matrices | Average target-to-target interval |
| DP4: Minimality | Different-sized hidden matrices; pruning empty rules and columns | Number of flash groups |
| DP5: Anti-adjacency | Checkerboard division; magic square placement; anti-adjacency placement algorithm | Adjacency measures; metrics for amalgamated adjacency, side adjacency, and diagonal adjacency |
| DP6: Equality | Magic square placement distributed over the hidden matrix | Difference between minimum and maximum length |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Huggins, J.E.; Biswas, P.; Huggins, J.K.; Chandel, R. A Flash Group Creation Algorithm for P300 Brain–Computer Interface Integration with Irregular Assistive Technology Keyboard Layouts. Sensors 2026, 26, 2123. https://doi.org/10.3390/s26072123
Huggins JE, Biswas P, Huggins JK, Chandel R. A Flash Group Creation Algorithm for P300 Brain–Computer Interface Integration with Irregular Assistive Technology Keyboard Layouts. Sensors. 2026; 26(7):2123. https://doi.org/10.3390/s26072123
Chicago/Turabian StyleHuggins, Jane E., Palash Biswas, James K. Huggins, and Rishabh Chandel. 2026. "A Flash Group Creation Algorithm for P300 Brain–Computer Interface Integration with Irregular Assistive Technology Keyboard Layouts" Sensors 26, no. 7: 2123. https://doi.org/10.3390/s26072123
APA StyleHuggins, J. E., Biswas, P., Huggins, J. K., & Chandel, R. (2026). A Flash Group Creation Algorithm for P300 Brain–Computer Interface Integration with Irregular Assistive Technology Keyboard Layouts. Sensors, 26(7), 2123. https://doi.org/10.3390/s26072123

