AllenInstitute / visual_behavior_analysis

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

Function for checking id type #760

Closed dougollerenshaw closed 3 years ago

dougollerenshaw commented 3 years ago

This PR adds a new function that will check the ID type when passed a LIMS ID. That will let us quickly check to ensure that the correct ID type is passed to a given function. Here are some example use cases:

>> get_id_type(914580664)
'ophys_experiment_id'

>> get_id_type(914211263)
'behavior_session_id'

>> get_id_type(1086515263)
'cell_specimen_id'

>> get_id_type(914161594)
'ophys_session_id'

>> get_id_type(1080784881)
'cell_roi_id'

>> get_id_type(1234)
'unknown_id'

The above examples are added as unit tests.

I added some logic to loading.get_ophys_dataset that will ensure that the passed ID is indeed an ophys_experiment_id. If not, it will throw a warning, then fail with an assertion error. This will stop the dreaded mystery crashes that are something 'One resulted expected ...' when I accidentally pass an ophys_session_id by mistake.

Here's what I see now when passing an ophys_session_id: image