Skip to content

Commit eff2079

Browse files
author
AJ Keller
authored
Merge pull request #159 from OpenBCI/development
Development
2 parents 7e8542b + c3fe433 commit eff2079

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2089
-922
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ OpenBCI_GUI/temp.txt
66
OpenBCI_GUI/t-temp.txt
77
OpenBCI_GUI/build/source/*.java
88
*.app
9+
OpenBCI_GUI/data/EEG_Data/*

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 2.2.0
2+
3+
### Bug Fixes
4+
* Fix #151 - Incorrect number of channels on playback caused index out of bounds errors.
5+
* Addresses #149 - Allows for proper scaling of channels with four thanks to #151 #157
6+
7+
### New Features
8+
* Band power widget #153 (thanks @sunwangshu)
9+
* Closes #138 - Able to drag and drop the electrodes on the head map (thanks @liqwid)
10+
111
# 2.1.2
212

313
### Bug Fixes

Icon

Whitespace-only changes.

OpenBCI_GUI/ControlPanel.pde

Lines changed: 100 additions & 423 deletions
Large diffs are not rendered by default.

OpenBCI_GUI/DataLogging.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,4 +1475,4 @@ public void convertSDFile() {
14751475
dataWriter.println();
14761476
}
14771477
}
1478-
}
1478+
}

OpenBCI_GUI/DataProcessing.pde

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ HashMap<String,float[][]> processed_file;
1111
HashMap<Integer,String> index_of_times;
1212
HashMap<String,Integer> index_of_times_rev;
1313

14+
// indexs
15+
final int DELTA = 0; // 1-4 Hz
16+
final int THETA = 1; // 4-8 Hz
17+
final int ALPHA = 2; // 8-13 Hz
18+
final int BETA = 3; // 13-30 Hz
19+
final int GAMMA = 4; // 30-55 Hz
20+
21+
1422
//------------------------------------------------------------------------
1523
// Global Functions
1624
//------------------------------------------------------------------------
@@ -109,6 +117,8 @@ int getDataIfAvailable(int pointCounter) {
109117
//if (eegDataSource==DATASOURCE_PLAYBACKFILE) println("OpenBCI_GUI: getDataIfAvailable: currentTableRowIndex = " + currentTableRowIndex);
110118
//println("OpenBCI_GUI: getDataIfAvailable: pointCounter = " + pointCounter);
111119
} // close "has enough time passed"
120+
else{
121+
}
112122
}
113123
return pointCounter;
114124
}
@@ -154,6 +164,7 @@ void processNewData() {
154164
// w_openbionics.process();
155165

156166
dataProcessing_user.process(yLittleBuff_uV, dataBuffY_uV, dataBuffY_filtY_uV, fftBuff);
167+
dataProcessing.newDataToSend = true;
157168

158169
//look to see if the latest data is railed so that we can notify the user on the GUI
159170
for (int Ichan=0; Ichan < nchan; Ichan++) is_railed[Ichan].update(dataPacketBuff[lastReadDataPacketInd].values[Ichan]);
@@ -330,12 +341,14 @@ int getPlaybackDataFromTable(Table datatable, int currentTableRowIndex, float sc
330341

331342
if(!isRunning){
332343
try{
333-
if(!isOldData) row.getString(nchan+4);
334-
else row.getString(nchan+3);
344+
row.getString(nchan+3);
335345

336-
nchan = 16;
346+
// nchan = 16; AJK 5/31/17 see issue #151
347+
}
348+
catch (ArrayIndexOutOfBoundsException e){
349+
println(e);
350+
println("8 Channel");
337351
}
338-
catch (ArrayIndexOutOfBoundsException e){ println("8 Channel");}
339352
}
340353

341354
}
@@ -357,14 +370,26 @@ class DataProcessing {
357370
private int currentNotch_ind = 0; // set to 0 to default to 60Hz, set to 1 to default to 50Hz
358371
float data_std_uV[];
359372
float polarity[];
360-
373+
boolean newDataToSend;
374+
private String[] binNames;
375+
final int[] processing_band_low_Hz = {
376+
1, 4, 8, 13, 30
377+
}; //lower bound for each frequency band of interest (2D classifier only)
378+
final int[] processing_band_high_Hz = {
379+
4, 8, 13, 30, 55
380+
}; //upper bound for each frequency band of interest
381+
float avgPowerInBins[][];
382+
float headWidePower[];
383+
int numBins;
361384

362385
DataProcessing(int NCHAN, float sample_rate_Hz) {
363386
nchan = NCHAN;
364387
fs_Hz = sample_rate_Hz;
365388
data_std_uV = new float[nchan];
366389
polarity = new float[nchan];
367-
390+
newDataToSend = false;
391+
avgPowerInBins = new float[nchan][processing_band_low_Hz.length];
392+
headWidePower = new float[processing_band_low_Hz.length];
368393

369394
//check to make sure the sample rate is acceptable and then define the filters
370395
if (abs(fs_Hz-250.0f) < 1.0) {
@@ -675,8 +700,25 @@ class DataProcessing {
675700
}
676701
fftBuff[Ichan].setBand(I, (float)foo); //put the smoothed data back into the fftBuff data holder for use by everyone else
677702
} //end loop over FFT bins
703+
for (int i = 0; i < processing_band_low_Hz.length; i++) {
704+
float sum = 0;
705+
for (int j = processing_band_low_Hz[i]; j < processing_band_high_Hz[i]; j++) {
706+
sum += fftBuff[Ichan].getBand(j);
707+
}
708+
avgPowerInBins[Ichan][i] = sum;
709+
}
678710
} //end the loop over channels.
711+
for (int i = 0; i < processing_band_low_Hz.length; i++) {
712+
float sum = 0;
713+
714+
for (int j = 0; j < nchan; j++) {
715+
sum += avgPowerInBins[j][i];
716+
}
717+
headWidePower[i] = sum/nchan;
718+
}
679719

720+
//delta in channel 2 ... avgPowerInBins[1][DELTA];
721+
//headwide beta ... headWidePower[BETA];
680722

681723
//find strongest channel
682724
int refChanInd = findMax(data_std_uV);
@@ -696,5 +738,12 @@ class DataProcessing {
696738
polarity[Ichan]=-1.0;
697739
}
698740
}
741+
742+
// println("Brain Wide DELTA = " + headWidePower[DELTA]);
743+
// println("Brain Wide THETA = " + headWidePower[THETA]);
744+
// println("Brain Wide ALPHA = " + headWidePower[ALPHA]);
745+
// println("Brain Wide BETA = " + headWidePower[BETA]);
746+
// println("Brain Wide GAMMA = " + headWidePower[GAMMA]);
747+
699748
}
700749
}

OpenBCI_GUI/HardwareSync.pde

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ void serialEvent(Serial port){
9898
numPacketsDropped = 0;
9999
}
100100

101-
//If networking enabled --> send data every sample if 8 channels or every other sample if 16 channels
102-
if (networkType !=0) {
103-
if (nchan==8) {
104-
sendRawData_dataPacket(dataPacketBuff[curDataPacketInd], openBCI.get_scale_fac_uVolts_per_count(), openBCI.get_scale_fac_accel_G_per_count());
105-
} else if ((nchan==16) && ((dataPacketBuff[curDataPacketInd].sampleIndex %2)!=1)) {
106-
sendRawData_dataPacket(dataPacketBuff[curDataPacketInd], openBCI.get_scale_fac_uVolts_per_count(), openBCI.get_scale_fac_accel_G_per_count());
107-
}
108-
}
109101
switch (outputDataSource) {
110102
case OUTPUT_SOURCE_ODF:
111103
fileoutput_odf.writeRawData_dataPacket(dataPacketBuff[curDataPacketInd], openBCI.get_scale_fac_uVolts_per_count(), openBCI.get_scale_fac_accel_G_per_count());

OpenBCI_GUI/Interactivity.pde

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void parseKey(char val) {
236236
case 's':
237237
println("case s...");
238238
stopRunning();
239+
239240
// stopButtonWasPressed();
240241
break;
241242
case 'b':
@@ -443,7 +444,16 @@ void parseKeycode(int val) {
443444
}
444445
}
445446

447+
void mouseDragged() {
448+
449+
if (systemMode >= SYSTEMMODE_POSTINIT) {
446450

451+
//calling mouse dragged inly outside of Control Panel
452+
if (controlPanel.isOpen == false) {
453+
wm.mouseDragged();
454+
}
455+
}
456+
}
447457
//swtich yard if a click is detected
448458
void mousePressed() {
449459

0 commit comments

Comments
 (0)