How to read nihon EEG file and how to set raw nihon

raw = mne.io.read_raw_nihon('sample_data_raw_file')


FileNotFoundError                         Traceback (most recent call last)
<ipython-input-56-0931b2c6efb6> in <module>
      1 #raw = mne.io.read_raw_nihon(sample_data_raw_file)
      2 
----> 3 raw = mne.io.read_raw_nihon('sample_data_raw_file')

~/anacondalele/envs/mne/lib/python3.8/site-packages/mne/io/nihon/nihon.py in read_raw_nihon(fname, preload, verbose)
     44     mne.io.Raw : Documentation of attribute and methods.
     45     """
---> 46     return RawNihon(fname, preload, verbose)
     47 
     48 

<decorator-gen-224> in __init__(self, fname, preload, verbose)

~/anacondalele/envs/mne/lib/python3.8/site-packages/mne/io/nihon/nihon.py in __init__(self, fname, preload, verbose)
    314         logger.info('Loading %s' % data_name)
    315 
--> 316         header = _read_nihon_header(fname)
    317         metadata = _read_nihon_metadata(fname)
    318 

~/anacondalele/envs/mne/lib/python3.8/site-packages/mne/io/nihon/nihon.py in _read_nihon_header(fname)
    131     header = {}
    132     logger.info(f'Reading header from {fname}')
--> 133     with open(fname, 'r') as fid:
    134         version = np.fromfile(fid, '|S16', 1).astype('U16')[0]
    135         if version not in _valid_headers:

See UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 6437: character maps to <undefined> · Issue #9272 · mne-tools/mne-python · GitHub and How to fix: “UnicodeDecodeError: ‘ascii’ codec can’t decode byte” · Issue #9267 · mne-tools/mne-python · GitHub, this seems like a bug and should be discussed there.

The specified file cannot be found.

Ah, I didn’t see that! Yes, this explains the error.

1 Like

to expand on Richard’s answer, the problem is most likely that you’re trying to load a file with the filename “sample_data_raw_file” (note that you have quote marks around it in your code), and there is no file with that filename. Instead you probably meant to load a file whose filename is stored in a variable called sample_data_raw_file.