[Mne_analysis] How to save figures in a loop without displaying them?

Mainak Jas mainakjas at gmail.com
Mon Aug 18 06:19:54 EDT 2014
Search archives:

Great! The bug with the show parameter is now fixed. With the development
version, you should be able to simply do

fig = ica.plot_scores(scores, exclude=eog_inds, show=False)
plt.close(fig)

and this should not open a figure for the specified plot.

Mainak

On Mon, Aug 18, 2014 at 11:06 AM, Maria Hakonen <maria.hakonen at gmail.com>
wrote:

> Hi all,
>
> I moved matplotlib.use('Agg') before all imported modules but matplotlib
> as follows and this seems to run without displaying the figures:
>
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
>
> import numpy as np
> import mne
> from mne.io import Raw
> import os
> from mne.preprocessing import ICA, create_eog_epochs
>
> This doesn't work:
> import matplotli
>
> import numpy as np
> import mne
> from mne.io import Raw
> import os
> from mne.preprocessing import ICA, create_eog_epochs
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
>
> Regards,
> Maria
>
>
> 2014-08-18 2:04 GMT+03:00 Teon Brooks <teon.brooks at gmail.com>:
>
> Hey everyone,
>>
>> I was looking at the code for plot_ica_scores and there is currently no
>> 'show' kwarg. Also there's no conditional statement related to this as
>> well. I just submitted a PR to address this.
>>
>> -teon
>>
>>
>> On Sun, Aug 17, 2014 at 10:50 PM, Mainak Jas <mainakjas at gmail.com> wrote:
>>
>>> Hi Maria,
>>>
>>> On Sun, Aug 17, 2014 at 7:27 PM, Maria Hakonen <maria.hakonen at gmail.com>
>>> wrote:
>>>
>>>> I have set the show parameter false as follows:
>>>>  ica.plot_sources(epochttps://
>>>> mail.google.com/mail/u/0/?tab=wm#label/m-lists%2FMNE_analysis/147e00e5cb0f01d8hs_bp,eog_inds,show=False
>>>> )
>>>>
>>>>
>>>
>>>> However, the figures are still shown. I wonder what could be wrong
>>>> there?
>>>>
>>>
>>> It seems to me that you intend to use exclude=eog_inds but since you do
>>> not pass it as a keyword argument, it might get interpreted differently and
>>> give unexpected results. Is epochs_bp an instance of Epochs? I raised an
>>> issue on github: https://github.com/mne-tools/mne-python/issues/1516 to
>>> fix the problem with show=False. You should install the development version
>>> and use show=False once this is fixed.
>>>
>>> Mainak
>>>
>>>
>>>
>>>> -Maria
>>>>
>>>>
>>>>
>>>> 2014-08-17 16:26 GMT+03:00 Alexandre Gramfort <
>>>> alexandre.gramfort at telecom-paristech.fr>:
>>>>
>>>> hi Maria,
>>>>>
>>>>> > Thanks for the answer.
>>>>> > However, the script seems to run very long time if ipython is started
>>>>> > without --pylab qt flag. I wonder if there is any other ways to save
>>>>> the
>>>>> > figures in the loop without displaying them?
>>>>>
>>>>> most viz functions have a show parameter that is true by default. Set
>>>>> it
>>>>> to false to avoid showing the figures.
>>>>>
>>>>> HTH
>>>>> Alex
>>>>> _______________________________________________
>>>>> 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.
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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.
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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.
>>>
>>>
>>
>> _______________________________________________
>> 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.
>>
>>
>
> _______________________________________________
> 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/20140818/9c266acb/attachment.html 


More information about the Mne_analysis mailing list