How to use muse-js - 4 common examples

To help you get started, we’ve selected a few muse-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github makebrainwaves / BrainWaves / app / utils / eeg / muse.js View on Github external
import { from } from 'rxjs';
import { parseMuseSignalQuality } from './pipes';
import {
  MUSE_SAMPLING_RATE,
  MUSE_CHANNELS,
  PLOTTING_INTERVAL
} from '../../constants/constants';

const INTER_SAMPLE_INTERVAL = -(1 / 256) * 1000;

let bluetooth = {};
let client = {};
if (process.platform !== 'win32' || release().split('.')[0] >= 10) {
  // Just returns the client object from Muse JS
  bluetooth = require('bleat').webbluetooth;
  client = new MuseClient();
  client.enableAux = true;
}
// Gets an available Muse device
// TODO: test whether this will ever return multiple devices if available
export const getMuse = async () => {
  let device = {};
  if (process.platform === 'win32') {
    if (release().split('.')[0] < 10) {
      console.log('win 7 ');
      return null;
    }
    device = await bluetooth.requestDevice({
      filters: [{ services: [MUSE_SERVICE] }]
    });
  } else {
    device = await navigator.bluetooth.requestDevice({
github NeuroJS / angular-muse / src / app / app.component.ts View on Github external
async connect() {
    this.connecting = true;
    this.snackBar.dismiss();
    try {
      await this.muse.connect();
      this.controlResponses = this.muse.controlResponses;
      await this.muse.start();
      this.data = zipSamples(this.muse.eegReadings)
        .takeUntil(this.destroy)
        .do(() => this.cd.detectChanges());
      this.batteryLevel = this.muse.telemetryData
        .takeUntil(this.destroy)
        .map(t => t.batteryLevel);
      this.muse.accelerometerData
        .takeUntil(this.destroy)
        .map(reading => reading.samples[reading.samples.length - 1])
        .subscribe(this.accelerometer);
    } catch (err) {
      this.snackBar.open('Connection failed: ' + err.toString(), 'Dismiss');
    } finally {
      this.connecting = false;
    }
  }
github makebrainwaves / BrainWaves / app / utils / eeg / muse.js View on Github external
export const createRawMuseObservable = async () => {
  await client.start();
  const eegStream = await client.eegReadings;
  const markers = await client.eventMarkers.pipe(startWith({ timestamp: 0 }));
  return from(zipSamples(eegStream)).pipe(
    filter(sample => !sample.data.includes(NaN)),
    withLatestFrom(markers, synchronizeTimestamp),
    share()
  );
};
github NeuroJS / angular-muse / src / app / time-series / time-series.component.ts View on Github external
const samplingFrequency = 256;

@Component({
  selector: 'time-series',
  templateUrl: 'time-series.component.html',
  styleUrls: ['time-series.component.css'],
})
export class TimeSeriesComponent implements OnInit, OnDestroy, AfterViewInit {

  @Input() data: Observable;

  filter = false;

  readonly channels = 4;
  readonly channelNames = channelNames.slice(0, this.channels);
  readonly amplitudes = [];
  readonly uVrms = [0, 0, 0, 0];
  readonly uMeans = [0, 0, 0, 0];

  readonly options = this.chartService.getChartSmoothieDefaults({
    millisPerPixel: 8,
    maxValue: 1000,
    minValue: -1000
  });
  readonly colors = this.chartService.getColors();
  readonly canvases = Array(this.channels).fill(0).map(() => new SmoothieChart(this.options));

  private readonly lines = Array(this.channels).fill(0).map(() => new TimeSeries());
  private readonly bandpassFilters: BandpassFilter[] = [];

  constructor(private view: ElementRef, private chartService: ChartService) {

muse-js

Muse 2016 EEG Headset JavaScript Library

MIT
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages