SpikeInterface / spikeinterface

A Python-based module for creating flexible and robust spike sorting pipelines.
https://spikeinterface.readthedocs.io
MIT License
517 stars 186 forks source link

Issue with reading .pl2 files #2214

Open Bosswang12138 opened 11 months ago

Bosswang12138 commented 11 months ago

Hello everyone,

I'm trying to use the spikeinterface.extractors.read_plexon2() function to read a .pl2 file using the following code:

import spikeinterface.extractors as se from pathlib import Path

folderPath = Path(r"D:\PROGRAM") filename = Path("16ch1.pl2") fullfilename = folderPath.joinpath(filename)

recording = se.read_plexon2(file_path=fullfilename, stream_id='6')

However, I'm facing the following error:


ArgumentError Traceback (most recent call last)

File d:\Anaconda\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\plexon2.py:30, in Plexon2RecordingExtractor.init(self, file_path, stream_id, stream_name, all_annotations) 28 def init(self, file_path, stream_id=None, stream_name=None, all_annotations=False): 29 neo_kwargs = self.map_to_neo_kwargs(file_path) ---> 30 NeoBaseRecordingExtractor.init( 31 self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs 32 ) 33 self._kwargs.update({"file_path": str(file_path)})

File d:\Anaconda\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py:185, in NeoBaseRecordingExtractor.init(self, stream_id, stream_name, block_index, all_annotations, use_names_as_ids, neo_kwargs) 156 def init( 157 self, 158 stream_id: Optional[str] = None, (...) 163 neo_kwargs: Dict[str, Any], 164 ) -> None: 165 """ 166 Initialize a NeoBaseRecordingExtractor instance. 167 (...) 182 183 """ --> 185 _NeoBaseExtractor.init(self, block_index, **neo_kwargs) 187 kwargs = dict(all_annotations=all_annotations) 188 if block_index is not None:

File d:\Anaconda\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py:25, in _NeoBaseExtractor.init(self, block_index, neo_kwargs) 23 def init(self, block_index, neo_kwargs): 24 if not hasattr(self, "neo_reader"): # Avoid double initialization ---> 25 self.neo_reader = self.get_neo_io_reader(self.NeoRawIOClass, **neo_kwargs) 27 if self.neo_reader.block_count() > 1 and block_index is None: 28 raise Exception( 29 "This dataset is multi-block. Spikeinterface can load one block at a time. " 30 "Use 'block_index' to select the block to be loaded." 31 )

File d:\Anaconda\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py:64, in _NeoBaseExtractor.get_neo_io_reader(cls, raw_class, neo_kwargs) 62 neoIOclass = getattr(rawio_module, raw_class) 63 neo_reader = neoIOclass(neo_kwargs) ---> 64 neo_reader.parse_header() 66 return neo_reader

File d:\Anaconda\envs\si_env\lib\site-packages\neo\rawio\baserawio.py:178, in BaseRawIO.parse_header(self) 165 def parse_header(self): 166 """ 167 This must parse the file header to get all stuff for fast use later on. 168 (...) 176 177 """ --> 178 self._parse_header() 179 self._check_stream_signal_channel_characteristics()

File d:\Anaconda\envs\si_env\lib\site-packages\neo\rawio\plexon2rawio\plexon2rawio.py:239, in Plexon2RawIO._parse_header(self) 237 for spike_channel_idx, spike_header in enumerate(self.header['spike_channels']): 238 schannel_name = spike_header['name'].split('.')[0] --> 239 schannel_info = self.pl2reader.pl2_get_spike_channel_info_by_name(schannel_name) 241 spiketrain_an = seg_ann['spikes'][spike_channel_idx] 242 for key in spike_annotation_keys:

File d:\Anaconda\envs\si_env\lib\site-packages\neo\rawio\plexon2rawio\pypl2\pypl2lib.py:651, in PyPL2FileReader.pl2_get_spike_channel_info_by_name(self, channel_name) 642 self.pl2_dll.PL2_GetSpikeChannelInfoByName.memsync = [ 643 { 644 'p': [1], 645 'n': True, # null-terminated string flag 646 } 647 ] 649 pl2_spike_channel_info = PL2SpikeChannelInfo() --> 651 result = self.pl2_dll.PL2_GetSpikeChannelInfoByName(self._file_handle, 652 channel_name, 653 ctypes.byref(pl2_spike_channel_info)) 655 if not result: 656 self._print_error()

ArgumentError: argument 2: TypeError: expected c_char_Array_5 instance instead of bytes

Has anyone encountered a similar issue with the read_plexon2() function or has any suggestions on how to resolve this error?

Any help or guidance would be greatly appreciated. Thank you!

alejoe91 commented 11 months ago

Hi,

SpikeInterface uses NEO for IO. Can you open an issue there? https://github.com/NeuralEnsemble/python-neo/issues

Bosswang12138 commented 11 months ago

Hi,

SpikeInterface uses NEO for IO. Can you open an issue there? https://github.com/NeuralEnsemble/python-neo/issues

"Hi,

Thank you for your suggestion! I'll open an issue in the NEO repository to address this matter.

Best regards,"