Repository navigation
Closed
Description
import pynwb
import lindi
import pynapple as nap
# Load https://api.dandiarchive.org/api/assets/2b9e441b-56bc-4be2-893e-0e02d22d239d/download/
f = lindi.LindiH5pyFile.from_lindi_file("https://lindi.neurosift.org/dandi/dandisets/000582/assets/2b9e441b-56bc-4be2-893e-0e02d22d239d/nwb.lindi.json")
nwb = pynwb.NWBHDF5IO(file=f, mode='r').read()
nap_nwb = nap.NWBFile(nwb)
results = nap.compute_tuning_curves(nap_nwb["units"], nap_nwb["ElectricalSeriesLFP"], 20)---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/miniconda3/lib/python3.12/site-packages/numpy/lib/_histograms_impl.py:988, in histogramdd(sample, bins, range, density, weights)
986 try:
987 # Sample is an ND-array.
--> 988 N, D = sample.shape
989 except (AttributeError, ValueError):
990 # Sample is a sequence of 1D arrays.
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 results = nap.compute_tuning_curves(nap_nwb["units"], nap_nwb["ElectricalSeriesLFP"],20)
File ~/miniconda3/lib/python3.12/site-packages/pynapple/process/tuning_curves.py:253, in compute_tuning_curves(data, features, bins, range, epochs, fs, feature_names, return_pandas, return_counts)
250 raise TypeError("return_counts should be a boolean.")
252 # occupancy
--> 253 occupancy, bin_edges = np.histogramdd(features, bins=bins, range=range)
255 # tuning curves
256 keys = (
257 data.keys()
258 if isinstance(data, nap.TsGroup)
259 else data.columns if isinstance(data, nap.TsdFrame) else [0]
260 )
File ~/miniconda3/lib/python3.12/site-packages/pynapple/core/time_series.py:330, in _BaseTsd.__array_function__(self, func, types, args, kwargs)
327 else:
328 new_args.append(a)
--> 330 out = func._implementation(*new_args, **kwargs)
332 if modifies_time_axis(func, new_args, kwargs):
333 return out
File ~/miniconda3/lib/python3.12/site-packages/numpy/lib/_histograms_impl.py:991, in histogramdd(sample, bins, range, density, weights)
988 N, D = sample.shape
989 except (AttributeError, ValueError):
990 # Sample is a sequence of 1D arrays.
--> 991 sample = np.atleast_2d(sample).T
992 N, D = sample.shape
994 nbin = np.empty(D, np.intp)
File ~/miniconda3/lib/python3.12/site-packages/numpy/_core/shape_base.py:122, in atleast_2d(*arys)
120 res = []
121 for ary in arys:
--> 122 ary = asanyarray(ary)
123 if ary.ndim == 0:
124 result = ary.reshape(1, 1)
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/dataset.py:1112, in Dataset.__array__(self, dtype, copy)
1109 if self.size == 0:
1110 return arr
-> 1112 self.read_direct(arr)
1113 return arr
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/dataset.py:1054, in Dataset.read_direct(self, dest, source_sel, dest_sel)
1046 """ Read data directly from HDF5 into an existing NumPy array.
1047
1048 The destination array must be C-contiguous and writable.
(...)
1051 Broadcasting is supported for simple indexing.
1052 """
1053 with phil:
-> 1054 if self._is_empty:
1055 raise TypeError("Empty datasets have no numpy representation")
1056 if source_sel is None:
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/base.py:532, in cached_property.__get__(self, obj, cls)
529 if obj is None:
530 return self
--> 532 value = obj.__dict__[self.func.__name__] = self.func(obj)
533 return value
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/dataset.py:666, in Dataset._is_empty(self)
663 @cached_property
664 def _is_empty(self):
665 """Check if extent type is empty"""
--> 666 return self._extent_type == h5s.NULL
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/base.py:532, in cached_property.__get__(self, obj, cls)
529 if obj is None:
530 return self
--> 532 value = obj.__dict__[self.func.__name__] = self.func(obj)
533 return value
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File ~/miniconda3/lib/python3.12/site-packages/h5py/_hl/dataset.py:661, in Dataset._extent_type(self)
657 @cached_property
658 @with_phil
659 def _extent_type(self):
660 """Get extent type for this dataset - SIMPLE, SCALAR or NULL"""
--> 661 return self.id.get_space().get_simple_extent_type()
AttributeError: 'str' object has no attribute 'get_space'Metadata
Metadata
Assignees
Labels
No labels
Activity
Fix numpy array conversion for LindiH5pyDataset
bendichter commentedon Mar 8, 2026
Fixed in #121