Support for using event names as IDs in PL2 files #4049
+21
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I was having issues using the event ids of .pl2 data. The ids were all numbers and not unique (like '1', '2', ..., '1', '2', ..., which are supposed to be 'KBD01', 'KBD02', ... 'EVT01', 'EVT02'...). So I added an option to use event names as ids for .pl2 files.
Summary by copilot
This pull request introduces a new feature to allow the use of channel names as unique identifiers (
use_names_as_ids
) in event extractors, along with corresponding updates to ensure compatibility and proper functionality. The changes primarily affect theNeoBaseEventExtractor
class and its subclasses.Enhancements to event extraction:
use_names_as_ids
parameter toNeoBaseEventExtractor
: The__init__
method ofNeoBaseEventExtractor
now includes ause_names_as_ids
parameter. When set toTrue
, channel names are used as identifiers instead of channel IDs. An assertion ensures that channel names are unique when this option is enabled. (src/spikeinterface/extractors/neoextractors/neobaseextractor.py
, src/spikeinterface/extractors/neoextractors/neobaseextractor.pyL668-R680)NeoEventSegment
to supportuse_names_as_ids
: TheNeoEventSegment
class now accepts theuse_names_as_ids
parameter and uses it to determine whether to index event channels by name or ID. (src/spikeinterface/extractors/neoextractors/neobaseextractor.py
, src/spikeinterface/extractors/neoextractors/neobaseextractor.pyL687-R709)Subclass-specific updates:
Plexon2EventExtractor
to defaultuse_names_as_ids
toTrue
: ThePlexon2EventExtractor
subclass now defaults theuse_names_as_ids
parameter toTrue
in its constructor, ensuring that channel names are used as identifiers by default for this extractor. (src/spikeinterface/extractors/neoextractors/plexon2.py
, src/spikeinterface/extractors/neoextractors/plexon2.pyL126-R128)