Skip to content

Commit

Permalink
neuron CompartmentModel: speed up adding recordings by ...
Browse files Browse the repository at this point in the history
... looking up all segments at once
  • Loading branch information
schlegelp committed Oct 6, 2023
1 parent fd557fa commit 95d62cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions navis/interfaces/neuron/comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,18 @@ def _add_record(self, where, what, label=None):
if rec_type not in self.records:
self.records[rec_type] = {}

for w in where:
# # Get node segments only for nodes
is_node = ~np.array([is_NEURON_object(w) for w in where])
node_segs = np.zeros(len(where), dtype=object)
node_segs[is_node] = self.get_node_segment(where[is_node])

for i, w in enumerate(where):
# If this is a neuron object (e.g. segment, section or point
# process) we assume this does not need mapping
if is_NEURON_object(w):
seg = w
else:
seg = self.get_node_segment(w)
seg = node_segs[i]

rec = neuron.h.Vector().record(getattr(seg, what))

Expand Down

0 comments on commit 95d62cb

Please sign in to comment.