  The ability to efficiently match the frequency of the brain's response to
repetitive visual stimuli in real time is the basis for reliable SSVEP-based
Brain-Computer-Interfacing (BCI). The detection of different stimuli is posed
as a composite hypothesis test, where SSVEPs are assumed to admit a sparse
representation in a Ramanujan Periodicity Transform (RPT) dictionary. For the
binary case, we develop and analyze the performance of an RPT detector based on
a derived generalized likelihood ratio test. Our approach is extended to
multi-hypothesis multi-electrode settings, where we capture the spatial
correlation between the electrodes using pre-stimulus data. We also introduce a
new metric for evaluating SSVEP detection schemes based on their achievable
efficiency and discrimination rate tradeoff for given system resources. We
obtain exact distributions of the test statistic in terms of confluent
hypergeometric functions. Results based on extensive simulations with both
synthesized and real data indicate that the RPT detector substantially
outperforms spectral-based methods. Its performance also surpasses the
state-of-the-art Canonical Correlation Analysis (CCA) methods with respect to
accuracy and sample complexity in short data lengths regimes crucial for
real-time applications. The proposed approach is asymptotically optimal as it
closes the gap to a perfect measurement bound as the data length increases. In
contrast to existing supervised methods which are highly data-dependent, the
RPT detector only uses pre-stimulus data to estimate the per-subject spatial
correlation, thereby dispensing with considerable overhead associated with data
collection for a large number of subjects and stimuli. Our work advances the
theory and practice of emerging real-time BCI and affords a new framework for
comparing SSVEP detection schemes across a wider spectrum of operating regimes.
