You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: openBCIUtilities.js
+52-10Lines changed: 52 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,7 @@ let utilitiesModule = {
141
141
},
142
142
transformRawDataPacketToSample,
143
143
transformRawDataPacketsToSample,
144
+
convertGanglionArrayToBuffer,
144
145
getRawPacketType,
145
146
getFromTimePacketAccel,
146
147
getFromTimePacketTime,
@@ -382,6 +383,7 @@ let utilitiesModule = {
382
383
}
383
384
},
384
385
newSample,
386
+
newSampleNoScale,
385
387
/**
386
388
* @description Create a configurable function to return samples for a simulator. This implements 1/f filtering injection to create more brain like data.
387
389
* @param numberOfChannels {Number} - The number of channels in the sample... either 8 or 16
@@ -1041,6 +1043,18 @@ function transformRawDataPacketToSample (o) {
1041
1043
returnsample;
1042
1044
}
1043
1045
1046
+
/**
1047
+
* Used to convert a ganglions decompressed back into a buffer
1048
+
* @param arr {Array} - An array of four numbers
1049
+
* @param data {Buffer} - A buffer to store into
1050
+
*/
1051
+
functionconvertGanglionArrayToBuffer(arr,data){
1052
+
for(leti=0;i<k.OBCINumberOfChannelsGanglion;i++){
1053
+
data.writeInt16BE(arr[i]>>8,(i*3));
1054
+
data.writeInt8(arr[i]&255,(i*3)+2);
1055
+
}
1056
+
}
1057
+
1044
1058
/**
1045
1059
* @description This function takes a raw data buffer of 4 3-byte signed integers for ganglion
1046
1060
* @param o {Object} - The input object
@@ -1643,6 +1657,26 @@ function newSample (sampleNumber) {
1643
1657
};
1644
1658
}
1645
1659
1660
+
functionnewSampleNoScale(sampleNumber){
1661
+
if(sampleNumber||sampleNumber===0){
1662
+
if(sampleNumber>255){
1663
+
sampleNumber=255;
1664
+
}
1665
+
}else{
1666
+
sampleNumber=0;
1667
+
}
1668
+
return{
1669
+
startByte: k.OBCIByteStart,
1670
+
sampleNumber: sampleNumber,
1671
+
channelDataCounts: [],
1672
+
accelDataCounts: [],
1673
+
auxData: null,
1674
+
stopByte: k.OBCIByteStop,
1675
+
boardTime: 0,
1676
+
timestamp: 0
1677
+
};
1678
+
}
1679
+
1646
1680
/**
1647
1681
* @description Convert float number into three byte buffer. This is the opposite of .interpret24bitAsInt32()
1648
1682
* @param float - The number you want to convert
@@ -1705,34 +1739,42 @@ function makeDaisySampleObject (lowerSampleObject, upperSampleObject) {
expect(bufferEqual(rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw),data),`expected ${data.toString('hex')} but got ${rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw).toString('hex')}`).to.be.true();
0 commit comments