.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/datasets/plot_volume.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_volume.py: ================ Plot Volume Data ================ This plots example volume 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.Volume object is instantiated with a numpy array of the same size as the scan for this subject and transform. Instead of the random test data, you can replace this with any numpy array of the correct dimensionality. By changing the parameters vmin and vmax, you get thresholded data, as shown in the colorbar for the figure. If you have NaN values within your array, those voxels show up transparent on the brain. .. GENERATED FROM PYTHON SOURCE LINES 20-49 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume_001.png :alt: plot volume :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume_002.png :alt: plot volume :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume_003.png :alt: plot volume :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5140): CRITICAL **: 01:27:03.098: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5140): CRITICAL **: 01:27:03.098: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5140): CRITICAL **: 01:27:03.098: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5144): CRITICAL **: 01:27:04.129: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5144): CRITICAL **: 01:27:04.129: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5144): CRITICAL **: 01:27:04.129: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5147): CRITICAL **: 01:27:05.165: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5147): CRITICAL **: 01:27:05.165: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5147): CRITICAL **: 01:27:05.165: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import numpy as np np.random.seed(1234) import matplotlib.pyplot as plt subject = 'S1' xfm = 'fullhead' # Creating a random dataset that is the shape for this transform with one # entry for each voxel test_data = np.random.randn(31, 100, 100) # This creates a Volume object for our test dataset for the given subject # and transform vol_data = cortex.Volume(test_data, subject, xfm) cortex.quickshow(vol_data) plt.show() # Can also alter the minimum and maximum values shown on the colorbar vol_data_thresh = cortex.Volume(test_data, subject, xfm, vmin=-1, vmax=1) cortex.quickshow(vol_data_thresh) plt.show() # If you have NaN values, those voxels show up transparent on the brain test_data[10:15, :, :] = np.nan vol_data_nan = cortex.Volume(test_data, subject, xfm) cortex.quickshow(vol_data_nan) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.435 seconds) .. _sphx_glr_download_auto_examples_datasets_plot_volume.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_volume.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_volume.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_