fixed pipes
Esse commit está contido em:
@@ -59,7 +59,7 @@ export function PageSwitcher() {
|
||||
const [status, setStatus] = useState(generalTranslations.connect);
|
||||
|
||||
// for picking a new module
|
||||
const [selected, setSelected] = useState(intro);
|
||||
const [selected, setSelected] = useState(heartSpectra);
|
||||
const handleSelectChange = useCallback(value => {
|
||||
setSelected(value);
|
||||
|
||||
|
||||
@@ -31,19 +31,19 @@ export function getSettings () {
|
||||
interval: 50,
|
||||
srate: 256,
|
||||
duration: 1024,
|
||||
name: 'Raw'
|
||||
name: 'HeartRaw'
|
||||
}
|
||||
};
|
||||
|
||||
export function buildPipe(Settings) {
|
||||
if (window.subscriptionRaw) window.subscriptionRaw.unsubscribe();
|
||||
if (window.subscriptionHeartRaw) window.subscriptionHeartRaw.unsubscribe();
|
||||
|
||||
window.pipeRaw$ = null;
|
||||
window.multicastRaw$ = null;
|
||||
window.subscriptionRaw = null;
|
||||
window.pipeHeartRaw$ = null;
|
||||
window.multicastHeartRaw$ = null;
|
||||
window.subscriptionHeartRaw = null;
|
||||
|
||||
// Build Pipe
|
||||
window.pipeRaw$ = zipSamples(window.source.eegReadings$).pipe(
|
||||
window.pipeHeartRaw$ = zipSamples(window.source.eegReadings$).pipe(
|
||||
bandpassFilter({
|
||||
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
|
||||
nbChannels: Settings.nbChannels }),
|
||||
@@ -56,7 +56,7 @@ export function buildPipe(Settings) {
|
||||
console.log(err);
|
||||
})
|
||||
);
|
||||
window.multicastRaw$ = window.pipeRaw$.pipe(
|
||||
window.multicastHeartRaw$ = window.pipeHeartRaw$.pipe(
|
||||
multicast(() => new Subject())
|
||||
);
|
||||
}
|
||||
@@ -64,10 +64,10 @@ export function buildPipe(Settings) {
|
||||
export function setup(setData, Settings) {
|
||||
console.log("Subscribing to " + Settings.name);
|
||||
|
||||
if (window.multicastRaw$) {
|
||||
window.subscriptionRaw = window.multicastRaw$.subscribe(data => {
|
||||
setData(rawData => {
|
||||
Object.values(rawData).forEach((channel, index) => {
|
||||
if (window.multicastHeartRaw$) {
|
||||
window.subscriptionHeartRaw = window.multicastHeartRaw$.subscribe(data => {
|
||||
setData(heartRawData => {
|
||||
Object.values(heartRawData).forEach((channel, index) => {
|
||||
if (index < 4) {
|
||||
channel.datasets[0].data = data.data[index];
|
||||
channel.xLabels = generateXTics(Settings.srate, Settings.duration);
|
||||
@@ -76,16 +76,16 @@ export function setup(setData, Settings) {
|
||||
});
|
||||
|
||||
return {
|
||||
ch0: rawData.ch0,
|
||||
ch1: rawData.ch1,
|
||||
ch2: rawData.ch2,
|
||||
ch3: rawData.ch3
|
||||
ch0: heartRawData.ch0,
|
||||
ch1: heartRawData.ch1,
|
||||
ch2: heartRawData.ch2,
|
||||
ch3: heartRawData.ch3
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
window.multicastRaw$.connect();
|
||||
console.log("Subscribed to Raw");
|
||||
window.multicastHeartRaw$.connect();
|
||||
console.log("Subscribed to HeartRaw");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export function renderModule(channels) {
|
||||
},
|
||||
elements: {
|
||||
line: {
|
||||
borderColor: 'rgba(' + channel.datasets[0].qual*10 + ', 128, 128)',
|
||||
borderColor: 'rgba(' + channel.datasets[0].qual + ', 128, 128)',
|
||||
fill: false
|
||||
},
|
||||
point: {
|
||||
@@ -134,11 +134,15 @@ export function renderModule(channels) {
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card.Section key={"Card_" + index}>
|
||||
<Line key={"Line_" + index} data={channel} options={options} />
|
||||
</Card.Section>
|
||||
);
|
||||
if (index === 1) {
|
||||
return (
|
||||
<Card.Section key={"Card_" + index}>
|
||||
<Line key={"Line_" + index} data={channel} options={options} />
|
||||
</Card.Section>
|
||||
);
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -224,7 +228,7 @@ export function renderRecord(recordPopChange, recordPop, status, Settings) {
|
||||
<Card title={'Record ' + Settings.name + ' Data'} sectioned>
|
||||
<Card.Section>
|
||||
<p>
|
||||
{"When you are recording raw data it is recommended you set the "}
|
||||
{"When you are recording HeartRaw data it is recommended you set the "}
|
||||
{"number of sampling points between epochs onsets to be equal to the epoch duration. "}
|
||||
{"This will ensure that consecutive rows of your output file are not overlapping in time."}
|
||||
{"It will make the live plots appear more choppy."}
|
||||
@@ -277,7 +281,7 @@ function saveToCSV(Settings) {
|
||||
|
||||
// for each module subscribe to multicast and make header
|
||||
// take one sample from selected observable object for headers
|
||||
localObservable$ = window.multicastRaw$.pipe(
|
||||
localObservable$ = window.multicastHeartRaw$.pipe(
|
||||
take(1)
|
||||
);
|
||||
//take one sample to get header info
|
||||
@@ -296,7 +300,7 @@ function saveToCSV(Settings) {
|
||||
}
|
||||
});
|
||||
// put selected observable object into local and start taking samples
|
||||
localObservable$ = window.multicastRaw$.pipe(
|
||||
localObservable$ = window.multicastHeartRaw$.pipe(
|
||||
take(numSamplesToSave)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "Heart Rate (Electrocardiogram)",
|
||||
"title": "Electrocardiogram (Heart Beats)",
|
||||
"description": [
|
||||
"As a first introduction to measurement of electrical potentials from the body we will look at something accessible. ",
|
||||
"As the heart beats and pumps blood throuhgouts our body, a series of electrical potentials are created, which can be measured using electrodes placed around the heart. ",
|
||||
|
||||
@@ -25,29 +25,29 @@ import * as specificTranslations from "./translations/en";
|
||||
|
||||
export function getSettings() {
|
||||
return {
|
||||
cutOffLow: 2,
|
||||
cutOffLow: .01,
|
||||
cutOffHigh: 20,
|
||||
nbChannels: 4,
|
||||
interval: 100,
|
||||
bins: 256,
|
||||
sliceFFTLow: 1,
|
||||
sliceFFTHigh: 30,
|
||||
duration: 1024,
|
||||
bins: 2048,
|
||||
sliceFFTLow: 0.5,
|
||||
sliceFFTHigh: 3,
|
||||
duration: 2048,
|
||||
srate: 256,
|
||||
name: 'Spectra'
|
||||
name: 'HeartSpectra'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export function buildPipe(Settings) {
|
||||
if (window.subscriptionSpectra) window.subscriptionSpectra.unsubscribe();
|
||||
if (window.subscriptionHeartHeartSpectra) window.subscriptionHeartSpectra.unsubscribe();
|
||||
|
||||
window.pipeSpectra$ = null;
|
||||
window.multicastSpectra$ = null;
|
||||
window.subscriptionSpectra = null;
|
||||
window.pipeHeartSpectra$ = null;
|
||||
window.multicastHeartSpectra$ = null;
|
||||
window.subscriptionHeartSpectra = null;
|
||||
|
||||
// Build Pipe
|
||||
window.pipeSpectra$ = zipSamples(window.source.eegReadings$).pipe(
|
||||
window.pipeHeartSpectra$ = zipSamples(window.source.eegReadings$).pipe(
|
||||
bandpassFilter({
|
||||
cutoffFrequencies: [Settings.cutOffLow, Settings.cutOffHigh],
|
||||
nbChannels: Settings.nbChannels }),
|
||||
@@ -63,7 +63,7 @@ export function buildPipe(Settings) {
|
||||
})
|
||||
);
|
||||
|
||||
window.multicastSpectra$ = window.pipeSpectra$.pipe(
|
||||
window.multicastHeartSpectra$ = window.pipeHeartSpectra$.pipe(
|
||||
multicast(() => new Subject())
|
||||
);
|
||||
}
|
||||
@@ -71,26 +71,26 @@ export function buildPipe(Settings) {
|
||||
export function setup(setData, Settings) {
|
||||
console.log("Subscribing to " + Settings.name);
|
||||
|
||||
if (window.multicastSpectra$) {
|
||||
window.subscriptionSpectra = window.multicastSpectra$.subscribe(data => {
|
||||
setData(spectraData => {
|
||||
Object.values(spectraData).forEach((channel, index) => {
|
||||
if (window.multicastHeartSpectra$) {
|
||||
window.subscriptionHeartSpectra = window.multicastHeartSpectra$.subscribe(data => {
|
||||
setData(heartSpectraData => {
|
||||
Object.values(heartSpectraData).forEach((channel, index) => {
|
||||
if (index < 4) {
|
||||
channel.datasets[0].data = data.psd[index];
|
||||
channel.xLabels = data.freqs;
|
||||
channel.xLabels = data.freqs.map(function(x) {return x * 60});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
ch0: spectraData.ch0,
|
||||
ch1: spectraData.ch1,
|
||||
ch2: spectraData.ch2,
|
||||
ch3: spectraData.ch3
|
||||
ch0: heartSpectraData.ch0,
|
||||
ch1: heartSpectraData.ch1,
|
||||
ch2: heartSpectraData.ch2,
|
||||
ch3: heartSpectraData.ch3
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
window.multicastSpectra$.connect();
|
||||
window.multicastHeartSpectra$.connect();
|
||||
console.log("Subscribed to " + Settings.name);
|
||||
}
|
||||
}
|
||||
@@ -133,11 +133,15 @@ export function renderModule(channels) {
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card.Section key={"Card_" + index}>
|
||||
<Line key={"Line_" + index} data={channel} options={options} />
|
||||
</Card.Section>
|
||||
);
|
||||
if (index === 1) {
|
||||
return (
|
||||
<Card.Section key={"Card_" + index}>
|
||||
<Line key={"Line_" + index} data={channel} options={options} />
|
||||
</Card.Section>
|
||||
);
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -289,7 +293,7 @@ function saveToCSV(Settings) {
|
||||
console.log('making ' + Settings.name + ' headers')
|
||||
|
||||
// take one sample from selected observable object for headers
|
||||
localObservable$ = window.multicastSpectra$.pipe(
|
||||
localObservable$ = window.multicastHeartSpectra$.pipe(
|
||||
take(1)
|
||||
);
|
||||
|
||||
@@ -310,7 +314,7 @@ function saveToCSV(Settings) {
|
||||
}
|
||||
});
|
||||
// put selected observable object into local and start taking samples
|
||||
localObservable$ = window.multicastSpectra$.pipe(
|
||||
localObservable$ = window.multicastHeartSpectra$.pipe(
|
||||
take(numSamplesToSave)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "Heart Rate (Electrocardiogram)",
|
||||
"title": "Heart Rate (Beats per minute)",
|
||||
"description": [
|
||||
"Now we look at the same data, but in a different way. Instead of looking at the voltage over time, ",
|
||||
"We now transform the data to show us what frequencies are present in the continuous signal. ",
|
||||
@@ -8,6 +8,6 @@
|
||||
"Along the horizontal axis is the beats per minute, or the frequency of the peaks in your ECG. ",
|
||||
"The vertical y-axis shows the power of the rhythms in the data at each frequency, or how large the changes are between peak and through of the oscillations. "
|
||||
],
|
||||
"xlabel": "Time (msec)",
|
||||
"ylabel": "Voltage (\u03BCV)"
|
||||
"xlabel": "Frequency (Hz)",
|
||||
"ylabel": "Power (\u03BCV\u00B2)"
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário