Save a 2D static flatmap as PNG

Plot a 2D static flatmap and save it as PNG file.

Some words on the `recache` parameter before we begin:

Setting the recache=True parameter recaches the flatmap cache located in <filestore>/<subject>/cache. By default intermediate steps for a flatmap are cached after the first generation to speed up the process for the future. If any of the intermediate steps changes, the flatmap generation may fail. recache=True will load these intermediate steps new. This can be helpful if you think there is no reason that the quickflat.make_figure to fail but it nevertheless fails. Try it, it’s magic!

The default background is set to be a transparent image. If you want to change that use the parameter bgcolor.

plot make png

Out:

Failed to get connection
** (inkscape:5233): CRITICAL **: 01:27:59.628: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed
** (inkscape:5233): CRITICAL **: 01:27:59.628: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed
** (inkscape:5233): CRITICAL **: 01:27:59.628: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed
Failed to get connection
** (inkscape:5238): CRITICAL **: 01:28:00.663: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed
** (inkscape:5238): CRITICAL **: 01:28:00.663: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed
** (inkscape:5238): CRITICAL **: 01:28:00.663: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed

import cortex
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(1234)

# Create a random pycortex Volume
volume = cortex.Volume.random(subject='S1', xfmname='fullhead')

# Plot a flatmap with the data projected onto the surface
_ = cortex.quickflat.make_figure(volume)
plt.show()

# Save this flatmap
filename = "./my_flatmap.png"
_ = cortex.quickflat.make_png(filename, volume, recache=False)

Total running time of the script: ( 0 minutes 4.446 seconds)

Gallery generated by Sphinx-Gallery