|
2 | 2 | Tests of neo.rawio.examplerawio |
3 | 3 | """ |
4 | 4 |
|
5 | | -import os |
6 | 5 | import unittest |
7 | 6 | import warnings |
8 | 7 |
|
@@ -153,7 +152,7 @@ def test_compare_blackrockio_with_matlabloader_v21(self): |
153 | 152 | raw_sigs = reader.get_analogsignal_chunk(channel_indexes=[c]) |
154 | 153 | raw_sigs = raw_sigs.flatten() |
155 | 154 | # The Matlab export stops one sample before the end of the file |
156 | | - # (see test_nsx21_signal_size_matches_file_size) |
| 155 | + # (see test_nsx21_reads_the_last_sample) |
157 | 156 | self.assertEqual(raw_sigs.size, lfp_ml.shape[1] + 1) |
158 | 157 | assert_equal(raw_sigs[: lfp_ml.shape[1]], lfp_ml[c, :]) |
159 | 158 |
|
@@ -191,23 +190,20 @@ def test_compare_blackrockio_with_matlabloader_v21(self): |
191 | 190 | matlab_digievents = mts_ml[mid_ml == int(label)] |
192 | 191 | assert_equal(python_digievents, matlab_digievents) |
193 | 192 |
|
194 | | - def test_nsx21_signal_size_matches_file_size(self): |
195 | | - """ |
196 | | - NSx 2.1 headers do not store the number of samples, so it has to come from the file size: |
197 | | - a 32-byte basic header and 4 bytes per channel, then int16 samples for every channel. |
198 | | - """ |
199 | | - dirname = self.get_local_path("blackrock/blackrock_2_1/l101210-001") |
200 | | - for nsx_nb in (2, 5): |
201 | | - reader = BlackrockRawIO(dirname, nsx_to_load=nsx_nb) |
202 | | - reader.parse_header() |
203 | | - num_channels = reader.signal_channels_count(stream_index=0) |
204 | | - data_bytes = os.path.getsize(f"{dirname}.ns{nsx_nb}") - (32 + 4 * num_channels) |
205 | | - self.assertEqual(data_bytes % (2 * num_channels), 0) |
206 | | - expected_num_samples = data_bytes // (2 * num_channels) |
207 | | - self.assertEqual(reader.get_signal_size(block_index=0, seg_index=0, stream_index=0), expected_num_samples) |
208 | | - # the last sample is readable |
209 | | - last = reader.get_analogsignal_chunk(i_start=expected_num_samples - 1, i_stop=expected_num_samples) |
210 | | - self.assertEqual(last.shape, (1, num_channels)) |
| 193 | + def test_nsx21_reads_the_last_sample(self): |
| 194 | + filename = self.get_local_path("blackrock/version_2_1/spikes/offline_sorted_units/online_sorted_units") |
| 195 | + |
| 196 | + reader = BlackrockRawIO(filename=filename, nsx_to_load=2) |
| 197 | + reader.parse_header() |
| 198 | + number_of_samples = reader.get_signal_size(block_index=0, seg_index=0, stream_index=0) |
| 199 | + expected_number_of_samples = 300 # 0.3 s at 1 kHz |
| 200 | + self.assertEqual(number_of_samples, expected_number_of_samples) |
| 201 | + |
| 202 | + reader = BlackrockRawIO(filename=filename, nsx_to_load=5) |
| 203 | + reader.parse_header() |
| 204 | + number_of_samples = reader.get_signal_size(block_index=0, seg_index=0, stream_index=0) |
| 205 | + expected_number_of_samples = 9000 # 0.3 s at 30 kHz |
| 206 | + self.assertEqual(number_of_samples, expected_number_of_samples) |
211 | 207 |
|
212 | 208 | def test_blackrockrawio_ptp_timestamps(self): |
213 | 209 | dirname = self.get_local_path("blackrock/blackrock_3_0_ptp/20231027-125608-001") |
|
0 commit comments