NeurodataWithoutBorders / nwbinspector

Tool to help inspect NWB files for compliance with NWB Best Practices
https://nwbinspector.readthedocs.io/
Other
17 stars 10 forks source link

[Bug]: `OSError: Unable to synchronously open file (bad object header version number)` #422

Closed TheChymera closed 9 months ago

TheChymera commented 9 months ago

What happened?

Hello, not really a bug, but the issue tracker only has fixed categories.

I'm trying to validate a file I created with:

from datetime import datetime
from dateutil import tz
from pathlib import Path
from neuroconv.converters import SpikeGLXConverterPipe
import json

dir_path = "/mnt/DATA/data/studies/manish/mvmnda/sourcedata/sub-M388/M388-2023-11-20_2_g0"
#dir_path = "/mnt/DATA/data/studies/manish/mvmnda/sourcedata/sub-pixelfiber/M387-2023-10-20_g0"
#dir_path = "../../sourcedata/M387-2023-10-20_g0"
converter = SpikeGLXConverterPipe(folder_path=dir_path)

# Extract what metadata we can from the source files
metadata = converter.get_metadata()

# The following doesn't work as per the guide ( https://neuroconv.readthedocs.io/en/main/conversion_examples_gallery/recording/spikeglx.html#single-stream ), apparently no session_start_time is read in:
session_start_time = metadata["NWBFile"]["session_start_time"].replace(tzinfo=tz.gettz("US/Pacific"))
# So we do:
#session_start_time = datetime.now(tz.tzlocal())
metadata["NWBFile"].update(session_start_time=session_start_time)

# Choose a path for saving the nwb file and run the conversion
nwbfile_path = "/mnt/DATA/data/studies/manish/mvmnda/rawdata/my_spikeglx_session.nwb"
converter.run_conversion(nwbfile_path=nwbfile_path, metadata=metadata)

With the command:

nwbinspector _my_spikeglx_session.nwb

And I get:

Traceback (most recent call last):
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/bin/nwbinspector", line 8, in <module>
    sys.exit(inspect_all_cli())
             ^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/nwbinspector/nwbinspector.py", line 271, in inspect_all_cli
    messages = list(
               ^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/nwbinspector/nwbinspector.py", line 402, in inspect_all
    with pynwb.NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True, driver=driver) as io:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/hdmf/utils.py", line 664, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/pynwb/__init__.py", line 236, in __init__
    super().load_namespaces(tm, path, file=file_obj, driver=driver)
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/hdmf/utils.py", line 664, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/hdmf/backends/hdf5/h5tools.py", line 169, in load_namespaces
    open_file_obj = cls.__resolve_file_obj(path, file_obj, driver)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/hdmf/backends/hdf5/h5tools.py", line 144, in __resolve_file_obj
    file_obj = File(path, 'r', **file_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/h5py/_hl/files.py", line 562, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/DATA/data/studies/manish/mvmnda/rawdata/code/venvs/reposit/lib/python3.11/site-packages/h5py/_hl/files.py", line 235, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 102, in h5py.h5f.open
OSError: Unable to synchronously open file (bad object header version number)

...pretty obvious that this is a broken file, but any idea why it might be broken or how I could generate a non-broken one?

Operating System

Linux

Python Version

3.11

Were you streaming with ROS3?

None

Package Versions

Package Version


aiohttp 3.8.6 aiosignal 1.3.1 altair 5.2.0 appdirs 1.4.4 arrow 1.3.0 asciitree 0.3.3 asttokens 2.4.1 async-timeout 4.0.3 attrs 23.1.0 bidsschematools 0.7.2 blessed 1.20.0 boto3 1.28.76 botocore 1.31.76 cbor2 5.5.1 certifi 2023.7.22 cffi 1.16.0 charset-normalizer 3.3.2 ci-info 0.3.0 click 8.1.7 click-didyoumean 0.3.0 cloudpickle 3.0.0 comm 0.2.0 contourpy 1.2.0 cryptography 41.0.5 cuda-python 12.3.0 cycler 0.12.1 dandi 0.57.0 dandischema 0.8.4 dask 2023.12.0 decorator 5.1.1 distinctipy 1.2.3 distributed 2023.12.0 dnspython 2.4.2 email-validator 2.1.0.post1 etelemetry 0.3.1 executing 2.0.1 fasteners 0.19 figurl 0.2.18 fonttools 4.46.0 fparse 1.20.1 fqdn 1.5.1 frozenlist 1.4.0 fscacher 0.4.0 fsspec 2023.10.0 h5py 3.10.0 hdmf 3.11.0 humanize 4.8.0 idna 3.4 importlib-metadata 6.8.0 interleave 0.2.1 ipympl 0.9.3 ipython 8.18.1 ipython-genutils 0.2.0 ipywidgets 8.1.1 isodate 0.6.1 isoduration 20.11.0 jaraco.classes 3.3.0 jedi 0.19.1 jeepney 0.8.0 Jinja2 3.1.2 jmespath 1.0.1 joblib 1.3.2 jsonpointer 2.4 jsonschema 4.19.2 jsonschema-specifications 2023.7.1 jupyterlab-widgets 3.0.9 kachery-cloud 0.4.6 keyring 24.2.0 keyrings.alt 5.0.0 kiwisolver 1.4.5 llvmlite 0.41.1 locket 1.0.0 MarkupSafe 2.1.3 matplotlib 3.8.2 matplotlib-inline 0.1.6 more-itertools 10.1.0 msgpack 1.0.7 multidict 6.0.4 natsort 8.4.0 neo 0.12.0 networkx 3.2.1 neuroconv 0.4.4 numba 0.58.1 numcodecs 0.12.1 numpy 1.26.1 nwbinspector 0.4.31 packaging 21.3 pandas 2.1.2 parso 0.8.3 partd 1.4.1 pexpect 4.9.0 Pillow 10.1.0 pip 23.0.1 probeinterface 0.2.20 prompt-toolkit 3.0.43 psutil 5.9.6 ptyprocess 0.7.0 pubnub 7.3.2 pure-eval 0.2.2 py-spy 0.3.14 pycparser 2.21 pycryptodomex 3.19.0 pydantic 1.10.13 Pygments 2.17.2 pynwb 2.5.0 pyout 0.7.3 pyparsing 3.1.1 python-dateutil 2.8.2 pytz 2023.3.post1 PyYAML 6.0.1 quantities 0.14.1 referencing 0.30.2 requests 2.31.0 rfc3339-validator 0.1.4 rfc3987 1.3.8 rpds-py 0.10.6 ruamel.yaml 0.18.4 ruamel.yaml.clib 0.2.8 s3fs 0.4.2 s3transfer 0.7.0 scikit-learn 1.3.2 scipy 1.11.3 SecretStorage 3.3.3 semantic-version 2.10.0 setuptools 66.1.1 simplejson 3.19.2 six 1.16.0 sortedcontainers 2.4.0 sortingview 0.12.0 spikeinterface 0.99.1 stack-data 0.6.3 tblib 3.0.0 tenacity 8.2.3 threadpoolctl 3.2.0 toolz 0.12.0 tornado 6.4 tqdm 4.66.1 traitlets 5.14.0 types-python-dateutil 2.8.19.14 typing_extensions 4.8.0 tzdata 2023.3 uri-template 1.3.0 urllib3 2.0.7 wcwidth 0.2.9 webcolors 1.13 widgetsnbextension 4.0.9 xarray 2023.12.0 yarl 1.9.2 zarr 2.16.1 zarr-checksum 0.2.9 zict 3.0.0 zipp 3.17.0

Code of Conduct

TheChymera commented 9 months ago

nevermind, re-running the conversion produced a file which no longer gives the above error. Will re-open if this happens again.