Loading eeglab .set files give error "TypeError: bad operand type for unary -: 'RawEEGLAB'"

Hello, sorry if this is a stupid question but I can’t get around this problem. I am trying to load .set files coming from eeglab, with spyder . I keep getting this error

TypeError: bad operand type for unary -: ‘RawEEGLAB’

I am using a version of python installed by mamba as per the instructions on the site.

I have tried different ways to load them but failed.
Any suggestion? I paste the configuration I am using below.

Thanks,

l.

Platform: macOS-12.5.1-arm64-arm-64bit
Python: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:41:22) [Clang 13.0.1 ]
Executable: /Users/luca/opt/miniconda3/envs/mne/bin/python
CPU: arm: 8 cores
Memory: 16.0 GB

mne: 1.1.1
numpy: 1.22.4 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy: 1.9.0
matplotlib: 3.5.3 {backend=MacOSX}

sklearn: 1.1.2
numba: 0.55.2
nibabel: 4.0.1
nilearn: 0.9.2
dipy: 1.5.0
cupy: Not found
pandas: 1.4.3
pyvista: 0.36.1 {OpenGL 4.1 Metal - 76.3 via Apple M1}
pyvistaqt: 0.9.0
ipyvtklink: 0.2.2

vtk: 9.1.0
qtpy: 2.2.0 {PyQt5=5.15.4}
ipympl: Not found
pyqtgraph: 0.12.4
pooch: v1.6.0

mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: 0.3.1
mne_connectivity: Not found
mne_icalabel: Not found

One way you would get that error is if you were to do something like this:

raw = mne.io.read_raw_eeglab('my_data.set')
raw = -raw  # note the '-', known as a 'unary -' mentioned in the error message

Could you post your exact code? Perhaps there is an erroneous - in there somewhere. If not, we can investigate further.

Thank you for your prompt answer. The code is extremely simple

– I import the modules I would need later

import numpy as np
import scipy as scipy
import mne
import pymatreader as pymatreader
import os as os
import time as time

– I set my own directory (I skip it)

– I load my file

myraw1 =-mne.io.read_raw_eeglab('prp_S13_reref.set')

(change the name to yours, or if you want I can make the file available.

That’s it. Changes in the parameters for the mne.io.read_raw_eeglab make no effect, for what I can see. I have to add that I can load these files correctly with the same command with MNE-r (but with my own python environment, which has not been installed via conda). ( I do find other problems, unrelated, and this is why I am trying to move away from MNE-r and see if I can solve them in MNE-python).

Can I provide any other info?

l.

you typed:

myraw1 =-mne.io.read_raw_eeglab(‘prp_S13_reref.set’)

can you try:

myraw1 = mne.io.read_raw_eeglab(‘prp_S13_reref.set’)

Alex

1 Like

Dear Alexandre:

Thanks a lot, this was very silly. It does work as you suggested.

The - remained because I copied code from r and it was a part of the assignment <-. I guess I will have to buy new glasses. Sorry for bothering you all, and thanks again.

l.

1 Like