Skip to content

Commit

Permalink
address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Weina Ji committed Mar 11, 2024
1 parent 60680e3 commit 30cd087
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions commonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from neuron import h
from pathlib import Path
from typing import List

def mkdir_p(path):
try:
Expand Down Expand Up @@ -193,16 +194,23 @@ def write_report_config(output_file, report_name, target_name, report_type, repo
# Write the array of integers to the file in binary format
fp.write(struct.pack(f'{num_gids}i', *gids))
fp.write(b'\n')
fp.write(b"1\n")
fp.write(b"default 0\n")
fp.write(b"spikes.h5\n")

def write_spike_config(output_file: str, spike_filename: str,
population_names: List[str], population_offsets: List[int]):
report_conf = Path(output_file)
num_population = len(population_names)
with report_conf.open("a") as fp:
fp.write(f"{num_population}\n")
for pop_name, offset in zip(population_names, population_offsets):
fp.write(f"{pop_name} {offset}\n")
fp.write(f"{spike_filename}\n")

def write_sim_config(output_file, coredata_dir, report_conf, tstop):
sim_conf = Path(output_file)
sim_conf.parent.mkdir(parents=True, exist_ok=True)
os.makedirs(coredata_dir, exist_ok=True)
with sim_conf.open("w") as fp:
fp.write(f"outpath=./\n")
fp.write("outpath=./\n")
fp.write(f"datpath=./{coredata_dir}\n")
fp.write(f"tstop={tstop}\n")
fp.write(f"report-conf='{report_conf}'\n")
Expand Down
1 change: 1 addition & 0 deletions ringtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def prun(tstop):
if settings.rank == 0:
write_report_config(report_conf_file, "soma.h5", "Mosaic", "compartment", "v",
"mV", "SONATA", 2, 1, 0, tstop, list(range(ncell)))
write_spike_config(report_conf_file, "spikes.h5", ["default"], [0])
write_sim_config(sim_conf_file, "corenrn_data", report_conf_file, tstop)
coreneuron.sim_config=sim_conf_file

Expand Down

0 comments on commit 30cd087

Please sign in to comment.