Interpolate the missing channels in sensor level grand_average

Hi MNE members,

Current implementation of **mne.grand_average API equalizes channels across subjects before performing a grand average. Is there any way to construct/interpolate the missing channels based on the neighboring channels on grand average data similarly to a single subject?

best,
Dip

hi Dip,

interpolation is a linear operation you can do it before or after grand average.

Either you interpolate channels for all files before the grand_average or you do it
after.

HTH
Alex

Hi @agramfort,

The problem that I am facing is something similar:

sub1 has grad channels (physical) : 1, 2, …50, 51, 52, 53
sub2 has grad channels : 1,2, … 50, 51, 53 (ch 52 is missing, it’s not registered as bad that can be interpolated)
sub3 has grad channels: 1, 2, …51, 52, 53 (50 is missing)

… and so on!
now, if you do grand average, the output becomes: 1, 2, …51, 53 (50 and 52 are not there due to channel equalization across subjects). How can I interpolate or retreat back the missing channels in the grand average unless the missing channels across subjects can be labeled/marked as bad in the grand average? At the moment, MNE doesn’t offer this option. I hope I am clearer with the explanation.

best,
Dip

Can the missing channel locations be known somehow? I.e., if they’re grad channels in a SQUID system then the location is fixed, and you could add an all-zero channel to the montage of subject 2, getting its location from the montage of subject 1. Be mindful of coordinate system transforms if you take this approach (e.g., look at montage.dig[0]['coord_frame'] of both subjects)

@dasdiptyajit the mne.grand_average() function accepts a combination of the interpolate_bads and drop_bads parameters. I think what you’re looking for is

grand_average(…, drop_bads=False, interpolate_bads=True)

This will interpolate bad channels of each instance / participant before submitting the data to the grand average calculation.

Hi!

The solution that I am looking for is something similar what @drammock has proposed. The channels were physically turned off due to high noise. So, they aren’t marked as bads that can be interpolated.

I will give it a go and try to post the intermediate results.

best,

1 Like

@dasdiptyajit hey hope you are doing good. I encountered the same problem as of yours. Did u manage to interpolate missing channels?

@rdrammock
Is there any example which I can take it as an example?

Hi @UmayKulsoom, did you manage to solve your issues? I think have some scratch codes that can be used. Let me know if you need it.

cheers,
Dip

1 Like

@UmayKulsoom here is the link: Comparing mne-tools:main...dasdiptyajit:master · mne-tools/mne-python · GitHub

@richard @drammock feel free to run the code and perhaps this/similar codes can be added in the tutorial section for MNE. I am happy to help further if needed.

best,
Dip

@dasdiptyajit I had a look at your script and I think it’s a great candidate for our examples gallery.

side note: the examples are meant to be “quick-how-to recipes for common needs” and the tutorials are meant to be “step-by-step learning resources that show many options / discuss tradeoffs / model best practices”

I think this would be good as an example because it answers one straightforward question: “how do I interpolate a sensor that was completely missing from a recording?” and because the answer is fairly straightforward: step 1 simulates data with a missing sensor; step 2 adds a flat sensor in its place and interpolates it. You’ve got a lot of code comments in there already so I think it’s mostly a matter of tidying up to make it render nicely in HTML.

Can you open a PR to put your example in examples/preprocessing? There’s already an “interpolate bad channels” example, so adding an “interpolate missing sensors” example would be a good complement.

@drammock sounds great to me. Thanks for looking up the script. I will open a PR soon. Currently, I am working on a similar issue (remapping gradiometers activity to virtual magnetometers (i.e., creating virtual magnetometers). Gradiometers maps are difficult to understand. Currently, MNE doesn’t provide a solution to create virtual magnetometers (only remapping is allowed between existing sensor types). This can be really useful during ICA decomposition. I will tag you in MNE-Github once I have an example solution.

best,
Dip

1 Like

Thank you Dip. Soon I am going to work on it, Thank you so much for your help. will try and get back to you soon :slight_smile: