@@ -11,6 +11,14 @@ HashMap<String,float[][]> processed_file;
1111HashMap<Integer ,String > index_of_times;
1212HashMap<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}
0 commit comments