From c873b4cf3f3bb09963ee2d2415bd4b8cfa000fe3 Mon Sep 17 00:00:00 2001 From: Frithjof Gressmann Date: Thu, 19 Oct 2023 22:25:52 -0500 Subject: [PATCH] Improve logging when constraits are invalid --- src/miv_simulator/config.py | 37 +++++++++++++++++-- .../generate_network_architecture.py | 12 ++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/miv_simulator/config.py b/src/miv_simulator/config.py index e327868..f66592a 100644 --- a/src/miv_simulator/config.py +++ b/src/miv_simulator/config.py @@ -149,15 +149,46 @@ def _cast(v) -> int: """One of the layers defined in the LayersDef enum.""" CellDistribution = Dict[LayerName, int] -"""For a given neuron kind, this defines the distribution (i.e. numbers) of neurons accross the different layers.""" +"""For a given neuron kind, this defines the distribution (i.e. numbers) of neurons accross the different layers. + +Example: +```python +{ + "STIM": {"SO": 0, "SP": 64, "SR": 0, "SLM": 0}, + "PYR": {"SO": 0, "SP": 223, "SR": 0, "SLM": 0}, + "PVBC": {"SO": 35, "SP": 50, "SR": 8, "SLM": 0}, + "OLM": {"SO": 21, "SP": 0, "SR": 0, "SLM": 0}, +} +``` +""" LayerExtents = Dict[LayerName, List[ParametricCoordinate]] -"""Describes a volume extent""" +"""Describes a volume extent + +Example: +```python +{ + "SO": [[0.0, 0.0, 0.0], [200.0, 200.0, 5.0]], + "SP": [[0.0, 0.0, 5.0], [200.0, 200.0, 50.0]], + "SR": [[0.0, 0.0, 50.0], [200.0, 200.0, 100.0]], + "SLM": [[0.0, 0.0, 100.0], [200.0, 200.0, 150.0]], +} +``` +""" CellConstraints = Optional[ Dict[PopulationName, Dict[LayerName, Tuple[float, float]]] ] -"""Describes constraints on the distribution of neurons in a given layer.""" +"""Describes constraints on the distribution of neurons in a given layer. + +Example: +```python +{ + "PC": {"SP": [100, 120]}, + "PVBC": {"SR": [150, 200]}, +} +``` +""" # Pydantic data models diff --git a/src/miv_simulator/simulator/generate_network_architecture.py b/src/miv_simulator/simulator/generate_network_architecture.py index c707144..ed25ab1 100755 --- a/src/miv_simulator/simulator/generate_network_architecture.py +++ b/src/miv_simulator/simulator/generate_network_architecture.py @@ -99,6 +99,10 @@ def rho(x): ) ) ] + if len(nodes) != len(nodes1): + logger.info( + f"{len(nodes) - len(nodes1)} nodes out of {len(nodes)} were NaN" + ) # remove nodes outside of the domain vert, smp = domain @@ -113,6 +117,14 @@ def rho(x): and current_xyz[i][2] <= constraint[1] ): valid_idxs.append(i) + if len(valid_idxs) == 0: + logger.info( + f"Warning: all in_nodes have been rejected due to constraint {constraint}!" + ) + elif len(valid_idxs) != len(in_nodes): + logger.info( + f"Removing {len(in_nodes)-len(valid_idxs)} out of {len(in_nodes)} nodes due to constraint {constraint}" + ) in_nodes = in_nodes[valid_idxs] node_count = len(in_nodes) N = int(1.5 * N)