.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/datasets/plot_volume2D.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_volume2D.py: =================== Plot 2D 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.Volume2D object is instantiated with two numpy arrays of the same size as the scan for this subject and transform. Here, there are two datasets that have been generated to look like gradients across the brain, but you can replace these with any numpy arrays of the correct dimensionality. The colormap used in the first two flatmaps is .. image:: ../../../filestore/colormaps/RdBu_covar.png As with a 1D Volume, you can change vmin and vmax to threshold, but here they can be manipulated individually for the two arrays. You can also change the colormap when creating a new 2D volume. The colormap used in the last flatmap is .. image:: ../../../filestore/colormaps/GreenWhiteBlue_2D.png .. GENERATED FROM PYTHON SOURCE LINES 28-62 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume2D_001.png :alt: plot volume2D :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume2D_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume2D_002.png :alt: plot volume2D :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume2D_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_volume2D_003.png :alt: plot volume2D :srcset: /auto_examples/datasets/images/sphx_glr_plot_volume2D_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/runner/work/pycortex/pycortex/cortex/quickflat/utils.py:497: UserWarning: Trying to register the cmap 'RdBu_covar' which already exists. cm.register_cmap(dataview.cmap, cmap) Failed to get connection ** (inkscape:5164): CRITICAL **: 01:27:16.461: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5164): CRITICAL **: 01:27:16.461: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5164): CRITICAL **: 01:27:16.461: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed /home/runner/work/pycortex/pycortex/cortex/quickflat/utils.py:497: UserWarning: Trying to register the cmap 'RdBu_covar' which already exists. cm.register_cmap(dataview.cmap, cmap) Failed to get connection ** (inkscape:5168): CRITICAL **: 01:27:17.574: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5168): CRITICAL **: 01:27:17.574: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5168): CRITICAL **: 01:27:17.574: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5171): CRITICAL **: 01:27:18.683: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5171): CRITICAL **: 01:27:18.683: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5171): CRITICAL **: 01:27:18.683: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import numpy as np import matplotlib.pyplot as plt subject = "S1" xfm = "fullhead" # Creating two different test datasets that are both the same shape as this # transform with one entry for each voxel # The matrices have just been reordered in different ways so that they make # gradients across the brain in different directions test_data1 = np.arange(31 * 100 * 100).reshape((31, 100, 100), order='C') test_data2 = np.arange(31 * 100 * 100).reshape((31, 100, 100), order='F') # This creates a 2D Volume object for both of our test datasets for the given # subject and transform vol_data = cortex.Volume2D(test_data1, test_data2, subject, xfm) cortex.quickshow(vol_data, with_colorbar=False) plt.show() # You can alter the minimum and maximum values shown on the colorbar and this # can be done separately for the two different datasets vol_data = cortex.Volume2D(test_data1, test_data2, subject, xfm, vmin=np.mean(test_data1), vmax=np.max(test_data1), vmin2=np.min(test_data2), vmax2=np.mean(test_data2)) cortex.quickshow(vol_data, with_colorbar=False) plt.show() # To change the colormap, you have to create a new Volume2D object vol_color = cortex.Volume2D(test_data1, test_data2, subject, xfm, cmap="GreenWhiteBlue_2D") cortex.quickshow(vol_color, with_colorbar=False) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.264 seconds) .. _sphx_glr_download_auto_examples_datasets_plot_volume2D.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_volume2D.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_volume2D.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_