.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_load_destrieux_left_hemisphere_gyri.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_load_destrieux_left_hemisphere_gyri.py: Loading and Querying the Destrieux et al. Atlas' Left Hemisphere ======================================================================== Uploading the Destrieux regions NeuroLang and executing a simple query. .. GENERATED FROM PYTHON SOURCE LINES 10-21 .. code-block:: default import warnings warnings.filterwarnings("ignore") from matplotlib import pyplot as plt import nibabel as nib from nilearn import datasets, plotting from neurolang.frontend import NeurolangDL .. GENERATED FROM PYTHON SOURCE LINES 22-23 Initialise the NeuroLang probabilistic engine. .. GENERATED FROM PYTHON SOURCE LINES 23-27 .. code-block:: default nl = NeurolangDL() .. GENERATED FROM PYTHON SOURCE LINES 28-29 Load the Destrieux example from nilearn as a fact list .. GENERATED FROM PYTHON SOURCE LINES 29-40 .. code-block:: default atlas_destrieux = datasets.fetch_atlas_destrieux_2009() atlas_labels = { label: str(name.decode('utf8')) for label, name in atlas_destrieux['labels'] } nl.add_atlas_set('destrieux_atlas', atlas_labels, nib.load(atlas_destrieux['maps'])) .. rst-class:: sphx-glr-script-out .. code-block:: none Dataset created in /home/circleci/nilearn_data/destrieux_2009 Downloading data from https://www.nitrc.org/frs/download.php/11942/destrieux2009.tgz ... ...done. (0 seconds, 0 min) Extracting data from /home/circleci/nilearn_data/destrieux_2009/2a2e5a5707983d509d9319c692c867ab/destrieux2009.tgz..... done. destrieux_atlas: typing.AbstractSet[typing.Tuple[str, neurolang.regions.ExplicitVBR]] = ('Background', Region(VBR= affine:[[ 2. 0. 0. -76.] [ 0. 2. 0. -109.] [ 0. 0. 2. -64.] [ 0. 0. 0. 1.]], voxels:[[ 0 0 0] [ 0 0 1] [ 0 0 2] ... [75 92 73] [75 92 74] [75 92 75]])) ... .. GENERATED FROM PYTHON SOURCE LINES 41-42 Add utility function .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: default @nl.add_symbol def startswith(prefix: str, s: str) -> bool: return s.startswith(prefix) .. GENERATED FROM PYTHON SOURCE LINES 49-51 Query all left hemisphere regions superior to the temporal superior sulucs and anterior to the central sulcus .. GENERATED FROM PYTHON SOURCE LINES 51-61 .. code-block:: default with nl.scope as e: e.on_left_hemisphere[e.x] = ( e.destrieux_atlas(e.l, e.x) & e.startswith('L S', e.l) ) result = nl.query((e.r,), e.on_left_hemisphere(e.r)) .. GENERATED FROM PYTHON SOURCE LINES 62-63 Visualise results .. GENERATED FROM PYTHON SOURCE LINES 63-72 .. code-block:: default subplots = plt.subplots( nrows=len(result), ncols=1, figsize=(10, 5 * len(result)) )[1] for (r, subplot) in zip(result, subplots): region = r[0] plotting.plot_roi(region.spatial_image(), axes=subplot) .. image-sg:: /auto_examples/images/sphx_glr_plot_load_destrieux_left_hemisphere_gyri_001.png :alt: plot load destrieux left hemisphere gyri :srcset: /auto_examples/images/sphx_glr_plot_load_destrieux_left_hemisphere_gyri_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 53.340 seconds) .. _sphx_glr_download_auto_examples_plot_load_destrieux_left_hemisphere_gyri.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_load_destrieux_left_hemisphere_gyri.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_load_destrieux_left_hemisphere_gyri.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_