From 21aa4b6244a524654b35310a9c5cae31a8e230a1 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Mon, 12 Aug 2024 10:39:54 +0200 Subject: [PATCH 1/6] add condition on ndx-events version --- .../tools/nwb_helpers/_configure_backend.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/neuroconv/tools/nwb_helpers/_configure_backend.py b/src/neuroconv/tools/nwb_helpers/_configure_backend.py index a67308d43..520b0903d 100644 --- a/src/neuroconv/tools/nwb_helpers/_configure_backend.py +++ b/src/neuroconv/tools/nwb_helpers/_configure_backend.py @@ -1,6 +1,7 @@ """Collection of helper functions related to configuration of datasets dependent on backend.""" import importlib +from packaging import version from typing import Union from hdmf.common import Data @@ -8,11 +9,11 @@ from ._configuration_models._hdf5_backend import HDF5BackendConfiguration from ._configuration_models._zarr_backend import ZarrBackendConfiguration -from ..importing import is_package_installed +from ..importing import is_package_installed, get_package_version def configure_backend( - nwbfile: NWBFile, backend_configuration: Union[HDF5BackendConfiguration, ZarrBackendConfiguration] + nwbfile: NWBFile, backend_configuration: Union[HDF5BackendConfiguration, ZarrBackendConfiguration] ) -> None: """ Configure all datasets specified in the `backend_configuration` with their appropriate DataIO and options. @@ -53,13 +54,15 @@ def configure_backend( dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs ) # Special ndx-events v0.2.0 types - elif is_ndx_events_installed and isinstance(neurodata_object, ndx_events.Events): - neurodata_object.set_data_io( - dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs - ) + elif is_ndx_events_installed and (get_package_version("ndx-events") == version.parse("0.2.0")): + if isinstance(neurodata_object, ndx_events.Events): + neurodata_object.set_data_io( + dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs + ) # But temporarily skipping LabeledEvents - elif is_ndx_events_installed and isinstance(neurodata_object, ndx_events.LabeledEvents): - continue + elif is_ndx_events_installed and (get_package_version("ndx-events") == version.parse("0.2.0")): + if isinstance(neurodata_object, ndx_events.LabeledEvents): + continue # Skip the setting of a DataIO when target dataset is a link (assume it will be found in parent) elif isinstance(neurodata_object, TimeSeries) and is_dataset_linked: continue From edcf28d13958ad9fe0f589c5bb0b41025e20415d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 08:42:14 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/neuroconv/tools/nwb_helpers/_configure_backend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/neuroconv/tools/nwb_helpers/_configure_backend.py b/src/neuroconv/tools/nwb_helpers/_configure_backend.py index 520b0903d..d967deb74 100644 --- a/src/neuroconv/tools/nwb_helpers/_configure_backend.py +++ b/src/neuroconv/tools/nwb_helpers/_configure_backend.py @@ -1,19 +1,19 @@ """Collection of helper functions related to configuration of datasets dependent on backend.""" import importlib -from packaging import version from typing import Union from hdmf.common import Data +from packaging import version from pynwb import NWBFile, TimeSeries from ._configuration_models._hdf5_backend import HDF5BackendConfiguration from ._configuration_models._zarr_backend import ZarrBackendConfiguration -from ..importing import is_package_installed, get_package_version +from ..importing import get_package_version, is_package_installed def configure_backend( - nwbfile: NWBFile, backend_configuration: Union[HDF5BackendConfiguration, ZarrBackendConfiguration] + nwbfile: NWBFile, backend_configuration: Union[HDF5BackendConfiguration, ZarrBackendConfiguration] ) -> None: """ Configure all datasets specified in the `backend_configuration` with their appropriate DataIO and options. From d24b262e379686dd493d4c4942440c97f9f75226 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Mon, 12 Aug 2024 11:01:21 +0200 Subject: [PATCH 3/6] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fcfff01e..f8f5af3d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fixed the conversion option schema of a `SpikeGLXConverter` when used inside another `NWBConverter`. [PR #922](https://github.com/catalystneuro/neuroconv/pull/922) * Fixed a case of the `NeuroScopeSortingExtractor` when the optional `xml_file_path` is not specified. [PR #926](https://github.com/catalystneuro/neuroconv/pull/926) * Fixed `Can't specify experiment type when converting .abf to .nwb with Neuroconv`. [PR #609](https://github.com/catalystneuro/neuroconv/pull/609) +* Fixed a check in `_configure_beckend` on neurodata_object ndx_events.Events to work only when nex-events==0.2.0 is used. [PR #998](https://github.com/catalystneuro/neuroconv/pull/998) ### Improvements * Make annotations from the raw format available on `IntanRecordingInterface`. [PR #934](https://github.com/catalystneuro/neuroconv/pull/943) From 19ebd9f5c056c3ffe3665662829a9c6f984671d8 Mon Sep 17 00:00:00 2001 From: Alessandra Trapani <55453048+alessandratrapani@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:34:45 +0200 Subject: [PATCH 4/6] Update CHANGELOG.md Co-authored-by: Szonja Weigl --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02dd7ae33..b95ad3eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ ### Bug fixes * Fixed the default naming of multiple electrical series in the `SpikeGLXConverterPipe`. [PR #957](https://github.com/catalystneuro/neuroconv/pull/957) * Write new properties to the electrode table use the global identifier channel_name, group [PR #984](https://github.com/catalystneuro/neuroconv/pull/984) -* Fixed a check in `_configure_beckend` on neurodata_object ndx_events.Events to work only when nex-events==0.2.0 is used. [PR #998](https://github.com/catalystneuro/neuroconv/pull/998) +* Fixed a check in `_configure_backend` on neurodata_object ndx_events.Events to work only when ndx-events==0.2.0 is used. [PR #998](https://github.com/catalystneuro/neuroconv/pull/998) ### Improvements * The `OpenEphysBinaryRecordingInterface` now uses `lxml` for extracting the session start time from the settings.xml file and does not depend on `pyopenephys` anymore. [PR #971](https://github.com/catalystneuro/neuroconv/pull/971) From 9682a12999cc60064c496a98c3354d20987409d8 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Mon, 12 Aug 2024 14:37:59 +0200 Subject: [PATCH 5/6] combine checks on ndx-events --- src/neuroconv/tools/nwb_helpers/_configure_backend.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/neuroconv/tools/nwb_helpers/_configure_backend.py b/src/neuroconv/tools/nwb_helpers/_configure_backend.py index d967deb74..2723ebddd 100644 --- a/src/neuroconv/tools/nwb_helpers/_configure_backend.py +++ b/src/neuroconv/tools/nwb_helpers/_configure_backend.py @@ -54,15 +54,15 @@ def configure_backend( dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs ) # Special ndx-events v0.2.0 types + # Special ndx-events v0.2.0 types elif is_ndx_events_installed and (get_package_version("ndx-events") == version.parse("0.2.0")): - if isinstance(neurodata_object, ndx_events.Events): + # Temporarily skipping LabeledEvents + if isinstance(neurodata_object, ndx_events.LabeledEvents): + continue + elif isinstance(neurodata_object, ndx_events.Events): neurodata_object.set_data_io( dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs ) - # But temporarily skipping LabeledEvents - elif is_ndx_events_installed and (get_package_version("ndx-events") == version.parse("0.2.0")): - if isinstance(neurodata_object, ndx_events.LabeledEvents): - continue # Skip the setting of a DataIO when target dataset is a link (assume it will be found in parent) elif isinstance(neurodata_object, TimeSeries) and is_dataset_linked: continue From f3f0ef7010b7dc180c631b73b9b59eb45128b498 Mon Sep 17 00:00:00 2001 From: Alessandra Trapani <55453048+alessandratrapani@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:42:32 +0200 Subject: [PATCH 6/6] Update src/neuroconv/tools/nwb_helpers/_configure_backend.py Co-authored-by: Szonja Weigl --- src/neuroconv/tools/nwb_helpers/_configure_backend.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/neuroconv/tools/nwb_helpers/_configure_backend.py b/src/neuroconv/tools/nwb_helpers/_configure_backend.py index 2723ebddd..3ae0a7db9 100644 --- a/src/neuroconv/tools/nwb_helpers/_configure_backend.py +++ b/src/neuroconv/tools/nwb_helpers/_configure_backend.py @@ -54,7 +54,6 @@ def configure_backend( dataset_name=dataset_name, data_io_class=data_io_class, data_io_kwargs=data_io_kwargs ) # Special ndx-events v0.2.0 types - # Special ndx-events v0.2.0 types elif is_ndx_events_installed and (get_package_version("ndx-events") == version.parse("0.2.0")): # Temporarily skipping LabeledEvents if isinstance(neurodata_object, ndx_events.LabeledEvents):