Skip to content

Commit 02f2aee

Browse files
committed
fixed bug with title of heartSpectra, fixed it so if stream aux and go to other module it doesnt crash
1 parent 510d8e2 commit 02f2aee

File tree

7 files changed

+72
-84
lines changed

7 files changed

+72
-84
lines changed

src/components/PageSwitcher/PageSwitcher.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Select, Card, Stack, Button, ButtonGroup, Checkbox } from "@shopify/pol
55
import { mockMuseEEG } from "./utils/mockMuseEEG";
66
import * as translations from "./translations/en.json";
77
import * as generalTranslations from "./components/translations/en";
8-
import { emptyChannelData, emptyAuxChannelData, emptySingleChannelData } from "./components/chartOptions";
8+
import { emptyAuxChannelData } from "./components/chartOptions";
99

1010
import * as funIntro from "./components/EEGEduIntro/EEGEduIntro"
1111
import * as funHeartRaw from "./components/EEGEduHeartRaw/EEGEduHeartRaw"
@@ -47,18 +47,18 @@ export function PageSwitcher() {
4747
let showAux = true; // if it is even available to press (to prevent in some modules)
4848

4949
// data pulled out of multicast$
50-
const [introData, setIntroData] = useState(emptyChannelData)
51-
const [heartRawData, setHeartRawData] = useState(emptyChannelData);
52-
const [heartSpectraData, setHeartSpectraData] = useState(emptySingleChannelData);
50+
const [introData, setIntroData] = useState(emptyAuxChannelData)
51+
const [heartRawData, setHeartRawData] = useState(emptyAuxChannelData);
52+
const [heartSpectraData, setHeartSpectraData] = useState(emptyAuxChannelData);
5353
const [rawData, setRawData] = useState(emptyAuxChannelData);
5454
const [spectraData, setSpectraData] = useState(emptyAuxChannelData);
5555
const [bandsData, setBandsData] = useState(emptyAuxChannelData);
56-
const [animateData, setAnimateData] = useState(emptyChannelData);
57-
const [spectroData, setSpectroData] = useState(emptyChannelData);
56+
const [animateData, setAnimateData] = useState(emptyAuxChannelData);
57+
const [spectroData, setSpectroData] = useState(emptyAuxChannelData);
5858
const [alphaData, setAlphaData] = useState(emptyAuxChannelData);
5959
const [ssvepData, setSsvepData] = useState(emptyAuxChannelData);
6060
const [evokedData, setEvokedData] = useState(emptyAuxChannelData);
61-
const [predictData, setPredictData] = useState(emptyChannelData);
61+
const [predictData, setPredictData] = useState(emptyAuxChannelData);
6262

6363
// pipe settings
6464
const [introSettings] = useState(funIntro.getSettings);

src/components/PageSwitcher/components/EEGEduAnimate/EEGEduAnimate.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function getSettings () {
3232
return {
3333
cutOffLow: 2,
3434
cutOffHigh: 20,
35-
nbChannels: 4,
3635
interval: 16,
3736
bins: 256,
3837
duration: 128,
@@ -52,7 +51,7 @@ export function buildPipe(Settings) {
5251
window.pipeAnimate$ = zipSamples(window.source.eegReadings$).pipe(
5352
bandpassFilter({
5453
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
55-
nbChannels: Settings.nbChannels }),
54+
nbChannels: window.nchans }),
5655
epoch({
5756
duration: Settings.duration,
5857
interval: Settings.interval,
@@ -76,7 +75,6 @@ export function setup(setData, Settings) {
7675
window.subscriptionAnimate = window.multicastAnimate$.subscribe(data => {
7776
setData(animateData => {
7877
Object.values(animateData).forEach((channel, index) => {
79-
if (index < 4) {
8078
channel.datasets[0].data = [
8179
data.delta[index],
8280
data.theta[index],
@@ -85,14 +83,14 @@ export function setup(setData, Settings) {
8583
data.gamma[index]
8684
];
8785
channel.xLabels = bandLabels;
88-
}
8986
});
9087

9188
return {
9289
ch0: animateData.ch0,
9390
ch1: animateData.ch1,
9491
ch2: animateData.ch2,
95-
ch3: animateData.ch3
92+
ch3: animateData.ch3,
93+
ch4: animateData.ch4
9694
};
9795
});
9896
});
@@ -129,14 +127,15 @@ export function renderModule(channels) {
129127
}, []);
130128

131129
return Object.values(channels.data).map((channel, index) => {
132-
// console.log(channel)
133130
if (channel.datasets[0].data) {
134-
// console.log( channel.datasets[0].data[2])
135-
window.delta = channel.datasets[0].data[0];
136-
window.theta = channel.datasets[0].data[1];
137-
window.alpha = channel.datasets[0].data[2];
138-
window.beta = channel.datasets[0].data[3];
139-
window.gamma = channel.datasets[0].data[4];
131+
if (index === 1) {
132+
// console.log( channel.datasets[0].data[2])
133+
window.delta = channel.datasets[0].data[0];
134+
window.theta = channel.datasets[0].data[1];
135+
window.alpha = channel.datasets[0].data[2];
136+
window.beta = channel.datasets[0].data[3];
137+
window.gamma = channel.datasets[0].data[4];
138+
}
140139
}
141140

142141
let thisSketch = sketchTone;

src/components/PageSwitcher/components/EEGEduHeartRaw/EEGEduHeartRaw.js

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export function getSettings () {
2424
return {
2525
cutOffLow: 2,
2626
cutOffHigh: 20,
27-
nbChannels: 4,
2827
interval: 50,
2928
srate: 256,
3029
duration: 1024,
@@ -43,7 +42,7 @@ export function buildPipe(Settings) {
4342
window.pipeHeartRaw$ = zipSamples(window.source.eegReadings$).pipe(
4443
bandpassFilter({
4544
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
46-
nbChannels: Settings.nbChannels }),
45+
nbChannels: window.nchans }),
4746
epoch({
4847
duration: Settings.duration,
4948
interval: Settings.interval,
@@ -65,18 +64,17 @@ export function setup(setData, Settings) {
6564
window.subscriptionHeartRaw = window.multicastHeartRaw$.subscribe(data => {
6665
setData(heartRawData => {
6766
Object.values(heartRawData).forEach((channel, index) => {
68-
if (index < 4) {
6967
channel.datasets[0].data = data.data[index];
7068
channel.xLabels = generateXTics(Settings.srate, Settings.duration);
7169
channel.datasets[0].qual = standardDeviation(data.data[index])
72-
}
7370
});
7471

7572
return {
7673
ch0: heartRawData.ch0,
7774
ch1: heartRawData.ch1,
7875
ch2: heartRawData.ch2,
79-
ch3: heartRawData.ch3
76+
ch3: heartRawData.ch3,
77+
ch4: heartRawData.ch4
8078
};
8179
});
8280
});
@@ -89,49 +87,49 @@ export function setup(setData, Settings) {
8987
export function renderModule(channels) {
9088
function renderCharts() {
9189
return Object.values(channels.data).map((channel, index) => {
92-
const options = {
93-
...generalOptions,
94-
scales: {
95-
xAxes: [
96-
{
97-
scaleLabel: {
98-
...generalOptions.scales.xAxes[0].scaleLabel,
99-
labelString: specificTranslations.xlabel
90+
if (index === 1) {
91+
const options = {
92+
...generalOptions,
93+
scales: {
94+
xAxes: [
95+
{
96+
scaleLabel: {
97+
...generalOptions.scales.xAxes[0].scaleLabel,
98+
labelString: specificTranslations.xlabel
99+
}
100100
}
101-
}
102-
],
103-
yAxes: [
104-
{
105-
scaleLabel: {
106-
...generalOptions.scales.yAxes[0].scaleLabel,
107-
labelString: specificTranslations.ylabel
108-
},
109-
ticks: {
110-
max: 300,
111-
min: -300
101+
],
102+
yAxes: [
103+
{
104+
scaleLabel: {
105+
...generalOptions.scales.yAxes[0].scaleLabel,
106+
labelString: specificTranslations.ylabel
107+
},
108+
ticks: {
109+
max: 300,
110+
min: -300
111+
}
112112
}
113+
]
114+
},
115+
elements: {
116+
line: {
117+
borderColor: 'rgba(' + channel.datasets[0].qual + ', 128, 128)',
118+
fill: false
119+
},
120+
point: {
121+
radius: 0
113122
}
114-
]
115-
},
116-
elements: {
117-
line: {
118-
borderColor: 'rgba(' + channel.datasets[0].qual + ', 128, 128)',
119-
fill: false
120123
},
121-
point: {
122-
radius: 0
124+
animation: {
125+
duration: 0
126+
},
127+
title: {
128+
...generalOptions.title,
129+
text: generalTranslations.channel + channelNames[index] + ' --- SD: ' + channel.datasets[0].qual
123130
}
124-
},
125-
animation: {
126-
duration: 0
127-
},
128-
title: {
129-
...generalOptions.title,
130-
text: generalTranslations.channel + channelNames[index] + ' --- SD: ' + channel.datasets[0].qual
131-
}
132-
};
131+
};
133132

134-
if (index === 1) {
135133
return (
136134
<Card.Section key={"Card_" + index}>
137135
<Line key={"Line_" + index} data={channel} options={options} />

src/components/PageSwitcher/components/EEGEduHeartSpectra/EEGEduHeartSpectra.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export function getSettings() {
2727
return {
2828
cutOffLow: .01,
2929
cutOffHigh: 20,
30-
nbChannels: 4,
3130
interval: 100,
3231
bins: 8192,
3332
sliceFFTLow: 0.6,
@@ -50,7 +49,7 @@ export function buildPipe(Settings) {
5049
window.pipeHeartSpectra$ = zipSamples(window.source.eegReadings$).pipe(
5150
bandpassFilter({
5251
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
53-
nbChannels: Settings.nbChannels }),
52+
nbChannels: window.nchans }),
5453
epoch({
5554
duration: Settings.duration,
5655
interval: Settings.interval,
@@ -125,7 +124,7 @@ export function renderModule(channels) {
125124
title: {
126125
...generalOptions.title,
127126
text: generalTranslations.channel +
128-
channelNames[index] +
127+
channelNames[1] +
129128
" - Estimated HR: " +
130129
channel.peakF + " BPM"
131130
}

src/components/PageSwitcher/components/EEGEduIntro/EEGEduIntro.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export function getSettings () {
2424
name: "Intro",
2525
cutOffLow: 2,
2626
cutOffHigh: 20,
27-
nbChannels: 4,
2827
interval: 2,
2928
srate: 256,
3029
duration: 512
@@ -42,7 +41,7 @@ export function buildPipe(Settings) {
4241
window.pipeIntro$ = zipSamples(window.source.eegReadings$).pipe(
4342
bandpassFilter({
4443
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
45-
nbChannels: Settings.nbChannels }),
44+
nbChannels: window.nchans }),
4645
epoch({
4746
duration: Settings.duration,
4847
interval: Settings.interval,
@@ -72,10 +71,7 @@ export function setup(setData, Settings) {
7271
});
7372

7473
return {
75-
ch0: introData.ch0,
76-
ch1: introData.ch1,
77-
ch2: introData.ch2,
78-
ch3: introData.ch3
74+
ch0: introData.ch0
7975
};
8076
});
8177
});

src/components/PageSwitcher/components/EEGEduPredict/EEGEduPredict.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export function getSettings() {
3030
return {
3131
cutOffLow: 2,
3232
cutOffHigh: 20,
33-
nbChannels: 4,
3433
interval: 256,
3534
bins: 256,
3635
sliceFFTLow: 1,
@@ -52,7 +51,7 @@ export function buildPipe(Settings) {
5251
window.pipePredict$ = zipSamples(window.source.eegReadings$).pipe(
5352
bandpassFilter({
5453
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
55-
nbChannels: Settings.nbChannels }),
54+
nbChannels: window.nchans }),
5655
epoch({
5756
duration: Settings.duration,
5857
interval: Settings.interval,
@@ -77,17 +76,16 @@ export function setup(setData, Settings) {
7776
window.subscriptionPredict = window.multicastPredict$.subscribe(data => {
7877
setData(predictData => {
7978
Object.values(predictData).forEach((channel, index) => {
80-
if (index < 4) {
81-
channel.datasets[0].data = data.psd[index];
82-
channel.xLabels = data.freqs;
83-
}
79+
channel.datasets[0].data = data.psd[index];
80+
channel.xLabels = data.freqs;
8481
});
8582

8683
return {
8784
ch0: predictData.ch0,
8885
ch1: predictData.ch1,
8986
ch2: predictData.ch2,
90-
ch3: predictData.ch3
87+
ch3: predictData.ch3,
88+
ch4: predictData.ch4
9189
};
9290
});
9391
});

src/components/PageSwitcher/components/EEGEduSpectro/EEGEduSpectro.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export function getSettings () {
2626
return {
2727
cutOffLow: 1,
2828
cutOffHigh: 100,
29-
nbChannels: 4,
3029
interval: 16,
3130
bins: 128,
3231
duration: 128,
@@ -48,7 +47,7 @@ export function buildPipe(Settings) {
4847
window.pipeSpectro$ = zipSamples(window.source.eegReadings$).pipe(
4948
bandpassFilter({
5049
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
51-
nbChannels: Settings.nbChannels }),
50+
nbChannels: window.nchans }),
5251
epoch({
5352
duration: Settings.duration,
5453
interval: Settings.interval,
@@ -72,17 +71,16 @@ export function setup(setData, Settings) {
7271
window.subscriptionSpectro = window.multicastSpectro$.subscribe(data => {
7372
setData(spectroData => {
7473
Object.values(spectroData).forEach((channel, index) => {
75-
if (index < 4) {
76-
channel.datasets[0].data = data.psd[index];
77-
channel.xLabels = data.freqs
78-
}
74+
channel.datasets[0].data = data.psd[index];
75+
channel.xLabels = data.freqs
7976
});
8077

8178
return {
8279
ch0: spectroData.ch0,
8380
ch1: spectroData.ch1,
8481
ch2: spectroData.ch2,
85-
ch3: spectroData.ch3
82+
ch3: spectroData.ch3,
83+
ch4: spectroData.ch4
8684
};
8785
});
8886
});

0 commit comments

Comments
 (0)