Skip to content

Commit 38a012b

Browse files
committed
clean up PR
1 parent 3a6d64d commit 38a012b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

neo/rawio/spikegadgetsrawio.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@
2020
Author: Samuel Garcia
2121
"""
2222

23+
import numpy as np
24+
25+
from xml.etree import ElementTree
26+
2327
from .baserawio import (
2428
BaseRawIO,
2529
_signal_channel_dtype,
2630
_signal_stream_dtype,
2731
_spike_channel_dtype,
2832
_event_channel_dtype,
2933
)
30-
31-
import numpy as np
32-
33-
from xml.etree import ElementTree
34+
from neo.core import NeoReadWriteError
3435

3536

3637
class SpikeGadgetsRawIO(BaseRawIO):
@@ -89,15 +90,13 @@ def _produce_ephys_channel_ids(self, n_total_channels, n_channels_per_chip):
8990
0, 32, 64, 96, 1, 33, 65, 97, ..., 128
9091
See also: https://github.com/NeuralEnsemble/python-neo/issues/1215
9192
"""
92-
x = []
93-
for k in range(n_channels_per_chip):
94-
x.append(
95-
[
96-
k + i * n_channels_per_chip
97-
for i in range(int(n_total_channels / n_channels_per_chip))
98-
]
99-
)
100-
return [item for sublist in x for item in sublist]
93+
ephys_channel_ids_list = []
94+
for hw_channel in range(n_channels_per_chip):
95+
hw_channel_list = [
96+
hw_channel + chip * n_channels_per_chip for chip in range(int(n_total_channels / n_channels_per_chip))
97+
]
98+
ephys_channel_ids_list.append(hw_channel_list)
99+
return [channel for channel_list in ephys_channel_ids_list for channel in channel_list]
101100

102101
def _parse_header(self):
103102
# parse file until "</Configuration>"
@@ -123,21 +122,21 @@ def _parse_header(self):
123122

124123
self._sampling_rate = float(hconf.attrib["samplingRate"])
125124
num_ephy_channels = int(hconf.attrib["numChannels"])
126-
125+
127126
# check for agreement with number of channels in xml
128127
sconf_channels = np.sum([len(x) for x in sconf])
129128
if sconf_channels < num_ephy_channels:
130129
num_ephy_channels = sconf_channels
131130
if sconf_channels > num_ephy_channels:
132-
raise ValueError(
131+
raise NeoReadWriteError(
133132
"SpikeGadgets: the number of channels in the spike configuration is larger than the number of channels in the hardware configuration"
134133
)
135134

136135
try:
137136
num_chan_per_chip = int(sconf.attrib["chanPerChip"])
138137
except KeyError:
139138
num_chan_per_chip = 32 # default value for Intan chips
140-
139+
141140
# explore sub stream and count packet size
142141
# first bytes is 0x55
143142
packet_size = 1
@@ -208,9 +207,7 @@ def _parse_header(self):
208207
signal_streams.append((stream_name, stream_id))
209208
self._mask_channels_bytes[stream_id] = []
210209

211-
channel_ids = self._produce_ephys_channel_ids(
212-
num_ephy_channels, num_chan_per_chip
213-
)
210+
channel_ids = self._produce_ephys_channel_ids(num_ephy_channels, num_chan_per_chip)
214211
chan_ind = 0
215212
self.is_scaleable = "spikeScalingToUv" in sconf[0].attrib
216213
if not self.is_scaleable:

0 commit comments

Comments
 (0)