Skip to content

Commit

Permalink
bug fixes in check_synapses
Browse files Browse the repository at this point in the history
  • Loading branch information
iraikov committed Apr 4, 2024
1 parent 13b2798 commit 6c80245
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/miv_simulator/simulator/distribute_synapses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
append_cell_attributes,
read_population_ranges,
)
from typing import Optional, Tuple, Literal
from typing import Optional, Tuple, Literal, Dict

sys_excepthook = sys.excepthook

Expand Down Expand Up @@ -132,6 +132,7 @@ def check_syns(
seg_density_per_sec,
layer_set_dict,
swc_set_dict,
env.layers,
logger,
)

Expand All @@ -143,30 +144,39 @@ def check_synapses(
seg_density_per_sec,
layer_set_dict,
swc_set_dict,
swc_defs,
layer_defs,
logger,
):
layer_stats = syn_stats_dict["layer"]
swc_stats = syn_stats_dict["swc_type"]

warning_flag = False
incomplete_layers = []
for syn_type, layer_set in list(layer_set_dict.items()):
for layer in layer_set:
if layer in layer_stats:
if layer_stats[layer][syn_type] <= 0:
layer_index = layer_defs[layer]
if layer_index in layer_stats:
if layer_stats[layer_index][syn_type] <= 0:
incomplete_layers.append(layer)
warning_flag = True
else:
incomplete_layers.append(layer)
warning_flag = True
if warning_flag:
logger.warning(
f"Rank {MPI.COMM_WORLD.Get_rank()}: incomplete synapse layer set for cell {gid}: {layer_stats}"
f"Rank {MPI.COMM_WORLD.Get_rank()}: incomplete synapse layer set for cell {gid}: "
f" incomplete layers: {incomplete_layers}\n"
f" populated layers: {layer_stats}\n"
f" layer_set_dict: {layer_set_dict}\n"
f" seg_density_per_sec: {seg_density_per_sec}\n"
f" morph_dict: {morph_dict}"
)
for syn_type, swc_set in swc_set_dict.items():
for swc_type in swc_set:
if swc_type in swc_stats:
if swc_stats[swc_type][syn_type] <= 0:
swc_type_index = swc_defs[swc_type]
if swc_type_index in swc_stats:
if swc_stats[swc_type_index][syn_type] <= 0:
warning_flag = True
else:
warning_flag = True
Expand Down Expand Up @@ -222,6 +232,8 @@ def distribute_synapse_locations(
return distribute_synapses(
forest_filepath=forest_path,
cell_types=env.celltypes,
swc_defs=env.SWC_Types,
layer_defs=env.layers,
populations=populations,
distribution=distribution,
template_path=template_path,
Expand All @@ -238,6 +250,8 @@ def distribute_synapse_locations(
def distribute_synapses(
forest_filepath: str,
cell_types: config.CellTypes,
swc_defs: Dict[str, int],
layer_defs: Dict[str, int],
populations: Tuple[str, ...],
distribution: Literal["uniform", "poisson"],
template_path: str,
Expand Down Expand Up @@ -388,6 +402,8 @@ def distribute_synapses(
seg_density_per_sec,
layer_set_dict,
swc_set_dict,
swc_defs,
layer_defs,
logger,
)

Expand Down

0 comments on commit 6c80245

Please sign in to comment.