Skip to content

Splitting _brain.py into multiple modules #14331

Description

@payamsash

Describe the new feature or enhancement

mne/viz/_brain/_brain.py is currently over 5k lines and all in one Brain class which makes adding new features and debugging difficult. also as mentioned by @wmvanvliet:

The _brain.py code is become too long though. We should split it up into multiple files at some point.

``

Describe your proposed implementation

I would suggest using mixing classes (as it also been used at other places like BaseRaw and BaseEpochs) sth like:

@fill_doc
class Brain(
    _SourceDataMixin,    # add_data, add_label, add_annotation, _add_volume_data, ...
    _ObjectsMixin,       # add_forward/dipole/head/skull/volume_labels/foci/sensors/text
    _ScalarDataMixin,    # update_lut, colormap range, time interpolation, _update_glyphs
    _AppearanceMixin,    # set_surf, set_cortex_colormap, silhouette
    _CameraMixin,        # show_view, _set_camera, reset_view
    _PickingMixin,       # picking, hover, glyphs, mpl traces
   ...
)

and a _helpers.py for taking the module level helpers (e.g. _safe_interp1d, _update_limits, ...).

Do you agree with this approach? @larsoner @wmvanvliet , also consider that mixins will be single use. also I would like to wait until we finally decide on the skeleton, for example I'm not sure if we need _events.py for ui_events handlers or should we put plot_time_course into picking or sth like _traces.py.

Describe possible alternatives

.

Additional context

No response

Activity

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