Skip to content

Conversation

@drona-gyawali
Copy link

@drona-gyawali drona-gyawali commented Dec 7, 2025

Reference issue (if any)

Fixes #13485.

What does this implement/fix?

  • Automatically uses official MEGIN cable colors (1=red, 2=blue, 3=green, 4=yellow, 5=magenta, 6=cyan)
  • Optional hpi_labels=True shows coil ident as 3D text
  • Fully user-configurable (list/dict/single color)
  • Added test coverage

@welcome
Copy link

welcome bot commented Dec 7, 2025

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@drona-gyawali drona-gyawali marked this pull request as ready for review December 7, 2025 06:42
mne/viz/_3d.py Outdated
.. versionchanged:: 1.6
Support for passing a ``dict`` was added.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing here is incorrect, see other examples in codebase to get it right

Colors for HPI coils when ``dig=True``.
``'auto'`` (default): use standard MEGIN cable colors for Elekta/MEGIN data
(1=red, 2=blue, 3=green, 4=yellow, 5=magenta, 6=cyan).
Can also be a list of colors or ``{ident: color}`` dict.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need .. versionadded

interaction="terrain",
sensor_colors=None,
hpi_colors="auto",
hpi_labels=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should come after *

@testing.requires_testing_data
def test_plot_alignment_hpi_colors_and_labels(renderer):
"""Test hpi_colors and hpi_labels parameters."""
import mne
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be nested or needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encounter the error which says the file sample_audvis_raw.fif does not exist at the specified path, which likely means the dataset is not available in the current environment or the path is incorrect.

However, I’m a bit confused about which dataset I should be using here and how it’s expected to be selected or loaded.

Could you please guide me on the correct dataset selection and the recommended way to load it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to base this new test on the existing tests in the same file, most of the standard MEG datasets have HPI coils in them

mne/viz/_3d.py Outdated
nearest=nearest,
)

if result is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would result be None?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was being over-protective here, You’re totally right _plot_glyphs never returns None, and with surf=None for HPI coils we always get a single actor. The whole guard was dead code.

going to remove it soon...

mne/viz/_3d.py Outdated
)

if result is not None:
actor = result[0] if isinstance(result, tuple) else result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would it be each possible type here?


if hpi_colors == "auto":
megin_colors = {
1: "red",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future ref can you add a code comment about where you got this color mapping?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Clarify HPI coil order in plot_alignment

2 participants