.. 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:: Python 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:: Python 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:: Python atlas_destrieux = datasets.fetch_atlas_destrieux_2009() atlas_labels = { label: str(name) for label, name in atlas_destrieux['labels'] } nl.add_atlas_set('destrieux_atlas', atlas_labels, nib.load(atlas_destrieux['maps'])) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Add utility function .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python @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:: Python 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:: Python 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) .. _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-jupyter :download:`Download Jupyter notebook: plot_load_destrieux_left_hemisphere_gyri.ipynb ` .. 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-zip :download:`Download zipped: plot_load_destrieux_left_hemisphere_gyri.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_