From a27a012a6f19d39b9d2807b6c2f0819add1ba0d5 Mon Sep 17 00:00:00 2001 From: Nikhil Chandra Date: Mon, 9 Sep 2024 16:49:56 -0500 Subject: [PATCH 1/3] Fixed bug that prevented PL2 spike channels with unsorted spikes from loading properly. --- neo/rawio/plexon2rawio/plexon2rawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 821330027..4272a91cb 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -231,7 +231,7 @@ def _parse_header(self): if not (schannel_info.m_ChannelEnabled and schannel_info.m_ChannelRecordingEnabled): continue - for channel_unit_id in range(schannel_info.m_NumberOfUnits): + for channel_unit_id in range(schannel_info.m_NumberOfUnits+1): unit_name = f"{schannel_info.m_Name.decode()}.{channel_unit_id}" unit_id = f"unit{schannel_info.m_Channel}.{channel_unit_id}" wf_units = schannel_info.m_Units From 1cc36c990747e57f39af985f00cf3ab2533acec2 Mon Sep 17 00:00:00 2001 From: Nikhil Chandra Date: Wed, 11 Sep 2024 10:34:07 -0500 Subject: [PATCH 2/3] Added comment explaining changes from previous commit. --- neo/rawio/plexon2rawio/plexon2rawio.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 4272a91cb..4f0c519de 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -231,6 +231,13 @@ def _parse_header(self): if not (schannel_info.m_ChannelEnabled and schannel_info.m_ChannelRecordingEnabled): continue + # In a PL2 spike channel header, the field "m_NumberOfUnits" denotes the number + # of units to which spikes detected on that channel have been assigned. It does + # not account for unsorted spikes, i.e., spikes that have not been assigned to + # a unit. It is Plexon's convention to assign unsorted spikes to channel_unit_id=0, + # and sorted spikes to unit_id's 1, 2, 3...etc. Therefore, for a given value of + # m_NumberOfUnits, there are m_NumberOfUnits+1 channel_unit_ids to consider - 1 + # unsorted channel_unit_id (0) + the m_NumberOfUnits sorted channel_unit_ids. for channel_unit_id in range(schannel_info.m_NumberOfUnits+1): unit_name = f"{schannel_info.m_Name.decode()}.{channel_unit_id}" unit_id = f"unit{schannel_info.m_Channel}.{channel_unit_id}" From ba76a7644afda694e922f4950992b66ad20b9546 Mon Sep 17 00:00:00 2001 From: Nikhil Chandra Date: Wed, 11 Sep 2024 10:34:07 -0500 Subject: [PATCH 3/3] Added comment explaining changes from previous commit. --- neo/rawio/plexon2rawio/plexon2rawio.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 4272a91cb..baa838f10 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -231,6 +231,13 @@ def _parse_header(self): if not (schannel_info.m_ChannelEnabled and schannel_info.m_ChannelRecordingEnabled): continue + # In a PL2 spike channel header, the field "m_NumberOfUnits" denotes the number + # of units to which spikes detected on that channel have been assigned. It does + # not account for unsorted spikes, i.e., spikes that have not been assigned to + # a unit. It is Plexon's convention to assign unsorted spikes to channel_unit_id=0, + # and sorted spikes to channel_unit_id's 1, 2, 3...etc. Therefore, for a given value of + # m_NumberOfUnits, there are m_NumberOfUnits+1 channel_unit_ids to consider - 1 + # unsorted channel_unit_id (0) + the m_NumberOfUnits sorted channel_unit_ids. for channel_unit_id in range(schannel_info.m_NumberOfUnits+1): unit_name = f"{schannel_info.m_Name.decode()}.{channel_unit_id}" unit_id = f"unit{schannel_info.m_Channel}.{channel_unit_id}"