From 3187c76d32e00969c798fa08bfa94338e7bb8bb2 Mon Sep 17 00:00:00 2001 From: Ivan Raikov Date: Wed, 21 Aug 2024 18:41:47 -0500 Subject: [PATCH] support for configurable coordinates namespace --- src/miv_simulator/env.py | 2 ++ src/miv_simulator/network.py | 12 ++++++------ src/scripts/run_network.py | 7 +++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/miv_simulator/env.py b/src/miv_simulator/env.py index 3a69165..d6ae557 100644 --- a/src/miv_simulator/env.py +++ b/src/miv_simulator/env.py @@ -94,6 +94,7 @@ def __init__( spike_input_path: None = None, spike_input_namespace: None = None, spike_input_attr: None = None, + coordinates_namespace: str = "Coordinates", cleanup: bool = True, cache_queries: bool = False, profile_memory: bool = False, @@ -288,6 +289,7 @@ def __init__( if "Origin" in self.geometry["Parametric Surface"]: self.parse_origin_coords() + self.coordinates_ns = coordinates_namespace self.celltypes = self.model_config["Cell Types"] self.cell_attribute_info = {} self.phenotype_dict = {} diff --git a/src/miv_simulator/network.py b/src/miv_simulator/network.py index 82a5a49..c499ae5 100644 --- a/src/miv_simulator/network.py +++ b/src/miv_simulator/network.py @@ -1022,7 +1022,7 @@ def make_cells(env: Env) -> None: del trees elif (pop_name in env.cell_attribute_info) and ( - "Coordinates" in env.cell_attribute_info[pop_name] + env.coordinates_ns in env.cell_attribute_info[pop_name] ): if rank == 0: logger.info( @@ -1033,7 +1033,7 @@ def make_cells(env: Env) -> None: cell_attr_dict = scatter_read_cell_attributes( data_file_path, pop_name, - namespaces=["Coordinates"], + namespaces=[env.coordinates_ns], comm=env.comm, io_size=env.io_size, return_type="tuple", @@ -1042,7 +1042,7 @@ def make_cells(env: Env) -> None: cell_attr_dict = scatter_read_cell_attributes( data_file_path, pop_name, - namespaces=["Coordinates"], + namespaces=[env.coordinates_ns], node_allocation=env.node_allocation, comm=env.comm, io_size=env.io_size, @@ -1053,7 +1053,7 @@ def make_cells(env: Env) -> None: f"*** Done reading coordinates for population {pop_name}" ) - coords_iter, coords_attr_info = cell_attr_dict["Coordinates"] + coords_iter, coords_attr_info = cell_attr_dict[env.coordinates_ns] x_index = coords_attr_info.get("X Coordinate", None) y_index = coords_attr_info.get("Y Coordinate", None) @@ -1221,7 +1221,7 @@ def make_cell_selection(env): num_cells += 1 elif (pop_name in env.cell_attribute_info) and ( - "Coordinates" in env.cell_attribute_info[pop_name] + env.coordinates_ns in env.cell_attribute_info[pop_name] ): if rank == 0: logger.info( @@ -1232,7 +1232,7 @@ def make_cell_selection(env): data_file_path, pop_name, selection=gid_range, - namespace="Coordinates", + namespace=env.coordinates_ns, comm=env.comm, return_type="tuple", ) diff --git a/src/scripts/run_network.py b/src/scripts/run_network.py index 8ac2d93..e75e98a 100644 --- a/src/scripts/run_network.py +++ b/src/scripts/run_network.py @@ -200,6 +200,12 @@ def mpi_excepthook(type, value, traceback): type=str, help="attribute name for input spikes when cell selection is specified", ) +@click.option( + "--coordinates-namespace", + required=False, + type=str, + help="namespace for coordinates when cells without morphologies are instantiated", +) @click.option("--dt", type=float, default=0.025, help="") @click.option( "--ldbal", @@ -268,6 +274,7 @@ def main( spike_input_path, spike_input_namespace, spike_input_attr, + coordinates_namespace, dt, ldbal, lptbal,