1234567891011121314151617181920212223242526272829 |
- """
- Generate minimal EDF+C file.
- See also pyedflib and format specifications
- https://github.com/holgern/pyedflib
- https://www.edfplus.info/
- Author: Julia Sprenger
- """
- from pyedflib import highlevel
- import numpy as np
- # write an edf file with 5 channels á 265 samples (1 second)
- signals = np.random.rand(5, 256) * 200
- channel_names = ['ch1', 'ch2', 'ch3', 'ch4', 'ch5']
- dimensions = ['mV', 'uV', 'pA', 'dimensionless', 'C']
- transducer = ['unknown', 'A', 'B', '', 'Z']
- prefilter = ['true', 'false', 'false', 'true', 'true']
- signal_headers = highlevel.make_signal_headers(list_of_labels=channel_names, sample_rate=256)
- for i in range(len(signal_headers)):
- signal_headers[i]['dimension'] = dimensions[i]
- signal_headers[i]['transducer'] = transducer[i]
- signal_headers[i]['prefilter'] = prefilter[i]
- header = highlevel.make_header(patientname='patient_x', gender='Female')
- highlevel.write_edf('edf+C.edf', signals, signal_headers, header)
- # export plain signal also as txt file (transposed for compatiblity with AnalogSignal)
- np.savetxt('edf+C.txt', signals.T)
|