Skip to content

Issue with reading .pl2 files  #1349

Closed
Closed

Description

@Bosswang12138

Describe the bug
I encountered an issue while attempting to read a .pl2 file using the Plexon2RawIO from the neo library. Here's the snippet I used:

import neo.rawio
from pathlib import Path

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

r = neo.rawio.Plexon2RawIO(filename=fullfilename)
r.parse_header()

The demo pl2 file were downloaded from Plexon, https://plexon.com/wp-content/uploads/2017/08/4chDemoPL2.pl2
I received the following error traceback:

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

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

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

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

Environment:

  • OS: [Windows]
  • Python version: 3.10
  • Neo version: 0.13.0.dev0
  • NumPy version: 1.26.0

Could you please provide guidance or assistance regarding this error? Thank you for your support.

Activity

  1. h-mayorquin commented on Nov 17, 2023

    @h-mayorquin
    Contributor

    Can you give more details about your platform, what is your architecture?

    can you run?

    import platform
    
    platform.architecture()
    
  2. Bosswang12138 commented on Nov 18, 2023

    @Bosswang12138
    Author

    Can you give more details about your platform, what is your architecture?

    can you run?

    import platform
    
    platform.architecture()
    

    Hi, the output of platform.architecture() is ('64bit', 'WindowsPE')

  3. Bosswang12138 commented on Nov 18, 2023

    @Bosswang12138
    Author

    @h-mayorquin Are you referring to this branch(#1350)? I've attempted to use this branch just now, but unfortunately encountered the same error. I've previously encountered the issue you raised in this PR. However, I vaguely recall manually copying the 64-bit .dll file to the .plexon_dlls_for_neo folder, so it's unlikely the error is caused by conflicts between 64-bit and 32-bit .dll files.

    Additionally, in this commit(NeuralEnsemble/pypl2@2b25881), @JuliaSprenger committed changes stating "also accept bytes as channel names," which seems related to the error I'm experiencing. I'm not an expert in programming, could you please take a look?

  4. added this to the 0.14.0 milestone on Feb 23, 2024
  5. jklembcz commented on Feb 23, 2024

    @jklembcz

    Hi all,

    I am getting the same error and at the same point as Bosswang12138 when trying to use neo to read pl2 files.

    output: result = self.pl2_dll.PL2_GetSpikeChannelInfoByName(self._file_handle, ctypes.ArgumentError: argument 2: TypeError: expected c_char_Array_5 instance instead of bytes

    I have tried to implement the commit (NeuralEnsemble/pypl2@2b25881), but am still getting the same error.

    For reference, I am also running 64bit Windows PE, Python 3.10, neo 13.0, and numpy 1.26.4, and also utilizing neo via SpikeInterface, just as Bosswang12138 is.

    Thank you!

  6. h-mayorquin commented on Feb 23, 2024

    @h-mayorquin
    Contributor

    I will give it a try next week when I get into a windows machine.

  7. jklembcz commented on Feb 28, 2024

    @jklembcz

    Hi all,

    I did some digging into the data that I was trying to access, and I found that all of the .pl2 files that NEO errors when trying to read had a column of a unit that was sorted during recording, labeled as "Unit a". I'm not entirely sure how this causes the error.

    @Bosswang12138, not sure if this is still relevant to you, but using Plexon's batch processing to remove all sorted units from all channels allows my files to be read by NEO.

  8. jklembcz commented on Mar 25, 2024

    @jklembcz

    Hey all,

    I am currently attempting to use Spikeinterface and thus Neo to read some very recent pl2 files, and I am getting the exact same TypeError. These files do not have any units sorted during recording, or even any thresholded spikes that would appear on an SPK channel, so I'm not exactly sure how to approach this.

  9. h-mayorquin commented on Mar 25, 2024

    @h-mayorquin
    Contributor

    Sorry guys, I just have not had the time. Plexon does not make it easier by having a close format however.

    Please complain about it to Plexon or whowever makes the decision to buy the system if you ever get the chance.

  10. bendichter commented on Jun 21, 2024

    @bendichter
    Contributor
  11. bendichter commented on Jun 21, 2024

    @bendichter
    Contributor

    @samuelgarcia , could you please take a look at this? I have a file that reproduces the error I can send you

  12. cheydrick commented on Jun 22, 2024

    @cheydrick
    Contributor

    Coincidentally I looked at this myself this past week and just submitted PR #1495 that I believe fixes it. Open to thoughts.

  13. h-mayorquin commented on Jun 22, 2024

    @h-mayorquin
    Contributor

    Hi, @cheydrick, I will test this against the three OSs on neuroconv:
    catalystneuro/neuroconv#918

    I thought that the problem is that the ddls expect a different input in linux and windows but in your PR the test pass so gingers crossed. [EDIT] I see that the test have not run in your PR.

  14. added a commit that references this issue on Jun 28, 2024
  15. zm711 commented on Jun 28, 2024

    @zm711
    Contributor

    Could people test this out so we can confirm this can be closed? We've merged the two PRs associated with this so getting confirmation this works for people's problems would be great!

  16. bendichter commented on Jul 1, 2024

    @bendichter
    Contributor

    @zm711 it seems this has been addressed. I think it would be reasonable to close this issue and reopen if the problem reappears.

  17. zm711 commented on Jul 1, 2024

    @zm711
    Contributor

    That sounds good to me. :)

  18. modified the milestones: 0.14.0, 0.13.4 on Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions