Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Stimulus API group not finding all objects #1862

Closed
3 tasks done
CodyCBakerPhD opened this issue Mar 18, 2024 · 3 comments
Closed
3 tasks done

[Bug]: Stimulus API group not finding all objects #1862

CodyCBakerPhD opened this issue Mar 18, 2024 · 3 comments

Comments

@CodyCBakerPhD
Copy link
Collaborator

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

@CodyCBakerPhD CodyCBakerPhD changed the title [Bug]: [Bug]: Stimulus API group not finding all objects Mar 18, 2024
@CodyCBakerPhD
Copy link
Collaborator Author

@CodyCBakerPhD
Copy link
Collaborator Author

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

@CodyCBakerPhD
Copy link
Collaborator Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant