python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Error loading plx file

Open AlexLM96 opened this issue 3 years ago • 4 comments

I'm trying to load a .plx file and I'm getting an error when using .read(). This error seems to be specific for this file. However, I know the file is not corrupted because I can open it with other software. I have tested a couple more .plx files and they seem to work fine. I'm happy to share the file.

Here's my code:

from neo.io import PlexonIO

file = "my_file_location.plx"

reader = PlexonIO(filename = file)

This runs fine, although it outputs this Warning:

C:\Users\myusername\.conda\envs\neo2\lib\site-packages\neo\rawio\plexonrawio.py:163: RuntimeWarning: divide by zero encountered in double_scalars
  gain = global_header['SlowMaxMagnitudeMV'] / (

However, when I run reader.read() I get this error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File ~\.conda\envs\neo2\lib\site-packages\quantities\registry.py:20, in UnitRegistry.__Registry.__getitem__(self, string)
     19 try:
---> 20     return eval(string, self.__context)
     21 except NameError:
     22     # could return self['UnitQuantity'](string)

File <string>:1, in <module>

NameError: name 'inf' is not defined

During handling of the above exception, another exception occurred:

LookupError                               Traceback (most recent call last)
Input In [52], in <cell line: 1>()
----> 1 reader2.read()

File ~\.conda\envs\neo2\lib\site-packages\neo\io\baseio.py:124, in BaseIO.read(self, lazy, **kargs)
    121     if (hasattr(self, 'read_all_blocks') and
    122             callable(getattr(self, 'read_all_blocks'))):
    123         return self.read_all_blocks(lazy=lazy, **kargs)
--> 124     return [self.read_block(lazy=lazy, **kargs)]
    125 elif Segment in self.readable_objects:
    126     bl = Block(name='One segment only')

File ~\.conda\envs\neo2\lib\site-packages\neo\io\basefromrawio.py:166, in BaseFromRaw.read_block(self, block_index, lazy, create_group_across_segment, signal_group_mode, load_waveforms)
    164 # Read all segments
    165 for seg_index in range(self.segment_count(block_index)):
--> 166     seg = self.read_segment(block_index=block_index, seg_index=seg_index,
    167                             lazy=lazy, signal_group_mode=signal_group_mode,
    168                             load_waveforms=load_waveforms)
    169     bl.segments.append(seg)
    171 # create link between group (across segment) and data objects

File ~\.conda\envs\neo2\lib\site-packages\neo\io\basefromrawio.py:235, in BaseFromRaw.read_segment(self, block_index, seg_index, lazy, signal_group_mode, load_waveforms, time_slice, strict_slicing)
    233 for sub_stream in sub_streams:
    234     stream_index, inner_stream_channels, name = sub_stream
--> 235     anasig = AnalogSignalProxy(rawio=self, stream_index=stream_index,
    236                     inner_stream_channels=inner_stream_channels,
    237                     block_index=block_index, seg_index=seg_index)
    238     anasig.name = name
    240     if not lazy:
    241         # ... and get the real AnalogSignal if not lazy

File ~\.conda\envs\neo2\lib\site-packages\neo\io\proxyobjects.py:147, in AnalogSignalProxy.__init__(self, rawio, stream_index, inner_stream_channels, block_index, seg_index)
    145     str_units = ensure_signal_units(sig_chans['units'][0]).units.dimensionality.string
    146     gain0 = sig_chans['gain'][0]
--> 147     self._raw_units = pq.CompoundUnit(f'{gain0}*{str_units}')
    148 else:
    149     self._raw_units = None

File ~\.conda\envs\neo2\lib\site-packages\quantities\unitquantity.py:376, in CompoundUnit.__new__(cls, name)
    375 def __new__(cls, name):
--> 376     return UnitQuantity.__new__(cls, name, unit_registry[name])

File ~\.conda\envs\neo2\lib\site-packages\quantities\registry.py:60, in UnitRegistry.__getitem__(self, label)
     57 if "%" in label: label = label.replace("%", "percent")
     58 if label.lower() == "in": label = "inch"
---> 60 return self.__registry[label]

File ~\.conda\envs\neo2\lib\site-packages\quantities\registry.py:23, in UnitRegistry.__Registry.__getitem__(self, string)
     20     return eval(string, self.__context)
     21 except NameError:
     22     # could return self['UnitQuantity'](string)
---> 23     raise LookupError(
     24         'Unable to parse units: "%s"'%string
     25     )

LookupError: Unable to parse units: "inf*dimensionless"

AlexLM96 avatar Jul 21 '22 17:07 AlexLM96

Hi @AlexLM96 It looks like your signal does not have gain attached, as neo is attempting to use an infinite gain. I am surprised this is not an issue in other softwares. How do these handle this case? Have you tried loading the data in non-lazy mode? Does this also fail? Would it be possible for you to share the respective file for debugging purposes?

JuliaSprenger avatar Jul 22 '22 13:07 JuliaSprenger

It still fails in non-lazy mode. And sure, I'll email you the file. Thanks!

AlexLM96 avatar Jul 22 '22 15:07 AlexLM96

Sorry for the delay, if you can still provide the file you can deposit it here

JuliaSprenger avatar Nov 02 '22 10:11 JuliaSprenger

@AlexLM96 If the issue persists feel free to upload the file using the link provided above

JuliaSprenger avatar Apr 03 '23 13:04 JuliaSprenger