#include <assert.h>
#include <openedf.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <pctimer.h>
#include <ctype.h>
#include <nsutil.h>
#include <nsnet.h>
Go to the source code of this file.
Data Structures | |
struct | Options |
Command line options will be decoded into this structure. More... | |
Defines | |
#define | MINLINELENGTH 4 |
#define | DELIMS " \r\n" |
Functions | |
void | resetSampleBuffer () |
reset frame counter | |
void | writeSampleBuffer (unsigned int Channel, unsigned int SampleNr, char Byte0, char Byte1, char Byte2) |
writes sample data into data buffer in the right order | |
void | initSampleBuffer () |
allocates memory for data buffer | |
void | writeBufferToFile () |
writes data chunk to file | |
void | handleSamples (int packetCounter, int channels) |
copy data to sample buffer, write buffer to file if it is full | |
int | isANumber (const char *str) |
check, if data is a number | |
void | serverDied (void) |
action to take if server died | |
int | main (int argc, char **argv) |
Variables | |
const char * | helpText |
Program to save data from the neuroserver in a file. | |
EDFDecodedConfig | cfg |
EDF header information block. | |
InputBuffer | ib |
network input buffer | |
char | lineBuf [MAXLEN] |
buffer for ASCII data frames | |
int | blockCounter = 0 |
number of data blocks written | |
char * | dataarray |
pointer for data block | |
long | samples [MAXCHANNELS] |
channel sample data | |
size_t | sampleSize |
amount of memory for one sample (16 or 24 bits) | |
unsigned int | frameCount |
counter for received data frames | |
Options | opts |
place to store command line options |
|
Definition at line 71 of file writebdf.c. |
|
Definition at line 70 of file writebdf.c. |
|
copy data to sample buffer, write buffer to file if it is full
Definition at line 158 of file writebdf.c. References cfg, EDFDecodedConfig::chan, frameCount, Options::isBdf, opts, rprintf(), EDFDecodedChannelHeader::sampleCount, samples, writeBufferToFile(), and writeSampleBuffer(). |
|
allocates memory for data buffer < get 3 bytes/sample (BDF Standard) < get 2 bytes/sample (EDF Standard) < allocate one big array of bytes Definition at line 124 of file writebdf.c. References cfg, EDFDecodedConfig::chan, dataarray, EDFDecodedHeader::dataRecordChannels, EDFDecodedConfig::hdr, Options::isBdf, opts, resetSampleBuffer(), EDFDecodedChannelHeader::sampleCount, and sampleSize. Referenced by main(). |
|
check, if data is a number
Definition at line 200 of file writebdf.c. |
|
check filename open file start networking configure neuroserver connection now decode EDF header check for 24bit BDF data format write header to data file (if not in CSV mode) data0 data1 data2 ... Definition at line 218 of file writebdf.c. References cfg, cur, EDFDecodedHeader::dataFormat, DEFAULTHOST, DEFAULTPORT, DELIMS, EDFPacket, Options::eegNum, Options::filename, getOK(), handleSamples(), EDFDecodedConfig::hdr, EDFDecodedHeader::headerRecordBytes, helpText, Options::hostname, ib, initSampleBuffer(), isANumber(), Options::isArray, Options::isBdf, isEOF(), Options::isFilenameSet, Options::isLimittedTime, lineBuf, linePos, MAXHEADERLEN, MINLINELENGTH, ob, opts, pctimer(), Options::port, rconnectName(), readEDFString(), readline(), rexit(), rinitNetworking(), rprintf(), rselect(), rsocket(), samples, Options::seconds, serverDied(), sock_fd, sock_t, and writeString(). |
|
reset frame counter
Definition at line 103 of file writebdf.c. References frameCount. Referenced by initSampleBuffer(), and writeBufferToFile(). |
|
action to take if server died
Definition at line 210 of file writebdf.c. References rprintf(). |
|
writes data chunk to file goto end of file block write sample data Definition at line 139 of file writebdf.c. References blockCounter, cfg, dataarray, EDFDecodedHeader::dataRecordChannels, Options::filename, frameCount, EDFDecodedConfig::hdr, opts, resetSampleBuffer(), rprintf(), and sampleSize. Referenced by handleSamples(). |
|
writes sample data into data buffer in the right order
Definition at line 110 of file writebdf.c. References cfg, EDFDecodedConfig::chan, dataarray, Options::isBdf, opts, EDFDecodedChannelHeader::sampleCount, and sampleSize. Referenced by handleSamples(). |
|
number of data blocks written
Definition at line 92 of file writebdf.c. Referenced by writeBuffers(), and writeBufferToFile(). |
|
EDF header information block.
Definition at line 88 of file writebdf.c. Referenced by EDFEncodePacket(), getDataRecordChunkSize(), getSamplesPerSecond(), getSecondsPerSample(), handleSamples(), initSampleBuffer(), initSampleBuffers(), isValidREDF(), main(), newEDFInputIterator(), readEDF(), readEDFString(), setEDFHeaderBytes(), writeBuffers(), writeBufferToFile(), writeEDF(), writeEDFString(), and writeSampleBuffer(). |
|
pointer for data block
Definition at line 94 of file writebdf.c. Referenced by initSampleBuffer(), writeBufferToFile(), and writeSampleBuffer(). |
|
counter for received data frames
Definition at line 98 of file writebdf.c. Referenced by handleSamples(), resetSampleBuffer(), and writeBufferToFile(). |
|
Initial value: "writeedf v 0.35 by Rudi Cilibrasi, Moritz von Buttlar\n" "\n" "Usage: writeedf [options] <filename>\n" "\n" " -p port Port number to use (default 8336)\n" " -n hostname Host name of the NeuroCaster server to connect to\n" " (this defaults to 'localhost')\n" " -s <num> Only record this many seconds.\n" " (default is to record until interrupted)\n" " -e <intnum> Integer ID specifying which EEG to log (default: 0)\n" " -b use bdf format (same as edf, only 24 bits/sample) \n" " -c write as CSV array (can be imported to Excel, Scilab,etc.)" "The filename specifies the new EDF file to create.\n"
The program writes data blockwise: it opens the file, writes one data record, then closes the file (in the write_buffers function) Definition at line 54 of file writebdf.c. |
|
network input buffer
Definition at line 90 of file writebdf.c. |
|
buffer for ASCII data frames
Definition at line 91 of file writebdf.c. |
|
place to store command line options
Definition at line 99 of file writebdf.c. |
|
channel sample data
Definition at line 95 of file writebdf.c. Referenced by cmdDataFrame(), doesMatchP3(), fetchSamples(), handleSamples(), idleHandler(), isValidPacket(), and main(). |
|
amount of memory for one sample (16 or 24 bits)
Definition at line 97 of file writebdf.c. Referenced by initSampleBuffer(), writeBufferToFile(), and writeSampleBuffer(). |