# Unit errors when reading from csv file

**URL:** <https://mne.discourse.group/t/unit-errors-when-reading-from-csv-file/6831>\
**Category:** Support & Discussions\
**Tags:** preprocessing, eeg\
**Created:** [May 2, 2023, 6:45pm UTC](https://mne.discourse.group/t/unit-errors-when-reading-from-csv-file/6831 "2023-05-02T18:45:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@felix](https://mne.discourse.group/u/felix)\
**Post date:** [May 2, 2023, 6:45pm UTC](https://mne.discourse.group/t/unit-errors-when-reading-from-csv-file/6831/1 "2023-05-02T18:45:16Z")

</div>

- MNE version: 1.3.1
- operating system: macOS Ventura

Hi everyone, I’m trying to read EEG data from a csv file but I’m having a problem with the units, even after applying a solution described here on the forum \<\< raw.apply\_function(lambda x: x \* 1e-6) \>\> . When plotting raw, the unit of microvolts appears in the upper right corner.

Here is my code:

```python
file_name = 'example.csv'
data = pd.read_csv(file_name, skiprows=0, usecols=[*range(2, 18)])
channel_names = ['FP1', 'FP2', 'F3', 'F4', 'FC1', 'FC2', 'C4', 'C3', 'Cz', 'CP2', 'CP1', 'P4', 'Pz', 'P3', 'O2', 'O1']
sample_frequency = 512
info = mne.create_info(ch_names= channel_names, sfreq= sample_frequency, ch_types='eeg')
raw = mne.io.RawArray(data.transpose(), info)
raw.apply_function(lambda x: x * 1e-6)
raw.plot( scalings = 'auto' )
plt.show()

```

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [May 2, 2023, 6:59pm UTC](https://mne.discourse.group/t/unit-errors-when-reading-from-csv-file/6831/2 "2023-05-02T18:59:02Z")

</div>

Hello,

I’m going to guess you meant the upper left corner. Which is normal, EEG channels are plotted by default with a +/- 20uV scale displaying the range 40 uV in the top left corner. If you set `scalings='auto'` and get uV in the top left corner, you likely scaled the data correctly.

For instance:

```python
from mne.datasets import sample
from mne.io import read_raw_fif
from mne.viz import set_browser_backend

raw = read_raw_fif(sample.data_path() / "MEG" / "sample" / "sample_audvis_raw.fif", preload=True)
raw.pick_types(eeg=True)
raw.filter(1., 40.)
set_browser_backend("matplotlib")
raw.plot(scalings="auto")

```

displays 23.58 uV in the top left corner.

Mathieu

---

<div class="post-metadata">

**Author:** ![felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@felix](https://mne.discourse.group/u/felix)\
**Post date:** [May 3, 2023, 6:58pm UTC](https://mne.discourse.group/t/unit-errors-when-reading-from-csv-file/6831/3 "2023-05-03T18:58:49Z")

</div>

Thank You, Mathieu! You were right about the data being in the top left corner, my mistake.
