An easy-to-use platform for EEG experimentation in the classroom
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

experimenting with lsl

Co-authored-by: Yury Shevchenko <shevchenko_yury@mail.ru>

authored by

Yury Shevchenko
Yury Shevchenko
and committed by
Teon L Brooks
7714c36a 04109dbf

+27 -1
+1
app/package.json
··· 22 22 "enchannel-zmq-backend": "^6.0.11", 23 23 "kernelspecs": "^2.0.0", 24 24 "noble-winrt": "^0.1.0", 25 + "node-lsl": "git+https://github.com/urish/node-lsl.git", 25 26 "node-pre-gyp": "^0.10.0", 26 27 "spawnteract": "^4.0.0" 27 28 },
+26 -1
app/utils/jspsych/functions.js
··· 2 2 import { jsPsych } from 'jspsych-react'; 3 3 import * as path from 'path'; 4 4 import { readdirSync } from 'fs'; 5 + import lsl from 'node-lsl'; 5 6 import { EXPERIMENTS } from '../../constants/constants'; 6 7 import { buildOddballTimeline } from './timelines/oddball'; 7 8 import { buildN170Timeline } from './timelines/n170'; ··· 11 12 Trial, 12 13 ExperimentParameters 13 14 } from '../../constants/interfaces'; 15 + 16 + // create and open an outlet to stream data 17 + const info = lsl.create_streaminfo( 18 + 'Dummy', 19 + 'Marker', // type 20 + 1, // number of channels 21 + 10, // sample rate in 1 sec. 22 + lsl.channel_format_t.cft_float32, 23 + 'Dummy Marker Device' 24 + ); 25 + const desc = lsl.get_desc(info); 26 + lsl.append_child_value(desc, 'manufacturer', 'Random Inc.'); 27 + const channels = lsl.append_child(desc, 'channels'); 28 + const channel = lsl.append_child(channels, 'channel'); 29 + lsl.append_child_value(channel, 'type', 'Marker'); 30 + const outlet = lsl.create_outlet(info, 0, 360); 14 31 15 32 // loads a normalized timeline for the default experiments with specific callback fns 16 33 export const loadTimeline = (type: EXPERIMENTS) => { ··· 123 140 if (trial.id === 'trial') { 124 141 return { 125 142 ...trial, 126 - on_start: () => { 143 + on_start: e => { 144 + if (e) { 145 + const correctResponse = parseFloat(e.correct_response); 146 + lsl.push_sample_ft( 147 + outlet, 148 + new lsl.FloatArray([correctResponse]), 149 + lsl.local_clock() 150 + ); 151 + } 127 152 eventCallback( 128 153 jsPsych.timelineVariable('eventTypeVar')(), 129 154 new Date().getTime()