Skip to content

Commit 22984da

Browse files
committed
make brainwaresrcio handle cases with no spikes in a segment, with tests
1 parent 83a34d6 commit 22984da

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

neo/io/brainwaresrcio.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,18 @@ def __read_segment(self):
903903
# the first Segment
904904
trains = self._read_by_id()
905905
if not trains:
906-
trains = zip(unassigned_spikes)
906+
if unassigned_spikes:
907+
# if there are no assigned spikes,
908+
# just use the unassigned spikes
909+
trains = zip(unassigned_spikes)
910+
else:
911+
# if there are no spiketrains at all,
912+
# create an empty spike train
913+
train = self._default_spiketrain.copy()
914+
train.file_origin = self.__file_origin
915+
if self.__lazy:
916+
train.lazy_shape = (0,)
917+
trains = [[train]]
907918
elif hasattr(trains[0], 'dtype'):
908919
#workaround for some broken files
909920
trains = [unassigned_spikes +

neo/test/iotest/test_brainwaref32io.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ class BrainwareF32IOTestCase(BaseTestIO, unittest.TestCase):
109109

110110
# These are the files it tries to read and test for compliance
111111
files_to_test = ['block_300ms_4rep_1clust_part_ch1.f32',
112+
'block_500ms_5rep_empty_fullclust_ch1.f32',
113+
'block_500ms_5rep_empty_partclust_ch1.f32',
112114
'interleaved_500ms_5rep_ch2.f32',
115+
'interleaved_500ms_5rep_nospikes_ch1.f32',
113116
'multi_500ms_mulitrep_ch1.f32',
114117
'random_500ms_12rep_noclust_part_ch2.f32',
115118
'sequence_500ms_5rep_ch2.f32']

neo/test/iotest/test_brainwaresrcio.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ class BrainwareSrcIOTestCase(BaseTestIO, unittest.TestCase):
267267

268268
# These are the files it tries to read and test for compliance
269269
files_to_test = ['block_300ms_4rep_1clust_part_ch1.src',
270+
'block_500ms_5rep_empty_fullclust_ch1.src',
271+
'block_500ms_5rep_empty_partclust_ch1.src',
270272
'interleaved_500ms_5rep_ch2.src',
273+
'interleaved_500ms_5rep_nospikes_ch1.src',
271274
'interleaved_500ms_7rep_noclust_ch1.src',
272275
'long_170s_1rep_1clust_ch2.src',
273276
'multi_500ms_mulitrep_ch1.src',
@@ -276,7 +279,10 @@ class BrainwareSrcIOTestCase(BaseTestIO, unittest.TestCase):
276279

277280
# these are reference files to compare to
278281
files_to_compare = ['block_300ms_4rep_1clust_part_ch1',
282+
'block_500ms_5rep_empty_fullclust_ch1',
283+
'block_500ms_5rep_empty_partclust_ch1',
279284
'interleaved_500ms_5rep_ch2',
285+
'interleaved_500ms_5rep_nospikes_ch1',
280286
'interleaved_500ms_7rep_noclust_ch1',
281287
'',
282288
'multi_500ms_mulitrep_ch1',
@@ -294,6 +300,7 @@ class BrainwareSrcIOTestCase(BaseTestIO, unittest.TestCase):
294300

295301
def setUp(self):
296302
warnings.filterwarnings('ignore', message='Negative sequence count.*')
303+
warnings.filterwarnings('ignore', message='unknown ID:*')
297304
super(BrainwareSrcIOTestCase, self).setUp()
298305

299306
def test_reading_same(self):

0 commit comments

Comments
 (0)