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

Alexandre Gramfort alexandre.gramfort at telecom-paristech.fr
Sun Sep 11 09:19:39 EDT 2016
Search archives:

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



On Fri, Sep 9, 2016 at 6:41 PM, Mikkel Vinding <mikkel.vinding at ki.se> wrote:
> 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.vinding at ki.se | ki.se
> ______________________________________
> Karolinska Institutet – a medical university
>
>
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>



More information about the Mne_analysis mailing list