Skip to content

Commit 51063db

Browse files
authored
Merge pull request #1350 from h-mayorquin/platform_neo
Download correct ddl for 64 system on windows with Plexon
2 parents 3781bff + e869c3b commit 51063db

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

neo/rawio/plexon2rawio/plexon2rawio.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"""
2424
import pathlib
2525
import warnings
26+
import platform
27+
2628
from collections import namedtuple
2729
from urllib.request import urlopen
2830
from datetime import datetime
@@ -74,14 +76,19 @@ def __init__(self, filename, pl2_dll_file_path=None):
7476

7577
# download default PL2 dll once if not yet available
7678
if pl2_dll_file_path is None:
77-
pl2_dll_folder = pathlib.Path .home() / '.plexon_dlls_for_neo'
79+
architecture = platform.architecture()[0]
80+
if architecture == '64bit' and platform.system() == 'Windows':
81+
file_name = "PL2FileReader64.dll"
82+
else: # Apparently wine uses the 32 bit version in linux
83+
file_name = "PL2FileReader.dll"
84+
pl2_dll_folder = pathlib.Path.home() / '.plexon_dlls_for_neo'
7885
pl2_dll_folder.mkdir(exist_ok=True)
79-
pl2_dll_file_path = pl2_dll_folder / 'PL2FileReader.dll'
86+
pl2_dll_file_path = pl2_dll_folder / file_name
87+
88+
if not pl2_dll_file_path.exists():
89+
url = f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}'
90+
dist = urlopen(url=url)
8091

81-
if pl2_dll_file_path.exists():
82-
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
83-
else:
84-
dist = urlopen('https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/PL2FileReader.dll')
8592
with open(pl2_dll_file_path, 'wb') as f:
8693
print(f'Downloading plexon dll to {pl2_dll_file_path}')
8794
f.write(dist.read())
@@ -288,7 +295,7 @@ def _get_signal_size(self, block_index, seg_index, stream_index):
288295
stream_id = self.header['signal_streams'][stream_index]['id']
289296
stream_characteristic = list(self.signal_stream_characteristics.values())[stream_index]
290297
assert stream_id == stream_characteristic.id
291-
return stream_characteristic.n_samples
298+
return int(stream_characteristic.n_samples) # Avoids returning a numpy.int64 scalar
292299

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

0 commit comments

Comments
 (0)