Repository navigation
Description
Coming from SpikeInterface/spikeinterface#3025. TdtRawIO builds the signal streams from the .tsq entries, so a store saved only in .sev files comes back empty with a dummy sampling rate and dtype:
python-neo/neo/rawio/tdtrawio.py
Lines 238 to 268 in 5f64a9e
| mask = is_stream_event & matches_store_name & matches_channel | |
| data_index = tsq[mask].copy() | |
| self._sigs_index[seg_index][global_chan_index] = data_index | |
| size = info["NumPoints"] * data_index.size | |
| if stream_index not in self._sigs_lengths[seg_index]: | |
| self._sigs_lengths[seg_index][stream_index] = size | |
| else: | |
| if self._sigs_lengths[seg_index][stream_index] != size: | |
| raise ValueError(f"The sig lengths for {seg_index=}, {stream_index=} is not of size {size}") | |
| # signal start time, relative to start of segment | |
| if len(data_index["timestamp"]): | |
| t_start = data_index["timestamp"][0] | |
| else: | |
| # if no signal present use segment t_start as dummy value | |
| t_start = self._seg_t_starts[seg_index] | |
| if stream_index not in self._sigs_t_start[seg_index]: | |
| self._sigs_t_start[seg_index][stream_index] = t_start | |
| else: | |
| if self._sigs_t_start[seg_index][stream_index] != t_start: | |
| raise ValueError(f"The t_start for {seg_index=}, {stream_index=} is not of time {t_start}") | |
| # sampling_rate and dtype | |
| if len(data_index): | |
| _sampling_rate = float(data_index["frequency"][0]) | |
| _dtype = data_formats_map[data_index["dataformat"][0]] | |
| else: | |
| # if no signal present use dummy values | |
| _sampling_rate = 1.0 | |
| _dtype = "int" |
With tdt/dataset_0_single_block from gin, Wav5 has its four .sev files but reads as 0 samples at 1.0 Hz with dtype int (RSn1 and RSn2 too, but their .sev files are not in the test data).
The .Tbk already has the sampling rate and the data format of the store (24414.0625 Hz and float32 for Wav5), and the number of samples is the size of the .sev files minus their 40-byte header. When a store has no .sev files either we should raise or warn instead of returning an empty stream.
Activity
drkotireddysaripalli commentedon Oct 9, 2026
A repair also needs to reach the chunk-reading path. At current master
f568f506, supplying the correct length/rate/dtype still leaves_sigs_indexempty for an SEV-only store._get_analogsignal_chunkthen accessesdata_index[bl]["offset"]and raisesIndexError: index 0 is out of bounds for axis 0 with size 0.Here is a synthetic version-3, four-channel float32 fixture with 17 known samples per channel. It exercises the real
parse_header()and chunk reader; the private metadata assignments deliberately isolate the remaining chunk dependency and are not a proposed parser fix. No recorded data is needed.Self-contained reproduction (Python 3.12 / NumPy 2.1.3)
For this simple contiguous case, a sample slice
[i_start:i_stop)can be read from each SEV payload at byte offsets40 + i_start * itemsize : 40 + i_stop * itemsize. A dedicated contiguous-SEV path would avoid inventing TSQ blocks and handle a final partial block such as these 17 samples withNumPoints=4. That needs to remain distinct from streams whose real TSQ offsets describe the data.The local check covered float32/17 samples and int16/20 samples, single- and multi-block entry modes, full/first/interior/cross-boundary/final/empty slices, and channel order
[3, 0]. All 24 diagnostic direct slices matched the known payload; 24 corresponding TSQ-backed control reads also matched. These are focused synthetic checks, not a complete implementation or the upstream suite.Two scope boundaries matter:
(file_size - 40) // dtype.itemsize, with a divisibility check before accepting a truncated payload. The byte count alone is not the sample count. TDT's format guidance identifies per-channel SEV files and sampling-rate overrides; its RS4 documentation also describes segmented files and logs with starting/ending samples and gaps. Those variants need an explicit policy rather than assuming every SEV is one gap-free stream starting at block time.NeoReadWriteErrorin this check. That existing guard should be preserved rather than reintroducing TEV fallback for a UCF store.For reproducibility,
tdt==0.7.6recognized the synthetic sampling rate and all known payload samples, but its default read returned one extra trailing zero in these fixtures. The comparisons above therefore use the generated payload and physical sample count, not the SDK's returned length. Legacy headers, hourly segmentation, logs/gaps, timing alignment and unit scaling were not validated.Affiliation: Chief Scientist PinnacleAI(R), Pinnacle Blooms Network of Bharath Healthcare P LIMITED, https://www.pinnacleblooms.org/verify