lina-usc / pylossless

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

Questions about average reference #158

Open scott-huberty opened 9 months ago

scott-huberty commented 9 months ago

Hi @reispat

I'm migrating our conversation from Email to Github.

To sum up our email, you reached out with these questions:

Question 1

Per question 1, I previously told you that a robust average reference was applied to the raw object but I was mistaken. The average reference is currently not applied when applying the rejection policy.

To actually apply the the robust average reference I think we need to add the code here:

https://github.com/lina-usc/pylossless/blob/b30a67c9994fb9d0e14cacd2187b008edcc080ae/pylossless/config/rejection.py#L104-L156

Something like

pipeline.flags["ch"].rereference(pipeline)
# as an aside - the circular reference from instance of LossLessPipeline - to an instance of FlaggedCh - back to the LosslessPipeline instance bothers me!

Would set the robust average reference.

I would also need to add it as a projector for source localization

However If you want RejectionPolicy.apply to compute the robust average reference as a projection without directly applying it to the data, we need to expose the projection kwarg of set_eeg_reference - by adding something like a set_eeg_reference_kwargs parameter to the function call of apply.

Of course, knowing that the average reference isn't currently being applied to the raw object by the pipeline, you could probably just apply it on your own after you are done with the pipeline?

If you'd like to be able to set the reference during the RejectionPolicy.apply method, I can probably implement that feature in the next two weeks - but if anyone else wants to do it, PR welcome!

Question 2

Per question 2 (applying an average reference to data that already have an average reference)

I’m not sure of the effects of applying the common reference again (should have no effect when it was done previously?)…

I don't think that applying an average reference again after it has already been applied will have any noticable effect. But I'll ping @jadesjardins and @christian-oreilly to chime in if i'm wrong here.