DOI: 10.5061/dryad.73n5tb359
title: Data from: Individual-specific strategies inform category learning

description: Categorization is an essential task for sensory perception. Individuals
 learn category labels using a variety of strategies to ensure that sensory
 signals, such as sounds or images, can be assigned to proper categories.
 Categories are often learned on the basis of extreme examples, and the
 boundary between categories can differ among individuals. The trajectories
 for learning also differ among individuals, as different individuals rely
 on different strategies, such as repeating or alternating choices.
 However, little is understood about the relationship between individual
 learning trajectories and learned categorization. To study this
 relationship, we trained mice to categorize auditory stimuli into two
 categories using a two-alternative forced choice task. Because the mice
 took several weeks to learn the task, we were able to quantify the time
 course of individual strategies and how they relate to how mice categorize
 stimuli around the categorization boundary. Different mice exhibited
 different trajectories in learning the task. Mice displayed preferences
 for a specific category, manifested by a choice bias in their responses,
 but this bias drifted with learning. We found that this drift in choice
 bias correlated with variability in the category boundary for sounds with
 ambiguous category membership. Next, we asked how stimulus-independent,
 individual-specific strategies informed learning. We found that the
 tendency to repeat choices, which is a form of perseveration, contributed
 to long-term learning. These results indicate that long-term trends in
 individual strategies during category learning affect learned category
 boundaries.
description: This dataset contains raw behavioral data collected from 19 mice
 performing an auditory two-alternative forced choice categorization task,
 in which they turned a Lego wheel clockwise or counterclockwise to report
 whether a presented tone burst stimuli was perceived as being drawn from a
 low- or high-frequency distribution. It also contains
 learning trajectories (parameterized by three evolving weights: "Low
 Category Knowledge", "High Category Knowledge" and
 "Choice Bias") extracted from the behavioral data using PsyTrack
 (Roy et al, 2021). It also contains fitting results
 from: Fitting psychometric curves to
 testing sessions using PyBADS (Singh et al, 2023)
 Fitting two reinforcement learning models to training
 data
description: # Mouse 2AFC Categorization: Open Source Data for Collina et al,
 "Individual-specific strategies in category learning inform learned
 boundaries" This data, necessary to reproduce figures, is available
 at
 [https://doi.org/10.5061/dryad.73n5tb359](https://doi.org/10.5061/dryad.73n5tb359) ## Description of the data and file structure This data summarizes the behavior of mice performing a 2AFC task in which they were trained to respond to categorical stimuli using a wheel. The *trajectories* of their learning of the associations between wheel turns and stimulus categories were extracted and studied, and a computational model was used to understand the factors that might explain individual variability in learning trajectory. The data is divided into 5 folders: ### 1. MouseData ``` a. At the first level, MouseData is divided into folders based on the mouse ID. For example, the folder "GS027" contains all of the files pertaining to the behavior performed by the mouse GS027. Within that folder, each behavioral training or testing session always resulted in two files: a .mat file and a .txt file. The .txt file contains the information that the Arduino transmitted to Matlab during the session, alongside the relevant timestamps. The first column denotes the trial number, the second column denotes the timestamp (in microseconds) and the third denotes the event associated with that timestamp. This information allows us to check the raw data to make sure that the summary data is correct, and also allows us to reconstruct information about the location of the wheel at different points throughout each trial, if desired. The .mat file contains information about the parameters used for that behavioral session. Relevant parameters in the .mat file include: i. Params: - basePath - taskType: text inputs that are relevant for saving and accessing the data. - Fs: sampling rate for the stimulus. - ampF: modifier related to the Lynx speakers used. - responseWindowLength: time (in s) that animals have to respond. - responseWindowDelay: time (in s) post-stimulus onset before animal responses are captured. - timeoutDuration: time (in s) where animals must wait before next trial commences if they get a trial incorrect. - trialTypeRatios: how likely stimuli from different frequency bins are to be presented during the stimulus. The way that the stimuli were encoded here evolved throughout the experiment. - timeOutContingency: linked to trialTypeRatios, indicates which "bins" should result in time-outs. - correctionTrials: whether correctionTrials are included in the session. - stimFile: for earlier mice, a stimulus file with all of the stimuli was generated pre-session. For later mice, stimuli were generated online. - Hex: relevant arduino code. - boothID: which booth was used. - Com: COM port associated with that booth. - Device: ID for soundcard associated with that booth. - Channel: which channels of the soundcard will be accessed. - filtFile: the name of the filter used to filter the stimuli, based off of the speaker used. - rewardDuration: time (in s) that the solenoid will be open in order to produce 50 uL of water per reward. - Filtdir: github location for filters. - Filt: the filter. - rotaryDebounce: How far the mouse has to turn the wheel in order for a turn to be registered. - waitRotaryDebounce: The range the mouse has to keep the wheel within in order for the next trial to commence. - rewardContingency: which "directions" are associated with each stimulus frequency bin. - rewardDurationMult: sometimes used for earlier training sessions if animals were not regularly getting rewards so we wanted to make sure they were getting enough water. - cloudRange: total frequency range, usually [6kHz 28Hz]. - mouseInfo: for later mice, contains birthdate/sex/mouse line. - hexFile: full path to arduino hex file. - Fn: file name. - stimFunc: function used to generate stimulus. - totalDir: total duration of stimulus. - numTrialTypes: number of "bins" to divide stimulus range into. - numTonesPerBin: number of frequencies sampled within each bin. Usually 10, but for early mice this varies. - envDur: pure tone stimuli are "enveloped" to avoid sharp transitions, this is the length of that envelope. - toneLevel: amplitude in decibels of stimuli. - dynamicAtten: optional dynamic attentuation from that toneLevel. ii. wheelDir: for each trial, what direction was the wheel turned? 1: CCW, 2, CW, NaN: no turn. iii. Reward: for each trial, was there a reward? 0: no reward, 1: reward. iv. Resp: for each trial, what was the outcome? 0: incorrect, 1: correct, 2: no response. v. Lapsed: for each trial, was there a response? 0: response, 1: no response. vi. correctionTrial: for each trial, was it a correction trial? 0: not a CT, 1: CT. vii. TT: array with more detailed information about each trial. The structure changes slightly across mice, but in general: - Column 1: frequency bin that the stimulus was drawn from. - Column 2: stimulus number from within that bin. - Column 3: Trial type (1: randomly drawn, 2: correction trial). - Column 4: Tone level in decibels. - Column 5: Stimulus frequency in Hz. b. JC mice from JC044 onwards also generated a "_wheelRep.txt" file, which has the wheel "location" measured every few milliseconds on the same clock as the other text file for the session. This information can be used to study the wheel dynamics in more detail. c. Each folder also contains a "mouseParams.m" matlab file, which has mouse-specific information, such as the direction that the mosue was trained to associate with the "high" category (params.highCatAction), a reward multiplier in case the mouse needs additional reinforcement (params.rewardDurationMult) and, in some cases, information about the mouse (mouseBirthDate/mouseSex/mouseLine). ``` ### 2. MuscData ``` a. We bilaterally inactivated the auditory cortex using muscimol for a subset of mice while they were performing the auditory categorization task. The MuscData folder contains a pickle file with information about these sessions and the associated psychometric fit. Once "unpickled", the data is in list form. Unpickling can be performed using the following command: with open('data/MuscData/musc_data.pkl', 'rb') as f: Struct = pickle.load(f) At the first level, the data is divided by mouse. Struct['JC044'], for example, is then divided into two sub-lists: "pbs", which contains information about control sessions, and "mus" which contains information about muscimol sessions. Within Struct['JC044']['pbs'], the next level is session number, which ranges from 3-4 sessions. To access the first muscimol session for JC044, you would use Struct['JC044']['mus']['1']. This will yield 5 outputs:i. Behavior: the behavior from this session. Each row is a trial. The columns are session #, the stimulus frequency, the stimulus category, the mouse's choice, and the accuracy associated with that choice.ii. Function: what function was used to fit that behavior to produce the psychometric fit. In this case it's fitFns.psychFn, accessible through https://github.com/geffenlab/CategorizationStrategies. The dependencies for this function are numpy and scipy. This is the general structure: f = p[0] * p[3] + (1 - p[3]) * scs.norm.cdf(x,p[1],p[2]) Where x is the stimulus frequency in log2(Hz). The parameters p are, in order: gamma (guess behavior while lapsing), mu (psychometric threshold), sigma (inverse psychometric slope), and lambda (probability of being in a lapsing state). iii. Fit_method: what package was used for the fit, if you're interested in recreating the fits. iv. Fit_params: what were the best-fitting parameters after multiple fits, ordered by log-likelihood. This information, combined with the Function, can be used to re-create the best-fitting psychometric function. The results of the fit are accessible without having access to the generative function. The parameters are, in order: gamma (guess behavior while lapsing), mu (psychometric threshold), sigma (inverse psychometric slope), and lambda (probability of being in a lapsing state).v. Y_fit: the log-likelihood associated with each of the Fit_params.b. This data is plotted in the Figure1.ipynb notebook. ``` ### 3. RL\_Data ``` a. We fit a reinforcement learning model with 3 parameters and a model with 4 parameters to our behavioral data, as detailed in Figure 4. The results of those fits are presented in this folder. There are four csv files: i. Summary_3param: the best-fitting parameters for the 3-parameter model along with the negative log-likelihood for that fit. The "beta" column is empty for this model. ii. Fits_3param: all fits for each mouse for the 3-parameter model for a range of parameter initializations. For this data, each mouse had 27 different parameter starting points. iii. Summary_4param: the best-fitting parameters for the 4-parameter model along with the negative log-likelihood for that fit. The "beta" column is not empty for this model. iv. Fits_4param: all fits for each mouse for the 4-parameter model for a range of parameter initializations. For this data, each mouse had 27 different parameter starting points. b. This data is presented in the Figure4.ipynb notebook, and the models are further described in the analysis_SimulateRLModel notebook. ``` ### 4. Stimuli ``` a. For 17 of the earliest sessions, the stimuli were generated before the session began. In order to analyze these specific sessions, we need to include these external stimulus files. This is only a small fraction of the overall sessions. ``` ### 5. Trajectories ``` a. There are three different folders within Trajectories: all_learning_sessions, with_bias_testing and with_bias_learning. The reason for two separate "learning" folders is the following: for the comparison between "extracted bias at the end of learning" and "psychometric threshold during testing", we wanted to make sure that, for each mouse, the sessions up until the testing stage were included in the analysis. However, for some mice, this went a few sessions past the point where they reached 75% accuracy. So, for the clustering analysis, we only analyzed the sessions until they reached 75% accuracy. The analysis of all sessions up until testing is contained in the "all_learning_sessions" folder, while the analysis up until 75% accuracy is contained in the "with_bias_learning" folder. The "with_bias_testing" folder contains information about the psychometric fits of testing sessions for the "all_learning_sessions" data to be compared to (in Figure 2). Within each folder: b. Each "trainingData" is a dictionary with: i. Subject: mouse ID ii. Stim: all stimuli presented to the mouse, in log2(Hz) iii. Inputs: the transformation of those stimuli to: - S_low: evidence from the stimuli towards low - S_high: evidence from the stimuli towards high iv. Correct: whether the mouse was correct or not for each trial v. Answer: the correct direction for a given trial: 1: CW, 2: CCW vi. RT: the mouse's response time on each trial vii. Y: which direction the mouse turned the wheel: 1: CW, 2: CCW Session: session # associated with each trial viii. SessDate: the data of each session ix. dayLength: how many trials each sessions has x. Psytrack: a dictionary with wMode, which has three rows: the extracted bias weights, the extracted s_high weights, and the extracted s_low weights. xi. Weights: associated with the three rows of "psytrack" xii. Hyp: hyperparameters associated with the PsyTrack fit. c. Each "biasTestingFitData" has information about psychometric fits to the session: i. First level is the session number. Loaded_dictionary['1'] will extract information from the first session. ii. Behavior: Pandas dataframe with information about each trial in the session iii. Function: the psychometric function used to fit the behavioral data iv. Fit_params: the best-fitting psychometric parameters, sorted vertically by negative LL. The first column is the probability of responding "high" when lapsing, the second column is mu, the third column is sigma and the fourth column is the lapse probability. v. Y_fit is the negative LLs associated with each set of parameters in Fit_params. vi. Fit_method is the method used to fit the data, usually "Bads"- referring to the pyBADS Toolbox. ``` ## Code/Software The code neccessary to reproduce figures is available at [https://github.com/geffenlab/CategorizationStrategies](https://github.com/geffenlab/CategorizationStrategies) Code is written for Python 3.11.4 Dependencies: * numpy * pandas * matplotlib * os * scipy * pickle * scikit-learn * psytrack * tslearn * pybads Guide: The notebooks Figure1, Figure2, Figure3 and Figure4 generate the panels in the respective paper figures. For more detailed demonstrations of the methods used in the paper, analysis_GenerateTrajectories details how we transformed the raw behavioral data using a GLM, analysis_TrajectoryClustering details how we transformed the behavioral data and applied and validated time-series clustering, and analysis_SimulateRLModel details the validation and application of the Choice-History reinforcement learning model used in the paper. All other files consist of auxiliary functions used for plotting, clustering, simulating and fitting reinforcement learning models, and general data transformation and curation. The analysis_GenerateTrajectories and analysis_SimulateRLModel notebooks generate data to a created folder titles "new_data", which is then accessed in later parts of the notebooks. Multiple runs of these notebooks may result in writing over previously saved data.