[Mne_analysis] UnicodeDecodeError in mne.io.read_raw_cnt()

Brunner, Clemens (clemens.brunner@uni-graz.at) clemens.brunner at uni-graz.at
Tue Aug 25 07:21:46 EDT 2020
Search archives:

        External Email - Use Caution        

Hello!

It seems like the string contains a î character, which is not part of ASCII. We should probably use Latin-1 (aka ISO-8859-1) instead. I've created an issue to discuss at https://github.com/mne-tools/mne-python/issues/8157.

Thanks for your report!

Clemens

> On 25.08.2020, at 12:05, Jacques Pesnot <jacques.pesnot at hotmail.fr> wrote:
> 
>         External Email - Use Caution        
> 
> Hi MNE people!
> 
> I have a byte decoding error (UnicodeDecodeError) during the import of a ".cnt" EEG file.
> Do you know how to fix it?
> 
> Thanks !
> Jacques Pesnot Lerousseau. 
> 
> 
> File for reproduction of the error: 
> https://drive.google.com/drive/folders/1HS3576_KgPDuUXvVH_mXWivl8914rbgU?usp=sharing
> 
> Script: 
> 
> import mne
> fname = '20200824_1524.cnt'
> raw = mne.io.read_raw_cnt(fname)
> 
> Error:
> 
> ---------------------------------------------------------------------------
> UnicodeDecodeError
>                         Traceback (most recent call last)
> 
> <ipython-input-9-8d42a9688cc0> in <module>
>       1 fname = fnames[0]
> ----> 2 raw = mne.io.read_raw_cnt(fname)
> 
> 
> 
> ~/anaconda3/lib/python3.7/site-packages/mne/io/cnt/cnt.py in read_raw_cnt(input_fname, eog, misc, ecg, emg, data_format, date_format, preload, verbose)
>     163
>      return RawCNT(input_fname, eog=eog, misc=misc, ecg=ecg,
> 
>     164                   emg=emg, data_format=data_format, date_format=date_format,
> --> 165
>                    preload=preload, verbose=verbose)
> 
>     166
>  
> 
>     167
>  
> 
> 
> ~/anaconda3/lib/python3.7/site-packages/mne/io/cnt/cnt.py in __init__(self, input_fname, eog, misc, ecg, emg, data_format, date_format, preload, verbose)
>     389         input_fname = path.abspath(input_fname)
>     390
>          info, cnt_info = _get_cnt_info(input_fname, eog, ecg, emg, misc,
> 
> --> 391
>                                         data_format, _date_format)
> 
>     392         last_samps = [cnt_info['n_samples'] - 1]
>     393
>          super(RawCNT, self).__init__(
> 
> 
> ~/anaconda3/lib/python3.7/site-packages/mne/io/cnt/cnt.py in _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format)
>     179         patient_id = int(patient_id) if patient_id.isdigit() else 0
>     180         fid.seek(121)
> --> 181         patient_name = read_str(fid, 20).split()
>     182         last_name = patient_name[0] if len(patient_name) > 0 else ''
>     183         first_name = patient_name[-1] if len(patient_name) > 0 else ''
> 
> 
> 
> ~/anaconda3/lib/python3.7/site-packages/mne/io/utils.py in read_str(fid, count)
>     239
>                               b'\x00' in data else count]])
> 
>     240
>  
> 
> --> 241     return str(bytestr.decode('ascii'))  # Return native str type for Py2/3
>     242
>  
> 
>     243
>  
> 
> 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xee in position 0: ordinal not in range(128)
> 
>  
> 
> 
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis




More information about the Mne_analysis mailing list