.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/quickflat/plot_thickness_nanmean.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_quickflat_plot_thickness_nanmean.py: =================================== Ignore NaN (not-a-number) values in thickness mapping =================================== By default, pycortex quickshow averages across the thickness of the cortex for each pixel in the resulting flatmap. If any of these layers contain a value of NaN (not-a-number), then the result of the average will also be Nan. This behavior might be undesirable. To avoid it, pass the argument `nanmean=True` to `cortex.quickshow` (or `cortex.quickflat.make_figure`). This will only take the mean of the non-NaN values when averaging across the thickness of cortex. A pixel will only have the value NaN if every voxel between pia and white matter has the value NaN. .. GENERATED FROM PYTHON SOURCE LINES 15-43 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/quickflat/images/sphx_glr_plot_thickness_nanmean_001.png :alt: plot thickness nanmean :srcset: /auto_examples/quickflat/images/sphx_glr_plot_thickness_nanmean_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/quickflat/images/sphx_glr_plot_thickness_nanmean_002.png :alt: plot thickness nanmean :srcset: /auto_examples/quickflat/images/sphx_glr_plot_thickness_nanmean_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Failed to get connection ** (inkscape:5358): CRITICAL **: 01:30:27.787: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5358): CRITICAL **: 01:30:27.787: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5358): CRITICAL **: 01:30:27.787: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed Failed to get connection ** (inkscape:5361): CRITICAL **: 01:30:28.963: dbus_g_proxy_new_for_name: assertion 'connection != NULL' failed ** (inkscape:5361): CRITICAL **: 01:30:28.963: dbus_g_proxy_call: assertion 'DBUS_IS_G_PROXY (proxy)' failed ** (inkscape:5361): CRITICAL **: 01:30:28.963: dbus_g_connection_register_g_object: assertion 'connection != NULL' failed | .. code-block:: default import cortex import numpy as np from matplotlib import pyplot as plt # create dataset with volume of all 1's vol = cortex.Volume.empty('S1', 'fullhead', vmin=0, vmax=2) + 1 # set 20% of the values in the dataset to NaN vol.data[np.random.rand(*vol.data.shape) > 0.8] = np.nan # plot the volume with nanmean=False # here a nan in ANY layer of the thickness mapping will result in a nan # in the final image # so this image should have many, many holes that show curvature # and all the non-hole points should have value of 1 _ = cortex.quickshow(vol, nanmean=False, with_curvature=True) plt.show() # plot the volume with nanmean=True # here there should only be a nan in the final image if EVERY layer of the # thickness mapping has a nan for the given pixel # so this image should have many fewer holes that show curvature # and, again, all the non-hole points should have value of 1 _ = cortex.quickshow(vol, nanmean=True, with_curvature=True) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.428 seconds) .. _sphx_glr_download_auto_examples_quickflat_plot_thickness_nanmean.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_thickness_nanmean.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_thickness_nanmean.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_