Note
Click here to download the full example code
Save a 2D static flatmap as SVG¶
Plot a 2D static flatmap and save it as SVG file.
Some words on the `rechache` 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.
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.svg"
_ = cortex.quickflat.make_png(filename, volume, recache=False)
Total running time of the script: ( 0 minutes 4.303 seconds)