
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/01_atlases_and_parcellations/000_accessing_atlases.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_01_atlases_and_parcellations_000_accessing_atlases.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_01_atlases_and_parcellations_000_accessing_atlases.py:


.. _atlases:

Selecting a preconfigured atlas from an instance table
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`siibra` provides a table of preconfigured atlas objects of
different species.
Atlas objects are very simple structures: They are mostly used to group
a set of preconfigured parcellations and reference spaces by species.
They do not provide much further functionality on their own.

.. GENERATED FROM PYTHON SOURCE LINES 30-31

We start by loading the library

.. GENERATED FROM PYTHON SOURCE LINES 31-33

.. code-block:: Python

    import siibra








.. GENERATED FROM PYTHON SOURCE LINES 35-41

Preconfigured atlas objects are accessible via the instance table `siibra.atlases`,
which is a shortcut to `siibra.Atlas.registry()`.
Instance tables are simple container structures, populated with preconfigured objects
when accessed for the first time. The first call will require an internet connection to
retrieve the initial configuration information. After initial access, the configuration
information will cached on the local disk and can be accessed offline.

.. GENERATED FROM PYTHON SOURCE LINES 41-43

.. code-block:: Python

    print(type(siibra.atlases))





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    <class 'siibra.commons.InstanceTable'>




.. GENERATED FROM PYTHON SOURCE LINES 44-54

siibra uses instance tables not only for atlases, but also for parcellations
(`siibra.parcellations`), reference spaces (`siibra.spaces`) or feature
modalities (`siibra.modalities`), as will be shown in later code examples.

Objects stored in a siibra instance table can be accessed in
different ways:

 1. In "list-style": by iterating over all objects or using the index operator "[]"
 2. By fuzzy keyword matching via the get() function or index operator
 3. By tab-completion of their "keys"

.. GENERATED FROM PYTHON SOURCE LINES 54-58

.. code-block:: Python


    # We can print the keys of all predefined atlas objects in the registry:
    siibra.atlases.keys





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    ['MULTILEVEL_HUMAN_ATLAS', 'PRERELEASE_MARMOSET_ATLAS', 'MONKEY_ATLAS', 'ALLEN_MOUSE_COMMON_COORDINATE_FRAMEWORK_V3', 'WAXHOLM_SPACE_ATLAS_OF_THE_SPRAGUE_DAWLEY_RAT_BRAIN']



.. GENERATED FROM PYTHON SOURCE LINES 59-62

The keys can be used to select atlas object by autocompletion
when you hit <TAB>. This makes it convenient to find the right name
in an interactive shell.

.. GENERATED FROM PYTHON SOURCE LINES 62-65

.. code-block:: Python

    atlas = siibra.atlases.MULTILEVEL_HUMAN_ATLAS
    atlas





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <Atlas(identifier='juelich/iav/atlas/v1.0.0/1', name='Multilevel Human Atlas', species='Homo sapiens')>



.. GENERATED FROM PYTHON SOURCE LINES 66-68

We can also select an atlas by specifying the key as a string
in the get() method:

.. GENERATED FROM PYTHON SOURCE LINES 68-70

.. code-block:: Python

    siibra.atlases.get("MULTILEVEL HUMAN ATLAS")





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <Atlas(identifier='juelich/iav/atlas/v1.0.0/1', name='Multilevel Human Atlas', species='Homo sapiens')>



.. GENERATED FROM PYTHON SOURCE LINES 71-74

More importantly, we can use an arbitrary set of words
matching the name or key of atlas. This is usually the simplest way
to select from a Registry. It will fail if no unique match is found.

.. GENERATED FROM PYTHON SOURCE LINES 74-76

.. code-block:: Python

    siibra.atlases.get('human')





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <Atlas(identifier='juelich/iav/atlas/v1.0.0/1', name='Multilevel Human Atlas', species='Homo sapiens')>



.. GENERATED FROM PYTHON SOURCE LINES 77-79

Of course, as in a list, we can also iterate over the objects in the
instance table or use the index operator to fetch an objects by its position:

.. GENERATED FROM PYTHON SOURCE LINES 79-83

.. code-block:: Python

    for atlas in siibra.atlases:
        print(atlas.name)
    print(siibra.atlases[0])





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Multilevel Human Atlas
    [PRERELEASE] Marmoset Atlas
    Monkey Atlas
    Allen Mouse Common Coordinate Framework v3
    Waxholm Space atlas of the Sprague Dawley rat brain
    Multilevel Human Atlas




.. GENERATED FROM PYTHON SOURCE LINES 84-87

Fuzy string matching also works in the index operator.
For legibility however, we typically prefer the "get()" form
in our code examples.

.. GENERATED FROM PYTHON SOURCE LINES 87-89

.. code-block:: Python

    siibra.atlases['human']





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <Atlas(identifier='juelich/iav/atlas/v1.0.0/1', name='Multilevel Human Atlas', species='Homo sapiens')>



.. GENERATED FROM PYTHON SOURCE LINES 90-91

An atlas has a range of properties and functions, for example is linked to a species:

.. GENERATED FROM PYTHON SOURCE LINES 91-94

.. code-block:: Python

    atlas = siibra.atlases.WAXHOLM_SPACE_ATLAS_OF_THE_SPRAGUE_DAWLEY_RAT_BRAIN
    atlas.species





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    Species: Rattus norvegicus



.. GENERATED FROM PYTHON SOURCE LINES 95-97

Furthermore, an atlas provides its own registries of supported spaces and parcellations.
We will cover these in the next examples.

.. GENERATED FROM PYTHON SOURCE LINES 97-98

.. code-block:: Python

    atlas.spaces.keys




.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    ['WAXHOLM_SPACE_OF_THE_SPRAGUE_DAWLEY_V1_01']




.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 9.602 seconds)

**Estimated memory usage:**  257 MB


.. _sphx_glr_download_examples_01_atlases_and_parcellations_000_accessing_atlases.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: 000_accessing_atlases.ipynb <000_accessing_atlases.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: 000_accessing_atlases.py <000_accessing_atlases.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: 000_accessing_atlases.zip <000_accessing_atlases.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
