mne-python: [BUG/MAINT] Topomap `image_interp='None'` still interpolates

In writing https://github.com/mne-tools/mne-python/pull/10571, having values that are not spatially continuous over a topomap made for real problems with the existing interpolation methods so I added a Voronoi option. The following code uses image_interp='None' but in my mind, this is still applying an interpolation. I was planning on adding the Voronoi option to image_interp but I thought maybe it should replace None. In the matplotlib documentation, the interpolations are demonstrated on images, which makes much more sense for None, but with points, I think this behavior is unexpected–for me, I just want an option to see the raw data. I added a new opinions-wanted tag because I think this is an especially good one to hear what other people think.

import os.path as op
import mne
import matplotlib.pyplot as plt

data_path = mne.datasets.sample.data_path()
evoked =mne.read_evokeds(op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif'))[0]
evoked.pick_types(eeg=True)
evoked.apply_proj()
fig, ax = plt.subplots()
mne.viz.plot_topomap(evoked.data.mean(axis=1), evoked.info, image_interp='None', axes=ax)   # still interpolates
Screen Shot 2022-04-28 at 11 33 00 AM

The Voronoi plot looks like this:

Screen Shot 2022-04-28 at 12 26 56 PM

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (29 by maintainers)

Most upvoted comments

So I tend to prefer option (4). Alternatively, we could implement the behavior of (4) with out existing image_interp parameter, which would be less breaking I guess.

+1 for (4) while keeping the name as (the slight misnomer) image_interp rather than rename to interpolation by deprecation

Another downside would be loss of control over matplotlibs imshow smoothing that we use. But the resulting API would be simple and clear.

If people really need it, there should be something like ax.images[0].set_interpolation(...) that they can do afterward, so I’m not too worried about this

Why would anyone want to distinguish between data interpolation and image interpolation?

@cbrnr This is what we do now (kind of), but I agree it is not ideal. The reason for current state of afairs is rather technical, I think - we do cubic interpolation on a grid, but do not waste resources to make the grid super-fine-grained (although it can be controlled by res) if it can be linearily smoothed by matplotlib when displayed for a similar visual effect. I actually never used image_interp when plotting topomaps, and I guess many users did not, so maybe option 4 wouldn’t be so destructive as it sounds. So you can count me as +0.5 on option 4 as well. 😃

And yes, I think the Voronoi option is a great default no-interpolation, but whether it should be image_interp=False or image_interp='none' (etc.) - I have no strong opinion.