NeurodataWithoutBorders/pynwb

[Bug]: Stimulus API group not finding all objects

Closed this issue · 3 comments

What happened?

I'm guessing there was a missed test case when the ability to add tables to the stimulus was enabled? I successfully created such files but upon reading them back through PyNWB for demonstration purposes, the stimulus group in the file read back does not find anything besides the classic TimeSeries descendants

Also confirmed the HDF5 file contained the desired objects

Steps to Reproduce

import dandi
import h5py
import remfile
import warnings

def read_dandi_file(asset: RemoteAsset) -> pynwb.NWBFile:
    """Remotely load the NWB file from a DANDI asset object."""
    # Harmless warnings from PyNWB
    warnings.filterwarnings(action="ignore", message="No cached namespaces found in .*")
    warnings.filterwarnings(action="ignore", message="Ignoring cached namespace .*")
    
    s3_url = asset.get_content_url()
    byte_stream = remfile.File(url=s3_url)
    file = h5py.File(name=byte_stream)
    io = pynwb.NWBHDF5IO(file=file, mode="r", load_namespaces=True)
    nwbfile = io.read()

    return nwbfile

def read_visual_coding_ophys_file(dandiset: RemoteDandiset, session_id: str) -> pynwb.NWBFile:
    """Load the NWB file from DANDI given only the unique session ID in the Visual Coding - Optical Physiology dataset."""
    asset = next(asset for asset in dandiset.get_assets() if f"ses-{session_id}" in asset.path)
    return read_dandi_file(asset=asset)

dandiset_id = "000728"

client = DandiAPIClient()
dandiset = client.get_dandiset(dandiset_id=dandiset_id)

session_id_with_drifting_gratings = "501940850"

nwbfile_with_drifting_gratings = read_visual_coding_ophys_file(dandiset=dandiset, session_id=session_id_with_drifting_gratings)

list(nwbfile_with_drifting_gratings.stimulus.keys())
> ['natural_movie_one_stimulus', 'natural_movie_three_stimulus']

# but...

list(nwbfile_with_drifting_gratings._AbstractContainer__read_io._HDF5IO__file["stimulus"]["presentation"].keys())
> ['drifting_gratings', 'natural_movie_one_stimulus', 'natural_movie_three_stimulus', 'spontaneous_stimulus']

Traceback

No response

Operating System

Windows

Python Executable

Conda

Python Version

3.11

Package Versions

PyNWB==2.6.0

Code of Conduct

Also worth mentioning the missing objects aren't even found in nwbfile_with_drifting_gratings.objects either

Oh. Guessing this has to do with

#1820 still not being merged and released

Was trying to read the files using latest release of PyNWB but used that dev branch to create them

@rly @oruebel Any timeline on getting that through?