Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 32c0e55

Browse files
authored
New features related to the revision of the accompanying manuscript (#6)
* Added new features and examples (cross-validation, synapse parameter correlation) * Changed afferent section types in accordance with MorphIO (1: soma, 2: axon, 3: basal dendrite, 4: apical dendrite) * Improved readme and documentation
1 parent c34b2a0 commit 32c0e55

File tree

57 files changed

+2501
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2501
-348
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
Version 1.0.2
5+
-------------
6+
7+
- Added new features and examples (cross-validation, synapse parameter correlation)
8+
- Changed afferent section types in accordance with MorphIO (1: soma, 2: axon, 3: basal dendrite, 4: apical dendrite)
9+
- Improved readme and documentation
10+
11+
412
Version 1.0.1
513
-------------
614

@@ -17,8 +25,6 @@ Version 1.0.0
1725
Version 0.0.11.dev1
1826
-------------------
1927

20-
New Features
21-
~~~~~~~~~~~~
2228
- New synapse position re-use mode "reuse_strict" with re-use restricted to source selection
2329
- Minor fixes for empty data splits, node selection, and data logs
2430
- Additional examples
@@ -27,8 +33,6 @@ New Features
2733
Version 0.0.11.dev0
2834
-------------------
2935

30-
New Features
31-
~~~~~~~~~~~~
3236
- Added offset operation to synapse properties alteration
3337
- Minor fixes
3438

@@ -42,8 +46,6 @@ Version 0.0.10
4246
Version 0.0.10.dev4
4347
-------------------
4448

45-
New Features
46-
~~~~~~~~~~~~
4749
- Added license & copyright for open-sourcing
4850
- Added example notebook
4951
- Added version info to log files

CONTRIBUTING.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ As a contributor, here are the guidelines we would like you to follow:
77
- [Issues and Bugs](#found-a-bug)
88
- [Feature Requests](#missing-a-feature)
99
- [Submissions](#submission-guidelines)
10-
- [Development Guidelines](#development)
11-
- [Release Procedure](#release)
10+
- [How to extend](#how-to-extend)
1211

1312
# Got a Question?
1413

@@ -19,7 +18,7 @@ Please do not hesitate to raise an issue on [github project page][github].
1918
If you find a bug in the source code, you can help us by [submitting an issue](#issues)
2019
to our [GitHub Repository][github]. Even better, you can [submit a Pull Request](#pull-requests) with a fix.
2120

22-
# Missing a Feature?
21+
# Missing a Feature?
2322

2423
You can *request* a new feature by [submitting an issue](#issues) to our GitHub Repository.
2524
If you would like to *implement* a new feature, please submit an issue with a proposal for your
@@ -107,33 +106,37 @@ the main (upstream) repository:
107106

108107
[github]: https://github.com/BlueBrain/connectome-manipulator
109108

110-
# Development Environment
109+
# How to extend
111110

112-
Please make sure to install the project requirements,
113-
see the [dependencies](./README.md#dependencies) section in top README.
111+
The connectome manipulation framework has been developed using reusable primitives, such as Python classes and specific file structures for individual code modules that allow easy extension of the framework in order to add new functionality. Specifically, new types of (stochastic) models, tools for fitting them, new manipulation operations, and additional structural validation methods can be added to the code repository as outlined below:
114112

115-
This section applies to both Python versions 2 and 3.
113+
## Models
116114

117-
## Setup
115+
All models are implemented under [`/model_building/model_types.py`](connectome_manipulator/model_building/model_types.py) and are derived from an abstract base class `AbstractModel` which provides general functionality for loading/saving models and evaluating them, i.e., returning the model output given its input. Specific functionality must be implemented in a respective derived class which must define the model parameter names (`param_names`; i.e., variables storing the internal representation of the model), default parameter values (`param_defaults`), names of data frames (`data_names`; for large data elements, if any, that would be stored as associated HDF5 file), and input names (`input_names`; i.e., input variables the model output depends on). Moreover, the derived class must provide implementations of `get_model_output()` for returning the model output given its input variables, and `__str__()` for returning a string representation describing the model. When initializing a concrete model instance, values for all specified model parameters and data frames must be provided. Values for model parameters can be omitted in case default parameter values have been defined instead.
118116

119-
It is recommended to use `virtualenv` to develop in a sandbox environment:
117+
Another useful (abstract) base class `PathwayModel` exists which can be used in the same way as outlined above, but which already includes pathway-specific model parameterization. Specifically, it allows to store different parameter values dependent on pairs of pre-synaptic (`src_type`) and post-synaptic (`tgt_type`) m-types, together with default values in case no pathway is specified.
120118

121-
```
122-
virtualenv venv
123-
. venv/bin/activate
124-
pip install -r tests/requirement_tests.txt
125-
```
119+
## Model fitting functions
126120

127-
## Build
121+
All model fitting functions are implemented as separate code modules (.py files) under [`/model_building`](connectome_manipulator/model_building) and must always contain the following functions for implementing the three steps of model building:
128122

129-
Run the following command to build incrementally the project: `pip install -e .`
123+
- `extract()` for extracting relevant data (e.g., connection probabilities at binned distances) from a given connectome which will be stored automatically in a .pickle file by the framework
124+
- `build()` for fitting model parameters against the data extracted during the previous step and initializing a model instance which will then be stored automatically as a .json file, optionally together with an associated HDF5 file
125+
- `plot()` for generating visualizations of the extracted data versus the model output, and storing them in the output folder
130126
131-
## Test
127+
Importantly, arbitrary parameters (optionally, including default values) can be added as keyword arguments to any of the three functions, values of which must be provided through a configuration file (see *Configuration file structure* in the [Documentation](https://connectome-manipulator.readthedocs.io/en/netneuro-24-0092-rev1/config_file_structure.html)) when launching model building.
132128
133-
Run the following command to run the Python unit-tests: `pytest tests`
129+
## Manipulations
134130
135-
## Coding conventions
131+
All manipulations are derived from an abstract base class `Manipulation` which is implemented in [`/connectome_manipulation/manipulation/base.py`](connectome_manipulator/connectome_manipulation/manipulation/base.py). The base class provides access to the neurons of a network model (through `self.nodes`) as well as to the input (i.e., before a manipulation) and output (i.e., after a manipulation) synapse tables (through `self.writer`). An alternative (abstract) base class, `MorphologyCachingManipulation`, exists which additionally provides efficient access to morphologies (through `self._get_tgt_morphs`) including a caching mechanism, i.e., without reloading them from the file system in case of repeated invocations.
136132
137-
The code coverage of the Python unit-tests may not decrease over time.
138-
It means that every change must go with their corresponding Python unit-tests to
139-
validate the library behavior as well as to demonstrate the API usage.
133+
A concrete manipulation must be implemented in a derived classes and stored in a separate code module (.py file) under [`/connectome_manipulation/manipulation`](connectome_manipulator/connectome_manipulation/manipulation). It must contain an implementation for the `apply()` method which must return a new synapse table (through `self.writer`) as a result of the manipulation. Importantly, arbitrary parameters (optionally, including default values) can be added as keyword arguments to the `apply()` method, values of which must be provided through a configuration file (see *Configuration file structure* in the [Documentation](https://connectome-manipulator.readthedocs.io/en/netneuro-24-0092-rev1/config_file_structure.html)) when launching a manipulation.
134+
135+
## Structural comparison functions
136+
137+
All structural comparison functions are implemented as separate code modules (.py files) under [`/connectome_comparison`](connectome_manipulator/connectome_comparison) and must always contain functions for implementing the two following steps:
138+
139+
- `compute()` for computing specific structural features from a given connectome (e.g., connection probability by layer), which will be evaluated for both connectomes to compare and results of which will be automatically stored as .pickle files by the framework
140+
- `plot()` for plotting a graphical representation of individual feature instances (e.g., 2D matrix plot of connection probabilities by layer) or the difference between two such instances, which will be automatically stored in a compound output figure when comparing two connectomes
141+
142+
Importantly, arbitrary parameters (optionally, including default values) can be added as keyword arguments to the two functions, values of which must be provided through a configuration file (see *Configuration file structure* in the [Documentation](https://connectome-manipulator.readthedocs.io/en/netneuro-24-0092-rev1/config_file_structure.html)) when launching a structural comparison.

README.rst

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ Table of contents
2424
- `Structural comparison`_
2525

2626
5. `Examples`_
27-
6. `How to contribute`_
28-
7. `Citation`_
29-
8. `Publications that use or mention Connectome-Manipulator`_
27+
6. `Documentation`_
28+
7. `How to contribute`_
29+
8. `Citation`_
30+
9. `Publications that use or mention Connectome-Manipulator`_
3031

3132
- `Scientific papers that use Connectome-Manipulator`_
3233
- `Posters that use Connectome-Manipulator`_
3334

34-
9. `Funding & Acknowledgment`_
35+
10. `Funding & Acknowledgment`_
3536

3637
Introduction
3738
------------
@@ -62,6 +63,11 @@ All dependencies declared in ``setup.py`` and are available from PyPI, including
6263

6364
Recommended Python version: v3.10.8
6465

66+
❗ Compatibility notes
67+
~~~~~~~~~~~~~~~~~~~~~~
68+
69+
The software famework is intended to be used on Linux/MacOS-based systems! Specifically, some dependencies, like ``libsonata``, are currently not compatible with Microsoft Windows OS.
70+
6571
Framework overview
6672
------------------
6773

@@ -73,11 +79,11 @@ consists of the following main components:
7379

7480
- | **Connectome manipulator**
7581
| As specified in the config, applies one or a sequence of manipulations to a given SONATA connectome, and writes the manipulated connectome to a new SONATA edges file. All manipulations are separately implemented in sub-modules and can be easily extended.
76-
| Details can be found in the corresponding README file in the repository: `connectome_manipulation/README.md <https://github.com/BlueBrain/connectome-manipulator/blob/main/connectome_manipulator/connectome_manipulation/README.md>`_
82+
| Details can be found in the corresponding README file in the repository: `connectome_manipulation/README.md <connectome_manipulator/connectome_manipulation/README.md>`_
7783
7884
- | **Model building**
7985
| As specified in the config, builds a model from a given connectome and writes the model to a file to be loaded and used by specific manipulations requiring a model (e.g., model-based rewiring based on connection probability model). All models are separately implemented in sub-modules and can be easily extended.
80-
| Details can be found in the corresponding README file in the repository: `model_building/README.md <https://github.com/BlueBrain/connectome-manipulator/blob/main/connectome_manipulator/model_building/README.md>`_
86+
| Details can be found in the corresponding README file in the repository: `model_building/README.md <connectome_manipulator/model_building/README.md>`_
8187
8288
Notes:
8389

@@ -87,7 +93,9 @@ consists of the following main components:
8793

8894
- | **Structural comparator**
8995
| As specified in the config, performs a structural comparison of the original and manipulated connectomes. Different structural parameters to compare (connection probability, synapses per connection, ...) are separately implemented in sub-modules and can be easily extended.
90-
| Details can be found in the corresponding README file in the repository: `connectome_comparison/README.md <https://github.com/BlueBrain/connectome-manipulator/blob/main/connectome_manipulator/connectome_comparison/README.md>`_
96+
| Details can be found in the corresponding README file in the repository: `connectome_comparison/README.md <connectome_manipulator/connectome_comparison/README.md>`_
97+
98+
The structure of the respective configuration files can be found under `doc/source/config_file_structure.rst <doc/source/config_file_structure.rst>`_
9199

92100
ℹ️ More details can be also found in the accompanying publication (esp.
93101
*Supplementary tables*), see `Citation`_.
@@ -180,6 +188,24 @@ Please note that this feature will require at least 4 MPI ranks. Dask will use 2
180188

181189
When processing with ``parallel-manipulator``, one may pass the flag ``--target-payload`` to determine how big the individual workload for each process should be. The default value of 20e9 was determined empirically to run on the whole mouse brain with 75 million neurons. We recommend to use this value as a starting point and scale it up or down to achieve the desired runtime characteristics.
182190

191+
Details on the CONFIG file structure can be found under `doc/source/config_file_structure.rst <doc/source/config_file_structure.rst>`_
192+
193+
❗ Notes on error handling
194+
^^^^^^^^^^^^^^^^^^^^^^^^^^
195+
196+
Errors may occur for many different reasons and are not always easy to track. Most common errors are that an allocation gets "killed", either due to a time limit or due to an out-of-memory error. Here we provide a few hints on how to avoid or track errors that may occur:
197+
198+
- Use the "verbose" mode (``-v`` flag) which will produce a lot of log output.
199+
- Look into the log files: there is usually one master log file and individual log files for all data splits, all of which can be found in the ``/logs`` subfolder of the output circuit folder.
200+
- Use a small connectome to start with.
201+
- Use a simple operation to start with, such as ``null_manipulation`` (see examples).
202+
- Run serially to start with, before switching to parallel processing.
203+
- Start with a single data split.
204+
- But: In case of memory errors, use more than a single data splits, even when running serially (!), which will reduce the memory consumption as individual splits will be processed one after the other.
205+
- When running in parallel, use ``--tasks-per-node`` in the SLURM configuration to define how many tasks (=splits) will be executed on a single node; reducing this number may reduce the risk of out-of-memory errors.
206+
- In general: Increasing memory allocation and/or allocation time may help.
207+
- For high performance: Allocate many nodes and use parallel processing together with a relatively large number of data splits depending on the network size (i.e., aim for a few hundered post-synaptic neurons per data split).
208+
183209
Model building
184210
~~~~~~~~~~~~~~
185211

@@ -190,9 +216,13 @@ Model building
190216
Extract and build models from existing connectomes.
191217

192218
Options:
193-
--force-reextract Force re-extraction of data, in case already existing.
194-
--force-rebuild Force model re-building, in case already existing.
195-
--help Show this message and exit.
219+
--force-reextract Force re-extraction of data, in case already existing.
220+
--force-rebuild Force model re-building, in case already existing.
221+
--cv-folds INTEGER Optional number of cross-validation folds, overwrites
222+
value in config file
223+
--help Show this message and exit.
224+
225+
Details on the CONFIG file structure can be found under `doc/source/config_file_structure.rst <doc/source/config_file_structure.rst>`_
196226

197227
Structural comparison
198228
~~~~~~~~~~~~~~~~~~~~~
@@ -210,15 +240,22 @@ Structural comparison
210240
in case already existing.
211241
--help Show this message and exit.
212242

243+
Details on the CONFIG file structure can be found under `doc/source/config_file_structure.rst <doc/source/config_file_structure.rst>`_
244+
213245
Examples
214246
--------
215247

216-
Examples can be found under `examples/ <https://github.com/BlueBrain/connectome-manipulator/tree/main/examples>`_ in the repository.
248+
Examples can be found under `examples/ </examples>`_ in the repository.
249+
250+
Documentation
251+
-------------
252+
253+
The full documentation (API reference, CONFIG file structure, ...) can be found on `Read the Docs <https://connectome-manipulator.readthedocs.io/en/netneuro-24-0092-rev1>`_.
217254

218255
How to contribute
219256
-----------------
220257

221-
Contribution guidelines can be found in `CONTRIBUTING.md <https://github.com/BlueBrain/connectome-manipulator/blob/main/CONTRIBUTING.md>`_ in the repository.
258+
Contribution guidelines can be found in `CONTRIBUTING.md <CONTRIBUTING.md>`_ in the repository.
222259

223260
Citation
224261
--------
@@ -244,11 +281,11 @@ Publications that use or mention Connectome-Manipulator
244281
Scientific papers that use Connectome-Manipulator
245282
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246283

247-
- Michael W. Reimann, Sirio Bolaños-Puchet, Jean-Denis Courcol, Daniela Egas Santander, et al. (2022) **Modeling and Simulation of Neocortical Micro- and Mesocircuitry. Part I: Anatomy.** bioRxiv 2022.08.11.503144. DOI: `10.1101/2022.08.11.503144 <https://doi.org/10.1101/2022.08.11.503144>`_
284+
- Michael W. Reimann, Sirio Bolaños-Puchet, Jean-Denis Courcol, Daniela Egas Santander, et al. (2024) **Modeling and Simulation of Neocortical Micro- and Mesocircuitry. Part I: Anatomy.** eLife, 13:RP99688. DOI: `10.7554/eLife.99688.1 <https://doi.org/10.7554/eLife.99688.1>`_
248285

249-
- James B. Isbister, András Ecker, Christoph Pokorny, Sirio Bolaños-Puchet, Daniela Egas Santander, et al. (2023) **Modeling and Simulation of Neocortical Micro- and Mesocircuitry.** Part II: Physiology and Experimentation. bioRxiv 2023.05.17.541168. DOI: `10.1101/2023.05.17.541168 <https://doi.org/10.1101/2023.05.17.541168>`_
286+
- James B. Isbister, András Ecker, Christoph Pokorny, Sirio Bolaños-Puchet, Daniela Egas Santander, et al. (2023) **Modeling and Simulation of Neocortical Micro- and Mesocircuitry. Part II: Physiology and Experimentation.** bioRxiv, 2023.05.17.541168. DOI: `10.1101/2023.05.17.541168 <https://doi.org/10.1101/2023.05.17.541168>`_
250287

251-
- Daniela Egas Santander, Christoph Pokorny, András Ecker, Jānis Lazovskis, Matteo Santoro, Jason P. Smith, Kathryn Hess, Ran Levi, and Michael W. Reimann. (2024) **Efficiency and reliability in biological neural network architectures.** bioRxiv 2024.03.15.585196. DOI: `10.1101/2024.03.15.585196 <https://doi.org/10.1101/2024.03.15.585196>`_
288+
- Daniela Egas Santander, Christoph Pokorny, András Ecker, Jānis Lazovskis, Matteo Santoro, Jason P. Smith, Kathryn Hess, Ran Levi, and Michael W. Reimann. (2024) **Efficiency and reliability in biological neural network architectures.** bioRxiv, 2024.03.15.585196. DOI: `10.1101/2024.03.15.585196 <https://doi.org/10.1101/2024.03.15.585196>`_
252289

253290
Posters that use Connectome-Manipulator
254291
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)