Skip to content

Store head sphere in the info dictionary #14307

Closed

Description

@wmvanvliet

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

Image

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

  1. larsoner commented on Sep 14, 2026

    @larsoner
    Member

    Interesting idea... I think it makes sense to store this on info directly, 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 info as 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 the layer_struct is laid out, which Lauri or Matti might be able to help us track down.

  2. larsoner commented on Sep 14, 2026

    @larsoner
    Member

    ... and then API-wise the sphere=None could be expanded to mean "use sphere defined in info if available" in a backward-compatible way, which is great.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions