.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_applications/plot_02_celegans.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 or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_07_applications_plot_02_celegans.py: The frontal neural network of C. elegans ======================================== The NOCAD software paper analysed the 131 frontal neurons of *C. elegans* (positions and labels from Kaiser and Hilgetag). The network has 764 connections; its condensation is a bow tie: a few source neurons feed one large strongly connected core, which feeds a few sinks. Maximum matching, path finding and the exact minimum agree on twelve driver neurons; the neurons' anatomical positions show where control enters and how far it has to travel. .. GENERATED FROM PYTHON SOURCE LINES 14-16 Design and hierarchy -------------------- .. GENERATED FROM PYTHON SOURCE LINES 16-36 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import nocad from nocad.datasets import load_network from nocad.viz import plot_depth_map, plot_scc_hierarchy net = load_network("celegans131") # [snippet:celegans] design = nocad.InputOutputDesign().fit(net.adj) cond = nocad.condensation(net.adj) print(f"{net.n_states} neurons, {net.n_edges} connections, {cond.n_components} components, " f"largest {cond.sizes.max()}") print("driver neurons:", [net.labels[v] for v in design.driver_nodes_]) print("sensor neurons:", [net.labels[v] for v in design.sensor_nodes_]) # [/snippet:celegans] fig, ax = plt.subplots(figsize=(7.4, 5.6)) plot_scc_hierarchy(net.adj, design.driver_nodes_, design.sensor_nodes_, ax=ax, labels=False, node_size=60, legend=False, title="condensation of the frontal network: a bow tie") .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_celegans_001.png :alt: condensation of the frontal network: a bow tie :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_celegans_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 131 neurons, 764 connections, 22 components, largest 109 driver neurons: ['ASJL', 'RMEL', 'RMER', 'SIADL', 'SIADR', 'SIAVL', 'SIAVR', 'SIBDL', 'SIBDR', 'SIBVL', 'SIBVR', 'SMDDR'] sensor neurons: ['AINL', 'ASHL', 'ASIR', 'ASJR', 'AWAL', 'IL2DL', 'IL2DR', 'IL2L', 'SIBDL', 'URADR', 'URBL', 'URYDL'] .. GENERATED FROM PYTHON SOURCE LINES 37-39 Control depth on the anatomical layout -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python pos = (net.positions - net.positions.mean(axis=0)) * np.array([60.0, 160.0]) fig, ax = plt.subplots(figsize=(9.0, 4.2)) plot_depth_map(net.adj, design.driver_nodes_, pos=pos, ax=ax, labels=False, node_size=55, regions=False, title="control depth of the neurons (anatomical positions)") .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_celegans_002.png :alt: control depth of the neurons (anatomical positions) :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_celegans_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 45-47 Parameter study: methods and roles ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 47-53 .. code-block:: Python for method in ("matching", "signal_sharing", "path_finding", "minimum"): d = nocad.InputOutputDesign(method).fit(net.adj) print(f"{method:15s} inputs={d.n_inputs_:2d} drivers={d.n_drivers_:2d} sensors={d.n_sensors_:2d}") roles = nocad.node_roles(net.adj) print({r: int((roles == r).sum()) for r in ("critical", "intermittent", "redundant")}) .. rst-class:: sphx-glr-script-out .. code-block:: none matching inputs=12 drivers=12 sensors=12 signal_sharing inputs=12 drivers=12 sensors=12 path_finding inputs=12 drivers=12 sensors=12 minimum inputs=12 drivers=12 sensors=12 {'critical': 10, 'intermittent': 30, 'redundant': 91} .. GENERATED FROM PYTHON SOURCE LINES 54-57 **Take-away.** In the frontal network the inputs are dictated by its source neurons and the outputs by its sinks; the large core is controlled through them in at most a few steps. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.896 seconds) .. _sphx_glr_download_auto_examples_07_applications_plot_02_celegans.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/nocad/main?urlpath=lab/tree/notebooks/auto_examples/07_applications/plot_02_celegans.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_celegans.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_celegans.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_celegans.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_