From 1ce20439d99c32a3b348e71a5515377d46715c97 Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Thu, 26 Jun 2025 18:50:26 -0700 Subject: [PATCH 1/8] Update baserawio.py Correct duplicate channel_id assignments within stream (keep first instance) --- neo/rawio/baserawio.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index 7b5d8b768..f6017a530 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -711,6 +711,12 @@ def _check_stream_signal_channel_characteristics(self): f"do not have the same {_common_sig_characteristics} {unique_characteristics}" ) + # if stream has duplicate channel_id assignments, correct this + seen = set() + uniqid = [i for i,x in enumerate(signal_channels[mask]["id"]) if x not in seen and not seen.add(x)] + signal_channels = signal_channels[uniqid] + mask = signal_channels["stream_id"] == stream_id + # also check that channel_id is unique inside a stream channel_ids = signal_channels[mask]["id"] if np.unique(channel_ids).size != channel_ids.size: From 53fe4a717b1b442760bb9da94cb8d02a28f83d80 Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Sun, 29 Jun 2025 21:46:26 -0700 Subject: [PATCH 2/8] Update baserawio.py MaxWell sometimes creates non-bijective channel-electrode mapping. Warn users but allow to proceed as this will be dealt with in neobaseextractor in spikeinterface. --- neo/rawio/baserawio.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index f6017a530..375c833fd 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -72,6 +72,7 @@ import logging import numpy as np +import pandas as pd import os import sys @@ -716,11 +717,19 @@ def _check_stream_signal_channel_characteristics(self): uniqid = [i for i,x in enumerate(signal_channels[mask]["id"]) if x not in seen and not seen.add(x)] signal_channels = signal_channels[uniqid] mask = signal_channels["stream_id"] == stream_id + + characteristics = signal_channels[mask][_common_sig_characteristics] + unique_characteristics = np.unique(characteristics) + if unique_characteristics.size != 1: + raise ValueError( + f"Some channels in stream_id {stream_id} " + f"do not have the same {_common_sig_characteristics} {unique_characteristics}" + ) # also check that channel_id is unique inside a stream channel_ids = signal_channels[mask]["id"] if np.unique(channel_ids).size != channel_ids.size: - raise ValueError(f"signal_channels do not have unique ids for stream {stream_index}") + warnings.warn(f"signal_channels do not have unique ids for stream {stream_index}", RuntimeWarning) self._several_channel_groups = signal_streams.size > 1 From 0b2d63ee1e04c6c064c55b2eff2935280510584e Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Sun, 29 Jun 2025 21:47:11 -0700 Subject: [PATCH 3/8] Update baserawio.py --- neo/rawio/baserawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index 375c833fd..f06ff901f 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -72,7 +72,7 @@ import logging import numpy as np -import pandas as pd +import warnings import os import sys From 237fff99dadaf30a3681cc9782b650411672f66b Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Mon, 30 Jun 2025 00:00:10 -0700 Subject: [PATCH 4/8] Update baserawio.py --- neo/rawio/baserawio.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index f06ff901f..0b00b66a9 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -72,6 +72,7 @@ import logging import numpy as np +import pandas as pd import warnings import os import sys @@ -704,20 +705,6 @@ def _check_stream_signal_channel_characteristics(self): for stream_index in range(signal_streams.size): stream_id = signal_streams[stream_index]["id"] mask = signal_channels["stream_id"] == stream_id - characteristics = signal_channels[mask][_common_sig_characteristics] - unique_characteristics = np.unique(characteristics) - if unique_characteristics.size != 1: - raise ValueError( - f"Some channels in stream_id {stream_id} " - f"do not have the same {_common_sig_characteristics} {unique_characteristics}" - ) - - # if stream has duplicate channel_id assignments, correct this - seen = set() - uniqid = [i for i,x in enumerate(signal_channels[mask]["id"]) if x not in seen and not seen.add(x)] - signal_channels = signal_channels[uniqid] - mask = signal_channels["stream_id"] == stream_id - characteristics = signal_channels[mask][_common_sig_characteristics] unique_characteristics = np.unique(characteristics) if unique_characteristics.size != 1: From 6331ef2ba0fc8da73a805e3835e0dd0e8ba7a64a Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Mon, 30 Jun 2025 00:02:27 -0700 Subject: [PATCH 5/8] Update baserawio.py --- neo/rawio/baserawio.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index 0b00b66a9..f4af63f75 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -72,7 +72,6 @@ import logging import numpy as np -import pandas as pd import warnings import os import sys From 4e5852872a9eb266a6fa5076f9256d006b901c00 Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Tue, 1 Jul 2025 09:43:18 -0700 Subject: [PATCH 6/8] Update baserawio.py --- neo/rawio/baserawio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index f4af63f75..23af65d9f 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -712,11 +712,11 @@ def _check_stream_signal_channel_characteristics(self): f"do not have the same {_common_sig_characteristics} {unique_characteristics}" ) - # also check that channel_id is unique inside a stream - channel_ids = signal_channels[mask]["id"] - if np.unique(channel_ids).size != channel_ids.size: - warnings.warn(f"signal_channels do not have unique ids for stream {stream_index}", RuntimeWarning) - + # also check that channel_names are unique inside a stream + channel_names = signal_channels[mask]["name"] + if np.unique(channel_names).size != channel_names.size: + raise ValueError(f"signal_channels do not have unique names for stream {stream_index}") + self._several_channel_groups = signal_streams.size > 1 def channel_name_to_index(self, stream_index: int, channel_names: list[str]): From 8769136400e4309978abb117a6a58044672b8a6c Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Tue, 1 Jul 2025 09:44:00 -0700 Subject: [PATCH 7/8] Update baserawio.py --- neo/rawio/baserawio.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index 23af65d9f..b9c0f3daa 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -72,7 +72,6 @@ import logging import numpy as np -import warnings import os import sys From 598224561d6b87c237bac76c367fffb9b5533e17 Mon Sep 17 00:00:00 2001 From: cmccrimmon <103812790+cmccrimmon@users.noreply.github.com> Date: Tue, 1 Jul 2025 09:46:36 -0700 Subject: [PATCH 8/8] Update baserawio.py