You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add_channels should update _orig_units attribute #11119
# %%# Importsimportmneimportnumpyasnp# Load data for testingdata_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)assertlen(raw._orig_units) ==len(raw.ch_names)
# Create a new channel and add itnew_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_unitsmsg=f"failed: {len(raw._orig_units)} != {len(raw.ch_names)}"assertlen(raw._orig_units) ==len(raw.ch_names), msg
Activity
larsoner commentedon Aug 30, 2022
I can try to look tomorrow
agramfort commentedon Aug 31, 2022
why not but it means we need to be consistent that the
_orig_unitsattribute is a part the API of Raw. So I feel is not an isolated change.sappelhoff commentedon Sep 13, 2022
@agramfort you mean making it a public attribute? I think I'd keep it private and just include this small fix