http://code.google.com/p/tempo/
The EDF file reader in Tempo is simpler than BioSig Library. After looking through the sample data ("sample.edf" http://code.google.com/p/tempo/source/browse/#hg%2Fdata) and the EDF reader codes "Input.cpp"http://code.google.com/p/tempo/source/b ... 423da2d763
I wonder if it is possible to write a OpenVIBE Reader that can read the binary "sample.edf".
Here are the supporting argument for the effort
(1)
There are many publications that uses Tempo to generate figures. To do that, the authors must have prepared many EDF files compatible with the Tempo. If there is a OpenVIBE EDF reader compatible with that of Tempo, the same files can be used to generate many more interesting diagrams offered by OpenVIBE.
(2)
Currently, the Research Edition and above of Emotiv allows saving of raw EEG data in EDF format for playback and distribution. I can not say right now how compatible is the Emotiv EDF format until further testing. Having an OpenVIBE EDF reader that is also compatible with the Emotiv EDF file format will motivate more users to combine Emotiv headset and OpenVIBE for BCI research.
I would like to hear from others if the simplified EDF format used in Tempo is a good starting point to prepare OpenVIBE towards having a EDF file reader eventually.
Below is an extract from the Input.cpp file that read the sample.edf.
Questions:
based on the available readers in OpenVIBE, which of them is more "Compatible" as a template to evaluate the feasibility to incorporate the code below into a OpenVIBE Edf reader.
Thanks.
(FYI, I have downloaded 0.9 openVIBE source, it is straight forwards to generate VS2008 projects and compile, good work).
Code: Select all
/* Open file with sampled values. */
std::ifstream stream(name.c_str(), std::ios::binary);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
char buffer[81];
int i, j;
/* Read and check version string. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
if (buffer != VERSION)
throw Exception(Exception::INVALID_INPUT_FILE);
/* Read patient information. */
stream.read(buffer, 80);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[80] = 0;
for (i = 79; i >= 0 && buffer[i] == ' '; i--)
buffer[i] = 0;
patient = buffer;
/* Read recording information. */
stream.read(buffer, 80);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[80] = 0;
for (i = 79; i >= 0 && buffer[i] == ' '; i--)
buffer[i] = 0;
recording = buffer;
/* Read start date of recording. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
for (i = 7; i >= 0 && buffer[i] == ' '; i--)
buffer[i] = 0;
std::istringstream date(buffer);
date >> day;
date.get();
date >> month;
date.get();
date >> year;
if (!date)
throw Exception(Exception::INVALID_INPUT_FILE);
/* Read start time of recording. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
for (i = 7; i >= 0 && buffer[i] == ' '; i--)
buffer[i] = 0;
std::istringstream time(buffer);
time >> hour;
time.get();
time >> minute;
time.get();
time >> second;
if (!time)
throw Exception(Exception::INVALID_INPUT_FILE);
/* Read number of bytes in input file header. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
offset = std::atoi(buffer);
/* Read first reserved block. */
stream.read(buffer, 44);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
/* Read number of data records. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
data = std::atoi(buffer);
/* Read data record duration. */
stream.read(buffer, 8);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[8] = 0;
duration = std::atoi(buffer);
/* Read number of signals in input file. */
stream.read(buffer, 4);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[4] = 0;
count = std::atoi(buffer);
/* Create signal objects. */
for (i = 0; i < count; i++) {
/* Read signal label. */
stream.read(buffer, 16);
if (!stream)
throw Exception(Exception::INVALID_INPUT_FILE);
buffer[16] = 0;
for (j = 15; j >= 0 && buffer[j] == ' '; j--)
buffer[j] = 0;
const std::vector<std::string> &names = sensors.getNames();
const std::vector<Vector> &positions = sensors.getPositions();
/* Compare signal label with all known sensor
names... */
for (j = 0; j < (int) names.size(); j++)
/* ...and if match found, create signal object
and read signal information from file, then
remember signal object and position of
corresponding sensor. */
if (names[j] == buffer) {
signals.push_back(Signal(name, i));
points.push_back(positions[j]);
break;
}
}