Skip to content

add_channels should update _orig_units attribute #11119

Closed

Description

@sappelhoff

add_channels should add the unit the channel is in to raw._orig_units.

This came up in:

cc @hoechenberger

# %%
# Imports
import mne
import numpy as np

# Load data for testing
data_path = mne.datasets.testing.data_path()
vhdr = data_path / "montage" / "bv_dig_test.vhdr"
raw = mne.io.read_raw_brainvision(vhdr, preload=True)

# This has 67 units (as many as there are channels)
assert len(raw._orig_units) == len(raw.ch_names)

# Create a new channel and add it
new_info = mne.create_info(
    ch_names=["NewChannel"], sfreq=raw.info["sfreq"], ch_types=["gsr"]
)
new_data = np.atleast_2d(np.array([2.1e-6] * len(raw.times)))
new_channel = mne.io.RawArray(data=new_data, info=new_info, first_samp=raw.first_samp)
raw.add_channels([new_channel], force_update_info=True)

# The units of the new channel are not added to _orig_units
msg = f"failed: {len(raw._orig_units)} != {len(raw.ch_names)}"
assert len(raw._orig_units) == len(raw.ch_names), msg

Activity

  1. larsoner commented on Aug 30, 2022

    @larsoner
    Member

    I can try to look tomorrow

  2. agramfort commented on Aug 31, 2022

    @agramfort
    SponsorMember

    why not but it means we need to be consistent that the _orig_units attribute is a part the API of Raw. So I feel is not an isolated change.

  3. sappelhoff commented on Sep 13, 2022

    @sappelhoff
    MemberAuthor

    @agramfort you mean making it a public attribute? I think I'd keep it private and just include this small fix

  4. added this to the 1.2 milestone on Sep 13, 2022
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions