Skip to content

Commit b06e933

Browse files
committed
Fix TimeSeries output over LSL
1 parent c94e160 commit b06e933

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

Networking-Test-Kit/LSL/lslStreamTest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# create a new inlet to read from the stream
1111
inlet = StreamInlet(streams[0])
12-
duration = 5
12+
duration = 10
1313

1414
sleep(1)
1515

@@ -24,12 +24,13 @@ def testLSLSamplingRate():
2424
# get chunks of samples
2525
chunk, timestamp = inlet.pull_chunk()
2626
if chunk:
27+
print("\nNew chunk!")
2728
numChunks += 1
2829
# print( len(chunk) )
2930
totalNumSamples += len(chunk)
30-
# print(chunk);
31+
# print(chunk)
3132
for sample in chunk:
32-
# print(sample)
33+
print(sample)
3334
validSamples += 1
3435

3536
print( "Number of Chunks and Samples == {} , {}".format(numChunks, totalNumSamples) )

OpenBCI_GUI/W_Networking.pde

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ class W_Networking extends Widget {
957957
// Fix #644 - Remove confusing #Chan textfield from Networking Widget and
958958
// account for this here
959959
private int getDataTypeNumChanLSL(String dataType) {
960-
if (dataType.equals("TimeSeries")) {
960+
if (dataType.equals("TimeSeriesFilt") || dataType.equals("TimeSeriesRaw")) {
961961
return currentBoard.getNumEXGChannels();
962962
} else if (dataType.equals("Focus")) {
963963
return 1;
@@ -1383,15 +1383,17 @@ class Stream extends Thread {
13831383
}
13841384

13851385
} else if (this.protocol.equals("LSL")) {
1386-
1387-
for (int i = 0; i < newDataFromBuffer.length; i++) {
1388-
for (int j = 0; j < newDataFromBuffer[i].length; j++) {
1389-
dataToSend[j + numExgChannels * i] = newDataFromBuffer[i][j];
1386+
int numChannels = newDataFromBuffer.length;
1387+
int numSamples = newDataFromBuffer[0].length;
1388+
float[] _dataToSend = new float[numChannels * numSamples];
1389+
for (int sample = 0; sample < numSamples; sample++) {
1390+
for (int channel = 0; channel < numChannels; channel++) {
1391+
_dataToSend[channel + sample * numChannels] = newDataFromBuffer[channel][sample];
13901392
}
13911393
}
13921394
// From LSLLink Library: The time stamps of other samples are automatically
13931395
// derived based on the sampling rate of the stream.
1394-
outlet_data.push_chunk(dataToSend);
1396+
outlet_data.push_chunk(_dataToSend);
13951397

13961398
} else if (this.protocol.equals("Serial")) {
13971399

0 commit comments

Comments
 (0)