Repository navigation
Description
Describe the new feature or enhancement
There are many visualization functions in MNE-Python that contain some form of topomap. hese all expose a sphere argument on some form or another. In many cases, the user does not need to touch the sphere argument, because the default of automatically fitting of the head-sphere to the "extra" digitized headpoints is good enough.
However, in cases when one needs to set the sphere argument in order to produce good looking topomap layouts, this becomes annoying quickly. You need to set it every time you call any sort of function using the head sphere and there are more of them then you may think, because we have been adding them to many of our figures: plot_sensors, plot_topo, plot_topomap,plot_joint, ica.plot_properties, plot_evoked, etc. It is especially annoying when the sphere argument is buried in a topomap_args dictionary. At least, I became pretty annoyed while updating our teaching materials that use the Wakeman & Henson "face" dataset, which need a sphere="eeg" or all the topomaps look very wrong.
Describe your proposed implementation
What if we added an inst.set_head_sphere(sphere="auto") method to our SetChannelsMixin that fits the head sphere with the given method in sphere and writes it into the .info dictionary? Then, all the functions that use sphere, which defaults to sphere="auto", can first look in the .info to see if a head sphere is there and use it. The user will only have to set it once and since the .info is carried over throughout the entire analysis pipeline, never worry about it again and have beautiful topomap plots everywhere all the time.
Describe possible alternatives
Instead of adding it to the .info dictionary, we could also have an object-level attribute ._head_sphere. Or we could just decide that setting sphere="eeg" or something all over the place is not that big of a deal.
Additional context
Digitization scheme used in the Wakeman & Henson dataset. By default, the gray headpoints are used to fit the head sphere, which would be wrong here. We'd rather use the digitized EEG electrode locations for this data, so sphere="eeg".
Activity
larsoner commentedon Sep 14, 2026
Interesting idea... I think it makes sense to store this on
infodirectly, it's the most natural location I think (it's related to the subject head dig / geometry).Looking at the FIF spec, it actually already has origin and layers for a sphere model, so we could maybe save this on
infoas a one-layer sphere "conductor model" with a radius and origin without needing any new FIF constants, which is nice. We'd "just" have to figure out how thelayer_structis laid out, which Lauri or Matti might be able to help us track down.larsoner commentedon Sep 14, 2026
... and then API-wise the
sphere=Nonecould be expanded to mean "use sphere defined ininfoif available" in a backward-compatible way, which is great.