.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/datasets/plot_vertex.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_datasets_plot_vertex.py: ================ Plot Vertex Data ================ This plots example vertex data onto an example subject, S1, onto a flatmap using quickflat. In order for this to run, you have to have a flatmap for this subject in the pycortex filestore. The cortex.Vertex object is instantiated with a numpy array of the same size as the total number of vertices in that subject's flatmap. Each pixel is colored according to the value given for the nearest vertex in the flatmap. Instead of the random test data, you can replace this with any array that is the length of all of the vertices in the subject. Additionally, if you create a Vertex object using only the number of vertices that exists in the left hemisphere of the brain, the right hemisphere is filled in with zeros. .. GENERATED FROM PYTHON SOURCE LINES 21-55 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_vertex_001.png :alt: plot vertex :srcset: /auto_examples/datasets/images/sphx_glr_plot_vertex_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_vertex_002.png :alt: plot vertex :srcset: /auto_examples/datasets/images/sphx_glr_plot_vertex_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5153): CRITICAL **: 01:27:09.888: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5153): CRITICAL **: 01:27:09.888: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5153): CRITICAL **: 01:27:09.888: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5156): CRITICAL **: 01:27:10.878: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5156): CRITICAL **: 01:27:10.878: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5156): CRITICAL **: 01:27:10.878: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import cortex.polyutils import numpy as np np.random.seed(1234) import matplotlib.pyplot as plt subject = 'S1' # In order to get the number of vertices in this subject's cortical surface # we have to load in their surfaces and get the number of points in each surfs = [cortex.polyutils.Surface(*d) for d in cortex.db.get_surf(subject, "fiducial")] # This is the total number of vertices in both hemispheres combined num_verts = surfs[0].pts.shape[0] + surfs[1].pts.shape[0] # Creating a random dataset with one entry for each vertex test_data = np.random.randn(num_verts) # This creates a Vertex object for our subject and test dataset vertex_data = cortex.Vertex(test_data, subject) # And now we can display it on a flatmap cortex.quickshow(vertex_data) plt.show() # We can also plot just the left hemisphere data numl = surfs[0].pts.shape[0] # This creates a Vertex object with an array only as long as the number of # vertices in the left hemisphere, and the right hemisphere will be filled # in with zeros vertex_data_left = cortex.Vertex(test_data[:numl], subject) cortex.quickshow(vertex_data_left) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.388 seconds) .. _sphx_glr_download_auto_examples_datasets_plot_vertex.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_vertex.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_vertex.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_