@@ -78,7 +78,7 @@ class SpikeGLXRawIO(BaseRawWithBufferApiIO):
78
78
The spikeglx folder containing meta/bin files
79
79
load_sync_channel: bool, default: False
80
80
Can be used to load the synch stream as the last channel of the neural data.
81
- This option is deprecated and will be removed in version 0.15.
81
+ This option is deprecated and will be removed in version 0.15.
82
82
From versions higher than 0.14.1 the sync channel is always loaded as a separate stream.
83
83
load_channel_location: bool, default: False
84
84
If True probeinterface is used to load the channel locations from the directory
@@ -116,7 +116,8 @@ def __init__(self, dirname="", load_sync_channel=False, load_channel_location=Fa
116
116
warn (
117
117
"The load_sync_channel=True option is deprecated and will be removed in version 0.15 \n "
118
118
"The sync channel is now loaded as a separate stream by default and should be accessed as such. " ,
119
- DeprecationWarning , stacklevel = 2
119
+ DeprecationWarning ,
120
+ stacklevel = 2 ,
120
121
)
121
122
self .load_channel_location = load_channel_location
122
123
@@ -162,7 +163,7 @@ def _parse_header(self):
162
163
signal_streams = []
163
164
signal_channels = []
164
165
sync_stream_id_to_buffer_id = {}
165
-
166
+
166
167
for stream_name in stream_names :
167
168
# take first segment
168
169
info = self .signals_info_dict [0 , stream_name ]
@@ -179,16 +180,21 @@ def _parse_header(self):
179
180
for local_chan in range (info ["num_chan" ]):
180
181
chan_name = info ["channel_names" ][local_chan ]
181
182
chan_id = f"{ stream_name } #{ chan_name } "
182
-
183
+
183
184
# Sync channel
184
- if "nidq" not in stream_name and "SY0" in chan_name and not self .load_sync_channel and local_chan == info ["num_chan" ] - 1 :
185
+ if (
186
+ "nidq" not in stream_name
187
+ and "SY0" in chan_name
188
+ and not self .load_sync_channel
189
+ and local_chan == info ["num_chan" ] - 1
190
+ ):
185
191
# This is a sync channel and should be added as its own stream
186
192
sync_stream_id = f"{ stream_name } -SYNC"
187
193
sync_stream_id_to_buffer_id [sync_stream_id ] = buffer_id
188
194
stream_id_for_chan = sync_stream_id
189
195
else :
190
196
stream_id_for_chan = stream_id
191
-
197
+
192
198
signal_channels .append (
193
199
(
194
200
chan_name ,
@@ -205,26 +211,26 @@ def _parse_header(self):
205
211
206
212
# all channel by default unless load_sync_channel=False
207
213
self ._stream_buffer_slice [stream_id ] = None
208
-
214
+
209
215
# check sync channel validity
210
216
if "nidq" not in stream_name :
211
217
if not self .load_sync_channel and info ["has_sync_trace" ]:
212
218
# the last channel is removed from the stream but not from the buffer
213
219
self ._stream_buffer_slice [stream_id ] = slice (0 , - 1 )
214
-
220
+
215
221
# Add a buffer slice for the sync channel
216
222
sync_stream_id = f"{ stream_name } -SYNC"
217
223
self ._stream_buffer_slice [sync_stream_id ] = slice (- 1 , None )
218
-
224
+
219
225
if self .load_sync_channel and not info ["has_sync_trace" ]:
220
226
raise ValueError ("SYNC channel is not present in the recording. " "Set load_sync_channel to False" )
221
227
222
228
signal_buffers = np .array (signal_buffers , dtype = _signal_buffer_dtype )
223
-
229
+
224
230
# Add sync channels as their own streams
225
231
for sync_stream_id , buffer_id in sync_stream_id_to_buffer_id .items ():
226
232
signal_streams .append ((sync_stream_id , sync_stream_id , buffer_id ))
227
-
233
+
228
234
signal_streams = np .array (signal_streams , dtype = _signal_stream_dtype )
229
235
signal_channels = np .array (signal_channels , dtype = _signal_channel_dtype )
230
236
@@ -266,14 +272,14 @@ def _parse_header(self):
266
272
t_start = frame_start / sampling_frequency
267
273
268
274
self ._t_starts [stream_name ][seg_index ] = t_start
269
-
275
+
270
276
# This need special logic because sync not present in stream_names
271
277
if f"{ stream_name } -SYNC" in signal_streams ["name" ]:
272
278
sync_stream_name = f"{ stream_name } -SYNC"
273
279
if sync_stream_name not in self ._t_starts :
274
280
self ._t_starts [sync_stream_name ] = {}
275
281
self ._t_starts [sync_stream_name ][seg_index ] = t_start
276
-
282
+
277
283
t_stop = info ["sample_length" ] / info ["sampling_rate" ]
278
284
self ._t_stops [seg_index ] = max (self ._t_stops [seg_index ], t_stop )
279
285
@@ -302,11 +308,11 @@ def _parse_header(self):
302
308
if self .load_channel_location :
303
309
# need probeinterface to be installed
304
310
import probeinterface
305
-
311
+
306
312
# Skip for sync streams
307
313
if "SYNC" in stream_name :
308
314
continue
309
-
315
+
310
316
info = self .signals_info_dict [seg_index , stream_name ]
311
317
if "imroTbl" in info ["meta" ] and info ["stream_kind" ] == "ap" :
312
318
# only for ap channel
0 commit comments