AI agents to work with MNE...

Hi all,

I guess many of us are using LLMs for quick MNE-Python snippets, but I’m curious: has anyone started moving toward AI agentic workflows for more complex MNE pipelines or standard tasks?

Specifically, I’m talking about moving beyond copy-pasting into a chat window and instead using tools like Cursor, Continue, or Claude Code that have full project context, or even defining specialized “skills” and “rules” for agents to handle specific tasks.

Is there already a topic exploring this that I missed here? On Discord? If not, would it make sense to start something here?

I’ll add a few keywords here to help others find this: AI, claude.ai, copilot, continue, cursor, skills, rules, agent, vibe coding, automation

Best,

Max

Hi! I’ve thought about something like this, as I’ve experienced LLMs making a lot of mistakes and hallucinating on neural data processing tasks (for example in basic MNE). It would be really helpful to have an AI assistant not only for coding but for generating full experiment pipelines. I don’t know of any existing solutions in this direction. I also think the huge barrier in such tasks is data’s high heterogenity (different standards, modalities) and AI agents can solve this by creating unified adaptive pipelines.

Thanks for the question @maximilien.chaumon. We’ve had a couple of internal discussions about this. The current state of affairs is:

  1. we (maintainers) are not opposed to providing / facilitating use of AI by our users in writing their own scripts
  2. we’re not sure what that would look like / what would be most helpful (agents.md/claude.md; an MCP server; a custom AI model…). One thing that has been proposed is adding an AI chat widget to the webpage (Add OSA chat widget to documentation by neuromechanist · Pull Request #13702 · mne-tools/mne-python · GitHub) but I don’t think that’s really what you’re after.
  3. So far nobody has come forward volunteering to lead the effort; in particular, nobody from our maintainer team has because… :backhand_index_pointing_down:
  4. we are totally overwhelmed by a large increase in issues/PRs in the last ~3 months (possibly due to upcoming GSoC application deadline), combined with some project-internal tasks/deadlines that took our 2 most active maintainers out of action for a while. But even before that, we were already barely keeping up with maintenance + support, and not making much progress on the roadmap :frowning:
  5. at the same time: we are internally divided as to whether to accept AI-aided contributions into the software itself: some maintainers feel acutely the license violation problem and associated legal risk; others assume we’ll be fine if we go along with what similar Python projects are doing. Sorting this out and putting out an official policy feels more pressing than the task of building an MCP server or whatever.

Anyway, there isn’t a canonical issue / place where this is being discussed. I guess right here is as good a place as any!

Thanks Dan for these points.

The use cases I had in mind are:

  • helping students to write proper MNE code, so defining an agent that knows well how to use the API
  • even more usefully defining an agent that knows (and explains) some of the tricks that are written in books and experts know-how (like “beware of edge effects if filtering epochs”, “look at filter responses”, “make sure your conditions have similar amounts of trials when doing this or that analysis”, “check the colinearity of your regressors when doing GLM”, “keep this and that in mind when setting up your cross-validation”…)

I have the intuition that .md files, perhaps structured with rules, skills, tools would work well. An MCP setup would probably be a later step.

It may be a longer task than I imagined at first, but wouldn’t it be worth the pain? How about we connect a group of voluntary people?

Hi @maximilien.chaumon, I think indeed the best way to extend libraries like mine to better use AI would be to write a small skill library like the pymc team did or the marginaleffects library as a separate experimental repo. I might be willing to help write or test it, but maybe closer to June.

(Below example links to skills from scientific libraries; I hope this ok to link here.)
For example, `marginaleffects` repository includes a “skill” that allows large language models to discuss and explain chapters with statistical handbooks related to the package and functions in this package; analogy could be to choose with mne an existing tutorial paper or new open data repository and try to provide a skill to facilitate such analysis; so best to start with a limited scope in mind. I think that the developers may not have time to build it, so it might be rather community-based, but maybe it can be helpful later to use the forum expertise to review the proposed methods/content.