EDFtk

EDFtk (short for EDF Toolkit) is a commandline tool for manipulating EDF and BDF files (European Data Format).
It can:

Manual


Linux 64-bit

Source code

      https://gitlab.com/Teuniz/edftk/

Examples

List (print) the header:


  edftk 1.edf list
  filetype: EDF+
  signals: 8
  file duration: 0:00:30
  startdate: 1-1-2000
  starttime: 0:00:30.757
  patientcode:
  sex:
  birthdate:
  patient_name: X
  patient_additional:
  admincode:
  technician:
  equipment:
  recording_additional:
  datarecord duration: 1 second
  number of datarecords: 30
  number of annotations: 2
  number of annotation channels: 1
  +-----+------------------+--------------+------------+----------+----------+----------+----------+-----------+------------+------------+
  |  #  |     label        |  samplerate  | smpls per  | digital  | digital  | physical | physical | physical  | resolution | smpls in   |
  |     |                  |              | datarecord | maximum  | minimum  | maximum  | minimum  | dimension |            | file       |
  +-----+------------------+--------------+------------+----------+----------+----------+----------+-----------+------------+------------+
  |   1 | sine 0.62Hz      |1579          |       1579 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      47370 |
  |   2 | sine 1.25Hz      |1999          |       1999 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      59970 |
  |   3 | sine 1.25Hz      |1197          |       1197 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      35910 |
  |   4 | sine 2.5Hz       |1755          |       1755 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      52650 |
  |   5 | sine 5Hz         |1333          |       1333 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      39990 |
  |   6 | sine 10Hz        |999           |        999 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      29970 |
  |   7 | ramp 0.5Hz       |513           |        513 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |      15390 |
  |   8 | ramp 0.05Hz      |  1           |          1 |    32767 |   -32768 | 3000     | -3000    | uV        | 0.09155413 |         30 |
  +-----+------------------+--------------+------------+----------+----------+----------+----------+-----------+------------+------------+


Merge two files into a new file:


  edftk 1.edf 2.edf merge output 3.edf


Merge a selection of signals of two files into a new file, signals 1 to 4 from file 1.edf and
signals 2 to 7 and signal 12 from file 2.edf goes into file 3.edf.


  edftk A=1.edf B=2.edf merge A1-4 B2-7 B12 output 3.edf


Export signals 3, 8, 9 and 10 into a new file:


  edftk 1.edf cat 3 8-10 output 2.edf


Export all signals except signals 1 and 2 into a new file:


  edftk 1.edf cat 3-end output 2.edf


Trim a file (remove the first minute, copy only 5 minutes):


  edftk 1.edf merge start=0:01:00 duration=0:05:00 output 2.edf


Combining the previous commands:


  edftk A=1.edf B=2.edf merge A1-4 B2-7 B12 start=0:01:00 duration=0:05:00 output 3.edf




Catenating vs. merging



Timegaps will be filled with zero/baseline.




Examples related to debugging/inspection


Dump the digital values of the 5th channel of the 2nd datarecord in hexadecimal:


  edftk 1.edf dump hex 2 5

  00000000  0000 01aa 034b 04d7  0644 078a 08a0 0980  |....K...D.......|
  00000008  0a24 0a88 0aaa 0a88  0a24 0980 08a0 078a  |$.......$.......|
  00000010  0644 04d7 034b 01aa  0000 fe55 fcb4 fb28  |D...K.....U...(.|
  00000018  f9bb f875 f75f f67f  f5db f577 f555 f577  |..u._.....w.U.w.|
  00000020  f5db f67f f75f f875  f9bb fb28 fcb4 fe55  |...._.u...(...U.|
  00000028  0000 01aa 034b 04d7  0644 078a 08a0 0980  |....K...D.......|
  00000030  0a24 0a88 0aaa 0a88  0a24 0980 08a0 078a  |$.......$.......|
  00000038  0644 04d7 034b 01aa  0000 fe55 fcb4 fb28  |D...K.....U...(.|
  00000040  f9bb f875 f75f f67f  f5db f577 f555 f577  |..u._.....w.U.w.|


Dump the digital values of the 5th channel of the 2nd datarecord in decimal:


  edftk 1.edf dump dec 2 5

  0000000000  +00000 +00426 +00843 +01239  +01604 +01930 +02208 +02432  |....K...D.......|
  0000000008  +02596 +02696 +02730 +02696  +02596 +02432 +02208 +01930  |$.......$.......|
  0000000016  +01604 +01239 +00843 +00426  +00000 -00427 -00844 -01240  |D...K.....U...(.|
  0000000024  -01605 -01931 -02209 -02433  -02597 -02697 -02731 -02697  |..u._.....w.U.w.|
  0000000032  -02597 -02433 -02209 -01931  -01605 -01240 -00844 -00427  |...._.u...(...U.|
  0000000040  +00000 +00426 +00843 +01239  +01604 +01930 +02208 +02432  |....K...D.......|
  0000000048  +02596 +02696 +02730 +02696  +02596 +02432 +02208 +01930  |$.......$.......|
  0000000056  +01604 +01239 +00843 +00426  +00000 -00427 -00844 -01240  |D...K.....U...(.|
  0000000064  -01605 -01931 -02209 -02433  -02597 -02697 -02731 -02697  |..u._.....w.U.w.|


Dump the physical values of the 5th channel of the 2nd datarecord in decimal:


  edftk 1.edf dump phys 2 5

  0000000000  +0.000e+00 +1.560e+01 +3.087e+01 +4.537e+01  +5.874e+01 +7.068e+01 +8.086e+01 +8.906e+01  |....K...D.......|
  0000000008  +9.507e+01 +9.873e+01 +9.998e+01 +9.873e+01  +9.507e+01 +8.906e+01 +8.086e+01 +7.068e+01  |$.......$.......|
  0000000016  +5.874e+01 +4.537e+01 +3.087e+01 +1.560e+01  +0.000e+00 -1.564e+01 -3.091e+01 -4.541e+01  |D...K.....U...(.|
  0000000024  -5.878e+01 -7.072e+01 -8.090e+01 -8.910e+01  -9.511e+01 -9.877e+01 -1.000e+02 -9.877e+01  |..u._.....w.U.w.|
  0000000032  -9.511e+01 -8.910e+01 -8.090e+01 -7.072e+01  -5.878e+01 -4.541e+01 -3.091e+01 -1.564e+01  |...._.u...(...U.|
  0000000040  +0.000e+00 +1.560e+01 +3.087e+01 +4.537e+01  +5.874e+01 +7.068e+01 +8.086e+01 +8.906e+01  |....K...D.......|
  0000000048  +9.507e+01 +9.873e+01 +9.998e+01 +9.873e+01  +9.507e+01 +8.906e+01 +8.086e+01 +7.068e+01  |$.......$.......|
  0000000056  +5.874e+01 +4.537e+01 +3.087e+01 +1.560e+01  +0.000e+00 -1.564e+01 -3.091e+01 -4.541e+01  |D...K.....U...(.|
  0000000064  -5.878e+01 -7.072e+01 -8.090e+01 -8.910e+01  -9.511e+01 -9.877e+01 -1.000e+02 -9.877e+01  |..u._.....w.U.w.|


Dump the raw data of the 5th channel of the 2nd datarecord and pipe it to 'hexdump':


  edftk 1.edf dump raw 2 5 | hexdump -C

  00000000  00 00 aa 01 4b 03 d7 04  44 06 8a 07 a0 08 80 09  |....K...D.......|
  00000010  24 0a 88 0a aa 0a 88 0a  24 0a 80 09 a0 08 8a 07  |$.......$.......|
  00000020  44 06 d7 04 4b 03 aa 01  00 00 55 fe b4 fc 28 fb  |D...K.....U...(.|
  00000030  bb f9 75 f8 5f f7 7f f6  db f5 77 f5 55 f5 77 f5  |..u._.....w.U.w.|
  00000040  db f5 7f f6 5f f7 75 f8  bb f9 28 fb b4 fc 55 fe  |...._.u...(...U.|
  00000050  00 00 aa 01 4b 03 d7 04  44 06 8a 07 a0 08 80 09  |....K...D.......|
  00000060  24 0a 88 0a aa 0a 88 0a  24 0a 80 09 a0 08 8a 07  |$.......$.......|
  00000070  44 06 d7 04 4b 03 aa 01  00 00 55 fe b4 fc 28 fb  |D...K.....U...(.|
  00000080  bb f9 75 f8 5f f7 7f f6  db f5 77 f5 55 f5 77 f5  |..u._.....w.U.w.|




Other EDF tools