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

Simultaneously importing ecephys_project_cache and behavior_ecephys_session breaks nwb file reading #2713

Open
brendanjohnharris opened this issue Aug 9, 2023 · 3 comments
Labels

Comments

@brendanjohnharris
Copy link
Contributor

Describe the bug
Importing both allensdk.brain_observatory.ecephys.ecephys_project_cache and allensdk.brain_observatory.ecephys.behavior_ecephys_session seems to break reading from NWB files

To Reproduce
Using a sample Neuropixels Visual Behavior nwb file, this runs as expected:

import allensdk
from allensdk.brain_observatory.ecephys import behavior_ecephys_session
S = behavior_ecephys_session.BehaviorEcephysSession.from_nwb_path('ecephys_session_1152811536.nwb') # Runs fine

But this fails:

import allensdk
from allensdk.brain_observatory.ecephys import ecephys_project_cache
from allensdk.brain_observatory.ecephys import behavior_ecephys_session
S = behavior_ecephys_session.BehaviorEcephysSession.from_nwb_path('ecephys_session_1152811536.nwb') # Fails

Expected behavior
BehaviourEcephysSession can be constructed from an NWB file.

Actual Behavior
The following error:

ConstructError: (root/general/metadata GroupBuilder {'attributes': {'behavior_session_id': 1152845816, 'behavior_session_uuid': 'None', 'equipment_name': 'NP.1', 'namespace': 'ndx-aibs-behavior-ophys', 'neurodata_type': 'BehaviorMetadata', 'object_id': 'c2891e70-2766-456c-8404-7955c316a657', 'session_type': 'EPHYS_1_images_H_3uL_reward', 'stimulus_frame_rate': 60.0}, 'groups': {}, 'datasets': {}, 'links': {}}, "Could not construct BehaviorMetadata object due to: CustomClassGenerator.set_init..__init__: missing argument 'project_code'")

Environment (please complete the following information):

  • OS & version: Arch Linux x86_64, 6.4.7-arch1-2
  • Python version 3.9
  • AllenSDK version 2.15.2
@brendanjohnharris
Copy link
Contributor Author

brendanjohnharris commented Aug 9, 2023

This occurs even when directly reading the nwb file using pynwb, without importing behavior_ecephys_session. The following also fails:

import allensdk
import pynwb
from allensdk.brain_observatory.ecephys import ecephys_project_cache

with pynwb.NWBHDF5IO('ecephys_session_1152811536.nwb', "r", load_namespaces=True) as read_io:
            nwbfile = read_io.read()
nwbfile 

@brendanjohnharris
Copy link
Contributor Author

Seems to be an issue with the allensdk nwb_api. The following fails also:

import allensdk
import pynwb
from allensdk.brain_observatory.nwb.nwb_api import NwbApi
with pynwb.NWBHDF5IO('ecephys_session_1152811536.nwb', "r", load_namespaces=True) as read_io:
            nwbfile = read_io.read()
nwbfile

@brendanjohnharris
Copy link
Contributor Author

brendanjohnharris commented Aug 9, 2023

In particular, the conflicting namespace loaded as below:

import allensdk
import pynwb

namespace_path = './allensdk/brain_observatory/nwb/ndx-aibs-behavior-ophys.namespace.yaml'
pynwb.load_namespaces(str(namespace_path))

with pynwb.NWBHDF5IO('ecephys_session_1152811536.nwb', "r", load_namespaces=True) as read_io:
            nwbfile = read_io.read()
nwbfile

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

No branches or pull requests

1 participant