From cf89ba02c8ab7678457fad47e9593d780d7ea22f Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Fri, 15 Nov 2024 13:26:51 +0100 Subject: [PATCH 01/12] Added fix --- src/probeinterface/io.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index 1175c4b..b75c474 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1699,6 +1699,12 @@ def read_openephys( if raise_error: raise Exception("NP_PROBE field not found in settings") return None + + np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "true"] + if len(np_probes) == 0: + if raise_error: + raise Exception("No enabled probes found in settings") + return None # read probes info # If STREAMs are not available, probes are sequentially named based on the node id From 4e7e1b3ac86dd7a82d98272191ce52da0d605713 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Fri, 15 Nov 2024 13:27:50 +0100 Subject: [PATCH 02/12] blacked --- src/probeinterface/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index b75c474..95ec4dc 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1699,7 +1699,7 @@ def read_openephys( if raise_error: raise Exception("NP_PROBE field not found in settings") return None - + np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "true"] if len(np_probes) == 0: if raise_error: From 5a86a2977bd37d6374cc041aa7f8795bdbcf0f87 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Fri, 15 Nov 2024 21:46:33 +0100 Subject: [PATCH 03/12] passing tests --- src/probeinterface/io.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index 95ec4dc..eba7caf 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1700,11 +1700,16 @@ def read_openephys( raise Exception("NP_PROBE field not found in settings") return None - np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "true"] - if len(np_probes) == 0: - if raise_error: - raise Exception("No enabled probes found in settings") - return None + # In neuropixel plugin 0.7, the option for enabling/disabling probes was added. + # Make sure we only keep enabled probes. + + # I don't understand why the range, but otherwise the test with OE_1.0_Neuropix-PXI-multi-probe fails: + if oe_version >= parse("0.7.0") and oe_version <= parse("0.9.0"): + np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "true"] + if len(np_probes) == 0: + if raise_error: + raise Exception("No enabled probes found in settings") + return None # read probes info # If STREAMs are not available, probes are sequentially named based on the node id From 446ec0b49152da79eac7cc72006b57a46f6bac4c Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Fri, 15 Nov 2024 21:51:50 +0100 Subject: [PATCH 04/12] added new assets --- .../settings_enabled-disabled.xml | 584 +++++++++++++++++ .../settings_enabled-enabled.xml | 603 ++++++++++++++++++ 2 files changed, 1187 insertions(+) create mode 100755 tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml create mode 100755 tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml diff --git a/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml b/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml new file mode 100755 index 0000000..30e5e54 --- /dev/null +++ b/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml @@ -0,0 +1,584 @@ + + + + + 0.6.7 + 8 + 14 Nov 2024 15:16:52 + Windows 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + diff --git a/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml b/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml new file mode 100755 index 0000000..3ab3379 --- /dev/null +++ b/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml @@ -0,0 +1,603 @@ + + + + + 0.6.7 + 8 + 14 Nov 2024 15:49:46 + Windows 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + From 0c72f664941f07268a018bca0580f934c8d11ba6 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Fri, 15 Nov 2024 22:03:01 +0100 Subject: [PATCH 05/12] tests for enabled probes --- src/probeinterface/io.py | 9 ++++--- .../settings_enabled-disabled.xml | 0 .../settings_enabled-enabled.xml | 0 tests/test_io/test_openephys.py | 27 +++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) rename tests/data/openephys/{OE_0.7_enabled_disabled_Neuropix-PXI => OE_6.7_enabled_disabled_Neuropix-PXI}/settings_enabled-disabled.xml (100%) rename tests/data/openephys/{OE_0.7_enabled_disabled_Neuropix-PXI => OE_6.7_enabled_disabled_Neuropix-PXI}/settings_enabled-enabled.xml (100%) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index eba7caf..da5ead5 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1700,12 +1700,13 @@ def read_openephys( raise Exception("NP_PROBE field not found in settings") return None - # In neuropixel plugin 0.7, the option for enabling/disabling probes was added. + # In neuropixel plugin 0.6.7, the option for enabling/disabling probes was added. # Make sure we only keep enabled probes. - + # I don't understand why the range, but otherwise the test with OE_1.0_Neuropix-PXI-multi-probe fails: - if oe_version >= parse("0.7.0") and oe_version <= parse("0.9.0"): - np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "true"] + print(oe_version) + if oe_version >= parse("0.6.7") and oe_version <= parse("0.9.0"): + np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "1"] if len(np_probes) == 0: if raise_error: raise Exception("No enabled probes found in settings") diff --git a/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml b/tests/data/openephys/OE_6.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml similarity index 100% rename from tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml rename to tests/data/openephys/OE_6.7_enabled_disabled_Neuropix-PXI/settings_enabled-disabled.xml diff --git a/tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml b/tests/data/openephys/OE_6.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml similarity index 100% rename from tests/data/openephys/OE_0.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml rename to tests/data/openephys/OE_6.7_enabled_disabled_Neuropix-PXI/settings_enabled-enabled.xml diff --git a/tests/test_io/test_openephys.py b/tests/test_io/test_openephys.py index 5e70927..21bb415 100644 --- a/tests/test_io/test_openephys.py +++ b/tests/test_io/test_openephys.py @@ -140,6 +140,33 @@ def test_multiple_probes(): assert np.min(ypos) >= 0 +def test_multiple_probes_enabled(): + # multiple probes, all enabled: + + probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", + probe_name="ProbeA") + assert probe.get_shank_count() == 1 + + probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", + probe_name="ProbeB") + assert probe.get_shank_count() == 4 + + +def test_multiple_probes_disabled(): + # multiple probes, some disabled + probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", + probe_name="ProbeA") + + assert probe.get_shank_count() == 1 + + # Fail as this is disabled: + with pytest.raises(Exception) as e: + probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", + probe_name="ProbeB") + + assert "Inconsistency betweem provided probe name ProbeB and available probe ProbeA" in str(e.value) + + def test_np_opto_with_sync(): probe = read_openephys(data_path / "OE_Neuropix-PXI-opto-with-sync" / "settings.xml") assert probe.model_name == "Neuropixels Opto" From a557a87e652a99ad475deb4e29aece9ec5574f62 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Sat, 16 Nov 2024 14:30:32 +0100 Subject: [PATCH 06/12] Update src/probeinterface/io.py Co-authored-by: Alessio Buccino --- src/probeinterface/io.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index da5ead5..f7ca9ba 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1704,7 +1704,6 @@ def read_openephys( # Make sure we only keep enabled probes. # I don't understand why the range, but otherwise the test with OE_1.0_Neuropix-PXI-multi-probe fails: - print(oe_version) if oe_version >= parse("0.6.7") and oe_version <= parse("0.9.0"): np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "1"] if len(np_probes) == 0: From b0d8d046f90571c9e2d473ab03b5b7bea2c59be2 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Sat, 16 Nov 2024 14:30:44 +0100 Subject: [PATCH 07/12] Update tests/test_io/test_openephys.py Co-authored-by: Alessio Buccino --- tests/test_io/test_openephys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_io/test_openephys.py b/tests/test_io/test_openephys.py index 21bb415..f41b21d 100644 --- a/tests/test_io/test_openephys.py +++ b/tests/test_io/test_openephys.py @@ -164,7 +164,7 @@ def test_multiple_probes_disabled(): probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", probe_name="ProbeB") - assert "Inconsistency betweem provided probe name ProbeB and available probe ProbeA" in str(e.value) + assert "Inconsistency between provided probe name ProbeB and available probe ProbeA" in str(e.value) def test_np_opto_with_sync(): From c3c6ce70b4e81cd94397d660141364c4b22f4b81 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Sat, 16 Nov 2024 14:41:05 +0100 Subject: [PATCH 08/12] Fixed typos --- src/probeinterface/io.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index f7ca9ba..680cea1 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1872,7 +1872,7 @@ def read_openephys( if available_probe_name not in stream_name: if raise_error: raise Exception( - f"Inconsistency betweem provided stream {stream_name} and available probe " + f"Inconsistency between provided stream {stream_name} and available probe " f"{available_probe_name}" ) return None @@ -1880,7 +1880,7 @@ def read_openephys( if probe_name != available_probe_name: if raise_error: raise Exception( - f"Inconsistency betweem provided probe name {probe_name} and available probe " + f"Inconsistency between provided probe name {probe_name} and available probe " f"{available_probe_name}" ) return None @@ -1888,7 +1888,7 @@ def read_openephys( if str(serial_number) != available_serial_number: if raise_error: raise Exception( - f"Inconsistency betweem provided serial number {serial_number} and available serial numbers " + f"Inconsistency between provided serial number {serial_number} and available serial numbers " f"{available_serial_number}" ) return None From e82d1b6a2410efe1f6797364310b88508cb1938f Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Sat, 16 Nov 2024 14:41:51 +0100 Subject: [PATCH 09/12] blacked --- tests/test_io/test_openephys.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/test_io/test_openephys.py b/tests/test_io/test_openephys.py index f41b21d..bf18711 100644 --- a/tests/test_io/test_openephys.py +++ b/tests/test_io/test_openephys.py @@ -143,26 +143,30 @@ def test_multiple_probes(): def test_multiple_probes_enabled(): # multiple probes, all enabled: - probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", - probe_name="ProbeA") + probe = read_openephys( + data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", probe_name="ProbeA" + ) assert probe.get_shank_count() == 1 - probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", - probe_name="ProbeB") + probe = read_openephys( + data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-enabled.xml", probe_name="ProbeB" + ) assert probe.get_shank_count() == 4 def test_multiple_probes_disabled(): # multiple probes, some disabled - probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", - probe_name="ProbeA") + probe = read_openephys( + data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", probe_name="ProbeA" + ) assert probe.get_shank_count() == 1 # Fail as this is disabled: with pytest.raises(Exception) as e: - probe = read_openephys(data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", - probe_name="ProbeB") + probe = read_openephys( + data_path / "OE_6.7_enabled_disabled_Neuropix-PXI" / "settings_enabled-disabled.xml", probe_name="ProbeB" + ) assert "Inconsistency between provided probe name ProbeB and available probe ProbeA" in str(e.value) From fbe4193dfe584c9b5082e6abd500e6b4b6dbf048 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Sat, 16 Nov 2024 23:32:50 +0100 Subject: [PATCH 10/12] version bug fix --- src/probeinterface/io.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index 680cea1..91d6d55 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1700,11 +1700,9 @@ def read_openephys( raise Exception("NP_PROBE field not found in settings") return None - # In neuropixel plugin 0.6.7, the option for enabling/disabling probes was added. + # In neuropixel plugin 0.7, the option for enabling/disabling probes was added. # Make sure we only keep enabled probes. - - # I don't understand why the range, but otherwise the test with OE_1.0_Neuropix-PXI-multi-probe fails: - if oe_version >= parse("0.6.7") and oe_version <= parse("0.9.0"): + if editor.find("NP_PROBE") and "isEnabled" in editor.find("NP_PROBE").attrib.keys(): np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "1"] if len(np_probes) == 0: if raise_error: From e8eaf9584477771fa960dd4b1047e48f8ed8ebfd Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Mon, 18 Nov 2024 14:30:07 +0100 Subject: [PATCH 11/12] version check fix --- src/probeinterface/io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index 91d6d55..d175157 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1700,9 +1700,9 @@ def read_openephys( raise Exception("NP_PROBE field not found in settings") return None - # In neuropixel plugin 0.7, the option for enabling/disabling probes was added. + # In neuropixel plugin 0.7.0, the option for enabling/disabling probes was added. # Make sure we only keep enabled probes. - if editor.find("NP_PROBE") and "isEnabled" in editor.find("NP_PROBE").attrib.keys(): + if neuropix_pxi_version >= parse("0.7.0") and neuropix_pxi_version < parse("1.0.0dev0"): np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "1"] if len(np_probes) == 0: if raise_error: From 705c0d141797a8911123faee4ccf4ad86efd045c Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Mon, 18 Nov 2024 16:23:31 +0100 Subject: [PATCH 12/12] Update src/probeinterface/io.py Co-authored-by: Alessio Buccino --- src/probeinterface/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index d175157..a74cc3c 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1703,7 +1703,7 @@ def read_openephys( # In neuropixel plugin 0.7.0, the option for enabling/disabling probes was added. # Make sure we only keep enabled probes. if neuropix_pxi_version >= parse("0.7.0") and neuropix_pxi_version < parse("1.0.0dev0"): - np_probes = [probe for probe in editor.findall("NP_PROBE") if probe.attrib["isEnabled"] == "1"] + np_probes = [probe for probe in np_probes if probe.attrib["isEnabled"] == "1"] if len(np_probes) == 0: if raise_error: raise Exception("No enabled probes found in settings")