如何在Python中读取“.edf”文件。我试过了,但显示了以下错误

2024-05-12 21:56:05 发布

您现在位置:Python中文网/ 问答频道 /正文

import matplotlib
import pathlib
import mne

raw_path = pathlib.Path("data/")

raw_data = raw_path / 'Subject1' / 'S1.edf'

raw = mne.io.read_raw_edf(raw_path)

**Extracting EDF parameters from C:\research\data\Subject1\S1.edf...
EDF file detected**
---------------------------------------------------------------------------
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-28-daad488a71cf> in <module>
----> 1 raw = mne.io.read_raw_edf(raw_path)

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in read_raw_edf(input_fname, eog, misc, stim_channel, exclude, preload, verbose)
   1218         raise NotImplementedError(
   1219             'Only EDF files are supported by read_raw_edf, got %s' % (ext,))
-> 1220     return RawEDF(input_fname=input_fname, eog=eog, misc=misc,
   1221                   stim_channel=stim_channel, exclude=exclude, preload=preload,
   1222                   verbose=verbose)

<decorator-gen-197> in __init__(self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in __init__(self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)
    112         logger.info('Extracting EDF parameters from {}...'.format(input_fname))
    113         input_fname = os.path.abspath(input_fname)
--> 114         info, edf_info, orig_units = _get_info(input_fname,
    115                                                stim_channel, eog, misc,
    116                                                exclude, preload)

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in _get_info(fname, stim_channel, eog, misc, exclude, preload)
    356     misc = misc if misc is not None else []
    357 
--> 358     edf_info, orig_units = _read_header(fname, exclude)
    359 
    360     # XXX: `tal_ch_names` to pass to `_check_stim_channel` should be computed

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in _read_header(fname, exclude)
    343     logger.info('%s file detected' % ext.upper())
    344     if ext in ('bdf', 'edf'):
--> 345         return _read_edf_header(fname, exclude)
    346     elif ext == 'gdf':
    347         return _read_gdf_header(fname, exclude), None

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in _read_edf_header(fname, exclude)
    569         else:
    570             meas_date = fid.read(8).decode('latin-1')
--> 571             day, month, year = [int(x) for x in meas_date.split('.')]
    572             year = year + 2000 if year < 85 else year + 1900
    573 

~\Anaconda3\envs\mne\lib\site-packages\mne\io\edf\edf.py in <listcomp>(.0)
    569         else:
    570             meas_date = fid.read(8).decode('latin-1')
--> 571             day, month, year = [int(x) for x in meas_date.split('.')]
    572             year = year + 2000 if year < 85 else year + 1900
    573 

ValueError: invalid literal for int() with base 10: 'EyeLink '

Tags: inioreadinputrawchannelyearfname