TY - JOUR TI - Computational Approach for the Reliable Inference of Task States Encoded by Neurons Using Calcium Imaging AU - Huang, Huixin AU - Adwanikar, Hita AU - Mysore, Shreesh P VL - 16 IS - 21 PY - 2026 DA - 2026/11/05 SP - e5867 C1 - Bio-protocol 2026;16:e5867 DO - 10.21769/BioProtoc.5867 UR - https://doi.org/10.21769/BioProtoc.5867 AB - Calcium imaging has become a widely used technique for measuring the activity of identified neurons during behavior. A key goal in such investigations is to determine whether, and to what extent, neurons preferentially encode one task-relevant state over another—a property referred to as neuronal selectivity. Despite the widespread use of calcium imaging for this purpose, no consensus exists on the parameter choices required to assess neuronal selectivity reliably: choices regarding neural data representation, behavioral position tracking, temporal binning, data balancing, and statistical shuffling all vary substantially across published studies. We recently developed a systematic computational approach to address this gap. Here, we describe the step-by-step protocol for implementing this computational pipeline. Starting from preprocessed calcium imaging data, the protocol guides users through all stages of the analysis: loading and aligning neural and behavioral data, deriving four metrics of neural activity, computing a selectivity index (SI), generating null distributions using four shuffling strategies, and assigning selectivity labels to individual neurons. The protocol introduces a principled, data-driven framework for evaluating the quality of any combination of parameter choices using quantitative metrics of accuracy and robustness and for identifying the optimal combination. The framework is validated using bootstrap resampling and hold-out cross-validation, and its generality is demonstrated by application to a different, regression-based approach for assessing selectivity of individual neurons. Finally, we describe the natural extension of this framework to inferences about task states encoded by populations of neurons. Thus, our protocol provides a reusable, extensible approach to identify optimal parameter settings for reliably characterizing neural encoding of two discrete task states. KW - Calcium imaging KW - Encoding KW - Neuron KW - Selectivity KW - Task states KW - Freely behaving mice JF - Bio-protocol SN - 2331-8325 PB - Bio-protocol LLC. BIO101 - False