[Mne_analysis] ica.labels_ contain None (possible bug)

Mikkel Vinding mikkel.vinding at ki.se
Fri Sep 9 12:41:39 EDT 2016
Search archives:

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>
______________________________________
Karolinska Institutet – a medical university

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160909/cea23bcc/attachment.html 


More information about the Mne_analysis mailing list