Set montage info channel name inconsistency error

Hi everyone,

I am importing EEG data with BrainVision format. Originally, the names of the recorded channels are saved as numbers. I match the names to the preferred names of channels. I then try to set the montage but I get the following error: “info channel name inconsistency detected, please notify mne-python developers”. Any help regarding resolving this issue is appreciated. Here is my code:

raw = mne.io.read_raw_brainvision(name, preload=True, verbose=False)
raw.info['line_freq'] = 60.

#Drop Acceleration Channels
raw.drop_channels(["x_dir", "y_dir", "z_dir"])

#Add reference channel
raw.add_reference_channels('FCz')

#Add channel names
Chan_Names= ['Fp1', 'Fz', 'F3', 'F7', 'FT9', 'FC5', 'FC1', 'C3',
             'T7', 'TP9', 'CP5', 'CP1', 'Pz', 'P3', 'P7', 'O1',
             'Oz', 'O2', 'P4', 'P8', 'TP10', 'CP6', 'CP2', 'Cz',
             'C4', 'T8', 'FT10', 'FC6', 'FC2', 'F4', 'F8','Fp2']
for i in range (0, 32):
    raw.ch_names[i] = Chan_Names[i]

#Set montage
montage = mne.channels.make_standard_montage('easycap-M1')
raw.set_montage("easycap-M1")

Hi @yvaghei, you shouldn’t change the contents of raw.ch_names - use raw.rename_channels() instead.

2 Likes

cc @cbrnr – I’d be +1 for making .ch_names a read-only property, WDYT?

yes! I was on the verge of proposing the same :slight_smile:

Why not, although what additional checks does rename_channels perform? I always like to be able to directly manipulate something instead of using set_* functions.

In addition, how do we handle raw.info["ch_names"]?

I’m not a fan of setters either, but was merely looking to quickly get an improvement here that won’t trigger 4 weeks of discussion :sweat_smile::sweat_smile::sweat_smile:

Probably at least checks that channel names are unique :slight_smile:

btw this always confuses me when you say this, because to me, a property can have a “setter” via the “@setter” decorator that behaves transparently to the user … I guess what you mean is a dedicated set_* function, yes?

Exactly. Checking for uniqueness is a valid point, but didn’t you say it should be read-only?

How do we handle the duplication in info? I’d only keep that one around and agent rid of the raw property.

1 Like

Let’s move this to GitHub :slight_smile:

This worked, Thanks so much.