This program was written in response to a need to convert numerous CSV files into EDF. EDFbrowser, an excellent program written by Teunis van Beelen, can do CSV->EDF conversion, but only via a graphical interface, making bulk conversions time-consuming. I adapted some of the EDFbrowser code to permit this conversion from the command line.
ascii2edf <csv_file> <template_file> <subject_name> <recording_name> <year> <month> <day> <hour> <minute> <second> <outputfilename>
The template file provides the information necessary to convert the columns of csv files into corresponding EDF channels. This template file is the same format that EDFbrowser uses for its ASCII->EDF conversions, though the file can be made independently of EDFbrowser if desired. The format is a fairly simple XML file. Here is an example:
<?xml version="1.0"?> <EDFbrowser_ascii2edf_template> <separator>tab</separator> <!-- either 'tab' or any single character --> <columns>8</columns> <!-- total number of columns in the CSV file --> <startline>2</startline> <!-- how many initial header lines to skip --> <samplefrequency>20.0000000000</samplefrequency> <autophysicalmaximum>1</autophysicalmaximum> <!-- automatically detect maxima? --> <edf_format>1</edf_format> <!-- EDF = 1, BDF = 0 --> <signalparams> <checked>1</checked> <!-- 1 = convert, 0 = ignore this column --> <label>Heartrate</label> <physical_maximum></physical_maximum> <physical_dimension>bpm</physical_dimension> <multiplier>1.000000</multiplier> </signalparams> <signalparams> <checked>1</checked> <label>Flow</label> <physical_maximum></physical_maximum> <physical_dimension>LPM</physical_dimension> <multiplier>1.000000</multiplier> </signalparams> <!-- ... Add more as needed ... --> </EDFbrowser_ascii2edf_template>