ica.labels_ contain None (possible bug)

Hi MNE list

I encountered an error whan I ran ICA decomposition, then saved the components to a file using ica.save(?myfilename-ica.fif) in one script, and then loaded it in another script using mne.preprocessing.read_ica with the aim to remove ECG and EOG related components (similar to how it is shown in the tutorial). When I try to use find_bads_ecg(?) I get an error saying: ??NoneType? object does not support item assignment? (see full error message below). The problem is that the value of ica.labels_ is None and the labelling of ECG component cannot be appended due to different datatypes ? at least that is what appears to be the problem as far as I can tell. I only write to inform that there might be a bug in the way ICA components are saved to- or read from file. By adding ica.labels_ = dict() right after loading the component file the problem is solved.

Code:
ica = read_ica(ica_fname)
#ica.labels_ = dict() #Adding this solves the problem
raw_single_file = Raw(in_fname, preload=True)

ecg_epochs = create_ecg_epochs(raw_single_file)
ecg_inds, ecg_scores = ica.find_bads_ecg(ecg_epochs, verbose=True) #This gives an error!

Output:
Reconstructing ECG signal from Magnetometers
Traceback (most recent call last):

File "<ipython-input-79-442f837a4d4e>", line 1, in <module>
ecg_inds, ecg_scores = ica.find_bads_ecg(ecg_epochs, verbose=True)

File "<string>", line 2, in find_bads_ecg

File "/home/mikkel/anaconda3/envs/default/lib/python2.7/site-packages/mne/utils.py", line 627, in verbose
return function(*args, **kwargs)

File "/home/mikkel/anaconda3/envs/default/lib/python2.7/site-packages/mne/preprocessing/ica.py", line 968, in find_bads_ecg
self.labels_['ecg'] = list(ecg_idx)

TypeError: 'NoneType' object does not support item assignment

I am running mne-python using anaconda on a linux machine if that is of interest.

Best regards
Mikkel

Mikkel C. Vinding | Ph.D. | Post doc
NatMEG - The National Research Facility for Magnetoencephalography Department of Clinical Neuroscience | Karolinska Institutet
171 77 Stockholm | Nobels v?g 9, office D313
Phone: +46 8 524 833 33 Email: mikkel.<mailto:mikkel at vinding@ki.se>vinding at ki.se <mailto:mikkel.vinding at ki.se> | ki.se<http://ki.se/ki/jsp/polopoly.jsp;jsessionid=aMdk8ad4iRL6OYOdFn?l=en&d=130>

hi Mikkel,

I cannot replicate the bug with:

https://gist.github.com/agramfort/638b9a1d38196f6bdd03cb8bace94b8e

can you provide a full gist to replicate?

also please use github issues for such problems with mne python code:

https://github.com/mne-tools/mne-python/issues

Alex