alexandrebarachant / muse-lsl

Python script to stream EEG data from the muse 2016 headset
BSD 3-Clause "New" or "Revised" License
622 stars 183 forks source link

EEG raw data from muse #11

Closed shirans closed 5 years ago

shirans commented 7 years ago

First of all, I’ve been playing with the code in this repo and it’s very helpful, thanks!

I managed to reproduce the p300, but I haven't figure out the scale of the values I see. The general saying is that eeg data is around 10-100 uv. According to the docs in Muse, values on /muse/eeg are 0-1600 uv.

I also tried to reproduce using data from muse monitor. I’m attaching a description of the two data frames - the df from this repo (sub1 session1) and the df I created using muse monitor data. (df = raw.to_data_frame(), raw is the same raw from the notebook, before filtering)

snip20170729_16

alexandrebarachant commented 7 years ago

Hi, I have no experience with muse monitor, so i will not be very helpful. All i can say is the following :

pdpino commented 7 years ago

Hi, I was wondering why those numbers in https://github.com/alexandrebarachant/muse-lsl/blob/master/muse/muse.py#L113, thanks. I still have one question though, are you sure the eeg data is encoded as unsigned integers?

alexandrebarachant commented 7 years ago

2048 is the center of the 12 bits (4096). 0.48828125 is because the datasheet say 2mv p-p input range (2000uV/4096)

pdpino commented 7 years ago

Sorry, I misexplained myself, I already got that from your latter comment. My question is why unsigned ints? couldn't the muse protocol use signed integers or floats? Floats of 12bit would be weird, and if the number is positive it makes sense to be unsigned, but are you sure of it?

alexandrebarachant commented 7 years ago

oh sorry about that :)

yes, i'm pretty sure (p-value < 0.01) it is unsigned, at least with the headset i have in hand. it is difficult to misread a signed int for an unsigned, because when the signal cross zeros, the signed bit flip and if you read it as an unsigned, it create large jump in the data.

pdpino commented 7 years ago

Ok, great. @shirans I had similar doubts about the units, I guess this discards that is a problem with the data delivered by muse-lsl. Maybe trying without centering the data around 0?

alexandrebarachant commented 7 years ago

To be clear, the units are a little bit arbitrary, but it's roughly in uV. As you pointed out, muse monitor values are from 0 to 1600uV, then my 2mV are off.

data are already centered around the mid scale of the ADC. there might be a little offset due to offset error in the hardware signal amplification chain, but since it is AC coupled, it should be around zeros. The muse monitor app return unsigned values, so there is an error on their side.

But in any case, centering does not matter at all, because you always high pass the data, or apply baseline correction, effectively removing the offset.

If for some reason your application need absolute precision, then i would suggest to contact muse and ask them for the equation to convert adc values into voltage :)

shirans commented 6 years ago

Sorry it's been a while :) I just tried to dig into it again, bottom line is I didn't find a better way to parse it. Just wanted to note that according to the docs the non scaled range is "0.0 - 1023.0 unitless". It also says "If you use the –no-scale command-line option with MuseIO, you get the EEG values as seen by the analog to digital converter." http://developer.choosemuse.com/research-tools/available-data#EEG_Data

Can't figure out why the non scaled has a 10 bits range while the data from the device comes in 12 bits range. Maybe cause 2014 version was sending 10 bits?

A naive straightforward way would be to normalize the data to 0-1680 range, i.e. data = res[1:] data = 0.48828125 (np.array(data)) 1680 ((data) - data.min()) / (data.max() - data.min())

But I'm feeling it's wrong doing it on 12 samples batches, and also not sure it really would scale to uv.