Open matchings opened 2 years ago
Hey Marina,
I've started looking into this issue and was able reproduce and find where I think we would have to add the calculation to compute the response_latency
column. However, I chatted with @aamster a bit and learned that the supported way of accessing the reward rate for the session is through the method BehaviorSession.get_reward_rate()
not the trials table. Here's the code for the method. It eventually calls the method same calculate_reward_rate
that you are using here. Does calling this method on the session
you load in the code above give you what you want?
Describe the bug the function
calculate_reward_rate
fromallensdk.brain_observatory.behavior.trials_processing
returns incorrect values (all zeros) with Visual Behavior Neuropixels data because it lacks the requisite columns to calculate the reward rate value. Specifically, the VBN trials table does not haveresponse_latency
.Response latency can be calculated as
trials['response_latency'] = trials.response_time-trials.change_time_no_display_delay
To Reproduce `from allensdk.brain_observatory.behavior.behavior_project_cache.\ behavior_neuropixels_project_cache \ import VisualBehaviorNeuropixelsProjectCache
cache = VisualBehaviorNeuropixelsProjectCache.from_local_cache( cache_dir=cache_dir, use_static_cache=use_static)
session_id = 1053941483 session = cache.get_ecephys_session( ecephys_session_id=session_id)
trials = session.trials.copy()
from allensdk.brain_observatory.behavior.trials_processing import calculate_reward_rate
trials['reward_rate'] = calculate_reward_rate(trials['response_latency'].values, trials['start_time'], window=.5)`
Expected behavior I expect the output of
calculate_reward_rate
to return thetrials
table with a column added calledreward_rate
with values that are not entirely zero or NaN.Actual Behavior![image](https://user-images.githubusercontent.com/21346970/188019375-770eafdc-b538-49ce-8957-5b9e05fd421e.png)
Environment (please complete the following information):
Additional context Add any other context about the problem here.