A modern JavaScript library for connecting to Muse EEG devices using Web Bluetooth API. This project aims to provide a maintained alternative to muse-js which is no longer actively maintained.
- 🔄 Active Development: Unlike muse-js, web-muse is actively maintained and works with current Muse firmware
- 🌐 Web Bluetooth: Direct browser connection without additional software
- ⚛️ React Integration: Built-in React hooks and context for easy integration
- 🧪 Mock Data: Development support with mock data capabilities
- 📊 Signal Processing: Built-in EEG processing utilities
- Direct connection to Muse EEG devices via Web Bluetooth
- Real-time EEG data streaming at 256Hz
- Built-in signal processing utilities
- React hooks and context for easy integration
- Mock data support for development
- Support for:
- EEG data (4 channels)
- PPG data (3 channels)
- Accelerometer data
- Gyroscope data
- Battery level monitoring
- Clone the repository:
git clone https://github.com/itayinbarr/web-muse.git
cd web-muse- Install dependencies:
npm install- Build the library:
npm run buildYou can install web-muse directly from your local clone using one of these methods:
# In web-muse directory
npm link
# In your project directory
npm link web-museAdd this to your project's package.json:
{
"dependencies": {
"web-muse": "file:../path/to/web-muse"
}
}Then run npm install
Add this to your project's package.json:
{
"dependencies": {
"web-muse": "github:itayinbarr/web-muse"
}
}Then run npm install
import { connectMuse } from "web-muse";
async function connectToMuse() {
const muse = await connectMuse();
console.log("Connected to Muse device:", muse);
// Start receiving EEG data
setInterval(() => {
const eegData = muse.eeg.map((buffer) => buffer.read());
console.log("EEG Data:", eegData);
}, 1000 / 256); // 256Hz sampling rate
}import { useEEG, EEGProvider } from "web-muse/react";
// Wrap your app with the provider
function App() {
return (
<EEGProvider>
<YourComponent />
</EEGProvider>
);
}
// Use the hook in your components
function YourComponent() {
const { isConnected, connectMuse, rawEEG } = useEEG();
return (
<div>
{!isConnected ? (
<button onClick={connectMuse}>Connect to Muse</button>
) : (
<div>EEG Data: {JSON.stringify(rawEEG)}</div>
)}
</div>
);
}# Install dependencies
npm install
# Run example
npm run dev
# Build library
npm run build
# Run tests
npm test- A Muse headband (tested with Muse 2 and Muse S)
- A Web Bluetooth-compatible browser:
- Chrome (desktop & android)
- Edge (desktop)
- Opera (desktop & android)
- Samsung Internet (android)
Note: Safari and iOS devices do not currently support Web Bluetooth.
Web Bluetooth API is required. Check browser compatibility.
MIT
- Thanks to muse-js for pioneering Web Bluetooth support for Muse devices
- Thanks to Interaxon for creating the Muse headband