Skip to content

Commit e6685be

Browse files
authored
Merge branch 'master' into fix_axonarawio
2 parents 0d4b92e + 2576037 commit e6685be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2333
-1051
lines changed

.github/workflows/core-test.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,13 @@ jobs:
2424
strategy:
2525
fail-fast: true
2626
matrix:
27-
os: ["ubuntu-latest", "windows-latest"]
28-
# "macos-latest",
29-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
30-
numpy-version: ['1.20.3', '1.21.6', '1.22.4', '1.23.5', '1.24.1', '1.25.1', '1.26.4']
27+
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
28+
python-version: ['3.9', '3.10', '3.11', '3.12']
29+
numpy-version: ['1.22.4', '1.23.5', '1.24.1', '1.25.1', '1.26.4']
30+
# numpy 1.22: 3.10, 1.23: 3.11, 1.24: 3.11, 1.25: 3.11, 1.26: 3.12
3131
exclude:
32-
- python-version: '3.8'
33-
numpy-version: '1.25.1'
34-
- python-version: '3.8'
35-
numpy-version: '1.26.4'
36-
- python-version: '3.10'
37-
numpy-version: '1.20.3'
38-
- python-version: '3.11'
39-
numpy-version: '1.20.3'
4032
- python-version: '3.11'
41-
numpy-version: '1.21.6'
42-
- python-version: '3.12'
43-
numpy-version: '1.20.3'
44-
# python 3.12 only works on latest numpy
45-
- python-version: '3.12'
46-
numpy-version: '1.21.6'
33+
numpy-version: '1.22.4'
4734
- python-version: '3.12'
4835
numpy-version: '1.22.4'
4936
- python-version: '3.12'

.github/workflows/io-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: true
2020
matrix:
21-
python-version: ['3.9', '3.11']
21+
python-version: ['3.9', '3.11.9']
2222
defaults:
2323
# by default run in bash mode (required for conda usage)
2424
run:

README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ A project with similar aims but for neuroimaging file formats is `NiBabel`_.
3131
Code status
3232
-----------
3333

34+
.. image:: https://img.shields.io/pypi/v/neo.svg
35+
:target: https://pypi.python.org/pypi/neo
36+
:alt: PyPI Release Version
3437
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/core-test.yml/badge.svg?event=push&branch=master
3538
:target: https://github.com/NeuralEnsemble/python-neo/actions?query=event%3Apush+branch%3Amaster
3639
:alt: Core Test Status (Github Actions)
37-
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/io-test.yml/badge.svg?event=push&branch=master
40+
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/io-test_trigger.yml/badge.svg?event=push&branch=master
3841
:target: https://github.com/NeuralEnsemble/python-neo/actions?query=event%3Apush+branch%3Amaster
3942
:alt: IO Test Status (Github Actions)
4043
.. image:: https://coveralls.io/repos/NeuralEnsemble/python-neo/badge.png
@@ -64,7 +67,8 @@ grant agreement FETPI-015879 (FACETS), by the European Union Seventh Framework P
6467
under grant agreements no. 269921 (BrainScaleS) and no. 604102 (HBP),
6568
and by the European Union’s Horizon 2020 Framework Programme for
6669
Research and Innovation under the Specific Grant Agreements No. 720270 (Human Brain Project SGA1),
67-
No. 785907 (Human Brain Project SGA2) and No. 945539 (Human Brain Project SGA3).
70+
No. 785907 (Human Brain Project SGA2) and No. 945539 (Human Brain Project SGA3),
71+
and by the European Union's Research and Innovation Program Horizon Europe Grant Agreement No. 101147319 (EBRAINS 2.0).
6872

6973
.. _OpenElectrophy: https://github.com/OpenElectrophy/OpenElectrophy
7074
.. _Elephant: http://neuralensemble.org/elephant

codemeta.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"license": "https://spdx.org/licenses/BSD-3-Clause",
55
"codeRepository": "https://github.com/NeuralEnsemble/python-neo",
66
"contIntegration": "https://github.com/NeuralEnsemble/python-neo/actions",
7-
"dateModified": "2024-08-01",
8-
"downloadUrl": "https://files.pythonhosted.org/packages/0f/16/4e22eb38621183d56acde0abbe591f15e79c6332e9ec360fc5db171b39ab/neo-0.13.2.tar.gz",
7+
"dateModified": "2024-10-14",
8+
"downloadUrl": "https://files.pythonhosted.org/packages/e0/0d/e973b7e8464b6f1d88022c46040f203d93c0b080af0e33702bb11873dbbb/neo-0.13.4.tar.gz",
99
"issueTracker": "https://github.com/NeuralEnsemble/python-neo/issues",
1010
"name": "Neo",
11-
"version": "0.13.2",
11+
"version": "0.13.4",
1212
"identifier": "RRID:SCR_000634",
1313
"description": "Neo is a Python package for working with electrophysiology data in Python, together with support for reading a wide range of neurophysiology file formats, including Spike2, NeuroExplorer, AlphaOmega, Axon, Blackrock, Plexon, Tdt, and support for writing to a subset of these formats plus non-proprietary formats including HDF5.\n\nThe goal of Neo is to improve interoperability between Python tools for analyzing, visualizing and generating electrophysiology data by providing a common, shared object model. In order to be as lightweight a dependency as possible, Neo is deliberately limited to represention of data, with no functions for data analysis or visualization.\n\nNeo is used by a number of other software tools, including SpykeViewer (data analysis and visualization), Elephant (data analysis), the G-node suite (databasing), PyNN (simulations), tridesclous_ (spike sorting) and ephyviewer (data visualization).\n\nNeo implements a hierarchical data model well adapted to intracellular and extracellular electrophysiology and EEG data with support for multi-electrodes (for example tetrodes). Neo's data objects build on the quantities package, which in turn builds on NumPy by adding support for physical dimensions. Thus Neo objects behave just like normal NumPy arrays, but with additional metadata, checks for dimensional consistency and automatic unit conversion.",
1414
"applicationCategory": "neuroscience",
15-
"releaseNotes": "https://neo.readthedocs.io/en/stable/releases/0.13.2.html",
15+
"releaseNotes": "https://neo.readthedocs.io/en/latest/releases/0.13.4.html",
1616
"funding": "https://cordis.europa.eu/project/id/945539",
1717
"developmentStatus": "active",
1818
"referencePublication": "https://doi.org/10.3389/fninf.2014.00010",
@@ -23,7 +23,7 @@
2323
"programmingLanguage": ["Python"],
2424
"operatingSystem": ["Linux", "Windows", "macOS"],
2525
"softwareRequirements": [
26-
"Python (version 3.8+)",
26+
"Python (version 3.9+)",
2727
"see https://github.com/NeuralEnsemble/python-neo/blob/master/pyproject.toml"
2828
],
2929
"relatedLink": ["https://neo.readthedocs.io", "https://neuralensemble.org/community"],
@@ -112,6 +112,7 @@
112112
{ "@type": "Person", "givenName": "Kyu Hun", "familyName": "Lee"},
113113
{ "@type": "Person", "givenName": "Xin", "familyName": "Niu"},
114114
{ "@type": "Person", "givenName": "Anthony", "familyName": "Pinto"},
115-
{ "@type": "Person", "givenName": "Chris", "familyName": "Heydrick"}
115+
{ "@type": "Person", "givenName": "Chris", "familyName": "Heydrick"},
116+
{"@type": "Person", "givenName": "Nikhil", "familyName": "Chandra"}
116117
]
117118
}

doc/source/authors.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ and may not be the current affiliation of a contributor.
8888
* Téo Lohrer
8989
* Anthony Pinto [41]
9090
* Xin Niu
91+
* Nikhil Chandra [40]
9192
* Letizia Signorelli [42]
9293

94+
9395
1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Universite Claude Bernard Lyon 1
9496
2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France
9597
3. University of California, Berkeley

doc/source/rawio.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,32 @@ Read event timestamps and times
281281
In [42]: print(ev_times)
282282
[ 0.0317]
283283

284+
Signal streams and signal buffers
285+
---------------------------------
286+
287+
For reading analog signals **neo.rawio** has 2 important concepts:
288+
289+
1. The **signal_stream** : it is a group of channels that can be read together using :func:`get_analog_signal_chunk()`.
290+
This group of channels is guaranteed to have the same sampling rate, and the same duration per segment.
291+
Most of the time, this group of channel is a "logical" group of channels. In short they are from the same headstage
292+
or from the same auxiliary board.
293+
Optionally, depending on the format, a **signal_stream** can be a slice of or an entire **signal_buffer**.
294+
295+
2. The **signal_buffer** : it is group of channels that share the same data layout in a file. The most simple example
296+
is channel that can be read by a simple :func:`signals = np.memmap(file, shape=..., dtype=... , offset=...)`.
297+
A **signal_buffer** can contain one or several **signal_stream**'s (very often it is only one).
298+
There are two kind of formats that handle this concept:
299+
300+
* Formats which use :func:`np.memmap()` internally
301+
* Formats based on hdf5
302+
303+
There are many formats that do not handle this concept:
304+
305+
* the ones that use an external python package for reading data (edf, ced, plexon2, ...)
306+
* the ones with a complicated data layout (e.g. those where the data blocks are split without structure)
307+
308+
To check if a format makes use of the buffer api you can check the class attribute flag `has_buffer_description_api` of the
309+
rawio class.
284310

285311

286312

doc/source/releases.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Release notes
66
.. toctree::
77
:maxdepth: 1
88

9+
releases/0.13.4.rst
10+
releases/0.13.3.rst
911
releases/0.13.2.rst
1012
releases/0.13.1.rst
1113
releases/0.13.0.rst

doc/source/releases/0.13.3.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
========================
2+
Neo 0.13.3 release notes
3+
========================
4+
5+
28 August 2024
6+
7+
This release of Neo contains bug fixes, still with a focus on the planned 1.0 release,
8+
and will be the last release not to support NumPy 2.0.
9+
10+
See all `pull requests`_ included in this release and the `list of closed issues`_.
11+
12+
13+
Updated dependencies
14+
--------------------
15+
16+
Neo has a limit of NumPy >= 1.19.5, < 2.0.0 and Quantities >= 14.0.1, < 0.16.0
17+
18+
19+
Bug fixes and improvements in IO modules
20+
----------------------------------------
21+
22+
Bug fixes and/or improvements have been made to :class:`PlexonIO`, :class:`SpikeGLXIO`,
23+
:class:`BiocamIO`.
24+
25+
Acknowledgements
26+
----------------
27+
28+
Thanks to Zach McKenzie, Heberto Mayorquin, and Alessio Buccino for their contributions to this release.
29+
30+
31+
.. _`pull requests`: https://github.com/NeuralEnsemble/python-neo/pulls?q=is%3Apr+is%3Aclosed+milestone%3A0.13.3
32+
33+
.. _`list of closed issues`: https://github.com/NeuralEnsemble/python-neo/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.13.3

doc/source/releases/0.13.4.rst

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
========================
2+
Neo 0.13.4 release notes
3+
========================
4+
5+
21 October 2024
6+
7+
This release of Neo contains bug fixes across many IOs, a new IO for :code:`NeuroNexus`, drop of Python 3.8, NumPy 1.20 & 1.21, still with a focus on the planned 1.0 release.
8+
Additionally Neo now supports Quantities >=16.1 which brings us closer to support for NumPy 2.0 +. At the :code:`RawIO` level a new :code:`buffer api` has been introduced
9+
with the goal of better grouping streams of data together. This is an ongoing effort to provide better access to streams of data that are typically analyzed together without
10+
changes to the public API.
11+
12+
This point release will be the last release to not support Python 3.13 and NumPy > 2.0.
13+
14+
See all `pull requests`_ included in this release and the `list of closed issues`_.
15+
16+
17+
Updated dependencies
18+
--------------------
19+
20+
Neo has a limit of NumPy >= 1.22.4, < 2.0.0
21+
Neo now supports Python >= 3.9, <3.13
22+
Neo has a limit of Quantities >= 16.1
23+
Neo has a limit of dhn_med_py < 2.0.0 (for reading MED format)
24+
25+
Deprecations
26+
------------
27+
28+
As Quantities has dropped support for the :code:`copy` argument when making Quantities arrays to be NumPy 2.0 compatible, the :code:`copy` argument
29+
has also been deprecated in all Neo core objects (e.g. :code:`SpikeTrain`, etc.). For this version and the next version the default is now :code:`copy=None`.
30+
If :code:`copy=True` or :code:`copy=False` are used an error will be raised. This also means that some functionality for rescaling and dtype conversion, which
31+
required :code:`copy=True` are no longer possible. Appropriate errors are raised if the user tries these now impossible behaviors at construction.
32+
33+
Additional changes that occurred in Quantities can be viewed at their changelog:
34+
https://github.com/python-quantities/python-quantities/blob/master/CHANGES.txt
35+
36+
Currently acceptable construction patterns can be found in the Neo test folder:
37+
https://github.com/NeuralEnsemble/python-neo/blob/master/neo/test/coretest
38+
39+
Many previous behaviors can still be achieved by using additional lines of code, e.g.:
40+
41+
.. code-block:: python
42+
43+
>>> import quantities as pq
44+
>>> import neo
45+
46+
# if we want to get a spiketrain in seconds, but we entered our times in ms
47+
# we used to be able to autoconvert by specifying units. But now this will
48+
# raise an error!
49+
>>> times = [1,2,3] * 1 * pq.ms
50+
>>> t_stop = 1 * pq.s
51+
>>> spiketrain = neo.SpikeTrain(times, t_stop=t_stop, units='s')
52+
ValueError: cannot rescale and return view
53+
# so instead we need to rescale in a second step
54+
>>> spiketrain = neo.SpikeTrain(times, t_stop=t_stop)
55+
>>> spiketrain
56+
<SpikeTrain(array[1, 2, 3] * ms, [0.0 ms, 1000.0 ms])>
57+
>>> rescaled_spiketrain = spiketrain.rescale('s')
58+
>>> rescaled_spiketrain
59+
<SpikeTrain(array[0.001, 0.002, 0.003] * s, [0.0 s, 10.0 s])>
60+
61+
62+
CI Additions/Changes
63+
--------------------
64+
65+
Neo has sped up the testing suite by ~15% and added additional testing for IOs: :class:`NeuralynxIO` and
66+
:class:`Plexon2IO`.
67+
68+
Testing around :code:`copy` was removed from the core testing, since this argument is no longer possible.
69+
70+
71+
Addition of a New IO module
72+
---------------------------
73+
74+
Neo now has support for reading NeuroNexus :code:`.xdat` files with the new :class:`NeuroNexusIO`.
75+
76+
77+
Bug fixes and improvements in IO modules
78+
----------------------------------------
79+
80+
Bug fixes and/or improvements have been made to :class:`MaxwellIO`, :class:`NeuroNexusIO`,
81+
:class:`IntanIO`, :class:`Plexon2IO`, :class:`IgorIO`, :class:`SpikeGadgetsIO`, :class:`PlexonIO`,
82+
and :class:`BrainVisionRawIO`, and :class:`EDFIO`
83+
84+
Buffer API
85+
----------
86+
87+
The motivation for this :code:`RawIO` was that many IOs have buffers of data (memmaps/hdf5) files, which allow for multiple unrelated streams of data to be packaged
88+
together. This has led to some inconsistencies in how IOs access streams of data. For example, the :code:`PlexonIO` stores WideBand and Filtered versions of the same
89+
data, but the end user likely wouldn't want to analyze them both at the same time as that would be duplication of information. :code:`SpikeGLX` also makes use of a sync
90+
channel which is stored with the electrophysiological channels, but should not be analyzed as an ephys channel. The Buffer API will be an ongoing set of PRs at the
91+
:code:`RawIO` level to better clarify how data enters and is mapped in Neo versus how the end-user might request streams of data. We hope that this process will allow
92+
the end-user better access to the data they want without having unrelated data mixed in. Importantly the public API is not being affected by this process at all. The end-user
93+
will still request their desired stream using :code:`stream_index` argument when interacting with a :code:`RawIO`.
94+
95+
In this release, each IO was divided into whether it would fit with the buffer api requirements or not and the initial :code:`buffer_id` was applied to all IOs. This step
96+
has not changed any behavior in Neo. But the :code:`RawIO.header` information will now have an additional field that will be used in future releases of Neo under-the-hood.
97+
98+
We want to emphasize this is not a public API change and over the next version we hope to fully implement this new schema to allow for better interaction with data at the
99+
:code:`RawIO` and :code:`IO` levels of Neo.
100+
101+
This project has largely been spearheaded by Samuel Garcia and we thank him for his herculean efforts.
102+
103+
Acknowledgements
104+
----------------
105+
106+
Thanks to Zach McKenzie, Heberto Mayorquin, Samuel Garcia, Andrew Davison, Alessio Buccino, Nikhil Chandra, and Peter Steinmetz for their contributions to this release.
107+
108+
109+
.. _`pull requests`: https://github.com/NeuralEnsemble/python-neo/pulls?q=is%3Apr+is%3Aclosed+milestone%3A0.13.4
110+
111+
.. _`list of closed issues`: https://github.com/NeuralEnsemble/python-neo/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.13.4

neo/core/analogsignal.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _new_AnalogSignalArray(
5252
signal,
5353
units=None,
5454
dtype=None,
55-
copy=True,
55+
copy=None,
5656
t_start=0 * pq.s,
5757
sampling_rate=None,
5858
sampling_period=None,
@@ -180,7 +180,7 @@ def __new__(
180180
signal,
181181
units=None,
182182
dtype=None,
183-
copy=True,
183+
copy=None,
184184
t_start=0 * pq.s,
185185
sampling_rate=None,
186186
sampling_period=None,
@@ -198,8 +198,13 @@ def __new__(
198198
199199
__array_finalize__ is called on the new object.
200200
"""
201+
if copy is not None:
202+
raise ValueError(
203+
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
204+
)
205+
201206
signal = cls._rescale(signal, units=units)
202-
obj = pq.Quantity(signal, units=units, dtype=dtype, copy=copy).view(cls)
207+
obj = pq.Quantity(signal, units=units, dtype=dtype).view(cls)
203208

204209
if obj.ndim == 1:
205210
obj.shape = (-1, 1)
@@ -218,7 +223,7 @@ def __init__(
218223
signal,
219224
units=None,
220225
dtype=None,
221-
copy=True,
226+
copy=None,
222227
t_start=0 * pq.s,
223228
sampling_rate=None,
224229
sampling_period=None,
@@ -257,7 +262,7 @@ def __reduce__(self):
257262
np.array(self),
258263
self.units,
259264
self.dtype,
260-
True,
265+
None,
261266
self.t_start,
262267
self.sampling_rate,
263268
self.sampling_period,
@@ -547,6 +552,7 @@ def time_shift(self, t_shift):
547552

548553
return new_sig
549554

555+
# copy in splice is a deepcopy not a numpy copy so we can keep
550556
def splice(self, signal, copy=False):
551557
"""
552558
Replace part of the current signal by a new piece of signal.

0 commit comments

Comments
 (0)