From 8edbcd7dfb8afc29500c58286ac34b70b3e9cd3b Mon Sep 17 00:00:00 2001 From: luiz Date: Mon, 21 Aug 2023 21:10:30 +0200 Subject: [PATCH] fix nwbfile object --- containers/run_script.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/containers/run_script.py b/containers/run_script.py index c301246..47e1303 100644 --- a/containers/run_script.py +++ b/containers/run_script.py @@ -14,7 +14,7 @@ import spikeinterface.comparison as sc from neuroconv.tools.spikeinterface import write_sorting, write_recording from nwbinspector import inspect_nwbfile_object -from pynwb import NWBFile +from pynwb import NWBHDF5IO, NWBFile from dandi.validate import validate @@ -427,7 +427,7 @@ def main( if not results_nwb_path.exists(): results_nwb_path.mkdir(parents=True) output_nwbfile_path = f"/results/nwb/{run_identifier}.nwb" - nwbfile = write_sorting( + write_sorting( sorting=sorting, nwbfile_path=output_nwbfile_path, metadata=metadata, @@ -436,7 +436,9 @@ def main( # Inspect nwb file for CRITICAL best practices violations logger.info("Inspecting NWB file...") - critical_violations = list(inspect_nwbfile_object(nwbfile_object=nwbfile, importance_threshold="CRITICAL")) + with NWBHDF5IO(path=output_nwbfile_path, mode="r", load_namespaces=True) as io: + nwbfile = io.read() + critical_violations = list(inspect_nwbfile_object(nwbfile_object=nwbfile, importance_threshold="CRITICAL")) if len(critical_violations) > 0: logger.info(f"Found critical violations in resulting NWB file: {critical_violations}") raise Exception(f"Found critical violations in resulting NWB file: {critical_violations}")