Zhao-Kuangshi / sleep-edf-converter

A python script (up to now) for convert annotation of Sleep-EDF and Sleep-EDFx database to numpy array or textfile.
4 stars 0 forks source link

FileNotFoundError: #1

Open blrk opened 3 years ago

blrk commented 3 years ago

hi thank you for sharing your code. I am trying to convert the sleep-EDF database to CSV files. I came across your code.

During execution, it throws an error

python3 annotation_convertor.py 'sleep_EDF/physionet.org/files/sleep-edf/1.0.0/'  '/sleep_EDF/csv_data/'```
Traceback (most recent call last):
  File "annotation_convertor.py", line 55, in read_header
    result = subprocess.run(['save2gdf', '-JSON', file], stdout = subprocess.PIPE);
  File "/home/blrk/anaconda3/envs/mne/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/blrk/anaconda3/envs/mne/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/blrk/anaconda3/envs/mne/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'save2gdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "annotation_convertor.py", line 161, in <module>
    main()
  File "annotation_convertor.py", line 155, in main
    start = get_start(os.path.join(source, rec));
  File "annotation_convertor.py", line 68, in get_start
    str_start = read_header(file)['StartOfRecording'];
  File "annotation_convertor.py", line 62, in read_header
    raise FileNotFoundError('The required command `save2gdf` seems not appearing in your environment variables. Please check!');
FileNotFoundError: The required command `save2gdf` seems not appearing in your environment variables. Please check!
Zhao-Kuangshi commented 3 years ago

Hello This is a piece of code written in 2019 and there may be some details that I am not quite able to remember. If it is to help you, I am glad to communicate with you here until it can run smoothly. This script needs to be used in conjunction with an open source software called biosig and you can download libbiosig and Biosig-tools at http://biosig.sourceforge.net/download.html (on the third line of the table). Please download a suitable version for your operating system and then decompress it. Then set the system environment variable which tolds the Python script accurately where to find the biosig suite you downloaded. If you are using a Windows 10 operating system, follow these steps:

  1. Find the folder you just downloaded and decompressed. On my computer it called biosig-2.3.1-Windows-64bit. The Python script depends save2gdf.exe under its bin directory.
  2. Before continue, you can move the downloaded files to another space (instead of the Download directory, avoiding deleting it later by accident). Of course you can not move it either. Anyway, remember exactly where save2gdf.exe is and put this path in your clipboard.
  3. Windows Settings -> System -> About (Bottom Left) -> Advanced System Settings (Bottom Right) -> Advanced (Tab) -> Environment Variables... -> System Variables
  4. Find the Path variable then click 'Edit...' button.
  5. Click New... button, then paste your path where save2gdf.exe is.
  6. Then click every 'OK' button to confirm every dialog. Now Windows knows where save2gdf.exe is.

Try the steps above, I think the problems will be resolved. If there is any question, it is welcomed to contact me here or mail to contact@zhaokuangshi.cn

blrk commented 3 years ago

Hi Zhao-Kuangshi

Thank you for your quick response.

I am a Linux user. I will try the steps given by you.

update you once it is done.

Thank you.

On Tue, Jul 27, 2021 at 12:16 PM Zhao Kuangshi @.***> wrote:

Hello This is a piece of code written in 2019 and there may be some details that I am not quite able to remember. If it is to help you, I am glad to communicate with you here until it can run smoothly. This script needs to be used in conjunction with an open source software called biosig and you can download libbiosig and Biosig-tools at http://biosig.sourceforge.net/download.html (on the third line of the table). Please download a suitable version for your operating system and then decompress it. Then set the system environment variable which tolds the Python script accurately where to find the biosig suite you downloaded. If you are using a Windows 10 operating system, follow these steps:

  1. Find the folder you just downloaded and decompressed. On my computer it called biosig-2.3.1-Windows-64bit. The Python script depends save2gdf.exe under its bin directory.
  2. Before continue, you can move the downloaded files to another space (instead of the Download directory, avoiding deleting it later by accident). Of course you can not move it either. Anyway, remember exactly where save2gdf.exe is and put this path in your clipboard.
  3. Windows Settings -> System -> About (Bottom Left) -> Advanced System Settings (Bottom Right) -> Advanced (Tab) -> Environment Variables... -> System Variables
  4. Find the Path variable then click 'Edit...' button.
  5. Click New... button, then paste your path where save2gdf.exe is.
  6. Then click every 'OK' button to confirm every dialog. Now Windows knows where save2gdf.exe is.

Try the steps above, I think the problems will be resolved. If there is any question, it is welcomed to contact me here or mail to @.***

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zhao-Kuangshi/sleep-edf-converter/issues/1#issuecomment-887256257, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZDENHVKPWYO6HZAY36NUTTZZI4JANCNFSM5BBLQ2UQ .