diff --git a/src/miv_simulator/config/__init__.py b/src/miv_simulator/config/__init__.py index 1a09bb3..e7c5081 100644 --- a/src/miv_simulator/config/__init__.py +++ b/src/miv_simulator/config/__init__.py @@ -46,6 +46,9 @@ class SynapseMechanismsDef(IntEnum): NMDA = 30 +SynapseMechanismsLiteral = Literal["AMPA", "GABA_A", "GABA_B", "NMDA"] + + class LayersDef(IntEnum): default = -1 Hilus = 0 @@ -145,11 +148,12 @@ def __getitem__(self, item): class Mechanism(BaseModel): - tau_rise: float = None - tau_decay: float = None - e: int = None g_unit: float weight: float + tau_rise: Optional[float] = None + tau_decay: Optional[float] = None + e: Optional[int] = None + class Synapse(BaseModel): @@ -157,7 +161,7 @@ class Synapse(BaseModel): sections: conlist(SWCTypesDefOrStr) layers: conlist(LayersDefOrStr) proportions: conlist(float) - mechanisms: Dict[SynapseMechanismsDefOrStr, Mechanism] + mechanisms: Dict[SynapseMechanismsLiteral, Mechanism] def _origin_value_to_callable(value: Union[str, float]) -> Callable: @@ -211,9 +215,7 @@ class AxonExtent(BaseModel): offset: Tuple[float, float] -AxonExtents = Dict[PopulationsDefOrStr, Dict[LayerName, AxonExtent]] - -# Composed +AxonExtents = Dict[PopulationsLiteral, Dict[LayerName, AxonExtent]] def probabilities_sum_to_one(x): diff --git a/src/miv_simulator/connections.py b/src/miv_simulator/connections.py index 0ea4ce4..bdcdf71 100644 --- a/src/miv_simulator/connections.py +++ b/src/miv_simulator/connections.py @@ -611,7 +611,7 @@ def generate_uv_distance_connections( projection_config[source_population].layers, projection_config[source_population].sections, projection_config[source_population].proportions, - projection_config[source_population].contacts, + projection_config[source_population].get("contacts", None), ) for source_population in source_populations } diff --git a/src/miv_simulator/interface/create_network.py b/src/miv_simulator/interface/create_network.py index fef31b0..e54c12a 100644 --- a/src/miv_simulator/interface/create_network.py +++ b/src/miv_simulator/interface/create_network.py @@ -123,8 +123,9 @@ def distance_connections(self, version: VersionType = None): "miv_simulator.interface.distance_connections", [ { - "blueprint": self.config.blueprint, - "coordinates": self.output_filepath, + "filepath": self.output_filepath, + "synapses": self.config.synapses, + "coordinates_namespace": self.config.coordinate_namespace, } ] + normversion(version), diff --git a/src/miv_simulator/interface/distance_connections.py b/src/miv_simulator/interface/distance_connections.py index 05ef336..58c3dcb 100644 --- a/src/miv_simulator/interface/distance_connections.py +++ b/src/miv_simulator/interface/distance_connections.py @@ -5,23 +5,24 @@ from machinable import Component from pydantic import BaseModel, Field from miv_simulator import config -from typing import Optional +from typing import Optional, Dict from miv_simulator.simulator import distance_connections +from miv_simulator.utils import from_yaml class DistanceConnections(Component): class Config(BaseModel): filepath: str = Field("???") forest_filepath: str = Field("???") + axon_extents: config.AxonExtents = Field("???") + synapses: config.Synapses = Field("???") include_forest_populations: Optional[list] = None - synapses: config.Synapses = {} - connection_extents: config.ConnectionExtents = {} template_path: str = "./templates" use_coreneuron: bool = False dt: float = 0.025 - tstop: float = (0.0,) + tstop: float = 0.0 celsius: Optional[float] = 35.0 - connectivity_namespace: str = "Connectivity" + connectivity_namespace: str = "Connections" coordinates_namespace: str = "Coordinates" synapses_namespace: str = "Synapse Attributes" distances_namespace: str = "Arc Distances" @@ -33,6 +34,9 @@ class Config(BaseModel): write_size: int = 1 ranks_: int = 8 + def config_from_file(self, filename: str) -> Dict: + return from_yaml(filename) + @property def output_filepath(self): return self.local_directory("connectivity.h5") @@ -44,7 +48,7 @@ def __call__(self): forest_filepath=self.config.forest_filepath, include_forest_populations=self.config.include_forest_populations, synapses=self.config.synapses, - connection_extents=self.config.connection_extents, + axon_extents=self.config.axon_extents, template_path=self.config.template_path, use_coreneuron=self.config.use_coreneuron, dt=self.config.dt, @@ -61,4 +65,5 @@ def __call__(self): cache_size=self.config.cache_size, write_size=self.config.write_size, dry_run=False, + seeds=self.seed ) diff --git a/src/miv_simulator/simulator/generate_distance_connections.py b/src/miv_simulator/simulator/generate_distance_connections.py index a28ef3b..4c6552b 100644 --- a/src/miv_simulator/simulator/generate_distance_connections.py +++ b/src/miv_simulator/simulator/generate_distance_connections.py @@ -241,8 +241,8 @@ def distance_connections( ) if seeds is None or isinstance(seeds, int): - r = random.Random(seed=seeds) - seeds = [r.randint(0, 2**32 - 1) for r in range(3)] + r = random.Random(seeds) + seeds = [r.randint(0, 2**32 - 1) for _ in range(3)] populations_dict = config.PopulationsDef.__members__ generate_uv_distance_connections(