diff --git a/doc/source/authors.rst b/doc/source/authors.rst index 357faaf52..f6ec68038 100644 --- a/doc/source/authors.rst +++ b/doc/source/authors.rst @@ -108,6 +108,7 @@ and may not be the current affiliation of a contributor. * Axel Coiffard-Donaty * Anthony Mercer * Aaron Kanzer [53] +* Eva B (evadiva3 on GitHub) 1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Université Claude Bernard Lyon 1 2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France diff --git a/neo/rawio/plexonrawio.py b/neo/rawio/plexonrawio.py index 0f713fcb0..3bef3f26a 100644 --- a/neo/rawio/plexonrawio.py +++ b/neo/rawio/plexonrawio.py @@ -481,7 +481,9 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea # right border # be careful that bl could be both bl0 and bl1!! border = data.size - (i_stop - data_blocks[bl]["cumsum"]) - data = data[:-border] + # Avoid an empty slice when the chunk ends at the block boundary. + if border > 0: + data = data[:-border] if bl == bl0: # left border border = i_start - data_blocks[bl]["cumsum"] diff --git a/neo/test/rawiotest/test_plexonrawio.py b/neo/test/rawiotest/test_plexonrawio.py index f1dac1cff..02f8e20df 100644 --- a/neo/test/rawiotest/test_plexonrawio.py +++ b/neo/test/rawiotest/test_plexonrawio.py @@ -21,6 +21,21 @@ class TestPlexonRawIO( "plexon/plx/timestamp_clock/one_megahertz_forty_bit_timestamps/sorted_spikes_and_strobed_events.plx", ] + def test_chunk_stopping_at_the_end_of_the_last_block(self): + """Keep the final block when the right border is zero.""" + reader = PlexonRawIO(filename=self.get_local_path("plexon/File_plexon_3.plx"), progress_bar=False) + reader.parse_header() + last = reader._data_blocks[5][0][-1] + samples = np.frombuffer(reader._memmap, dtype="int16", count=last["size"] // 2, offset=last["pos"]) + # Use the parsed start to test trimming independently of the block-offset fix in #1980. + start = int(last["cumsum"]) + stop = start + samples.size + for offset in (0, 10): + chunk = reader.get_analogsignal_chunk(i_start=start + offset, i_stop=stop) + np.testing.assert_array_equal(chunk[:, 0], samples[offset:]) + chunk = reader.get_analogsignal_chunk(i_start=start, i_stop=stop - 1) + np.testing.assert_array_equal(chunk[:, 0], samples[:-1]) + def test_timestamps_with_lower_word_above_two_to_the_31(self): """The lower 32 bits of the 40-bit block timestamp must be read unsigned.