SuperBruceJia / EEG-DL

A Deep Learning library for EEG Tasks (Signals) Classification, based on TensorFlow.
https://www.nitrc.org/projects/eeg_dl_library
MIT License
937 stars 222 forks source link

a IndexError in Extract-Raw-Data-Into-Matlab-Files.py #3

Closed ingod closed 3 years ago

ingod commented 3 years ago

IndexError Traceback (most recent call last)

in () 6 X = 'X_' + str(i) 7 Y = 'Y_' + str(i) ----> 8 X, Y = load_raw_data(electrodes=electrodes, subject=subject, num_classes=nclasses) 9 X = np.squeeze(X) 10 in load_raw_data(electrodes, subject, num_classes, long_edge) 180 except: 181 pass --> 182 return np.array(trials, dtype=np.float64).reshape((len(trials),) + trials[0].shape + (1,)), np.array(labels, dtype=np.float64) 183 184 IndexError: list index out of range how to debug it, thank you for helping.
SuperBruceJia commented 3 years ago

Be advised that

  1. This file depends on the "electrode_positions.txt", and you should place the two files in the same folder.
  2. This file must be executed under the Python 2 environment. Please double-check it. If u have additional questions, please let me know.
YiBinJin commented 3 years ago

I have the same error, too. I'm sure that I executed this file under the Python 2 environment while "electrode_position.txt" and "Extract-Raw-Data-Into-Matlab-Files.py" are in the same folder. When I'm debugging, I found that this error happened in a strange place: ` 46 def load_edf_signals(path): 47 try: 48 print('333') 49 print(path) 50 ---->sig = pyedflib.EdfReader(path) 51 print('444') 52 n = sig.signals_in_file 53 signal_labels = sig.getSignalLabels() 54 sigbuf = np.zeros((n, sig.getNSamples()[0]))

55 for j in np.arange(n): 56 sigbuf[j, :] = sig.readSignal(j) 57 # (n,3) annotations: [t in s, duration, type T0/T1/T2] 58 annotations = sig.read_annotation() 59 except KeyboardInterrupt: 60 # prevent memory leak and access problems of unclosed buffers 61 sig._close() 62 raise

63 sig._close() 64 del sig 65 return sigbuf.transpose(), annotations `

In the Python's terminal at line 48, we can find that we have an output of '333' and the path, while '444' didn't appear, so I guess there are some errors happened in line 50 pyedflib.EdfReader(path). Then I open Python2.7 and type the following code: `

import pyedflib sig = pyedflib.EdfReader('/root/EEG-DL/dataset/S001R01.edf') Traceback (most recent call last): File "", line 1, in File "pyedflib/_extensions/_pyedflib.pyx", line 116, in pyedflib._extensions._pyedflib.CyEdfReader.init File "pyedflib/_extensions/_pyedflib.pyx", line 155, in pyedflib._extensions._pyedflib.CyEdfReader.open File "pyedflib/_extensions/_pyedflib.pyx", line 127, in pyedflib._extensions._pyedflib.CyEdfReader.check_open_ok OSError: the file is not EDF(+) or BDF(+) compliant (Prefilter) `

This dataset is get from this project by using "MIND_Get_EDF.py", so I feel confused. Then I download the dataset from the new PhysioNet website and try to open the .edf files, but I failed. EDFbrower told me that both dataset download by the script or directly download from the website can not be opened. I tried to open the dataset by Matlab. This time I can open it, but I found that .edf files don't contain the EEG information. I wonder to know how to debug this problem. Thanks for helping and my apology for taking up your times.

XieTianLi commented 3 years ago

I meet the same question, I found the edf can't be opened.

SuperBruceJia commented 3 years ago

I have the same error, too. I'm sure that I executed this file under the Python 2 environment while "electrode_position.txt" and "Extract-Raw-Data-Into-Matlab-Files.py" are in the same folder. When I'm debugging, I found that this error happened in a strange place: ` 46 def load_edf_signals(path): 47 try: 48 print('333') 49 print(path) 50 ---->sig = pyedflib.EdfReader(path) 51 print('444') 52 n = sig.signals_in_file 53 signal_labels = sig.getSignalLabels() 54 sigbuf = np.zeros((n, sig.getNSamples()[0]))

55 for j in np.arange(n): 56 sigbuf[j, :] = sig.readSignal(j) 57 # (n,3) annotations: [t in s, duration, type T0/T1/T2] 58 annotations = sig.read_annotation() 59 except KeyboardInterrupt: 60 # prevent memory leak and access problems of unclosed buffers 61 sig._close() 62 raise

63 sig._close() 64 del sig 65 return sigbuf.transpose(), annotations `

In the Python's terminal at line 48, we can find that we have an output of '333' and the path, while '444' didn't appear, so I guess there are some errors happened in line 50 pyedflib.EdfReader(path). Then I open Python2.7 and type the following code: `

import pyedflib sig = pyedflib.EdfReader('/root/EEG-DL/dataset/S001R01.edf') Traceback (most recent call last): File "", line 1, in File "pyedflib/_extensions/_pyedflib.pyx", line 116, in pyedflib._extensions._pyedflib.CyEdfReader.init File "pyedflib/_extensions/_pyedflib.pyx", line 155, in pyedflib._extensions._pyedflib.CyEdfReader.open File "pyedflib/_extensions/_pyedflib.pyx", line 127, in pyedflib._extensions._pyedflib.CyEdfReader.check_open_ok OSError: the file is not EDF(+) or BDF(+) compliant (Prefilter) `

This dataset is get from this project by using "MIND_Get_EDF.py", so I feel confused. Then I download the dataset from the new PhysioNet website and try to open the .edf files, but I failed. EDFbrower told me that both dataset download by the script or directly download from the website can not be opened. I tried to open the dataset by Matlab. This time I can open it, but I found that .edf files don't contain the EEG information. I wonder to know how to debug this problem. Thanks for helping and my apology for taking up your times.

Hi,

I'm sure I have met the same issue before when I'm working on the EEG job. Nevertheless, I cannot remember how I address it.

There are several suggestions as follows which might be helpful:

  1. Please double-check your Python Environment. Python 2.7 Environment is highly Recommended.
  2. Please double-check the codes with regard to the data input and read.
  3. Please double-check the completion of the EDF files. If u are in Mainland China, be sure to use a VPN service to download the files. Otherwise, the downloaded files might not be completed.

I think the above methods should solve your problem. However, if there is any other problem, please be sure to let me know or Google & Baidu it. I'm sure u can find a proper solution.

Best,

Shuyue

SuperBruceJia commented 3 years ago

I meet the same question, I found the edf can't be opened.

Hi,

The problem of this issue might be the integrity of the downloaded EDF files. If u are in Mainland China, u should download the files using a VPN service. Otherwise, u should double-check your codes.

Best,

Shuyue

shenjianaixuexi commented 3 years ago

Hi, I have met the same question. Anyone who have solved the problem?

Kang1121 commented 3 years ago

why closed this issue?

Kang1121 commented 3 years ago

Please refer to Common Issues 5 in Readme, and in the command it is edf not def!!!

sumon3255 commented 1 year ago

@Kang1121 have you solve this index out of range issu?