diff --git a/src/miv_simulator/config.py b/src/miv_simulator/config.py index 7c81074..df588f1 100644 --- a/src/miv_simulator/config.py +++ b/src/miv_simulator/config.py @@ -215,19 +215,20 @@ class Synapse(BaseModel): layers: conlist(LayersDefOrStr) proportions: conlist(float) mechanisms: Dict[SynapseMechanismsLiteral, Mechanism] + contacts: int = 1 def _origin_value_to_callable(value: Union[str, float]) -> Callable: - if isinstance(value, (float, int)): + if isinstance(value, float): return lambda _: value return getattr(np, value) class Origin(BaseModel): - U: Union[str, float, int] - V: Union[str, float, int] - L: Union[str, float, int] + U: Union[str, float] + V: Union[str, float] + L: Union[str, float] def as_spec(self): return { @@ -245,7 +246,6 @@ class ParametricSurface(BaseModel): class CellType(BaseModel): template: str - mechanism: Union[str, Dict, None] synapses: Dict[ Literal["density"], Dict[ diff --git a/src/miv_simulator/connections.py b/src/miv_simulator/connections.py index ddb2c1f..919fc5e 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].get("contacts", 1), + projection_config[source_population].contacts, ) for source_population in source_populations } diff --git a/src/miv_simulator/geometry/geometry.py b/src/miv_simulator/geometry/geometry.py index ffaa033..d6c38d0 100644 --- a/src/miv_simulator/geometry/geometry.py +++ b/src/miv_simulator/geometry/geometry.py @@ -601,7 +601,7 @@ def distance_interpolant( vol_dist = get_volume_distances( ip_volume, - origin_spec=config.Origin(**origin).as_spec(), + origin_spec=origin, nsample=n_sample, comm=comm, alpha_radius=alpha_radius, diff --git a/src/miv_simulator/interface/distances.py b/src/miv_simulator/interface/distances.py index 5824c2e..d60e84e 100644 --- a/src/miv_simulator/interface/distances.py +++ b/src/miv_simulator/interface/distances.py @@ -42,7 +42,7 @@ def __call__(self): cell_distributions=self.config.cell_distributions, layer_extents=self.config.layer_extents, rotation=self.config.rotation, - origin=self.config.origin, + origin=config.Origin(**self.config.origin).as_spec(), n_sample=self.config.n_sample, alpha_radius=self.config.alpha_radius, io_size=self.config.io_size, diff --git a/src/miv_simulator/opto/run.py b/src/miv_simulator/opto/run.py index 9a09196..4000408 100644 --- a/src/miv_simulator/opto/run.py +++ b/src/miv_simulator/opto/run.py @@ -91,7 +91,7 @@ def init_mechanisms(self): rho_dict = self.pop_rho_dict[pop_name] mech = getattr(h, self.mechanisms[self.model.nStates]) - expProb = self.rho_params["expProb"] + expProb = self.rho_params.get("expProb", 1.0) for gid in gid_set: if not self.pc.gid_exists(gid): diff --git a/src/miv_simulator/simulator/generate_connections.py b/src/miv_simulator/simulator/generate_connections.py index c3bd8a1..84f6fca 100644 --- a/src/miv_simulator/simulator/generate_connections.py +++ b/src/miv_simulator/simulator/generate_connections.py @@ -86,9 +86,6 @@ def generate_distance_connections( synapses=env.connection_config, axon_extents=env.connection_extents, use_coreneuron=env.use_coreneuron, - dt=env.dt, - tstop=env.tstop, - celsius=env.celsius, output_filepath=connectivity_path, connectivity_namespace=connectivity_namespace, coordinates_namespace=coords_namespace, diff --git a/src/miv_simulator/simulator/generate_network_architecture.py b/src/miv_simulator/simulator/generate_network_architecture.py index 04617c7..5f90a6d 100755 --- a/src/miv_simulator/simulator/generate_network_architecture.py +++ b/src/miv_simulator/simulator/generate_network_architecture.py @@ -7,7 +7,6 @@ import random import sys from collections import defaultdict -import importlib import h5py import numpy as np @@ -171,7 +170,7 @@ def generate_soma_coordinates( layer_extents=env.geometry["Parametric Surface"]["Layer Extents"], rotation=env.geometry["Parametric Surface"]["Rotation"], cell_distributions=env.geometry["Cell Distribution"], - cell_constraints=env.geometry["Cell Constraints"], + cell_constraints=env.geometry.get("Cell Constraints", None), output_namespace=output_namespace, geometry_filepath=geometry_path, populations=populations, @@ -191,7 +190,7 @@ def generate_network_architecture( cell_distributions: config.CellDistributions, layer_extents: config.LayerExtents, rotation: config.Rotation, - cell_constraints: config.CellConstraints, + cell_constraints: Optional[config.CellConstraints], output_namespace: str, geometry_filepath: Optional[str], populations: Optional[Tuple[str, ...]], @@ -342,26 +341,6 @@ def generate_network_architecture( if count <= 0: continue - if layer.startswith("@"): - # generate via callback - module_path, _, obj_name = layer[1:].rpartition(".") - if module_path == "__main__" or module_path == "": - module = sys.modules["__main__"] - else: - module = importlib.import_module(module_path) - callback = getattr(module, obj_name) - - nodes = callback(count, layer_extents[layer]) - - if not len(nodes) == count: - logger.error( - f"Generator {layer} produced mismatch between actual count {len(nodes)} and configured count {count}" - ) - - xyz_coords_lst.append(nodes.reshape(-1, 3)) - - continue - alpha = layer_alpha_shapes[layer] vert = alpha.points @@ -604,12 +583,6 @@ def generate_network_architecture( for i in range(delta): for layer, count in pop_layers.items(): if count > 0: - if layer.startswith("@"): - logger.warning( - f"Generator {layer} did not return the specified number of coordinates" - ) - continue - min_extent = layer_extents[layer][0] max_extent = layer_extents[layer][1] coord_u = np.random.uniform( diff --git a/src/miv_simulator/simulator/measure_distances.py b/src/miv_simulator/simulator/measure_distances.py index e25af0c..dafcdf9 100644 --- a/src/miv_simulator/simulator/measure_distances.py +++ b/src/miv_simulator/simulator/measure_distances.py @@ -42,6 +42,7 @@ def measure_distances_( populations, resolution, nsample, + alpha_radius, io_size, chunk_size, value_chunk_size, @@ -52,15 +53,18 @@ def measure_distances_( utils.config_logging(verbose) env = Env(comm=MPI.COMM_WORLD, config=config, config_prefix=config_prefix) + parametric_surface = env.geometry["Parametric Surface"] return measure_distances( filepath=coords_path, geometry_filepath=geometry_path, coordinate_namespace=coords_namespace, populations=populations, cell_distributions=env.geometry["Cell Distribution"], - layer_extents=env.geometry["Layer Extents"], - rotation=env.geometry["Rotation"], - origin=env.geometry["Origin"], + layer_extents=parametric_surface["Layer Extents"], + rotation=parametric_surface["Rotation"], + origin=parametric_surface["Origin"], + resolution=resolution, + alpha_radius=alpha_radius, n_sample=nsample, io_size=io_size, chunk_size=chunk_size, diff --git a/src/scripts/measure_distances.py b/src/scripts/measure_distances.py index db5b113..7bb2a40 100644 --- a/src/scripts/measure_distances.py +++ b/src/scripts/measure_distances.py @@ -36,6 +36,7 @@ @click.option("--populations", "-i", required=True, multiple=True, type=str) @click.option("--resolution", type=(int, int, int), default=(30, 30, 10)) @click.option("--nsample", type=int, default=1000) +@click.option("--alpha-radius", type=float, default=100) @click.option("--io-size", type=int, default=-1) @click.option("--chunk-size", type=int, default=1000) @click.option("--value-chunk-size", type=int, default=1000) @@ -50,6 +51,7 @@ def main( populations, resolution, nsample, + alpha_radius, io_size, chunk_size, value_chunk_size, @@ -64,6 +66,7 @@ def main( populations, resolution, nsample, + alpha_radius, io_size, chunk_size, value_chunk_size,