.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/quickflat/plot_make_gif.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_quickflat_plot_make_gif.py: ==================================== Animate a series of volumes as a GIF ==================================== A convenient way to compare two flat maps (e.g., prediction performance or tuning weights) is to flip back and forth between them. This example shows how to make an animated gif in which each frame is a flatmap. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default import cortex import matplotlib.pyplot as plt import numpy as np np.random.seed(1234) .. GENERATED FROM PYTHON SOURCE LINES 17-19 Create several pycortex Volumes .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: default volumes = {'first': cortex.Volume.random(subject='S1', xfmname='fullhead', vmin=-2, vmax=2, cmap="RdBu_r"), 'second': cortex.Volume.random(subject='S1', xfmname='fullhead', vmin=-2, vmax=2, cmap="RdBu_r")} .. GENERATED FROM PYTHON SOURCE LINES 24-26 Plot flat maps individually .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: default _ = cortex.quickflat.make_figure(volumes['first'], colorbar_location="right") _ = cortex.quickflat.make_figure(volumes['second'], colorbar_location="right") _ = plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/quickflat/images/sphx_glr_plot_make_gif_001.png :alt: plot make gif :srcset: /auto_examples/quickflat/images/sphx_glr_plot_make_gif_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/quickflat/images/sphx_glr_plot_make_gif_002.png :alt: plot make gif :srcset: /auto_examples/quickflat/images/sphx_glr_plot_make_gif_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5327): CRITICAL **: 01:30:14.896: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5327): CRITICAL **: 01:30:14.896: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5327): CRITICAL **: 01:30:14.896: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5332): CRITICAL **: 01:30:15.933: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5332): CRITICAL **: 01:30:15.933: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5332): CRITICAL **: 01:30:15.933: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed .. GENERATED FROM PYTHON SOURCE LINES 33-35 Generate an animated gif that switches between frames every 1.5 seconds .. GENERATED FROM PYTHON SOURCE LINES 35-39 .. code-block:: default filename = "./flatmap_comparison.gif" cortex.quickflat.make_gif(filename, volumes, frame_duration=1.5, colorbar_location="right") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5337): CRITICAL **: 01:30:19.261: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5337): CRITICAL **: 01:30:19.261: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5337): CRITICAL **: 01:30:19.262: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5341): CRITICAL **: 01:30:21.048: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5341): CRITICAL **: 01:30:21.049: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5341): CRITICAL **: 01:30:21.049: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed .. GENERATED FROM PYTHON SOURCE LINES 40-42 Display gif inline in an IPython notebook .. GENERATED FROM PYTHON SOURCE LINES 42-52 .. code-block:: default import io from IPython.display import Image stream = io.BytesIO() cortex.quickflat.make_gif(stream, volumes, frame_duration=1.5, colorbar_location="right") Image(stream.read()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5347): CRITICAL **: 01:30:23.595: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5347): CRITICAL **: 01:30:23.595: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5347): CRITICAL **: 01:30:23.595: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5351): CRITICAL **: 01:30:25.381: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5351): CRITICAL **: 01:30:25.381: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5351): CRITICAL **: 01:30:25.381: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed .. GENERATED FROM PYTHON SOURCE LINES 53-54 .. image:: ../../flatmap_comparison.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 12.570 seconds) .. _sphx_glr_download_auto_examples_quickflat_plot_make_gif.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_make_gif.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_make_gif.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_