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

foraging2 translator is missing change times #73

Closed
dougollerenshaw opened this issue Apr 30, 2018 · 12 comments · Fixed by #78
Closed

foraging2 translator is missing change times #73

dougollerenshaw opened this issue Apr 30, 2018 · 12 comments · Fixed by #78
Assignees
Labels
bug Something isn't working

Comments

@dougollerenshaw
Copy link
Contributor

@neuromusic @mochic : No catch trials are being identified when loading Foraging2 data with the master branch. When I revert to the 'fix/load_licks' branch and reload the same PKL file, the problem resolves, so it would appear not to be an issue with the underlying Foraging2 data.

Minimum code to replicate error (on master branch):

from visual_behavior.translator.foraging2 import data_to_change_detection_core
from visual_behavior.change_detection.trials.extended import create_extended_dataframe
from visual_behavior.visualization.extended_trials.daily import make_daily_figure
import pandas as pd

datapath=r"\\allen\programs\braintv\workgroups\neuralcoding\Behavior\Data\M347745\output\180430100756650000.pkl"

data=pd.read_pickle(datapath)

core_data=data_to_change_detection_core(data)

trials = create_extended_dataframe(
    trials=core_data['trials'], 
    metadata=core_data['metadata'], 
    licks=core_data['licks'], 
    time=core_data['time'],
)

assert len(trials[trials['trial_type']=='catch'])>0
@dougollerenshaw dougollerenshaw added the bug Something isn't working label Apr 30, 2018
@neuromusic
Copy link
Contributor

@dougollerenshaw there's only one line changed on the fix/lload_licks branch & it should not affect this issue

indeed, when I use the fix/lload_licks branch, I still see the error you note on the file you are using.

@neuromusic
Copy link
Contributor

drilling into this file more, it looks like there simply weren't any non-aborted catch trials in this session...

no_change = ~pd.isnull(core_data['trials']['change_time'])
print (core_data['trials'][no_change]['initial_image_name']==core_data['trials'][no_change]['change_image_name']).sum()

yeilds 0

@dougollerenshaw
Copy link
Contributor Author

Hmm...
We are talking about this file, right?:\allen\programs\braintv\workgroups\neuralcoding\Behavior\Data\M347745\output\180430100756650000.pkl

on 'fix/load_licks' branch:

len(trials[
    (trials['trial_type']=='catch')&
    (trials['trial_type']!='aborted')
])

returns 50

on master:

len(trials[
    (trials['trial_type']=='catch')&
    (trials['trial_type']!='aborted')
])

returns 0

@neuromusic
Copy link
Contributor

I get 0 on fix/load_licks for those expressions.

are you using an older version of that branch?

@dougollerenshaw
Copy link
Contributor Author

Yes, I was using an older version of that branch. Sorry. Now that you've merged it in, it's displaying the same incorrect behavior for me. But there are catch trials in this session. I just went back to the 'foraging-2' branch that Chris committed on 4/20/18 at 1:06 and that is giving me 50 catch trials.

@dougollerenshaw
Copy link
Contributor Author

Well, it looks like I'm wrong. There don't appear to be any catch trials in this session. When I look directly at the core_data['trials'] object, I can't find any trials where the initial_image_name matches the final_image_name. This returns an empty dataframe:

core_data['trials'][
    ~pd.isnull(core_data['trials']['initial_image_name'])&
    (core_data['trials']['initial_image_name']==core_data['trials']['change_image_name'])
]

That would partially explain issue 65.

Tagging @derricw. Are we correct that there are no catch trials being generated by sessions from real mice on cluster D?

@neuromusic
Copy link
Contributor

note: the core_data['trials'] object is not "direct"... it is the object we are building from derric's foraging2 output

@dougollerenshaw
Copy link
Contributor Author

Is it possible that core_data['trials'] is missing the catch trials somehow?

@neuromusic
Copy link
Contributor

yes, absolutely. I'm investigating to see where it might have broken

@neuromusic
Copy link
Contributor

found the problem. working on a fix.

@neuromusic neuromusic changed the title No catch trials being identified in Master foraging2 translator is missing change times May 1, 2018
@dougollerenshaw
Copy link
Contributor Author

OK. One more bit of information. In this particular PKL file, I looked in core_data['trials'] for all changes with a first lick and a change time. Trial index 37 looks like a catch trial, but we don't have access to the initial and change stimuli in order to confirm that.

core_data['trials'][
    ~pd.isnull(core_data['trials']['first_lick'])&
    ~pd.isnull(core_data['trials']['change_time'])
][['first_lick','change_time','initial_image_name','change_image_name']][:10]

Gives:
image

@dougollerenshaw
Copy link
Contributor Author

Just had a quick conversation with @mochic about this. He's on it! Thanks Chris.

@mochic mochic closed this as completed in #78 May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants