Skip to content

Conversation

@alexrockhill
Copy link
Contributor

Fixes #10561.

This tutorial is pretty compelling even though there are a lot of parameters https://psychophysiology.cpmc.columbia.edu/software/eBridge/tutorial.html so I just did an exact replication despite there being a few different strategies in the literature that depend less on the histogram of electrical distance values and more on the projection of the nearest neighbors onto each electrode (intrinsic Hjorth) e.g. below.

Screen Shot 2022-04-26 at 4 29 36 PM

However, I'm getting a weird effect where the bridged electrodes are predominantly lateral to each other in the EEGBCI dataset. If anyone had a second to look through the code, it's not that complex but I'm guessing I did something wrong.

I'll keep looking as well and hopefully fix it soon. I think this is pretty valuable for EEG users.

@alexrockhill
Copy link
Contributor Author

alexrockhill commented Apr 27, 2022

The second plot here https://output.circle-artifacts.com/output/job/01cda15a-cc39-48d4-acf5-133082e67e2b/artifacts/0/dev/auto_examples/preprocessing/eeg_bridging.html has a preponderance of lateral connections whereas these bridges seem more evenly distributed https://doi.org/10.1016/j.clinph.2003.10.028
Screen Shot 2022-04-26 at 5 18 07 PM

@alexrockhill
Copy link
Contributor Author

Ok, I'm starting to think this is just a legitimate pattern, maybe having to do with the EEG experimenter applying gel from the side and so it bridges laterally for this dataset. Here are two channels where the top two are bridged and the bottom two are bridged but they are not all inter-bridged:

Screen Shot 2022-04-26 at 5 27 43 PM

Screen Shot 2022-04-26 at 5 29 11 PM

FCz-FC2 mirror each other the whole recording and F2-Fz mirror each other the whole recording but they are not all exactly the same, they are paired in that way.

If anyone wants to look this over/comment, please do, but I assume this is pretty much on track from this evidence.

@alexrockhill
Copy link
Contributor Author

Ok this ended up being a lot more work than I thought but I'm really happy with the result.

  • I changed the multiple confusing parameters to a parameter-free kernel density estimate with a minimization rather than using a histogram compared to EEGLAB (which works well)
  • I didn't use the confusing 100 / median(electrical distances collapsed across channels) that EEGLAB which loses unit interpretability and instead just stuck with microvolts**2
  • I added a Voroni plot topomap helper function because the matplotlib interpolation functions looks really misleading. I think it's kind of a cool representation and I wouldn't mind if it got used elsewhere.
  • I added a function to plot the electrical distances for each electrode which I think is really helpful in diagnosing

The only question I have currently is that it's a bit long as an example so it could be moved to the tutorial section. I really like the deep dive because I think this is an important topic in EEG and is doable to understand in a way that will help people collect data better.

@alexrockhill alexrockhill changed the title [ENH, WIP] Compute Electrode Bridging in EEG [ENH, MRG] Compute Electrode Bridging in EEG Apr 28, 2022
fix runtime warning divide by zero and 3.7 nan handling

fix warning filter

fix pydocstyle

fix links, refs

fix forgot to delete

one more error fixed

try to fix microvolts squared

that's not going to work, trying something else
@alexrockhill
Copy link
Contributor Author

Thanks for the review, sorry for the typos 😊

Should pass the tests now.

@alexrockhill
Copy link
Contributor Author

alexrockhill commented Apr 29, 2022

The test that timed out might need to be rerun but ready to merge by me

Wait muV^2 still got messed up one sec

@alexrockhill
Copy link
Contributor Author

@agramfort
Copy link
Member

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to have another review from one of our EEG experts

@mmagnuski
Copy link
Member

I'll take a look. :)

Copy link
Member

@mmagnuski mmagnuski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great tutorial! I never actually checked for bridging in my data and now I'm eager to do it. I think it would be useful to add some recommendations in the summary towards the end:

  • for example to record a few minutes before starting the experiment
    and have a script ready that plots bridges / warns about their presence? I'm just not sure what can be done if channel bridges are detected at this point.
  • what would be recommended course of action once brides are detected during preprocessing? Dropping or interpolating some of the channels if there is not too many brides? I don't know as I never actually checked for this problem (regrettably).

@alexrockhill
Copy link
Contributor Author

for example to record a few minutes before starting the experiment
and have a script ready that plots bridges / warns about their presence? I'm just not sure what can be done if channel bridges are detected at this point.

Something real-time would be very cool but once the bridges are created, to my knowledge there is nothing you can do about it. So I think the only feedback you would get in real time would be whether to abandon the session or not, which I don't think is really all that helpful. I think the better use would be post-hoc like this and to just see how many you bridged and try to do better in subsequent experiments.

You can interpolate the bridged channels for sure but that's at least two adjacent channels being interpolated...

@alexrockhill
Copy link
Contributor Author

Does this look okay now @mmagnuski?

@mmagnuski
Copy link
Member

Yes, looks good!

@mmagnuski mmagnuski merged commit a6a67de into mne-tools:main Apr 30, 2022
@mmagnuski
Copy link
Member

oh, I forgot one thing: Thanks @alexrockhill !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Add automatic detection of bridging in EEG electrodes

4 participants