From 4da8bcaa5b621c0c5a663397d338ae772e05ee24 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Mon, 2 Dec 2024 15:05:44 +0100 Subject: [PATCH] blacked --- neo/rawio/openephysbinaryrawio.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/neo/rawio/openephysbinaryrawio.py b/neo/rawio/openephysbinaryrawio.py index f53fe4287..fe6120aec 100644 --- a/neo/rawio/openephysbinaryrawio.py +++ b/neo/rawio/openephysbinaryrawio.py @@ -252,47 +252,47 @@ def _parse_header(self): # 'states' was introduced in OpenEphys v0.6. For previous versions, events used 'channel_states' if "states" in info or "channel_states" in info: states = info["channel_states"] if "channel_states" in info else info["states"] - + if states.size > 0: timestamps = info["timestamps"] labels = info["labels"] - + # Identify unique channels based on state values channels = np.unique(np.abs(states)) - + rising_indices = [] falling_indices = [] - + for channel in channels: # Find rising and falling edges for each channel rising = np.where(states == channel)[0] falling = np.where(states == -channel)[0] - + # Ensure each rising has a corresponding falling if rising.size > 0 and falling.size > 0: if rising[0] > falling[0]: falling = falling[1:] if rising.size > falling.size: rising = rising[:-1] - + rising_indices.extend(rising) falling_indices.extend(falling) - + rising_indices = np.array(rising_indices) falling_indices = np.array(falling_indices) - + # Sort the indices to maintain chronological order sorted_order = np.argsort(rising_indices) rising_indices = rising_indices[sorted_order] falling_indices = falling_indices[sorted_order] - + durations = None if len(rising_indices) == len(falling_indices): durations = timestamps[falling_indices] - timestamps[rising_indices] if not self._use_direct_evt_timestamps: timestamps = timestamps / info["sample_rate"] durations = durations / info["sample_rate"] - + info["rising"] = rising_indices info["timestamps"] = timestamps[rising_indices] info["labels"] = labels[rising_indices]