AllenInstitute / visual_behavior_analysis

Python package for analyzing behavioral data for Brain Observatory: Visual Behavior
Other
21 stars 6 forks source link

KeyError: 'LabTracks_ID' when calling session.metadata #732

Closed dougollerenshaw closed 3 years ago

dougollerenshaw commented 3 years ago

This code block:

from visual_behavior.data_access import loading
session = loading.get_ophys_dataset(958527474)
session.metadata

Leads to this error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-1-c787d7ad3e1e> in <module>
      1 from visual_behavior.data_access import loading
      2 session = loading.get_ophys_dataset(958527474)
----> 3 session.metadata

/allen/programs/braintv/workgroups/nc-ophys/Doug/code/AllenSDK/allensdk/core/lazy_property/lazy_property_mixin.py in __getattribute__(self, name)
     11 
     12         lazy_class = super(LazyPropertyMixin, self).__getattribute__('LazyProperty')
---> 13         curr_attr = super(LazyPropertyMixin, self).__getattribute__(name)
     14         if isinstance(curr_attr, lazy_class):
     15             return curr_attr.__get__(curr_attr)

/allen/programs/braintv/workgroups/nc-ophys/Doug/code/visual_behavior_analysis/visual_behavior/data_access/loading.py in metadata(self)
    339         # for figure titles & filenames
    340         metadata = super().metadata
--> 341         metadata['mouse_id'] = metadata['LabTracks_ID']
    342         metadata['equipment_name'] = metadata['rig_name']
    343         metadata['date_of_acquisition'] = metadata['experiment_datetime']

KeyError: 'LabTracks_ID'

It does not seem specific to any particular ophys experiment ID (I tried a few others at random).

dougollerenshaw commented 3 years ago

This appears to be unique to the 'dev' branch. This code block:

https://github.com/AllenInstitute/visual_behavior_analysis/blob/1e7a41ccb5bed82c7cb79035c022fa44464022dc/visual_behavior/data_access/loading.py#L338

expects three keys in the session.metadata dictionary that don't appear to exist: 'LabTracks_ID', 'rig_name', 'experiment_datetime'.

@matchings: any idea what the intent here is?

matchings commented 3 years ago

That entire method for getting metadata in the BehaviorOphysDataset class can be removed, that was a patch to overwrite errors in the SDK in the past. Sorry for not making this changes already.

matchings commented 3 years ago

Actually i may have made some of these changes on a different branch ive been working on. let me do a PR of that into dev and we can see if i have made any other fixes for SDK updating

dougollerenshaw commented 3 years ago

Solved in PR #733