Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download correct ddl for 64 system on windows with Plexon #1350

Merged
merged 9 commits into from
Dec 6, 2023
23 changes: 18 additions & 5 deletions neo/rawio/plexon2rawio/plexon2rawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"""
import pathlib
import warnings
import platform

from collections import namedtuple
from urllib.request import urlopen
from datetime import datetime
Expand Down Expand Up @@ -74,14 +76,25 @@ def __init__(self, filename, pl2_dll_file_path=None):

# download default PL2 dll once if not yet available
if pl2_dll_file_path is None:
pl2_dll_folder = pathlib.Path .home() / '.plexon_dlls_for_neo'
architecture = platform.architecture()[0]
if architecture == '64bit' and platform.system() == 'Windows':
file_name = "PL2FileReader64.dll"
else: # Apparently wine uses the 32 bit version in linux
file_name = "PL2FileReader.dll"

h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
pl2_dll_folder = pathlib.Path.home() / '.plexon_dlls_for_neo'
pl2_dll_folder.mkdir(exist_ok=True)
pl2_dll_file_path = pl2_dll_folder / 'PL2FileReader.dll'
pl2_dll_file_path = pl2_dll_folder / file_name

if pl2_dll_file_path.exists():
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
# I think this warning should be removed
# Warnings should provide a solution but this is
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
# just a reminder to the user of normal behavior
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super fair point. I don't think this warning is doing anything!

h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
else:
dist = urlopen('https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/PL2FileReader.dll')
url = f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}'
dist = urlopen(url=url)

with open(pl2_dll_file_path, 'wb') as f:
print(f'Downloading plexon dll to {pl2_dll_file_path}')
f.write(dist.read())
Expand Down Expand Up @@ -288,7 +301,7 @@ def _get_signal_size(self, block_index, seg_index, stream_index):
stream_id = self.header['signal_streams'][stream_index]['id']
stream_characteristic = list(self.signal_stream_characteristics.values())[stream_index]
assert stream_id == stream_characteristic.id
return stream_characteristic.n_samples
return int(stream_characteristic.n_samples) # Avoids returning a numpy.int64 scalar
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is related to this:
SpikeInterface/spikeinterface#2223


def _get_signal_t_start(self, block_index, seg_index, stream_index):
# This returns the t_start of signals as a float value in seconds
Expand Down