lina-usc / pylossless

🧠 EEG Processing pipeline that annotates continuous data
https://pylossless.readthedocs.io/en/latest/
MIT License
18 stars 8 forks source link

Re-referencing is causing weird signal properties? #96

Closed scott-huberty closed 1 year ago

scott-huberty commented 1 year ago

I assume this is only relevant to my development branch where we moved flag_outlier_chs into rereference (but I can confirm when I switch to the main branch.

BEFORE running the pipeline:

image

Looks good.

AFTER running flag_ch_sd_ch (the first step of the pipeline. The recording is re-referenced 2 times by the end of this step FYI...)

image

the signals are not legible.

scott-huberty commented 1 year ago

The trick seems to be to do a pick_types(eeg=True) here:

https://github.com/lina-usc/pylossless/blob/2095f13eff76c5abd7729340642b57424511a207/pylossless/pipeline.py#L81-L83

image

Which blows my mind a little.. I'd assume that by default MNE wouldn't let a non-data channel (i.e. STIM channel) be a reference!

christian-oreilly commented 1 year ago

Which blows my mind a little.. I'd assume that by default MNE wouldn't let a non-data channel (i.e. STIM channel) be a reference!

I think it probably does use only EEG channels by default but that it assumes that we know what we are doing so if we give it explicitly a list of channels, it uses that list without doing further exclusion... and I suspect that we were explicitly passing this stim channel to the rereferencing function:

        inst.set_eeg_reference(ref_channels=[ch for ch in inst.ch_names
                                             if ch not in self['manual']],
                               **kwargs)