It's easy to read EmotiBit data.
After you parse the data using the EmotiBit DataParser
, each data stream will be in a separate file as described in Working with EmotiBit Data.
Playback of EmotiBit PPG:IR (PI) data with Processing
Here's an example dataset and Processing script that reads a data stream and plays it back in a graphical display. Simply change dataType
to any EmotiBit data TypeTag to playback each stream.
// Reads EmotiBit data from a parsed data file // Plots data in a window and let's you do anything you want with the data! // ------------ CHANGE DATA TYPE HERE --------------- // String dataType = "PI"; float frequency = 25; //in Hz (samples per second) String dataFilename = "2021-04-12_16-53-27-967617_" + dataType + ".csv"; // See additional info here: // https://github.com/EmotiBit/EmotiBit_Docs/blob/master/Working_with_emotibit_data.md // https://www.emotibit.com/ // https://www.kickstarter.com/projects/emotibit/930776266?ref=5syezv&token=7176d37c // --------------------------------------------------- // Table table; FloatList dataList = new FloatList(); int row = 0; // --------------------------------------------------- // void setup() { size(320, 240); table = loadTable(dataFilename, "header"); println(table.getRowCount() + " total rows in table"); } // --------------------------------------------------- // void draw() { float data = table.getRow(row).getFloat(dataType); // get the data from a row of the table dataList.append(data); // store data for plotting and autoscaling // visualize the data int alpha = int(255 * autoscale(data)); // autoscale data println("data: " + row + ", " + alpha + ", " + data); // print alpha in the console background(alpha, 0, 0); // change the background using alpha drawData(); row = row + 1; // Go to the next row in the table if (row >= table.getRowCount()) { row = 0; // start over at the beginning of the table } delay(int(1000/frequency)); // playback data at specific frequency } // --------------------------------------------------- // // Draw the data like an oscilloscope display void drawData() { stroke(255); while (dataList.size() > width) { dataList.remove(0); // Remove oldest item in list if larger than window } // Plot the data autoscaled to the height for (int n = 0; n < dataList.size() - 1; n++) { float y1 = height * autoscale(dataList.get(n)); float y2 = height * autoscale(dataList.get(n+1)); line(n, height - y1, n+1, height - y2); } } // --------------------------------------------------- // // Outputs data value normalized to 0.0 to 1.0 float autoscale(float data) { if (dataList.size() > 0) { float minData = dataList.min(); float maxData = dataList.max(); return (data - minData) / (maxData - minData); // autoscale the data } else { return 0; } }
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article