Skip to content

Commit cea4f70

Browse files
authored
Rc0.7.2 beta (#515)
Update documentation (see #513)
2 parents 3c353db + 515014b commit cea4f70

13 files changed

Lines changed: 119 additions & 25 deletions

File tree

biophysics_fitting/hay/L5tt_parameter_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def set_hot_zone(cell_param, min_=None, max_=None, outsidescale_sections=None):
522522
max\_ (float): The maximum distance from the soma.
523523
outsidescale_sections (list):
524524
A list of sections not part of the hot zone, but including calcium channels nonetheless.
525-
These sections will get a Ca channel density equal to the :ref:`neuron_parameters_format` key ``outside_scale``.
525+
These sections will get a Ca channel density equal to the :ref:`cell_parameters_format` key ``outside_scale``.
526526
Usually, this is less than the hot zone density.
527527
See :ref:`~single_cell_parser.cell_parser.insert_range_mechanisms` for more information on channel density during neuron model creation.
528528

config/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"udvary2022",
2525
# no other methods have been implemented yet
2626
)
27+
"""Which methods ISF currently implements to infer synapse locations onto a poastsynaptic neuron morphology."""
2728

2829

2930
def _read_db_settings():
@@ -98,6 +99,14 @@ def get_default_db_dumper():
9899

99100

100101
def get_meta_file_format():
102+
"""Check which file format to use for saving data_base meta objects.
103+
104+
This is either ``"msgpack"`` or ``"json"``.
105+
The actual format is defined in the database settings. This functions simply reads it to check which one should be used.
106+
107+
Returns:
108+
str: The specified file format for meta objects.
109+
"""
101110
allowed_formats = ("msgpack", "json")
102111
db_settings = _read_db_settings()
103112
meta_file_format = db_settings.get("OBJECT_META_FORMAT")['file_format']

config/file_locking.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,30 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
"""Default values for file locking.
16+
17+
This module allows the user to set default fallback values for file locking.
18+
This default fallback value is only used when the env variable ``"ISF_DISTRIBUTED_LOCK_CONFIG"`` is unset.
19+
It is recommended to make use of this env variable when setting up your environment, especially for HPC contexts.
20+
21+
For example, to use the zookeeper locking configuration:
22+
23+
- launch a zookeeper server
24+
- write out the configuration for your session::
25+
26+
config = [{
27+
'config': {
28+
'hosts': 'ip:port'
29+
},
30+
'type': 'zookeeper'
31+
}]
32+
33+
- set ``"ISF_DISTRIBUTED_LOCK_CONFIG"`` to the filepath pointing to this config file.
34+
"""
1535
DEFAULT_CONFIG = [
1636
dict(type="file"),
1737
# dict(type="redis", config=dict(host="spock", port=8885, socket_timeout=1)),
1838
# dict(type="redis", config=dict(host="localhost", port=6379, socket_timeout=1)),
1939
]
40+
"""Default fallback value when no file locking is configured. Defaults to file-based file locking."""
2041

config/user/morphology.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
"""
16+
Configure label names for :ref:`hoc_file_format` and :ref:`swc_file_format` morphology files.
17+
"""
1518

1619
HOC_LABEL_MAP = {
1720
'soma': 'Soma',
@@ -26,4 +29,18 @@
2629
2730
For example, if a :ref:`hoc_file_format` contains the label "DEND", "Dend", or "BasalDendrite", these will be converted in ISF to just "Dendrite".
2831
If a connections spreadsheet contains labels "BASAL", it will be converted to "Dendrite".
29-
"""
32+
"""
33+
34+
SWC_LABEL_MAP = {
35+
1: 'Soma',
36+
2: "AIS",
37+
3: "Dendrite",
38+
4: "ApicalDendrite",
39+
5: "Myelin"
40+
}
41+
"""Mapping between labels found in :ref:`swc_file_format` morphology files, and the label to be used internally throughout ISF.
42+
43+
For example, if a :ref:`swc_file_format` contains the label ``3``, this will be converted in ISF to just "Dendrite".
44+
45+
Useful for defining custom labels on a project-wide basis.
46+
"""

config/user/network_connectivity.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
1+
# In Silico Framework
2+
# Copyright (C) 2025 Max Planck Institute for Neurobiology of Behavior - CAESAR
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
"""
16+
Configure the default values for synapse mapping and network connectivity workflows in ISF.
117
18+
This module allows the user to configure default settings for synapse mapping in ISF.
19+
20+
In particular, it allows:
21+
22+
- Setting a default synapse mapping strategy
23+
- Setting default paths for data sources for this synapse mapping strategy
24+
25+
We generally recommend to always explicitly pass both the synapse mapping strategy and the data sources, as it makes the code more explicit. Relying too much on these default values can have the undesirable side effect that the same code may yield different results, when these values are changed.
26+
"""
227
from pathlib import Path
328
from .. import AVAILABLE_SYNAPSE_MAPPING_METHODS
429

530
SELECTED_SYNAPSE_MAPPING_METHOD = "udvary2022"
31+
"""Which synapse mapping workflow to use for calculating synapse positions on the morphology. Default is :mod:`~singlecell_input_mapper.udvary2022`"""
632

733
prefix = Path(__file__).parent.parent.parent / "barrel_cortex"
834

@@ -17,4 +43,4 @@
1743

1844

1945
assert SELECTED_SYNAPSE_MAPPING_METHOD in AVAILABLE_SYNAPSE_MAPPING_METHODS, \
20-
f"The chosen synapse mapping method {SELECTED_SYNAPSE_MAPPING_METHOD} is not available. Available methods are: {AVAILABLE_SYNAPSE_MAPPING_METHODS}"
46+
f"The chosen synapse mapping method {SELECTED_SYNAPSE_MAPPING_METHOD} is not available. Available methods are: {AVAILABLE_SYNAPSE_MAPPING_METHODS}"

data_base/distributed_lock.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ def _get_locking_config():
7777
7878
This method allows for a lazy evaluation of the locking configuration,
7979
and is used to set the global variable ``_CONFIG``.
80+
81+
If the env variable ``ISF_DISTRIBUTED_LOCK_CONFIG`` is not set, it falls back to :attr:`~DEFAULT_CONFIG`.
82+
83+
Returns:
84+
List[dict]: List of configurations to try. Order of the list reflects priority.
8085
"""
8186
global _CONFIG
8287

docs/api_reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ API reference
1515
./api_reference/spike_analysis/index
1616
./api_reference/visualize/index
1717
./api_reference/mechanisms/index
18+
./api_reference/config/index
1819

1920
.. autoapisummary::
2021

@@ -27,3 +28,4 @@ API reference
2728
spike_analysis
2829
visualize
2930
mechanisms
31+
config

docs/file_formats.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ Parsed dataframe
648648

649649
Writers:
650650

651-
- :func:`~single_cell_parser.writer.write_presynaptic_spike_file` is used by :mod:`simrun` and :mod:`~single_cell_parser.analyze.synanalysis`
651+
- :func:`~single_cell_parser.io.activity.write_presynaptic_spike_times` is used by :mod:`simrun` and :mod:`~single_cell_parser.analyze.synanalysis`
652652
to write raw output data.
653653
- :func:`data_base.db_initializers.load_simrun_general.init` parses these files into a pandas dataframe.
654654

@@ -978,7 +978,8 @@ Example:
978978
979979
: What to calculate each time step
980980
BREAKPOINT {
981-
: solve the DERIVATIVE block named "states" using `sympy.dsolve` and fall back to `CNEXP` method
981+
: Solve the DERIVATIVE block named "states"
982+
: Use `cnexp` (Crank-Nicolson, exponential)
982983
: For more info, see https://www.neuronsimulator.org/en/latest/nmodl/transpiler/notebooks/nmodl-sympy-solver-cnexp.html#Implementation
983984
SOLVE states METHOD cnexp
984985
: Calculate the conductance of the Im current = conductance density * gating variable

docs/installation.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ Each ISF environment adapts the following environment variables:
125125

126126
Configuration
127127
-------------
128+
The :mod:`config` module allows the user to configure many aspects of ISF, such as:
128129

129-
ISF works best with a dask server for parallel computing. We provide default scripts to launch a dask server and workers
130-
that should work on most systems.
130+
- The default file format for saving objects in a :mod:`data_base` (see :mod:`config`)
131+
- Which file locking method to use (see :mod:`config.file_locking`)
132+
- User-specific configuration for your project, such as morphology label names, cell type definitions, synapse mapping strategies, and default values for activity data (see :mod:`config.user`)
133+
134+
ISF works best with a dask server for parallel computing, and all compute-intensive workflows in ISF work with a client for distributed computing.
135+
We provide default scripts to launch a dask server and workers that should work on most systems:
131136

132137
.. code-block:: bash
133138
@@ -140,6 +145,7 @@ that should work on most systems.
140145
For High-Performance Computing (HPC), you may want to launch the dask server with custom configuration instead of these default scripts.
141146
The underlying commands for these shortcuts are configured in the ``pyproject.toml`` file.
142147

148+
143149
Usage
144150
-----
145151

@@ -171,4 +177,4 @@ To test if all components of ISF are working as intended, you can run the test s
171177
172178
.. container:: doc-feedback
173179

174-
Documentation unclear, incomplete, broken or wrong? `Let us know <https://github.com/mpinb/in_silico_framework/issues/new?template=documentation.md&labels=docs>`_
180+
Documentation unclear, incomplete, broken or wrong? `Let us know <https://github.com/mpinb/in_silico_framework/issues/new?template=documentation.md&labels=docs>`_

single_cell_parser/io/morphology/swc.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@
1616
Read and write :ref:`swc_file_format` morphologies.
1717
"""
1818
from __future__ import annotations
19-
from typing import Any
19+
from config.user.morphology import SWC_LABEL_MAP
2020
import numpy as np
2121
import warnings
22-
from pathlib import Path
2322
import logging
2423
from ._edge import _Edge
2524
logger = logging.getLogger("ISF").getChild(__name__)
2625

27-
SWC_LABEL_MAP = {'Soma': 1, "AIS": 2, "Dendrite": 3, "ApicalDendrite": 4, "Myelin": 5}
28-
REVERSE_SWC_LABEL_MAP = {v: k for k, v in SWC_LABEL_MAP.items()}
29-
3026
def _get_swc_lines_per_section(
3127
sections,
3228
skip_myelin=False,
@@ -116,6 +112,7 @@ def _get_swc_lines_per_section(
116112
swc_lines_per_section.append(swc_lines_this_section)
117113
return swc_lines_per_section
118114

115+
119116
def _get_only_child_sections(sections):
120117
"""Check if a cell has sections that are only children.
121118
@@ -133,7 +130,7 @@ def _get_only_child_sections(sections):
133130
if sec.parent and len(sec.parent.children()) == 1:
134131
direct_desc_sections[sec_ind] = sections.index(sec.parent)
135132
return direct_desc_sections
136-
133+
137134

138135
def write_swc(sections, of, skip_myelin=False, remap_sections=None):
139136
"""
@@ -174,8 +171,8 @@ def write_swc(sections, of, skip_myelin=False, remap_sections=None):
174171
line = [str(e) for e in line]
175172
f.write(' '.join(line))
176173
f.write('\n')
177-
178-
174+
175+
179176
def swc_to_point_dict(swc_filepath):
180177
"""
181178
Extract point coordinate information.
@@ -273,7 +270,7 @@ def _traverse(point_id, sec_name, sec_label, parent_sec_id, points_dict, section
273270
parent_sec_id= len(sections) - 1
274271
for i, child_id in enumerate(children_pt_id):
275272
section_type = points_dict[child_id]["type"]
276-
child_sec_label = REVERSE_SWC_LABEL_MAP[section_type]
273+
child_sec_label = SWC_LABEL_MAP[section_type]
277274
child_sec_name = f"{sec_name}_{i}"
278275
sections= _traverse(
279276
point_id=child_id,
@@ -330,7 +327,7 @@ def build_section_directory(root_ids, points_dict):
330327
for child_id in points_dict[root_id]["children"]:
331328
if child_id <= len(sections[0].edgePts): continue # child is soma - already added
332329
section_type = points_dict[child_id]["type"]
333-
label = REVERSE_SWC_LABEL_MAP.get(section_type, f"type{section_type}")
330+
label = SWC_LABEL_MAP.get(section_type, f"type{section_type}")
334331
counters[section_type] = counters.get(section_type, 0) + 1
335332
child_sec_name = f"{label}_{counters[section_type]}_0"
336333
sections = _traverse(

0 commit comments

Comments
 (0)