From 6e02e3cb00689b71c0dc12a45e8f45b62d0577b9 Mon Sep 17 00:00:00 2001 From: Lennart Date: Fri, 9 May 2025 15:39:51 +0200 Subject: [PATCH 1/3] Fix issue due to disparity between routed and mapped channels --- neo/rawio/maxwellrawio.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/neo/rawio/maxwellrawio.py b/neo/rawio/maxwellrawio.py index 6d4a22ee4..4d6969d0d 100644 --- a/neo/rawio/maxwellrawio.py +++ b/neo/rawio/maxwellrawio.py @@ -65,6 +65,18 @@ def __init__(self, filename="", rec_name=None): def _source_name(self): return self.filename + + def _get_ids_and_electrodes(self, version, stream_id, h5file, mapping): + if int(version) == 20160704: + ids = np.array(mapping["channel"]) + els = np.array(mapping["electrode"]) + else: + ids = np.array(h5file["wells"][stream_id][self.rec_name]["groups"]["routed"]["channels"]) + els = np.array(mapping["electrode"]) + ids = ids[ids >= 0] + mask = np.isin(np.array(mapping["channel"]), ids) + return ids, els[mask] + def _parse_header(self): import h5py @@ -175,11 +187,7 @@ def _parse_header(self): } self._stream_buffer_slice[stream_id] = slice(None) - channel_ids = np.array(mapping["channel"]) - electrode_ids = np.array(mapping["electrode"]) - mask = channel_ids >= 0 - channel_ids = channel_ids[mask] - electrode_ids = electrode_ids[mask] + channel_ids, electrode_ids = self._get_ids_and_electrodes(version, stream_id, h5file, mapping) for i, chan_id in enumerate(channel_ids): elec_id = electrode_ids[i] From 4cb378b1b82d9ccaa70ac8ededf81a13616e5b25 Mon Sep 17 00:00:00 2001 From: LeMuellerGuy <107409831+LeMuellerGuy@users.noreply.github.com> Date: Fri, 9 May 2025 17:15:09 +0200 Subject: [PATCH 2/3] Update maxwellrawio.py Update mask to only allow unique electrodes to pass in addition to filtering out non-routed electrodes --- neo/rawio/maxwellrawio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neo/rawio/maxwellrawio.py b/neo/rawio/maxwellrawio.py index 4d6969d0d..38d63323f 100644 --- a/neo/rawio/maxwellrawio.py +++ b/neo/rawio/maxwellrawio.py @@ -74,7 +74,8 @@ def _get_ids_and_electrodes(self, version, stream_id, h5file, mapping): ids = np.array(h5file["wells"][stream_id][self.rec_name]["groups"]["routed"]["channels"]) els = np.array(mapping["electrode"]) ids = ids[ids >= 0] - mask = np.isin(np.array(mapping["channel"]), ids) + mask = np.unique(mapping["channel"][np.isin(np.array(mapping["channel"]), ids)], + return_index=True)[1] return ids, els[mask] From 17ade481c8fd56cc50ae7ef7222cbc54085e18db Mon Sep 17 00:00:00 2001 From: LeMuellerGuy <107409831+LeMuellerGuy@users.noreply.github.com> Date: Sun, 11 May 2025 12:44:31 +0200 Subject: [PATCH 3/3] Update maxwellrawio.py Stylistic cleanup --- neo/rawio/maxwellrawio.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/neo/rawio/maxwellrawio.py b/neo/rawio/maxwellrawio.py index 38d63323f..28800fd9b 100644 --- a/neo/rawio/maxwellrawio.py +++ b/neo/rawio/maxwellrawio.py @@ -68,15 +68,16 @@ def _source_name(self): def _get_ids_and_electrodes(self, version, stream_id, h5file, mapping): if int(version) == 20160704: - ids = np.array(mapping["channel"]) - els = np.array(mapping["electrode"]) + channel_ids = np.array(mapping["channel"]) + electrode_ids = np.array(mapping["electrode"]) else: - ids = np.array(h5file["wells"][stream_id][self.rec_name]["groups"]["routed"]["channels"]) - els = np.array(mapping["electrode"]) - ids = ids[ids >= 0] - mask = np.unique(mapping["channel"][np.isin(np.array(mapping["channel"]), ids)], - return_index=True)[1] - return ids, els[mask] + channel_ids = np.array(h5file["wells"][stream_id][self.rec_name]["groups"]["routed"]["channels"]) + electrode_ids = np.array(mapping["electrode"]) + channel_ids = channel_ids[channel_ids >= 0] + routed_channel_ids_mask = np.isin(np.array(mapping["channel"]), channel_ids) + unique_channel_ids_mask = np.unique(mapping["channel"][routed_channel_ids_mask], + return_index=True)[1] + return channel_ids, electrode_ids[unique_channel_ids_mask] def _parse_header(self):