How to change the unit in mne.io.RawArray.plot

Hello Everyone,

I am trying to plot recorded EEG signals in a .csv file. In the .csv file the unit is uV. Basically i read the data from csv file and plot it with MNE. But MNE takes these values as Volt not uVolt. Ex: 4150uV in csv file is 4150000000 uV in MNE. How can i fix this? I do not want to divide the data by 10^6 since i do not want lose precision. I could not find unit parameter in the functions.
I appreciate any comment. Than you.

path        = 'xxx'
scale       = dict(mag=1e-12, grad=4e-11, eeg=200, eog=150e-6, ecg=5e-4, emg=1e-3, ref_meg=1e-12, misc=1e-3, stim=1, resp=1, chpi=1e-4, whitened=1e2)
ch_names    = ['F3','FC5','AF3','F7','T7','P7','O1','O2','P8','T8','F8','AF4','FC6','F4'] 
ch_types    = ['eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg','eeg']
sfreq       = 256


data = pd.read_csv(path + '.csv')
data = data.transpose()

info = mne.create_info(ch_names = ch_names, ch_types=ch_types, sfreq = sfreq)
raw = mne.io.RawArray(data, info)

raw.plot(clipping=None,title="EEG",scalings = scale)
  • MNE version: 1.2.3
  • operating system: Windows 10

For plotting, you can provide the scalings argument to change the Y-scale. You can also change interactively the scale with the +/- keys on your keyboard.
However, you will not lose precision by rescaling your data by 1e-6. Thus, I would recommend to provide the data for each channel type in the unit expected by MNE. For exaple, 4150 uV should be provided as 4150 * 1e-6 Volts.

Mathieu

2 Likes

Is there a way to change the unit expected by MNE?
MNE only expects the unit in Volt? I need to make sure before moving on to other solutions.
Thank you.

The unit depends on the channel type, and yes, MNE expects a given unit for a given channel type.
For EEG, the expected unit is Volt. There is no way to change the expected unit (despite some FIFF fields existing, as I recently discovered), mostly because it’s easier to ask the user to comply with this convention rather than supporting all the different name/description for every units and trying to figure out the conversion at loading. For example: "uV", "microvolts", "ΞΌV", ... are all unit description that could be saved by an acquisition software.

It is however possible to use MNE on data in a different unit, at your own risk, and it will most likely mess up many visualization function, in which you will have to adapt the scale/colorbar/… as for example raw.plot().

1 Like

Thank you so much Mathieu. It was so helpful