[Mne_analysis] Mne_analysis Digest, Vol 117, Issue 3

Alexandre Gramfort alexandre.gramfort at inria.fr
Tue Oct 3 05:54:22 EDT 2017
Search archives:

Dear Dirk,

can you share privately the 2 -epo.fif files you're trying to concatenate?

thanks
Alex

On Tue, Oct 3, 2017 at 11:50 AM, Dirk van Moorselaar <
dirkvanmoorselaar at gmail.com> wrote:

> Dear Alexandre,
>
> I probably do something wrong but it does not seem to work. In the final
> step of preprocessing I interpolate channels like this
>
> epochs.interpolate_bads(reset_bads=True, mode ='accurate’) and then save
> them as a -epo.fif file
>
> When I try to combine multiple sessions, I read in the different files and
> store them in a list, which I try to concatenate with the following code:
>
> mne.concatenate_epochs(all_epochs) #where all_epochs is a list of epoched
> data data. However, this does seem to work and gives me the following error:
>
> /Users/dirk/mne-python/mne/epochs.py in concatenate_epochs(epochs_list)
>    2737     .. versionadded:: 0.9.0
>    2738     """
> -> 2739     return _finish_concat(*_concatenate_epochs(epochs_list))
>    2740
>    2741
>
> /Users/dirk/mne-python/mne/epochs.py in _finish_concat(info, data,
> events, event_id, tmin, tmax, baseline, selection, drop_log, verbose)
>    2716         selection=selection, drop_log=drop_log, proj=False,
>    2717         on_missing='ignore', verbose=verbose)
> -> 2718     out.drop_bad()
>    2719     return out
>    2720
>
> /Users/dirk/mne-python/mne/epochs.py in drop_bad(self, reject, flat,
> verbose)
>
> /Users/dirk/mne-python/mne/utils.py in verbose(function, *args, **kwargs)
>     724         with use_log_level(verbose_level):
>     725             return function(*args, **kwargs)
> --> 726     return function(*args, **kwargs)
>     727
>     728
>
> /Users/dirk/mne-python/mne/epochs.py in drop_bad(self, reject, flat,
> verbose)
>     964             raise ValueError('reject and flat, if strings, must
> be "existing"')
>     965         self._reject_setup(reject, flat)
> --> 966         self._get_data(out=False)
>     967         return self
>     968
>
> /Users/dirk/mne-python/mne/epochs.py in _get_data(self, out, verbose)
>
> /Users/dirk/mne-python/mne/utils.py in verbose(function, *args, **kwargs)
>     724         with use_log_level(verbose_level):
>     725             return function(*args, **kwargs)
> --> 726     return function(*args, **kwargs)
>     727
>     728
>
> /Users/dirk/mne-python/mne/epochs.py in _get_data(self, out, verbose)
>    1129             good_idx = []
>    1130             n_out = 0
> -> 1131             assert n_events == len(self.selection)
>    1132             for idx, sel in enumerate(self.selection):
>    1133                 if self.preload:  # from memory
>
> AssertionError:
>
> I checked and in both epoch objects self.info[‘bads’] = [].
>
> Hope that this is helpful,
>
> Dirk
>
> On 3 Oct 2017, at 11:30, mne_analysis-request at nmr.mgh.harvard.edu wrote:
>
> Send Mne_analysis mailing list submissions to
> mne_analysis at nmr.mgh.harvard.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> or, via email, send a message with subject or body 'help' to
> mne_analysis-request at nmr.mgh.harvard.edu
>
> You can reach the person managing the list at
> mne_analysis-owner at nmr.mgh.harvard.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Mne_analysis digest..."
>
>
> Today's Topics:
>
>   1. Re: trying to use ica.plot_overlay (Alexandre Gramfort)
>   2. Concatenate preprocessed epochs (Dirk van Moorselaar)
>   3. Re: Concatenate preprocessed epochs (Alexandre Gramfort)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 3 Oct 2017 10:15:19 +0200
> From: Alexandre Gramfort <alexandre.gramfort at inria.fr>
> Subject: Re: [Mne_analysis] trying to use ica.plot_overlay
> To: Discussion and support forum for the users of MNE Software
> <mne_analysis at nmr.mgh.harvard.edu>
> Message-ID:
> <CADeotZo_27h_S08iMPO2E4DRsYLW3QN_tDfmVAH765OjxY_F4w at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> hi Megan,
>
> can you try with:
>
> ica.plot_sources(epoch_avg, exclude=[35])
>
>
> exclude should be in an int not a string.
>
>
> Alex
>
>
>
> On Tue, Oct 3, 2017 at 12:55 AM, Megan Schendel <mschendel at mrn.org> wrote:
>
> Hi all,
> I'm having trouble following the tutorial for Artifact Correction with ICA.
> http://martinos.org/mne/stable/auto_tutorials/plot_
> artifacts_correction_ica.html?highlight=ica%20fit
>
> I have epoched data where my artifact is timed to the event; I'm not
> investigating EOG artifact.  I am able to use ica.plot_properties and
> ica.plot_sources fine.  But when I try to do ica.plot_overlay, it looks
> like it's not excluding my bad component.  Since artifact is timed to
> event, average is just the averaged epochs.
>
> Attached: images from ica.plot_properties, ica.plot_sources, and
> ica.plot_overlay.  I'm not exactly clear on what picks and exclude expects
> (list, array, int?).
>
> Commands used are below.
> Thanks very much for any help!
>
> Megan
>
> random_state = 23
> n_components =50  # if float, select n_components by explained variance of
> PCA
> method = 'fastica'  # for comparison with EEGLAB try "extended-infomax"
> here
> decim = 3  # we need sufficient statistics, not all time points -> saves
> time
> reject=None # artifact is rather large, so don't want to reject it...
>
> ica = ICA(n_components=n_components, method=method,
> random_state=random_state)
> ica.fit(epochs, picks=picks_meg, decim=decim, reject=reject)
>
> ica.plot_sources(epochs)
>
> epoch_avg= epochs.average()
>
> ica.plot_sources(epoch_avg, exclude=['35'])
>
> ica.plot_properties(epochs, picks=35, psd_args={'fmax': 35.},
>                    image_args={'sigma': 1.})
>
>
> # Following lines included with input and output:
>
> In [72]: ica.plot_overlay(epoch_avg, exclude=['35'], show=False)
> Transforming to ICA space (50 components)
> /export/research/analysis/human/jstephen/shared/
> programs/python/anaconda3/lib/python3.5/site-packages/numpy/lib/arraysetops.py:375:
> FutureWarning: elementwise comparison failed; returning scalar instead, but
> in the future will perform elementwise comparison
>  mask &= (ar1 != a)
> Zeroing out 0 ICA components
> Out[72]: <matplotlib.figure.Figure at 0x7f8c469d55c0>
>
>
> In [74]: mne.__version__
> Out[74]: '0.14.dev0'
>
>
> MEG Technician
> The Mind Research Network
> 1101 Yale Blvd. NE
> Albuquerque, New Mexico 87106
>
>
> _______________________________________________
> 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.
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/
> attachments/20171003/4fe3bc5c/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Tue, 3 Oct 2017 11:25:53 +0200
> From: Dirk van Moorselaar <dirkvanmoorselaar at gmail.com>
> Subject: [Mne_analysis] Concatenate preprocessed epochs
> To: mne_analysis at nmr.mgh.harvard.edu
> Message-ID: <A4177DA8-5BB1-4E8A-845F-8553D6A405B6 at gmail.com>
> Content-Type: text/plain; charset=us-ascii
>
> Hello,
>
> I have a follow up question on a question that I asked previously.
> In my experiment I have collected data into seperate sessions, on separate
> days. I apply preprocessing (artefact detection, Ica, bad electrode
> selection) on these sessions separately and after preprocessing and spline
> interpolation to correct bad channels I would like to combine these
> separate sessions int a single -epo.fif file.
>
> To do this I use mne.concatenate_epochs(). However, this fails and gives
> me an assertion error. I understood from my previous question that to get
> this to work  I need to remove the bad channels from both sessions (even if
> we are dealing with separate channels in the two sessions) and then use
> interpolation on the concatenated data before further processing.
>
> At first sight I do not necessarily like this solution as in some cases I
> have to remove perfectly fine channels from one session, even though their
> signal was good  in that session. Is there a workaround that still allows
> you to concatenate epochs, but does not force you to have the same channels
> marked as bad in both sessions?
>
> Thank you again,
>
> Dirk
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 3 Oct 2017 11:30:14 +0200
> From: Alexandre Gramfort <alexandre.gramfort at inria.fr>
> Subject: Re: [Mne_analysis] Concatenate preprocessed epochs
> To: Discussion and support forum for the users of MNE Software
> <mne_analysis at nmr.mgh.harvard.edu>
> Message-ID:
> <CADeotZoDBnCBX+dDE2hrkatDWUeE=w6DSwUwKSDoqBRoV=pkLQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear Dirk,
>
> if you interpolate the bads so you end up with only good channels it should
> work no?
>
> Alex
>
>
> On Tue, Oct 3, 2017 at 11:25 AM, Dirk van Moorselaar <
> dirkvanmoorselaar at gmail.com> wrote:
>
> Hello,
>
> I have a follow up question on a question that I asked previously.
> In my experiment I have collected data into seperate sessions, on separate
> days. I apply preprocessing (artefact detection, Ica, bad electrode
> selection) on these sessions separately and after preprocessing and spline
> interpolation to correct bad channels I would like to combine these
> separate sessions int a single -epo.fif file.
>
> To do this I use mne.concatenate_epochs(). However, this fails and gives
> me an assertion error. I understood from my previous question that to get
> this to work  I need to remove the bad channels from both sessions (even if
> we are dealing with separate channels in the two sessions) and then use
> interpolation on the concatenated data before further processing.
>
> At first sight I do not necessarily like this solution as in some cases I
> have to remove perfectly fine channels from one session, even though their
> signal was good  in that session. Is there a workaround that still allows
> you to concatenate epochs, but does not force you to have the same channels
> marked as bad in both sessions?
>
> Thank you again,
>
> Dirk
>
>
> _______________________________________________
> 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.
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/
> attachments/20171003/51627536/attachment.html
>
> ------------------------------
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
> End of Mne_analysis Digest, Vol 117, Issue 3
> ********************************************
>
>
>
> _______________________________________________
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171003/333123ef/attachment-0001.html 


More information about the Mne_analysis mailing list