Skip to content

Adding a reference does not work after a montage has been set #5619

@cbrnr

Description

@cbrnr

The order in which you perform assigning a montage and adding a reference matters, which probably shouldn't be the case.

Consider the following example using the testing data from mne/io/brainvision/tests/data/test.* (the first two lines could be combined by supplying the montage argument in the call to mne.io.read_raw_brainvision):

raw = mne.io.read_raw_brainvision("test.vhdr", preload=True)
raw.set_montage("standard_1020")
raw = mne.io.add_reference_channels(raw, "T3")

This assigns the montage first and then adds a new reference channel which wasn't part of the data. This produces a RuntimeWarning: The locations of multiple reference channels are ignored (set to zero)., which results in an incorrect location of the newly added channel T3.

If instead you first add the reference channel and then set the montage, everything works as expected:

raw = mne.io.read_raw_brainvision("test.vhdr", preload=True)
raw = mne.io.add_reference_channels(raw, "T3")
raw.set_montage("standard_1020")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions