From 498a410428237b16430c074335e1b344386f9b4a Mon Sep 17 00:00:00 2001 From: h-mayorquin Date: Fri, 17 Nov 2023 18:02:13 +0100 Subject: [PATCH 1/8] add architecture dependency in plexon --- neo/rawio/plexon2rawio/plexon2rawio.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index dd77a6c80..eff62d7b0 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -23,6 +23,8 @@ """ import pathlib import warnings +import platform + from collections import namedtuple from urllib.request import urlopen from datetime import datetime @@ -74,14 +76,24 @@ 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': + file_name = "PL2FileReader64.dll" + else: + file_name = "PL2FileReader.dll" + + 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}') + if not pl2_dll_file_path.exists(): + # I think this warning should be removed + # Warnings should provide a solution but this is just a reminder to the user of normal behavior + # Nothing to do + warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') else: - dist = urlopen('https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/PL2FileReader.dll') + dist = urlopen(f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}') + with open(pl2_dll_file_path, 'wb') as f: print(f'Downloading plexon dll to {pl2_dll_file_path}') f.write(dist.read()) From 0754b7bfd911a0a625bb53d79688aeec451d9e4b Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 17 Nov 2023 19:43:27 +0100 Subject: [PATCH 2/8] Update neo/rawio/plexon2rawio/plexon2rawio.py --- neo/rawio/plexon2rawio/plexon2rawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index eff62d7b0..399051603 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -86,7 +86,7 @@ def __init__(self, filename, pl2_dll_file_path=None): pl2_dll_folder.mkdir(exist_ok=True) pl2_dll_file_path = pl2_dll_folder / file_name - if not pl2_dll_file_path.exists(): + if pl2_dll_file_path.exists(): # I think this warning should be removed # Warnings should provide a solution but this is just a reminder to the user of normal behavior # Nothing to do From e5ddfa377360f76acc5674e5568ddedbf5096d39 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Sat, 18 Nov 2023 10:26:28 +0100 Subject: [PATCH 3/8] add windows condition --- neo/rawio/plexon2rawio/plexon2rawio.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 399051603..51e224130 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -77,9 +77,9 @@ 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: architecture = platform.architecture()[0] - if architecture == '64bit': + if architecture == '64bit' and platform.system() == 'Windows': file_name = "PL2FileReader64.dll" - else: + else: # Apparently wine uses the 32 bit version in linux file_name = "PL2FileReader.dll" pl2_dll_folder = pathlib.Path.home() / '.plexon_dlls_for_neo' @@ -88,11 +88,12 @@ def __init__(self, filename, pl2_dll_file_path=None): if pl2_dll_file_path.exists(): # I think this warning should be removed - # Warnings should provide a solution but this is just a reminder to the user of normal behavior - # Nothing to do + # Warnings should provide a solution but this is + # just a reminder to the user of normal behavior warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') else: - dist = urlopen(f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}') + 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}') From 2e1b35e3fdc9258aceeb051e975666fff1cf4f1c Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Sat, 18 Nov 2023 10:27:59 +0100 Subject: [PATCH 4/8] scalar --- neo/rawio/plexon2rawio/plexon2rawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 51e224130..01fbb7638 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -301,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 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 From 6737ecf181e37b20207ceb3d6f8dc3ab6dffa66f Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 21 Nov 2023 14:43:49 +0100 Subject: [PATCH 5/8] Update neo/rawio/plexon2rawio/plexon2rawio.py Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com> --- neo/rawio/plexon2rawio/plexon2rawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 01fbb7638..98495a649 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -90,7 +90,7 @@ def __init__(self, filename, pl2_dll_file_path=None): # I think this warning should be removed # Warnings should provide a solution but this is # just a reminder to the user of normal behavior - warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') + warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') else: url = f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}' dist = urlopen(url=url) From 1b31b1a0c31199455a66c44fa41ae3e1a996ffd3 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 21 Nov 2023 14:43:55 +0100 Subject: [PATCH 6/8] Update neo/rawio/plexon2rawio/plexon2rawio.py Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com> --- neo/rawio/plexon2rawio/plexon2rawio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 98495a649..e02308b1e 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -88,7 +88,7 @@ def __init__(self, filename, pl2_dll_file_path=None): if pl2_dll_file_path.exists(): # I think this warning should be removed - # Warnings should provide a solution but this is + # Warnings should provide a solution but this is # just a reminder to the user of normal behavior warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') else: From bb29a5b5a8ae0024983f40946e241cbb43690f11 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 21 Nov 2023 14:44:02 +0100 Subject: [PATCH 7/8] Update neo/rawio/plexon2rawio/plexon2rawio.py Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com> --- neo/rawio/plexon2rawio/plexon2rawio.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index e02308b1e..59834428f 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -81,7 +81,6 @@ def __init__(self, filename, pl2_dll_file_path=None): file_name = "PL2FileReader64.dll" else: # Apparently wine uses the 32 bit version in linux file_name = "PL2FileReader.dll" - pl2_dll_folder = pathlib.Path.home() / '.plexon_dlls_for_neo' pl2_dll_folder.mkdir(exist_ok=True) pl2_dll_file_path = pl2_dll_folder / file_name From 58266c7d6cdc8b1b43231833a9c82b17644e553c Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 6 Dec 2023 16:03:28 +0100 Subject: [PATCH 8/8] remove warning --- neo/rawio/plexon2rawio/plexon2rawio.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/neo/rawio/plexon2rawio/plexon2rawio.py b/neo/rawio/plexon2rawio/plexon2rawio.py index 01fbb7638..4fcc74b5b 100644 --- a/neo/rawio/plexon2rawio/plexon2rawio.py +++ b/neo/rawio/plexon2rawio/plexon2rawio.py @@ -86,12 +86,7 @@ def __init__(self, filename, pl2_dll_file_path=None): pl2_dll_folder.mkdir(exist_ok=True) pl2_dll_file_path = pl2_dll_folder / file_name - if pl2_dll_file_path.exists(): - # I think this warning should be removed - # Warnings should provide a solution but this is - # just a reminder to the user of normal behavior - warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}') - else: + if not pl2_dll_file_path.exists(): url = f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}' dist = urlopen(url=url)