From c0ba7e15f5e9c9958c5d0c606175c818685b171c Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 28 Jan 2025 10:58:21 -0600 Subject: [PATCH] `mock_ElectricalSeries` : Make number of electrodes between data an electrode region agree when explicitly passing data (#2019) * make n_electrodes between data and electrode region agree * added changelog * typo * Update CHANGELOG.md Co-authored-by: Steph Prince <40640337+stephprince@users.noreply.github.com> --------- Co-authored-by: Steph Prince <40640337+stephprince@users.noreply.github.com> --- CHANGELOG.md | 1 + src/pynwb/testing/mock/ecephys.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2230cbd49..21e9e8ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Deprecated `EventWaveform` neurodata type. @rly [#1940](https://github.com/NeurodataWithoutBorders/pynwb/pull/1940) - Deprecated `ImageMaskSeries` neurodata type. @rly [#1941](https://github.com/NeurodataWithoutBorders/pynwb/pull/1941) - Removed python 3.8 support, added python 3.13 support. @stephprince [#2007](https://github.com/NeurodataWithoutBorders/pynwb/pull/2007) +- `mock_ElectricalSeries`. Make number of electrodes between data and electrode region agree when explicitly passing data @h-mayorquin [#2019](https://github.com/NeurodataWithoutBorders/pynwb/pull/2019) ### Documentation and tutorial enhancements - Updated `SpikeEventSeries`, `DecompositionSeries`, and `FilteredEphys` examples. @stephprince [#2012](https://github.com/NeurodataWithoutBorders/pynwb/pull/2012) diff --git a/src/pynwb/testing/mock/ecephys.py b/src/pynwb/testing/mock/ecephys.py index 0669e7493..315eb3d9c 100644 --- a/src/pynwb/testing/mock/ecephys.py +++ b/src/pynwb/testing/mock/ecephys.py @@ -83,15 +83,16 @@ def mock_ElectricalSeries( # Set a default rate if timestamps are not provided rate = 30_000.0 if (timestamps is None and rate is None) else rate + n_electrodes = data.shape[1] if data is not None else 5 electrical_series = ElectricalSeries( name=name or name_generator("ElectricalSeries"), description=description, - data=data if data is not None else np.ones((10, 5)), + data=data if data is not None else np.ones((10, n_electrodes)), rate=rate, starting_time=starting_time, timestamps=timestamps, - electrodes=electrodes or mock_electrodes(nwbfile=nwbfile), + electrodes=electrodes or mock_electrodes(nwbfile=nwbfile, n_electrodes=n_electrodes), filtering=filtering, conversion=conversion, offset=offset,