Skip to content

Commit

Permalink
[BBPBGLIB-1127] Remove SpikeWriter.mod and out.dat (#123)
Browse files Browse the repository at this point in the history
## Context
After the deprecation of BlueConfig files, out.dat is not generated
anymore.
Remove the SpikeWriter mod file and the code that was handling the old
out.dat spike file.

## Review
* [x] PR description is complete
* [x] Coding style (imports, function length, New functions, classes or
files) are good
* [ ] Unit/Scientific test added
* [ ] Updated Readme, in-code, developer documentation
  • Loading branch information
jorblancoa authored Feb 13, 2024
1 parent 18b63e0 commit 975fb7c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 182 deletions.
142 changes: 0 additions & 142 deletions core/mod/SpikeWriter.mod

This file was deleted.

1 change: 0 additions & 1 deletion core/mod/coreneuron_modlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ lookupTableV2.mod
netstim_inhpoisson.mod
SonataReportHelper.mod
SonataReports.mod
SpikeWriter.mod
VecStim.mod
3 changes: 1 addition & 2 deletions examples/test_neurodamus.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def test_node_run(trace=False):
logging.info("Run")
node.run_all()

logging.info("Simulation finished. Gather spikes then clean up.")
node.spike2file("out.dat")
logging.info("Simulation finished.")
node.cleanup()


Expand Down
2 changes: 1 addition & 1 deletion neurodamus/core/_neurodamus.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def check_load_lib(mech, env_lib_path):
# which might not bring the model (support for split neurodamus) in which case
# we should load only the model libs pointed by BGLIBPY_MOD_LIBRARY_PATH.

if not check_load_lib("SpikeWriter", "NRNMECH_LIB_PATH"):
if not check_load_lib("SonataReport", "NRNMECH_LIB_PATH"):
logging.error("Could not load neurodamus core mechs from NRNMECH_LIB_PATH")
sys.exit(1)
if not check_load_lib("ProbAMPANMDA_EMS", "BGLIBPY_MOD_LIBRARY_PATH"):
Expand Down
35 changes: 0 additions & 35 deletions neurodamus/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from os import path as ospath
from collections import namedtuple, defaultdict
from contextlib import contextmanager
from shutil import copyfileobj, move

from .core import MPI, mpi_no_errors, return_neuron_timings, run_only_rank0
from .core import NeurodamusCore as Nd
Expand Down Expand Up @@ -1335,15 +1334,11 @@ def run_all(self):
timings = None
if SimConfig.use_neuron:
timings = self._run_neuron()
if not SimConfig.is_sonata_config:
self.spike2file("out.dat")
self.sonata_spikes()
if SimConfig.use_coreneuron:
print_mem_usage()
self.clear_model(avoid_clearing_queues=False)
self._run_coreneuron()
if not SimConfig.is_sonata_config:
self.adapt_spikes("out.dat")
return timings

# -
Expand Down Expand Up @@ -1487,36 +1482,6 @@ def clear_model(self, avoid_creating_objs=False, avoid_clearing_queues=True):
# output
# -------------------------------------------------------------------------

@run_only_rank0
def adapt_spikes(self, outfile):
"""Prepend /scatter to spikes file after coreneuron sim finishes.
"""
output_root = SimConfig.output_root
outfile = ospath.join(output_root, outfile)
tmpfile = ospath.join(output_root, 'tmp.out')
with open(outfile, 'r') as f_src:
with open(tmpfile, 'w') as f_dest:
f_dest.write("/scatter\n")
copyfileobj(f_src, f_dest)
move(tmpfile, outfile)

@mpi_no_errors
def spike2file(self, outfile):
""" Write the spike events that occured on each node into a single output file.
Nodes will write in order, one after the other.
"""
logging.info("Writing spikes to %s", outfile)
output_root = SimConfig.output_root
outfile = ospath.join(output_root, outfile)
spikevec = Nd.Vector()
idvec = Nd.Vector()
# merge spike_vecs and id_vecs for SpikeWriter
for spikes, ids in self._spike_vecs:
spikevec.append(spikes)
idvec.append(ids)
spikewriter = Nd.SpikeWriter()
spikewriter.write(spikevec, idvec, outfile)

def sonata_spikes(self):
""" Write the spike events that occured on each node into a single output SONATA file.
"""
Expand Down
2 changes: 1 addition & 1 deletion neurodamus/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SpikeManager:
""" Holds and manages gid spike time information, specially for Replay.
A SynapseReplay stim can be used for a single gid that has all the synapses instantiated.
Given an out.dat file from a previous run, this object uses a NetStim object to retrigger
Given a spikes file from a previous run, this object uses a NetStim object to retrigger
the synapses at the appropriate time as though the presynaptic cells were present and active.
Internally the spikes are stored in a :py:class:`neurodamus.utils.multimap.GroupedMultiMap`
Expand Down

0 comments on commit 975fb7c

Please sign in to comment.