# time-series scale

**URL:** <https://mne.discourse.group/t/time-series-scale/5804>\
**Category:** Support & Discussions\
**Tags:** preprocessing\
**Created:** [October 24, 2022, 11:21pm UTC](https://mne.discourse.group/t/time-series-scale/5804 "2022-10-24T23:21:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanna](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hanna/32/1835_2.png) [@Hanna](https://mne.discourse.group/u/Hanna)\
**Post date:** [October 24, 2022, 11:21pm UTC](https://mne.discourse.group/t/time-series-scale/5804/1 "2022-10-24T23:21:09Z")

</div>

Hello guys, I’m working with the CHB-MIT scalp EEG database, i transformed the data to a data frame so I could visualize the time points and i think that is something wrong, i don’t understand the scale. Do i have to do some rescale? The recordings are 256Hz and 1 hour long (3600s)  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/6/6729f436c22f067525291f371a09cbe52bdfb5c0.png)  
code:

```python
fname='chb24_01_edited.edf'
iir_params=dict(order=2, ftype='butter')
def preprocessing(file_path):
    datax=mne.io.read_raw_edf(file_path,preload=True)
    datax.set_eeg_reference()
    datax.filter(l_freq=0.5,h_freq=40.0, method='iir', iir_params=iir_params, verbose=True)
    epochs=mne.make_fixed_length_epochs(datax,duration=2)
    epochs=epochs.to_data_frame(picks=['F3-C3', 'C3-P3', 'F4-C4', 'C4-P4'])
    return epochs
data=preprocessing(fname)
print(data.shape)
print(data.head())

```

---

<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:** [October 25, 2022, 8:44am UTC](https://mne.discourse.group/t/time-series-scale/5804/2 "2022-10-25T08:44:14Z")

</div>

Hello,

It looks like the data is in uV.  
It’s not very easy to tell from 5 times points in a table. To visualize it, could you plot some of those channels and their scale? Either via `matplotlib` or with `raw.plot()` (in your case `datax.plot()`).

MNE expects volts, so if it is indeed in uV, I suggest you rescale it. You can do this via the method `raw.apply_function`: [mne.io.Raw — MNE 1.2.1 documentation](https://mne.tools/stable/generated/mne.io.Raw.html#mne.io.Raw.apply_function)

Mathieu

---

<div class="post-metadata">

**Author:** ![Hanna](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hanna/32/1835_2.png) [@Hanna](https://mne.discourse.group/u/Hanna)\
**Post date:** [October 25, 2022, 6:10pm UTC](https://mne.discourse.group/t/time-series-scale/5804/3 "2022-10-25T18:10:38Z")

</div>

I see, i asked before about this and they told me mne does automatically. Anyway, after the `raw.apply_function (lambda x: x * 1e-6)` i get this :  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/d/d478dd823817db93d34d5981c2a940f8bc9e5662.png)

But my question is about the time, why does it sums 3096? How is that related to the 3600 seconds of the recording or the 2 seconds (512 data points) epochs?

---

<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:** [October 25, 2022, 7:03pm UTC](https://mne.discourse.group/t/time-series-scale/5804/4 "2022-10-25T19:03:47Z")

</div>

MNE expects data in Volts, but it’s up to the user to provide data in the correct scale.

Again, it’s hard to tell from 5 data-points, could you please share some plots?

---

<div class="post-metadata">

**Author:** ![Hanna](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hanna/32/1835_2.png) [@Hanna](https://mne.discourse.group/u/Hanna)\
**Post date:** [October 25, 2022, 7:16pm UTC](https://mne.discourse.group/t/time-series-scale/5804/5 "2022-10-25T19:16:08Z")

</div>

The plot from the epochs data:  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/9/9581bde8c0f3caec79f7a52e00304f7b3249d310.png)

This one i did not put the data in a data frame before:  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/a/a83cb6b7af88c4da84973e3644e0958892617647.png)

---

<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:** [October 25, 2022, 8:22pm UTC](https://mne.discourse.group/t/time-series-scale/5804/6 "2022-10-25T20:22:14Z")

</div>

> But my question is about the time, why does it sums 3096? How is that related to the 3600 seconds of the recording or the 2 seconds (512 data points) epochs?

I missed where you mentioned this was the issue. What do you mean by sum to 3096? Your tables don’t show it, right?  
2 seconds epochs at 256 Hz should have 512 samples, what is the issue?

* * *

**For the Y-range:** based on the top plot for the epoch data, it looks like what you plotted ranges up to `0.0001` Volts, i.e. 100 uV. This does look correct to me.  
To confirm, could you plot 30s of the raw recording? That would be more informative as we could see both:

- actual brain signal and its quality
- scale of the signal

Do mind that you may have a large DC offset, thus I would first high-pass filter the data.

```python
raw = read_raw(fname, preload=True)
raw.filter(1., None)
raw.plot()

```

The default scaling of `raw.plot()` should display data without clipping (except for large artifacts such as eye blinks).

---

<div class="post-metadata">

**Author:** ![Hanna](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hanna/32/1835_2.png) [@Hanna](https://mne.discourse.group/u/Hanna)\
**Post date:** [October 25, 2022, 8:38pm UTC](https://mne.discourse.group/t/time-series-scale/5804/7 "2022-10-25T20:38:12Z")

</div>

I mean in the time column of the data frame, shouldn’t be in seconds? starts in 0, then 0.003096 and 0.007812… I’m sorry if i’m not clear about this, It’s the first time i work with eeg data and I’m not sure if the data is in the correct shape.

![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/4/4bf574100949b45429c2e719fd9346c18592d2eb.png)

`raw.plot(start=0, duration=30, scalings='auto')`  
The last one is the plot without filtering

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/6/64cad150fc8c2766ae8f944db3dc4e2f6ed717bd.jpeg)  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/e/e70b3d5015ef6332e2319a9768b7609c2d56288d.jpeg)

---

<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:** [October 25, 2022, 9:38pm UTC](https://mne.discourse.group/t/time-series-scale/5804/8 "2022-10-25T21:38:06Z")

</div>

It is in seconds. If your sampling frequency is 256 Hz, then you have `1 / 256` seconds separating 2 samples. i.e. `0.003906` seconds, a little less than 4ms (which would be 250 Hz sampling).  
A couple of quick common sampling frequencies in EEG:

- 1 kHz → 1 sample every 1 ms, i.e. 0.001 seconds
- 500 Hz → 1 sample every 2 ms, i.e. 0.002 seconds

---

<div class="post-metadata">

**Author:** ![Hanna](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hanna/32/1835_2.png) [@Hanna](https://mne.discourse.group/u/Hanna)\
**Post date:** [October 25, 2022, 9:42pm UTC](https://mne.discourse.group/t/time-series-scale/5804/9 "2022-10-25T21:42:40Z")

</div>

Thank you so much, I guess i’ve missed the basics math 🙂

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 26, 2022, 6:51am UTC](https://mne.discourse.group/t/time-series-scale/5804/10 "2022-10-26T06:51:37Z")

</div>

Also note that the DataFrame export defaults to a uV scale, even though MNE internally stores EEG data in Volts. **So I believe the values you showed in your first posting are already correct and no rescaling is needed.**
