G-Node / python-neo

Fork of python-neo for maintaining the NIX IO.
https://github.com/NeuralEnsemble/python-neo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Group signals only once per Block #15

Open achilleas-k opened 6 years ago

achilleas-k commented 6 years ago

The _group_signals() method is called once per Group/Segment https://github.com/G-Node/python-neo/blob/6bda7897756be1b950efdf708bd4a1197deed86e/neo/io/nixio.py#L283

and then a final time in each Block to find "groupless" signals: https://github.com/G-Node/python-neo/blob/6bda7897756be1b950efdf708bd4a1197deed86e/neo/io/nixio.py#L242

It's not generally a slow process. There's a sorting going on in the method which is going to be removed soon (see NeuralEnsemble/python-neo#545) and ignoring that, it's an O(N) function. Now, N is the number of signals first in a Group/Segment, and then for the whole Block, so all in all the entire reading process reads through the DataArrays twice. Since we're reading all the DataArrays in a Block anyway, we might as well collect them before descending into a Group and use a per-block collection/grouping of signals.