mscheltienne / antio

Python package to handle I/O with the CNT format from ANT Neuro.
GNU General Public License v3.0
3 stars 4 forks source link

Look into scaling/lowpass-highpass/channel reference #20

Closed mscheltienne closed 2 months ago

mscheltienne commented 2 months ago

As the last addition to this reader, I wanted to look into the different possible channel references (#5) and different channel units (#19). So, I went into the eego software and exported a file applying the following montage:

The dataset was recorded with no cap connected (floating pin) thus the data itself is garbage.


@proloyd Could you have a look through this and confirm that (1) I did not mess up the pyeep_get_channel_scale function and (2) that you also can't retrieve the unit/scale information from the attached dataset? Better to have 2 pairs of eyes on this before calling it quit. Thanks!

proloyd commented 2 months ago

@mscheltienne Thanks for bringing the scaling up. I looked into this earlier and reached to the conclusion that we don't need to do anything on our end. libeep C library takes care of the scaling in libeep_get_samples function that we use in pyeep_get_samples_as_buffer or pyeep_get_samples functions. CNT files do save all relevant scale and unit information, and libeep C library reads all those channel specific information as eegchan_s structure. See the definition here. Basically the actual sample values are raw_data_buffer * chan_info.iscale * chan_info.rscale in chan_info.runit. Function libeep_get_samples reads the raw buffer, and then applies the scaling chan_info.iscale * chan_info.rscale, so that the scaled buffer is in unit chan_info.runit. Refer to the buffer_scaled and buffer_scaled variables here. So, we no longer need to track the scaling explicitly in mne.io.rawANT objects, i.e., don't expose the pyeep_get_channel_scale method.

I second you on the absence of filtering information from the CNT file.

mscheltienne commented 2 months ago

Great, thanks for the explanation! Monday, I'll export an actual EEG recording while applying a montage with weird scaling, let's see how it loads back in MNE ;)

mscheltienne commented 2 months ago

OK, I can now confirm that scaling is a non-issue! I exported an actual EEG recording with a couple of surprising scaling in the montage, yielding 'flat' lines in the review mode of the eego software (e.g. 1000uV, 10000 uV, 1000V, 10000V). When loaded in MNE, the signals are correctly scaled ;)