“about:dino,” but with your brain!?

Asil Gilani
3 min readJan 3, 2023

--

Have you ever seen the “No Internet” sign pop up on google chrome? Well, you may have seen the Dino game where you’re jumping over cacti and ducking from birds.

“about:dino” game on Google Chrome

The “about:dino” game was originally meant to be played by pressing the space bar making the dinosaur jump over the cacti. However, due to the simplicity of the game, I thought I should try and apply the concepts of Brain Computing Interfaces to the game 🧠.

Hardware

For this particular project, I used the Muse Model 2 Headband, a Bluetooth-compatible EEG headband that uses electrodes to pick up brain activity.

Muse Model 2 Headband

Pairing Using Web Bluetooth

I used Web Bluetooth on Google Chrome to connect my Muse Headband to the computer. This is known to be one of the most secure methods for connecting web pages to external Bluetooth devices.

The Code

I begin by extracting the game’s code into a standalone HTML page. Then, using a terminal, I install Muse-JS and SystemJS and initialize a new NPM software. The muse-js library and rxjs are loaded using SystemJS (a module loader)

npm init -y
npm install - save muse-js
npm install - save systemjs

Index.Html

The code below will be inserted into the HTML page.

<script src="node_modules/systemjs/dist/system.js"></script>
<script>
System.config({
packages: {

'muse-js': {

defaultJSExtensions: true,

main: 'muse.js',

},

'rxjs': {

defaultJSExtensions: true,
}
},
map: {

'rxjs': 'node_modules/rxjs/',
'muse-js': 'node_modules/muse-js/dist'
}
});
SystemJS.import('brain.js');

The programming instructs the computer where to locate the rxjs and muse-js modules while loading SystemJS. SystemJs is instructed to load the brain.js file at the 18th line. The modules may have been managed by another system, however SystemJS required less configuration.

Brain.js

const { MuseClient, channelNames } = require('muse-js'); require('rxjs/add/operator/filter');
require('rxjs/add/operator/map'); async function connectToMuse() {
const client = new MuseClient();
await client.connect();
await client.start();

const leftChannel = channelNames.indexOf('AF7');
const blinks = client.eegReadings
.filter(r => r.electrode === leftChannel)
.map(r => Math.max(...r.samples.map(n => Math.abs(n))))
.filter(max => max > 400);

blinks.subscribe(() => {
const jumpEvent = new Event('keydown');
jumpEvent.keyCode = 32; // Space key
document.dispatchEvent(jumpEvent);
});
}
window.connectToMuse = connectToMuse;

MuseClient is initialized in lines 7–9, and the left eye’s observed blinks are filtered in lines 11–15. On line 15, while 150–200 occasionally performs better in a less loud setting, 400–500 often performs well in noisy environments. Blink occurrences are monitored by line 17. Lines 18 to 20 replicate a dom key event since, in the game, you often jump by pressing the space bar. Now, hitting the space bar is perceived as the user blinking.

<div> 
<button onclick=”connectToMuse()”> Connect </button>
</div>

Lastly, I ensured to add a connect button to index.html.

Demonstration

A web server will be required to provide the HTML page in order for the game to function. Although there are many more possibilities, I chose live server to manage the project.

An illustration of what may be done with BCIs is this game. The power of BCI technology can yet be more fully realized, though. For instance, picture being able to dim your home’s lights simply by thinking about it! or perhaps interacting with others via BCI chips inserted into your brain. I am eager to see how this technology will alter the world in the future because we have only just begun to explore its potential.

--

--