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

Denis-Alexander Engemann denis.engemann at gmail.com
Sun Aug 17 15:35:52 EDT 2014
Search archives:

Hi Maria,


On Sun, Aug 17, 2014 at 9:18 PM, Maria Hakonen <maria.hakonen at gmail.com>
wrote:

> Hi,
>
> I tried to activate Agg by adding matplotlib.use('Agg') in my code. Before
> it I have imported:
>
>
matplotlib.use('Agg') must be importet before


> import numpy as np
> import mne
> from mne.io import Raw
> import os
> from mne.preprocessing import ICA, create_eog_epochs
> import matplotlib
>

the line below


> import matplotlib.pyplot as plt
>
>
can you confirm this is the case?


>  I also added plt.close('all') at the end of the code.
> I started python without --pylab qt flag (i.e. typing ipython).
>
> However, I think that Agg is not activated because the script still plots
> the figures and waits until the figure is closed.
>
> -Maria
>
>
> 2014-08-17 19:32 GMT+03:00 Denis-Alexander Engemann <
> denis.engemann at gmail.com>:
>
> Maria, does this happen for all plots that you try not to show? Might be a
>> bug in that particular function.
>>
>> Btw. what did you mean when you said the script is running very long time?
>> You mean it hangs (because it's waiting for you to close the figures)?
>> Have you been able to activate the 'Agg' silent backend using the lines I
>> suggested?
>>
>> -Denis
>>
>> On Sun, Aug 17, 2014 at 6:27 PM, Maria Hakonen <maria.hakonen at gmail.com>
>> wrote:
>>
>>> I have set the show parameter false as follows:
>>>  ica.plot_sources(epochs_bp,eog_inds,show=False)
>>>
>>> However, the figures are still shown. I wonder what could be wrong there?
>>>
>>> -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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140817/6ca58b15/attachment.html 


More information about the Mne_analysis mailing list