Skip to content

Support any elc file with set_montage #9309

Closed

Description

@HanBnrd

Describe the new feature or enhancement

As discussed with @rob-luke, we think it could be interesting to have the possibility to set a montage with any elc file with MNI coordinates.

Describe your proposed implementation

Given a custom elc montage file my-montage.elc with MNI coordinates standardised the same way as other existing elc files, it would be great to have an API like this:

# Detailed implementation
my_montage = mne.channels.make_standard_montage('path/to/my-montage.elc')
raw.set_montage(my_montage)

# With also the possibility to use it in one step
raw.set_montage('path/to/my-montage.elc')

Describe possible alternatives

Alternatives include having a separate function set_custom_elc_montage which takes the raw or epochs or evoked object and the montage path as arguments.

Activity

  1. agramfort commented on Apr 16, 2021

    @agramfort
    SponsorMember
  2. HanBnrd commented on Apr 16, 2021

    @HanBnrd
    Author

    raw.set_montage can already take a string as parameter. Does it do what you want?

    At the moment the string argument is only working with a list of predefined montages, so it could be useful to have also a way to provide a custom montage file.

  3. agramfort commented on Apr 17, 2021

    @agramfort
    SponsorMember
  4. HanBnrd commented on Apr 17, 2021

    @HanBnrd
    Author

    you don't foresee a clash in API?

    It could maybe check if there is a file with the name being the string argument and if not check in the built in montages or the other way around. But maybe a separate function could be a safer option.

  5. larsoner commented on Apr 17, 2021

    @larsoner
    Member

    I'm not worried about the extremely rare corner case where someone has a filename that matches one of our extensionless built-in names. If someone ever hits this the workaround is easy, just pass './whatever' instead of 'whatever'.

  6. agramfort commented on Apr 19, 2021

    @agramfort
    SponsorMember
  7. HanBnrd commented on Apr 22, 2021

    @HanBnrd
    Author

    Hi, after diving deeper into this I realised that there is already the function read_custom_montage doing this, sorry for not seeing this earlier.

    It is not working directly with set_montage('path/to/file.elc') but like this:

    montage = mne.channels.read_custom_montage('path/to/file.elc')
    raw.set_montage(montage)

    which is good enough I think. So I'm closing this issue.

  8. rob-luke commented on Apr 22, 2021

    @rob-luke
    Member

    Great catch. Maybe worth adding to the new tutorial too?

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