|
23 | 23 | """ |
24 | 24 | import pathlib |
25 | 25 | import warnings |
| 26 | +import platform |
| 27 | + |
26 | 28 | from collections import namedtuple |
27 | 29 | from urllib.request import urlopen |
28 | 30 | from datetime import datetime |
@@ -74,14 +76,19 @@ def __init__(self, filename, pl2_dll_file_path=None): |
74 | 76 |
|
75 | 77 | # download default PL2 dll once if not yet available |
76 | 78 | 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' |
78 | 85 | 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) |
80 | 91 |
|
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') |
85 | 92 | with open(pl2_dll_file_path, 'wb') as f: |
86 | 93 | print(f'Downloading plexon dll to {pl2_dll_file_path}') |
87 | 94 | f.write(dist.read()) |
@@ -288,7 +295,7 @@ def _get_signal_size(self, block_index, seg_index, stream_index): |
288 | 295 | stream_id = self.header['signal_streams'][stream_index]['id'] |
289 | 296 | stream_characteristic = list(self.signal_stream_characteristics.values())[stream_index] |
290 | 297 | 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 |
292 | 299 |
|
293 | 300 | def _get_signal_t_start(self, block_index, seg_index, stream_index): |
294 | 301 | # This returns the t_start of signals as a float value in seconds |
|
0 commit comments