Skip to content

Commit

Permalink
Fix distance connections
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Sep 13, 2023
1 parent b5c3607 commit d33fe60
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/miv_simulator/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class SynapseMechanismsDef(IntEnum):
NMDA = 30


SynapseMechanismsLiteral = Literal["AMPA", "GABA_A", "GABA_B", "NMDA"]


class LayersDef(IntEnum):
default = -1
Hilus = 0
Expand Down Expand Up @@ -145,19 +148,20 @@ 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):
type: SynapseTypesDefOrStr
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:
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/miv_simulator/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions src/miv_simulator/interface/create_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
17 changes: 11 additions & 6 deletions src/miv_simulator/interface/distance_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand All @@ -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,
Expand All @@ -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
)
4 changes: 2 additions & 2 deletions src/miv_simulator/simulator/generate_distance_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d33fe60

Please sign in to comment.