How to scale properly my plot?

  • MNE version: 1.4.2
  • operating system: Windows 10

I load my data from edf format and do the following:

import matplotlib.pyplot as plt
import mne

raw = mne.io.read_raw_edf(r'C:\Users\Анна\Desktop\EEG_Analysis\Irina_artifacts_test.edf', preload=True)
raw.crop(tmin=69.0, tmax=94.0).pick_types(meg="mag", eeg=True, emg=True, stim=True, eog=True)
raw.plot(scalings="auto")

The result is pretty messy:

If I try to change scaligs, e.g.:

raw.plot(scalings=dict(eeg='1e-6', emg='1e-6'))

The result looks worse:

Please, help me, how can I change scalings?

Hi @annaprovorova

what does the plot look like if you just do raw.plot() ?

According to MNE documentation, the default scalings are

dict(mag=1e-12, grad=4e-11, eeg=20e-6, 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)

raw.plot() uses the default scalings, which are pretty different from the custom scalings you passed in your code above. This might solve your problem.

Hi, @scott-huberty!
Unfortunately, raw.plot() didn’t help. Result’s still the same:

How about raw.plot(scalings=dict(eeg='100e-6', emg='100e-6'))? You can just try larger and larger scalings until you get the desired results. Also note that the + and - keys on your keyboard will make things larger/smaller if you have an interactive plot window (i.e. you are not plotting inline into a notebook).

1 Like

Hi, @wmvanvliet !
Thank you for your suggestion, but it doesn’t work :frowning:
Result stay the same.

Could it be connected to the type of me file, .edf?

Looking at the units displayed in the first plot you shared, the units are astronomical (It’s a little blurry but if I’m reading that number right it’s something like 30 billion microvolts?).

Thats’ very large! It’s hard to help more without more info. At this point I’m just grasping at straws, but Is this data you collected? You might need to look into how your data looks after acquisition, and before you save it to EDF.

The scaling issues comes from your dataset. MNE expects EEG signal in Volts. Typical EEG signal would then range around 40e-6 Volts. Thus, plotting with raw.plot(scalings=dict(eeg=20e-6)) (default) yields. The best solution is for you to figure out which units the data is recorded in, and then apply a conversion:

raw.apply_function(lambda x: x*1e-6, picks="eeg")

In the example above, the EEG data is scaled from microvolts to volts.
You can also ignore this entirely and figure out a scaling which works for your dataset. The simplest way is to use raw.plot() interactively: press (or hold) the - key on your keyboard until the scale looks correct. See the Help button for all the keyboard shortcuts.

Mathieu

2 Likes

Hi @scott-huberty!
Here is raw.info data. So frequency is just 500 Hz
image

Before saving it looked like normal… I have the same result if I try to plot any data from experiments.

Here is the data in edf format Irina_artifacts_test.edf - Google Drive

Sorry for long answer and thank you for help!

is it possible that your data were recorded in nanovolts?

raw = mne.io.read_raw_edf("Irina_artifacts_test.edf")
raw.load_data()
raw.apply_function(lambda x: x * 1e-9)
raw.plot()

Note also that your raw.info says that your sampling rate was 500Hz and your highpass frequency was 1000Hz. That’s probably wrong (I don’t think MNE-Python will even allow a high-pass cutoff that is higher than the sampling frequency)

2 Likes

You are right. Data was in nanowolts, your solution helped!
Thank you so much!!

1 Like