@@ -252,47 +252,47 @@ def _parse_header(self):
252252 # 'states' was introduced in OpenEphys v0.6. For previous versions, events used 'channel_states'
253253 if "states" in info or "channel_states" in info :
254254 states = info ["channel_states" ] if "channel_states" in info else info ["states" ]
255-
255+
256256 if states .size > 0 :
257257 timestamps = info ["timestamps" ]
258258 labels = info ["labels" ]
259-
259+
260260 # Identify unique channels based on state values
261261 channels = np .unique (np .abs (states ))
262-
262+
263263 rising_indices = []
264264 falling_indices = []
265-
265+
266266 for channel in channels :
267267 # Find rising and falling edges for each channel
268268 rising = np .where (states == channel )[0 ]
269269 falling = np .where (states == - channel )[0 ]
270-
270+
271271 # Ensure each rising has a corresponding falling
272272 if rising .size > 0 and falling .size > 0 :
273273 if rising [0 ] > falling [0 ]:
274274 falling = falling [1 :]
275275 if rising .size > falling .size :
276276 rising = rising [:- 1 ]
277-
277+
278278 rising_indices .extend (rising )
279279 falling_indices .extend (falling )
280-
280+
281281 rising_indices = np .array (rising_indices )
282282 falling_indices = np .array (falling_indices )
283-
283+
284284 # Sort the indices to maintain chronological order
285285 sorted_order = np .argsort (rising_indices )
286286 rising_indices = rising_indices [sorted_order ]
287287 falling_indices = falling_indices [sorted_order ]
288-
288+
289289 durations = None
290290 if len (rising_indices ) == len (falling_indices ):
291291 durations = timestamps [falling_indices ] - timestamps [rising_indices ]
292292 if not self ._use_direct_evt_timestamps :
293293 timestamps = timestamps / info ["sample_rate" ]
294294 durations = durations / info ["sample_rate" ]
295-
295+
296296 info ["rising" ] = rising_indices
297297 info ["timestamps" ] = timestamps [rising_indices ]
298298 info ["labels" ] = labels [rising_indices ]
0 commit comments