Skip to content

Commit fdb0e7c

Browse files
committed
correctly handle channel index annotations in case timecolumn is included in usecols
1 parent 727207e commit fdb0e7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

neo/io/asciisignalio.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AsciiSignalIO(BaseIO):
3939
column delimiter in file, e.g. '\t', one space, two spaces, ',', ';'
4040
timecolumn:
4141
None or a valid integer that identifies which column contains the time vector
42-
(counting from zero)
42+
(counting from zero, within the list of selected columns, see also `usecols` Argument)
4343
units:
4444
units of AnalogSignal can be a str or directly a Quantity
4545
time_units:
@@ -251,13 +251,16 @@ def read_segment(self, lazy=False):
251251
t_start = sig[0, self.timecolumn] * self.time_units
252252

253253
if self.signal_group_mode == 'all-in-one':
254+
channel_index_annotation = self.usecols or np.arange(sig.shape[1])
255+
channel_index_annotation = np.asarray(channel_index_annotation)
254256
if self.timecolumn is not None:
255257
mask = list(range(sig.shape[1]))
256258
if self.timecolumn >= 0:
257259
mask.remove(self.timecolumn)
258260
else: # allow negative column index
259261
mask.remove(sig.shape[1] + self.timecolumn)
260262
signal = sig[:, mask]
263+
channel_index_annotation = channel_index_annotation[mask]
261264
else:
262265
signal = sig
263266
if sampling_rate is None:
@@ -269,7 +272,7 @@ def read_segment(self, lazy=False):
269272
ana_sig = AnalogSignal(signal * self.units, sampling_rate=sampling_rate,
270273
t_start=t_start,
271274
name='multichannel')
272-
ana_sig.array_annotate(channel_index=self.usecols or np.arange(signal.shape[1]))
275+
ana_sig.array_annotate(channel_index=channel_index_annotation)
273276
seg.analogsignals.append(ana_sig)
274277
else:
275278
if self.timecolumn is not None and self.timecolumn < 0:

0 commit comments

Comments
 (0)