AllenInstitute / visual_behavior_analysis

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

Foraging2: Even sampling not applied on catch trials #187

Closed dougollerenshaw closed 6 years ago

dougollerenshaw commented 6 years ago

@derricw and I just discussed this in person. It looks like, when even_sampling mode is enabled, after aborting failure_repeats trials in a row on a catch trial (but not a go trial), Foraging2 will advance to the next stimulus combination in the preset list. This leads to undersampling of the diagonal.

Code to demonstrate:

import pandas as pd
pd.set_option('display.max_columns', 500)
import numpy as np

from visual_behavior.translator.foraging2 import data_to_change_detection_core
from visual_behavior.translator.core import create_extended_dataframe

datapath=r"\\allen\aibs\mpe\Software\data\behavior\validation\files_to_troubleshoot\doc_images_7a13216_StupidDoCMouse.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'],
)

nonaborted_trials = trials[trials['trial_type'] != 'aborted']
transition_matrix = pd.pivot_table(
            nonaborted_trials,
            values='response',
            index=['initial_image_name'],
            columns=['change_image_name'],
            aggfunc=np.size,
            fill_value=0,
        )
transition_matrix

Which returns the following. Note that the im053 catch trial was only displayed twice: image

derricw commented 6 years ago

This should be fixed. You should start seeing output files fixed sometime this afternoon.