Skip to content

coh3toEDF CLI

Vincent STRAGIER edited this page Mar 12, 2021 · 2 revisions

The script coh3toEDF.py and associated executable coh3toEDFbatch.exe are intended to be used as a batch conversion tool (from .eeg coh3 Deltamed files to the EDF, a.k.a. European Data Format). To do so, in a Windows console you can write:

C:\Users\vince> .\path\to\coh3toEDFbatch.exe -h
usage: coh3toEDFbatch.exe [-h] [-dp DESTINATION_PATH] [-ep EXECUTABLE_PATH] [-o] [-y | -n] path

positional arguments:
  path                  path to the dataset to convert from coh3 (.eeg) to EDF

optional arguments:
  -h, --help            show this help message and exit
  -dp DESTINATION_PATH, --destination_path DESTINATION_PATH
                        destination of the converted (.edf) files
  -ep EXECUTABLE_PATH, --executable_path EXECUTABLE_PATH
                        path to the converter executable
  -o, --overwrite       if set, the program will overwrite the existing .edf files
  -y, --yes             if set, the program will start directly
  -n, --no              if set, the program will exit directly

With the above command you get the help of the tool.

N.B.: .\path\to\coh3toEDFbatch.exe -h and py -3.8-32 .\path\to\coh3toEDF.py -h are in fine equivalent command, however the last one needs Python 3.8 32 bit (x86) and its dependencies to be installed.

The positional argument path must always be provided. Then if you do not want to store the converted files "inplace" (the .eeg files are not removed in any case), you must provide the optional argument -dp path/to/converted/dataset or --destination_path path/to/converted/dataset.

The optional argument -ep or --executable_path is the trickiest. You either provide the path to the coh3toEDF.exe executable (it is a software under the Deltamed Natus Licence) via the config file named coh3toEDF.config. Note that if you only have the executable or the script, you just need to run it (via the console or not) and it will generate the configuration file with a path pointing to the same directory as the script (or executable). So the easiest way to generate this configuration file is to copy paste the coh3toEDFbatch.exe file, to run it and then fetch the generated configuration file to put it where you want to store all the tools (you can then remove coh3toEDFbatch.exe from that folder).

Then, the optional argument -o or --overwrite is used to tell to the program if it has to overwrite a previously generated .edf file. You can use this option when you have generated the EDF files and that you change the annotation in the .eeg and want to update you dataset of .edf files.

And finally you can provide the argument -y, --yes or -n, --no to execute the script directly or to quit it after prompting the parsed arguments.

C:\Users\vince> "D:\Vincent\Bureau\Executables\coh3toEDFbatch.exe" path/to/dataset -dp path/to/anonymised/dataset -o -n
The following arguments have been parsed:
path: path/to/dataset
destination_path: path/to/anonymised/dataset
executable_path: None
overwrite: True
yes: False
no: True
C:\Users\vince> "D:\Vincent\Bureau\Executables\coh3toEDFbatch.exe" E:\anonymised_dataset\ -dp E:\anonymised_dataset_EDF\ -y
The following arguments have been parsed:
path: E:\anonymised_dataset\
destination_path: E:\anonymised_dataset_EDF\
executable_path: None
overwrite: False
yes: True
no: False

1 - List the files to convert...
11 file(s) will be converted.
2 - Convert files
(1/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0000.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0000.EEG"
(2/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0001.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0001.EEG"
(3/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0002.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0002.EEG"
(4/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0003.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0003.EEG"
(5/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0004.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0004.EEG"
(6/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0005.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0005.EEG"
(7/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0006.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0006.EEG"
(8/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0007.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0007.EEG"
(9/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0008.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0008.EEG"
(10/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0009.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0009.EEG"
(11/11) Convert "E:\anonymised_dataset\PAT_10\012345A-B_0010.EEG" to "E:\anonymised_dataset_EDF\PAT_10\012345A-B_0010.EEG"
3 - Kill the converter process(es).
Erreur : le processus "coh3toEDF.exe" est introuvable.

We can see that the first command did exit after prompting the parsed arguments, has intended with the -n or --no parameter. The second command did convert the files, in three steps. The first is to list all the .eeg files present, the second is to convert them. During the second step, do not use your computer, since this script will control a graphical user interface, it will not be pleasant for the user to continue to use his machine. The last step just try to kill the coh3toEDF.exe process (it can fail, it's not a big deal).

Clone this wiki locally