Created
December 8, 2019 21:49
-
-
Save korymath/a1d1ef69a7b7aa6c0ce0a0fb6dc0fa89 to your computer and use it in GitHub Desktop.
This is the old connect function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// async function connect() { | |
// window.museClient = new MuseClient(); | |
// setStatus(generalTranslations.connecting); | |
// try { | |
// await window.museClient.connect(); | |
// await window.museClient.start(); | |
// setStatus(generalTranslations.connected); | |
// if (window.museClient && window.museClient.eegReadings) { | |
// switch (selected) { | |
// case translations.types.raw: | |
// if (window.rawZippedData$ === null) { | |
// window.rawZippedData$ = zipSamples( | |
// window.museClient.eegReadings | |
// ).pipe( | |
// bandpassFilter({ cutoffFrequencies: [2, 20], nbChannels: 4 }), | |
// epoch({ duration: 1024, interval: 50, samplingRate: 256 }), | |
// catchError(err => { | |
// console.log(err); | |
// }) | |
// ); | |
// } | |
// window.rawSubscription$ = window.rawZippedData$.subscribe(data => { | |
// setRawData(rawData => { | |
// Object.values(rawData).forEach( | |
// (channel, index) => { | |
// if (index < 4) { | |
// const sRate = data.info.samplingRate; | |
// channel.datasets[0].data = data.data[index]; | |
// channel.xLabels = customCount( | |
// (1000 / sRate) * data.data[2].length, | |
// 1000 / sRate, | |
// -(1000 / sRate) | |
// ).map(function(each_element) { | |
// return Number(each_element.toFixed(0)); | |
// }); | |
// } | |
// }, | |
// err => { | |
// console.log(err); | |
// } | |
// ); | |
// return { | |
// ch0: rawData.ch0, | |
// ch1: rawData.ch1, | |
// ch2: rawData.ch2, | |
// ch3: rawData.ch3 | |
// }; | |
// }); | |
// }); | |
// break; | |
// case translations.types.spectra: | |
// if (window.spectraZippedData$ === null) { | |
// window.spectraZippedData$ = zipSamples( | |
// window.museClient.eegReadings | |
// ).pipe( | |
// bandpassFilter({ cutoffFrequencies: [2, 20], nbChannels: 4 }), | |
// epoch({ duration: 1024, interval: 100, samplingRate: 256 }), | |
// fft({ bins: 256 }), | |
// sliceFFT([1, 30]), | |
// catchError(err => { | |
// console.log(err); | |
// }) | |
// ); | |
// } | |
// window.spectraSubscription$ = window.spectraZippedData$.subscribe( | |
// data => { | |
// setSpectraData(spectraData => { | |
// Object.values(spectraData).forEach((channel, index) => { | |
// if (index < 4) { | |
// channel.datasets[0].data = data.psd[index]; | |
// channel.xLabels = data.freqs; | |
// } | |
// }); | |
// return { | |
// ch0: spectraData.ch0, | |
// ch1: spectraData.ch1, | |
// ch2: spectraData.ch2, | |
// ch3: spectraData.ch3 | |
// }; | |
// }); | |
// } | |
// ); | |
// break; | |
// } | |
// } | |
// } catch (err) { | |
// setStatus(generalTranslations.connect); | |
// console.log(err); | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment