Scratcher: An automated machine-vision tool for dissecting the neural basis of itch

preprint OA: closed CC-BY-NC-4.0
📄 Open PDF Full text JSON View at publisher
AI-generated summary by claude@2026-07, 2026-07-16

This study developed Scratcher, an automated tool for analyzing scratching behavior in mice, which was used to show that activity in the lateral parabrachial nucleus modulates itch-evoked scratching.

One-sentence paraphrase of the abstract; not a substitute for reading it. No clinical advice. How this works

AI-generated deep summary by claude@2026-07, 2026-07-16 · read from full text

This paper studies how to automate and mechanistically dissect itch-driven scratching in mice by developing “Scratcher,” a GUI-based deep learning tool that uses real-time YOLOv8 object detection to quantify nape-directed scratching from video. The authors validate the system by recording chloroquine-induced acute itch and testing the effect of nail trimming, then combine Scratcher with Fos-TRAP genetic circuit dissection to target itch-activated neurons in the lateral parabrachial nucleus and show that LPBN activity modulates itch-evoked scratching. A major limitation is that the current Scratcher version is specialized for detecting nape-directed scratching in their specific experimental setup (nape pruritogen application and the videography conditions), rather than being universally general across all itch phenotypes or arenas. Relevance to endometriosis: itch circuitry and automated scratching quantification are used here to mechanistically interrogate pruritic signal pathways, which parallels the study of neuropathic and immune-linked sensory dysfunction implicated in endometriosis-associated pelvic pain, though the paper does not directly examine endometriosis or adenomyosis.

Read from the paper's body, not the abstract. Not a substitute for reading the paper. No clinical advice. How this works

Abstract

Itch or pruritus invokes a specific reflexive and repetitive directed nocifensive behavioural response, known as scratching. Recent decades have revealed neural circuits that are involved in the sensory and affective-motivational aspects of itch-induced scratching. However, most of these studies relied on manual subjective methods of quantifying scratching in laboratory mice and rats. Recent advances in deep learning have opened avenues for the development of computational tools to analyze animal behaviour in a reliable and automated manner. Further, combined with optogenetic and chemogenetic strategies, these tools can accelerate our understanding of neural circuits underlying itch and scratching. To that end, we have developed Scratcher , a GUI-based computational tool based on a real-time object detection algorithm that allows semi-supervised automated analysis of scratching behaviour in mice in a computationally inexpensive manner. We recorded chloroquine-induced acute itch as it developed and determined the consequence of nail-trimming on acute-itch induced scratching with Scratcher . To probe the neural mechanisms underlying itch, we combined Scratcher with genetic circuit dissection using the Fos-TRAP mouse line. By targeting itch-activated neurons in the lateral parabrachial nucleus (LPBN) - a key brainstem hub for pruritic signal transmission - we demonstrated that LPBN activity modulates itch-evoked scratching. Together, we present a novel, easy-to-use computational tool to dissect molecular, cellular, and circuit mechanisms of itch and scratching.
Full text 154,901 characters · extracted from oa-pdf · 9 sections · click to expand

Abstract

9 Itch or pruritus invokes a specific reflexive and repetitive directed nocifensive behavioural 10 response, known as scratching. Recent decades have revealed neural circuits that are involved in the 11 sensory and affective-motivational aspects of itch-induced scratching. However, most of these studies 12 relied on manual subjective methods of quantifying scratching in laboratory mice and rats. Recent 13 advances in deep learning have opened avenues for the development of computational tools to analyze 14 animal behaviour in a reliable and automated manner. Further, combined with optogenetic and 15 chemogenetic strategies, these tools can accelerate our understanding of neural circuits underlying itch 16 and scratching. To that end, we have developed Scratcher, a GUI-based computational tool based on a 17 real-time object detection algorithm that allows semi-supervised automated analysis of scratching 18 behaviour in mice in a computationally inexpensive manner. We recorded chloroquine-induced acute itch 19 as it developed and determined the consequence of nail-trimming on acute-itch induced scratching with 20 Scratcher. To probe the neural mechanisms underlying itch, we combined Scratcher with genetic circuit 21 dissection using the Fos-TRAP mouse line. By targeting itch-activated neurons in the lateral parabrachial 22 nucleus (LPBN) - a key brainstem hub for pruritic signal transmission - we demonstrated that LPBN 23 activity modulates itch-evoked scratching. Together, we present a novel, easy-to-use computational tool 24 to dissect molecular, cellular, and circuit mechanisms of itch and scratching. 25 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 2

Introduction

26 The advent and application of machine learning and computer vision tools(Mathis et al., 2018; 27 Pereira et al., 2022) have revolutionized behavioural neuroscience by making analysis of animal 28 behaviours automated, semi-supervised, scalable, and reproducible. These computational approaches 29 have accelerated data acquisition and interpretation and yielded mechanistic insights into complex 30 behaviours, from locomotion to social interactions. Despite these advances, easily deployable and 31 quantitative tools for measuring pruritic (itch-related) behaviours in rodents, which are the common 32 laboratory models for studying itch, remain lacking. Computational tools that would require minimal 33 exposure to programming languages and can be easily integrated with neural activity monitoring or 34 closed-loop stimulation paradigms can help in a better understanding of the circuits underlying itch 35 perception and processing. Importantly, despite its physiological and pathological relevance, the neural 36 circuits underlying physiological and pathological itch remain poorly understood. 37 The sensation of itch is subjective, and a quantitative representation of its intensity is difficult; 38 however, the behavioural output — scratching, can be objectively analyzed(Prajapati et al., 2024; 39 Wimalasena et al., 2021). Over the last two decades, there have been efforts to automate the 40 quantification of scratching behaviour in mice and rats. Hardware-dependent methods were developed to 41 improve the specificity of scratch detection by using copper or aluminum rings that detect paw proximity to 42 the nape of the neck(Elliott et al., 2000), a typical scratching target in rodents. These methods, however, 43 often restrict free movement, potentially confounding behavioural readouts. Moreover, the use of 44 magnetic or electric fields in these systems risks interfering with delicate neural recording techniques, 45 thus limiting their utility in integrated systems neuroscience pipelines. In another development, force 46 transducers placed on the floor of chambers were used to measure scratches in mice(Brash et al., 2005). 47 In this inexpensive setup, a programmed microcontroller distinguished between scratching and grooming, 48 and other non-specific movements simultaneously in multiple mice. Yet, they were limited in sensitivity 49 and prone to both over- and under-representation of scratching events, especially when subtle or 50 overlapping with other motor actions. More recently, an acoustic-based method was proposed wherein 51 microphone recordings and signal processing algorithms were used to detect scratching sounds in freely 52 moving animals(Elliott et al., 2017). While non-invasive and elegant in concept, this approach still suffers 53 from limitations in resolving overlapping behaviors or disambiguating acoustic artifacts, ultimately limiting 54 its robustness and specificity. Collectively, these approaches reflect sustained but cumbersome efforts to 55 automate identification and quantification of scratching behavior, none of which have proven sufficiently 56 accurate and generalizable across experimental contexts. 57 The emergence of deep learning-based pose estimation tools offered a promising new direction. 58 Notably, Scratch-AID, an automatic itch detection framework, combined convolutional and recurrent 59 neural networks (CNNs and RNNs) to classify scratching episodes(Yu et al., 2022). This approach 60 marked a significant step forward by moving away from hardware-based proxies to directly model the 61 behaviour from animal kinematics. However, despite its high precision, Scratch-AID requires substantial 62 post-processing to distinguish scratching from kinematically similar behavior such as grooming. This tool 63 introduces significant computational overhead and demands non-trivial pre-processing pipelines, which 64 can compromise speed and scalability. 65 Given these methodological challenges, the need for a fast, accurate, and computationally 66 efficient tool that can be deployed with minimal technical know-how remains unmet. Importantly, such a 67 tool must be versatile enough to be adapted to analyze multiple animals simultaneously, work across 68 different arenas, and integrate easily with neural recording or stimulation platforms - an increasingly 69 common requirement in behavioural systems neuroscience research. To address these challenges, we 70 developed Scratcher, an end-to-end, GUI-based behavioural analysis platform built on the YOLOv8 71 object detection framework(Redmon et al., 2016). Its computational efficiency and robustness across 72 various experimental contexts make it ideally suited for long-term, high-throughput studies. With a focus 73 on user-centric design and compatibility across experimental paradigms, Scratcher provides an 74 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 3 accessible and scalable solution for the automated quantification of scratching behaviour, enabling 75 broader adoption of objective and standardized itch analysis in rodent models. Notably, we employed 76 Scratcher to study how the itch-sensitive ensemble of lateral parabrachial neurons participates in non-77 histaminergic acute, as well as spontaneous itch.(Mu et al., 2017). This approach indicates that Scratcher 78 can be effectively deployed in itch circuit dissection studies. 79 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 4

Results

80 Development of Scratcher, a GUI-based deep learning tool to measure scratching in mice 81 We developed Scratcher, a computational tool to facilitate automated identification and 82 quantification of scratching behaviour in an accurate and precise manner in mice. We developed the tool 83 to provide the user with a suite of various quantitative measurements without compromising on 84 computational cost in terms of time spent to obtain complete analyses. Further, the current iteration of 85 Scratcher is specialized for detecting nape-directed scratching behaviour, since, in mechanistic studies, 86 interrogating molecular, cellular, or circuit mechanisms of itch, pruritogens are typically injected or applied 87 to the nape of the neck of mice. For acute itch, we injected 1% Chloroquine in the nape of wild-type CD1 88 mice (Figure 1A). We fabricated a behavioral setup (Figure 1B-C, see methods), an open-top box to 89 enable unrestrained videography of mouse behavior with a matte dark background with uniform lighting of 90 non-aversive intensity, to provide contrast to the coat color of the CD-1 wild-type strain of mice (Figure 91 1C). We leveraged the YOLOv8 object detection architecture to develop a deep learning-based pipeline 92 to enable high-throughput, frame-accurate quantification of scratching behaviour from raw video data 93 (Figure 1D-E). An object detection algorithm was selected over a classification-based approach(Oksuz et 94 al., 2021) because it provides both spatial and categorical information, and not just detects whether a 95 scratching event occurs, but also where in the frame it occurs. This localization capability is crucial for 96 future extensions of the pipeline to closed-loop experimental paradigms, where real-time detection of 97 scratch location can trigger targeted interventions(Mathis et al., 2018; Pereira et al., 2022; Schweihoff et 98 al., 2021). Furthermore, object detection algorithms like YOLOv8 are significantly more computationally 99 efficient during inference than frame-wise classification models(Hussain, 2024; Vasanthi and Mohan, 100 2024) which often require temporal context windows, optical flow, or full-frame analysis pipelines. Object 101 detectors also allow for greater scalability(Dang et al., 2024; Hussain, 2024) as they can be adapted to 102 detect multiple behaviours or features in parallel without restructuring the input format(Ge et al., 2024; 103 Vasanthi and Mohan, 2024) 104 The workflow begins with standard video acquisition within a custom-designed behaviour box (for 105 dimensions and other specifics see methods) optimized for visibility of scratching postures in freely 106 moving mice (Figure 1C). Videos are parsed frame by frame, and each image is processed by a YOLOv8 107 neural network trained to detect and classify individual scratching events through bounding box 108 localization. This bounding box approach(Segalin et al., 2021; Xu et al., 2025) provides precise spatial 109 information about the scratch posture without altering the raw image data, thereby preserving the full 110 anatomical context of the animal during behaviour. In contrast to other commonly used methods, such as 111

Background

subtraction(Hu et al., 2023), which involve removing static elements from the video to isolate 112 the mouse, bounding box detection is less computationally expensive(Sun et al., 2021) and avoids 113 common pitfalls like partial removal or distortion of mouse body parts. Background subtraction can be 114 particularly error-prone in behavioural settings(Wen et al., 2022; Zhao et al., 2019) where subtle 115 movements and complex postures are critical, as it may inadvertently eliminate or modify important visual 116 features necessary for accurate behaviour classification. By retaining the complete visual information and 117 focusing on the relevant scratch regions, the bounding box method ensures that critical behavioural cues 118 remain intact, enabling more reliable and robust detection across diverse experimental conditions(Wen et 119 al., 2022; Zhao et al., 2019) YOLOv8 was selected for its high inference speed, real-time detection 120 capability, and architectural advantages over previous versions, including a decoupled head structure, 121 deeper CSPDarknet53 backbone, and robust anchor-free predictions(Redmon et al., 2016) (Figure 1D). 122 These enhancements allowed the model to learn scratch-specific postures across diverse conditions with 123 minimal overfitting, even when trained on a relatively small annotated dataset, while also reducing the 124 spatial resolution and dimensionality of features in a manner that facilitates computation and increases 125 overall processing speed, without compromising on accuracy. The final dataset consisted of a data split of 126 81% (6906 images)and 19% (1598 images) for training and validation, respectively (Figure 1F). This 127 dataset consisted of videos from chloroquine-induced acute scratching, along with saline-injected rodent 128 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 5 videos as controls. For testing various iterations of the models, we would test videos in which we were 129 blind to the experimental condition. The entire open-source code and a full manual detailing the 130 installation and usage of the GUI (Figure S1) can be found at its GitHub page 131 (https://github.com/BarikLab-IISc/Scratcher). 132 133 Evaluation of the model-training performance of Scratcher 134 After training the YOLOv8 model on an annotated dataset encompassing various postures 135 associated with scratching, locomotion, and unrelated behaviours (“Others”), we assessed model 136 performance using standard object detection benchmarks. Precision-recall analysis revealed a peak F1 137 score of 0.854 at a confidence threshold of 0.95, reflecting optimal balance between sensitivity and 138 specificity for detecting behaviour-relevant bounding boxes (Figure 2A). Across the full prediction space, 139 the model achieved a maximum average precision ([email protected]) of 0.967 (Figure 2B) and a corresponding 140 average precision and recall of 0.97 and 0.99, respectively. (Figure 2C, 2D), indicating strong class 141 separability and reliable retrieval of true scratching events. These metrics remained stable across a range 142 of confidence thresholds, demonstrating consistent model behaviour across decision boundaries. Loss 143 convergence was evident across training epochs, with box, class, and distributional focal losses (DFL) for 144 both training and validation sets declining in a monotonic fashion (Figure 2E), consistent with stable 145 gradient propagation and avoidance of overfitting. These trends were further supported by a steady 146 increase in Mean Average Precision (mAP) and recall metrics across epochs, with class-wise spatial 147 accuracy and confidence remaining robust across all behavioural categories (Figure 2G). The evolution of 148 mAP was also tracked during training using two widely adopted evaluation standards: [email protected], which 149 considers predictions correct if their Intersection over Union (IoU) with ground truth exceeds 0.5, and the 150 stricter mAP@[0.5:0.95], which averages mAP across multiple IoU thresholds (0.5 to 0.95, in 0.05 151 increments). As shown in the left panel (Figure 2H, left panel), [email protected] rapidly increased during the 152 initial epochs and plateaued at ~0.94, indicating that the model learned to reliably localize and classify 153 scratch events with moderate spatial tolerance. This suggests a strong ability to identify scratch frames 154 with high sensitivity and low false positives under standard detection criteria. In contrast, the more 155 stringent mAP@[0.5:0.95] metric (Figure 2H, right panel) showed a slower rise and reached a final value 156 of ~0.97. The relatively higher final value under the stricter metric demonstrates the model's accurate 157 predictions while exhibiting good spatial alignment with ground-truth annotations across a range of 158 tolerances. A final confusion matrix constructed from the validation set confirmed near-perfect 159 discrimination between the primary classes (“Itch”, “Locomotion”, and “Others”), with minimal confusion 160 with the background class, further attesting to the model’s real-world applicability in noisy behavioural 161 settings (Figure 2I). To operationalize the frame-wise annotations generated by the trained YOLOv8 162 model for downstream behavioural quantification, we implemented a structured post-processing pipeline 163 (Figure 2J). This pipeline begins with the output files generated from the YOLOv8 model, which consist of 164 frame-by-frame annotations of individual behaviors i.e., Itch, Locomotion, and Others, along with their 165 associated confidence scores (Figure 2J, right) that proceeds to generate second-wise behavioural labels 166 by aggregating frame-wise predictions using five distinct heuristics (details in the next section). We 167 implemented and rigorously evaluated each of these heuristics, as each of them offers a different 168 perspective on how high-frequency predictions (30 fps) can be transformed from noisy frame-level 169 predictions into stable, second-level behavioral labels, making the data suitable for various downstream 170 analyses. 171 172 A rule-based majority voting algorithm of post-hoc binning for Frame-to-Second behavioral 173 aggregation using empirically derived tie-break rules 174 To convert frame-wise detections into behaviourally meaningful second-wise annotations, we 175 developed a suite of post hoc aggregation strategies aimed at resolving the temporal complexity inherent 176 in scratching behaviour. Unlike binary or posture-based motor acts, rodent scratching consists of a 177 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 6 sequence of temporally extended yet phenotypically distinct subcomponents: (1) paw lift toward the nape 178 (start), (2) rhythmic hind paw contact with the skin (scratching bout), (3) paw licking at the end of 179 scratching, and (4) paw withdrawal (end). Although all four components comprise the canonical 180 scratching sequence we are aware of, not all are equally suitable for classification in automated pipelines. 181 For example, paw licking often occurs outside of itch-related contexts, and its appearance in isolation 182 may not reliably indicate a scratching bout. In contrast, the scratching bout itself-characterized by rapid, 183 repetitive, nape-directed hindlimb movements-is both temporally constrained and phenotypically 184 distinctive, making it a robust unit for computer vision-based detection. Given the sub-second dynamics of 185 these transitions and the need to deliver user-oriented outputs at behaviourally relevant timescales, we 186 framed the binning task as a structured aggregation problem: the goal being to translate 30 frames of 187 frame-wise predictions (at 30 fps) into a single second-wise behavioural label. This approach allowed the 188 model to preserve the higher-resolution signature of scratching sequences while discarding ambiguous or 189 non-specific micro-behaviours that often accompany scratching but are not an accurate diagnostic on 190 their own. This approach also ensures that the resulting output reflects the user’s primary interest, i.e., 191 nape-directed scratching, without being confused by grooming-like actions such as paw licking, which 192 may have high visual overlap but completely different ethological relevance.(Shimada and LaMotte, 2008; 193 Smolinsky et al., 2009; Wimalasena et al., 2021) 194 In the binning step, we first implemented a majority-voting heuristic applied over non-overlapping 195 30-frame windows, assigning to each second the most frequent behaviour observed within that window. A 196 set of empirically derived tie-breaking rules was introduced to resolve ambiguous cases, prioritizing “Itch” 197 in situations where licking or mixed behaviours co-occurred, based on manual inspection of over 40 hours 198 of annotated recordings (Figure 3A). The resulting second-wise prediction series showed strong 199 alignment with ground-truth annotations, as indicated exhaustively by several metrics. The confusion 200 matrix revealed minimal misclassification between “Itch” and “Others” (Figure 3B), while time-aligned plots 201 of prediction correctness further confirmed consistent performance across the session (Figure 3C, D). 202 Quantitatively, the approach yielded an accuracy of 93.0%, precision of 94.3%, recall of 93.0%, and an 203 F1 score of 93.3% (Figure 3E), validating the robustness of the rule set under noisy behavioural 204 conditions. Distribution histograms showed strong agreement between predicted and actual class 205 proportions (Figure 3E), including rare tie-label classes such as “Locomotion, Others” (Figure 3F). 206 Precision-recall metrics remained high across individual classes (Figure 3G), and correlation analysis 207 yielded an R² of 0.96, indicating strong agreement in cumulative behaviour counts (Figure 3H). 208 Complementing this, a Bland–Altman plot was used to quantify agreement between the predicted and 209 ground-truth scratch durations across timepoints (Figure 3I). This method, widely used in clinical and 210 pharmacological research to assess bias and limits of agreement between measurement tools(Doğ an, 211 2018; Ludbrook, 2010), revealed that most predictions fell within narrow agreement bands, suggesting 212 negligible systematic bias. This indicates that our tool does not systematically overestimate or 213 underestimate scratching duration and can be trusted for accurate behavioural quantification in 214 experimental settings that have fundamental, as well as translational implications. To comprehensively 215 assess the classification precision of Scratcher, we quantified the false negative rate (FNR) and false 216 positive rate (FPR) for each behavioural class (Figure 3J). Across all annotated behaviours, Scratcher 217 maintained a low FNR of approximately 0.14 and an even lower FPR of around 0.04, underscoring its 218 robust ability to detect true behavioural events while minimizing false predictions. "Itch" events, in 219 particular, were detected with high accuracy, with minimal omission or over-representation. The color-220 coded bar plots - blue for FNR and red for FPR - allow for intuitive visual inspection and demonstrate 221 consistently low error rates across all behaviour types. These results highlight the tool’s strong reliability 222 and reinforce its suitability for high-throughput, automated scratching behavioural analysis. 223 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 7 Additionally, in order to arrive at a robust and generalizable heuristic, we evaluated five 224 approaches across the same dataset, using manual human annotations as the ground truth. The first 225 approach, a non-overlapping 30-frame majority voting scheme(Ren et al., 2020) with empirically 226 determined tie-breaking rules, emerged as the most accurate and computationally efficient strategy 227 (Figure 3). However, to evidence that this outcome was not incidental or biased by specific design 228 choices, we present the data on the application of the other four algorithms. A Bayesian inference-based 229 (Argiento et al., 2017; Beyer et al., 2013; McNamara et al., 2006) heuristic (Figure S2) was implemented 230 to compute posteriors over behaviours by combining class priors (estimated from the training data) with 231 likelihoods derived from YOLOv8 detection frequencies. While conceptually elegant, this approach 232 struggled to maintain precision-recall balance, especially for "Itch", which was consistently 233 underestimated (Figure S2D–F). The algorithm tended to over-prioritize "Locomotion", likely due to its 234 dominance in the training set, and its performance suffered from the strong class imbalance. Temporal 235 consistency in label assignment was also poor (Figure S2C), and aggregate accuracy metrics were 236 significantly lower than those achieved via the majority voting scheme. Next, we tested a Gaussian 237 Hidden Markov Model (HMM) (Macdonald and Raubenheimer, 1995; Patterson et al., 2009; Whoriskey et 238 al., 2017), reasoning that it might better capture temporal dependencies in behavioural transitions (Figure 239 S3). However, this approach performed poorly across all metrics, yielding an F1 score of just 11.1% 240 (Figure S3D). The inferred hidden states exhibited significant confusion, especially between "Locomotion" 241 and "Others", and failed to reliably capture even the dominant behavioural class at any time point (Figure 242 S3B). Ground truth distributions were not preserved (Figure S3E), and the overall correctness of 243 predictions across time remained flat and near zero (Figure S3C). These findings suggest that while 244 HMMs may be suitable for structured tasks with clean state transitions, they are ill-equipped for noisy, 245 ethologically rich behaviours like spontaneous scratching, which do not conform to tightly ordered state 246 machines. A third approach used a simple overlapping sliding window, where every window of 30 frames 247 was moved one frame at a time and assigned the modal behaviour (Figure S4). While this improved 248 temporal resolution, it introduced excessive redundancy, and its accuracy remained moderate (F1 = 249 46.9%). Notably, it severely overestimated "Locomotion" while underrepresenting "Others" and 250 inconsistently detected "Itch" (Figure S4E–F). Despite some improvements in label smoothness, it did not 251 outperform the non-overlapping majority vote. The fourth strategy, which averaged predicted class 252 probabilities within non-overlapping 30-frame windows and assigned the behaviour with the highest mean 253 confidence, showed considerable promise (Figure S5). This method maintained high confidence in its 254 predictions and achieved strong performance across standard metrics, including an F1 score of 81.5%, 255 the second highest among all tested heuristics (Figure S5D). Importantly, its predicted distribution closely 256 matched the ground truth, though “Others” remained underrepresented (Figure S5E). Unlike other 257 heuristics, this method exhibited high temporal correctness and a lower variance in frame-to-second 258 translation errors (Figure S5C). These characteristics make it a viable alternative to the existing algorithm 259 implemented in Scratcher currently for experiments where high prediction confidence is prioritized. Taken 260 together, these analyses not only justify our use of the majority-voting scheme in the main pipeline but 261 also demonstrate the breadth of computational approaches available for post hoc behaviour aggregation. 262 263 Leveraging Scratcher to analyze itch-induced scratching behavior in mice 264 Scratcher was next evaluated for its ability to accurately quantify scratching behaviour for long-265 duration recordings, a capability essential for assessing the effects of prolonged drug treatments or 266 neuromodulatory interventions. Typically, in studies designed to understand neural mechanisms of itch, 267 post-injection of pruritogens in the nape of the neck, or cheek, scratching frequency is measured for 30 268 minutes to an hour. The reason for the choice of the time period for which behavior is usually assayed 269 depends on the usual period for which the pruritogen-evoked scratching lasts at a high intensity, and the 270 optimized time for which an experimenter can visually count the number of scratches. We argued that 271 being able to record for a longer time period may delineate aspects of scratching behavior not revealed 272 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 8 by shorter recordings. For example, longer recordings may help determine if neural manipulations affect 273 the time for which the effect of pruritogens lasts. Animals sensitive to pruritogens may scratch at a similar 274 frequency but for prolonged periods of time compared to the control conditions. Thus, we tested whether 275 the Scratcher would allow us to analyze scratching behavior post-application of chloroquine in the nape of 276 the neck of wild-type CD1 mice for three hours. We found that, despite the extended duration and 277 increased behavioural variability, Scratcher maintained consistent frame-wise annotation accuracy and 278 generated interpretable summary outputs, including cumulative behaviour plots and per-animal 279 comparisons over time (Figure 4B–E). Individual animal trajectories revealed rich inter-animal 280 heterogeneity, with some mice exhibiting sustained scratching activity over the full session (e.g., M1 and 281 M6), and others demonstrating minimal or tapering responses (e.g., M3–M5) (Figure 4D). Linear 282 regression analysis of scratching time courses revealed consistent negative slopes across most animals 283 (Figure 4E), suggesting a decline in behavioural intensity over time. These results demonstrate that 284 Scratcher can handle high-throughput behavioural sessions over extended durations without degradation 285 in accuracy, offering a powerful solution for chronic assays or longitudinal tracking. 286 In the following experiments, we implemented Scratcher to ask if nail-clipping would alter itch-287 induced scratching patterns. Scratching an itch is known to bring relief; a lack of relief tends to increase 288 the urge to scratch, and this increased urge is observed in chronic itch conditions. We hypothesized that 289 clipping the nails of the mice would not provide them relief from chloroquine-induced itch by scratching, 290 and thus, we should observe increased frequency of scratching bouts. We clipped the nails from the hind 291 paws of mice and quantified chloroquine-induced scratching with the Scratcher before and after clipping 292 (Figure 5A). We found that the scratching was increased after clipping, as expected (Figure 5B-E). 293 Interestingly, the frequency of scratching was higher in the first 20 minutes in the mice after nail clipping 294 (Figure 5B-E). Thus, when the pruritic effect of the chloroquine was the highest (time-post chloroquine 295 administration), the nail clipping increased the scratching behavior compared to the unclipped condition. 296 Scratcher analysis showed that the inter-animal variability was as expected (Figure 5C-E). Thus, with the 297 help of an automated analytical pipeline, we show that the nail-clipping increases non-histaminergic 298 pruritogen-induced scratching. 299 300 Effect of chemogenetic manipulation of itch-TRAP neurons in the LPBN with Scratcher 301 The LPBN is known as a central component of the pruritic ascending neural pathway (Mu et al., 302 2017; Prajapati et al., 2025; Ren et al., 2023), and we sought to understand the effects of 303 chemogenetically activating the itch-sensitive neurons in the LPBN. To that end, we took advantage of 304 the Fos-TRAP strategy, where a transgenic mouse strain (TRAP2) expresses 4-hydroxytamoxifen (4-305 OHT) sensitive Cre-recombinase under the immediate early-gene cFos promoter (DeNardo et al., 2019; 306 Guenthner et al., 2013). In this transgenic strain, intraperitoneal administration of 4-OHT and 307 simultaneous induction of neural activity induces expression of Cre in the cell population of interest 308 (DeNardo et al., 2019; Onishi et al., 2024). We stereotaxically injected the AAV particles encoding Cre-309 dependent excitatory chemogenetic actuator tagged to mCherry fluorescent protein for visualization, 310 hM3Dq-mCherry in the right LPBN of TRAP2, and induced the expression of the hM3Dq-mCherry in the 311 LPBN itch-sensitive neurons by administering i.p. 4-OHT 120 minutes post-chloroquine injection in the 312 nape of the neck of the mice (Figure 6A). 30 minutes after chloroquine administration is known to be 313 sufficient for cFos induction, and 90 minutes is required for robust cFos-promoter driven gene 314 expression(Guenthner et al., 2013; Samineni et al., 2021, 2019). Thus, we decided that 120 minutes after 315 itch induction would be optimal for 4-OHT to drive Cre-expression in TRAP2 mice after pruritogen 316 administration. We found that the itch-Trap drove robust hM3Dq-mCherry neurons in the LPBN, and i.p. 317 DCZ administration induced cFos protein expression in the mCherry-positive neurons, implying 318 successful chemogenetic tool induced neuronal activation (Figure 6B). We found that chemogenetic 319 activation of the itch-sensitive LPBN neurons increased scratching (Figure 6C). Remarkably, the 320 increased scratching was distributed across the 30 minutes for which the behavioral recordings were 321 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 9 carried out (Figure 6D). Inter-animal variability was observed, which can be attributed to the differences in 322 experimental conditions, levels of hM3Dq expression, and internal state of the mice (Figure 6E-H, Figure 323 S6). Together, our findings indicate that targeted stimulation of the itch-responsive neural population in 324 the LPBN is sufficient to drive increased nocifensive behavioral responses to pruritogens. Next, we 325 wondered if the chemogenetic inactivation of the LPBN itch-TRAP neurons would alter the chloroquine-326 induced scratching in mice. To that end, we expressed the hM4Di-MCherry in the LPBN of TRAP2 mice 327 through a Cre-dependent viral strategy and 4-OHT administration after a chloroquine-mediated itch assay 328 (Figure 7A). We found that the chemogenetic inhibition of itch-TRAP neurons in the LPBN attenuated the 329 chloroquine-induced scratching (Figure 7C). Importantly, the effect of chemogenetic inhibition on the 330 scratching behavior was established within the first five minutes of the start of the assay, which was in 331 turn started 10 minutes after i.p. DCZ administration (Figure 7D, Figure S6). Together, the LPBN itch-332 sensitive neurons are sufficient and necessary for the expression of scratching behavior induced by intra-333 dermal chloroquine in mice. 334 335 Simultaneous calcium imaging of the itch-TRAP neurons in the LPBN and Scratcher-mediated itch 336 analysis 337 Finally, we demonstrate Scratcher’s compatibility with real-time systems neuroscience techniques 338 by integrating it with the in vivo fiber photometry technique. In the fiber photometry technique, neural 339 activity is measured indirectly from cell types of choice of behaving animals by expressing genetically 340 encoded calcium sensors such as the GCaMP6s and digitizing the reflected light collected through a fiber 341 optic cannula focused onto a CMOS camera with appropriate filters (Kielbinski and Bernacka, 2024; 342 Simpson et al., 2024). In combination with Scratcher, fiber photometry recordings from a neural circuit of 343 interest can inform us about the potential role of the circuit in the itch processing and scratching behavior. 344 Here, we expressed the GCaMP6s in the itch-TRAP LPBN neurons following similar methods as above 345 (Figure 6) and recorded the activity of the itch-TRAP neurons while the mice were injected with 346 chloroquine in the nape of the neck. With the help of Scratcher, we extracted the timing of scratch bout 347 onsets from the video data and aligned these to the calcium signal using a simple Δ F/F input file (Figure 348 8). This enabled automated generation of raster plots, bout-aligned heat maps, and peri-scratch Δ F/F 349 traces (Figure 9B–E). Critically, comparison of these traces with manually aligned photometry data 350 revealed close correspondence in both timing and shape of the average traces, affirming the temporal 351 precision of Scratcher’s bout detection. Interestingly and in contradiction to previous studies on LPBN’s 352 role in itch-induced scratching behaviors (Chen and Sun, 2020; Li et al., 2021; Mu et al., 2017; Pavlenko 353 et al., 2025; Piyush Shah and Barik, 2022), we found that the LPBN itch-TRAP neural activity preceded 354 the start of the scratching bouts. This seamless integration highlights Scratcher’s potential as a fully 355 automated, high-throughput behavioural quantification interface for linking behaviour to neural dynamics 356 without any need for manual adjustment or tuning. 357 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 10

Discussion

358 The study of itch has long been constrained by the lack of standardized, automated, scalable, 359 and objective tools for quantifying scratching behavior in rodent models. To that end, we present 360 Scratcher, a computationally efficient, accurate, and easy-to-deploy behavioral quantification tool for 361 pruritic behavior. Importantly, we aimed to create a solution that could seamlessly integrate with 362 experimental paradigms involving pharmacological, genetic, and circuit-level manipulations, while 363 minimizing user-side programming or hardware requirements. Our approach, which is based on the 364 YOLOv8 object detection framework and supported by an intuitive graphical user interface - provides a 365 unified pipeline for the detection, aggregation, and analysis of scratching behavior from raw video data. 366 We used Scratcher to demonstrate the ability to quantitate scratching behavior induced by a non-367 histaminergic pruritogen such as chloroquine. Importantly, we employed Scratcher to determine the 368 effects of chemogenetic manipulation of the itch-responsive neurons in the LPBN, a critical node in the 369 ascending neural pathways responsible for transmitting pruritic information from the dorsal spinal cord to 370 the mid- and fore-brain structures (Mu et al., 2017; Prajapati et al., 2025, 2024). Further, we combined 371 Scratcher with in-vivo calcium imaging to provide automated registration of itch-induced scratching 372 behavior with neural activity. Together, we provided comprehensive evidence for the utility of Scratcher 373 as a standardized analytical pipeline that helps uncover neural circuit mechanisms underlying scratching 374 caused by pruritus. 375 Quantifying scratching through manual annotation, although informative, is subjective and time-376 intensive, making it poorly suited for high-throughput or long-duration studies(Le Bras, 2023; Sakamoto et 377 al., 2022; Wimalasena et al., 2021) . There have been several efforts to automate scratch behavioral 378 analysis. Hardware-based approaches, which ranged from force sensors to proximity-based electrical 379 systems, all have historically provided partial solutions but suffer from critical drawbacks, including 380 mechanical interference, limited specificity, and incompatibility with systems neuroscience 381 techniques(Chun et al., 2021; Deuis et al., 2017) . Pose-estimation pipelines like Scratch-AID represent 382 important progress, yet the need for extensive pre-processing, susceptibility to motion artifacts, and 383 challenges in scaling across experimental conditions limit their usability for broad applications(Chen et al., 384 2022; Kobayashi et al., 2021; Sakamoto et al., 2022). In that note, Scratcher provides a generalizable, 385 intuitive, and accurate application with GUI for itch studies. 386 Our results validate the design decisions that underpin Scratcher. First, the use of YOLOv8 387 allowed us to bypass many of the issues inherent to classification-based or background-subtraction-388 based methods (Figure 1-E). The one-shot detection architecture offered superior speed without 389 compromising on accuracy, enabling real-time analysis that is well-suited for eventual closed-loop 390 integration (Figure 1-E). Importantly, bounding box-based object detection provided both spatial and 391 categorical behavioral information - allowing users not only to identify when scratching occurs, but where 392 in the frame it happens (Figure1-F). This localization ability has immediate utility in multi-animal 393 experiments and opens the door for future real-time manipulations guided by behavioral state. 394 To mitigate the challenges of translating high-frequency frame-level predictions into meaningful 395 behavioral metrics, we systematically compared multiple second-wise binning heuristics (Figure 3, Figure 396 S2-5). Among these, a non-overlapping majority vote strategy with rule-based corrections emerged as 397 both robust and computationally efficient, achieving >93% precision, recall, and F1 scores (Figure 2A-D). 398 The comparative evaluation of alternative heuristics - including Bayesian, Hidden Markov Model (HMM), 399 confidence-based, and sliding window approaches - revealed the limitations of probabilistic methods in 400 modeling the noisy and ethologically complex nature of scratching, while highlighting the importance of 401 context-aware but interpretable aggregation strategies (Figure S2-5). Each heuristic reflects a different 402 trade-off between temporal smoothness, class balance, interpretability, and computational cost. 403 Importantly, our results highlight that no single approach is universally superior across all metrics. For 404 instance, while Bayesian inference and HMMs offer principled probabilistic frameworks, they perform 405 poorly in practice due to the noise and spontaneity of real-world scratching behaviour. The exhaustive 406 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 11 comparison offered here provides a blueprint for users to select binning strategies suited to their specific 407 experimental contexts. By validating our tool’s robustness across a spectrum of binning algorithms, we 408 enable users to flexibly adapt the tool to a range of behavioural paradigms, including those that involve 409 pharmacological, genetic, or environmental manipulations - or where such manipulations are absent and 410 spontaneous behaviour is of primary interest. 411 Critically, Scratcher demonstrated strong generalizability across a range of experimental 412 conditions. Whether applied to acute itch induced by chloroquine, or altered mechanical conditions 413 introduced by nail clipping, the tool consistently captured behaviorally relevant changes. Its ability to 414 sensitively and reliably quantify both enhancements and suppressions in scratching behavior was further 415 demonstrated in chemogenetic experiments targeting Itch TRAPed neurons in the lateral parabrachial 416 nucleus (LPBN). Not only could Scratcher detect modulation of opposing behavioural phenotypes 417 following hM3Dq and hM4Di DREADD activation, it could also generate rich metrics such as slope 418 analyses, peak scratching durations, area under the curve (AUC) and even latency to scratch (Figure S6) 419 from the start of a session from simple video inputs, all via a user-friendly GUI. Moreover, we 420 demonstrated the temporal precision of Scratcher in a systems neuroscience context by aligning bout 421 onsets with in vivo calcium signals recorded from the LPBN. The high degree of temporal fidelity between 422 automatically and manually annotated peri-scratch Δ F/F traces suggests that Scratcher can be a reliable 423 companion to photometry workflows, and potentially extendable to closed-loop neural modulation 424 frameworks. 425 Despite these strengths, several limitations remain. Currently, Scratcher is optimized for nape-426 directed scratching in singly housed mice under standard illumination and fixed camera positioning. While 427 the tool can be retrained for other body sites or behaviors, this process still requires labeled datasets and 428 may not generalize to more complex social settings without further adaptation. Accordingly, the bounding-429 box architecture was adopted as it is also inherently suited to multi-animal analysis. However, the current 430 implementation does not perform individual tracking, which is essential for experiments involving more 431 than one subject per frame. Integrating identity tracking into future versions could extend Scratcher's 432 capabilities to social paradigms, drug screening in group-housed mice, or genetically heterogeneous 433 populations. 434 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 12

Materials and methods

435 436 Mouse line and treatments 437 Animal care and experimental procedures were performed following protocols approved by the 438 CPCSEA at the Indian Institute of Science. TRAP2 (Fos2A-CreERT2) mice, stock number 030323, were 439 purchased from Jackson Laboratory. For the rest of the studies, wild-type CD1 mice were used. The 440 animals were housed at the Central Animal Facility under standard transgenic animal housing conditions 441 in a 12-hour light-dark cycle with ad libitum access to food and water. Genotyping was performed 442 according to the protocols (for iCre) of Jackson Laboratories. All mice used in the behavioural assays 443 were between 8 and 12 weeks old. All the behaviours were done during the light cycle. 444 445 Viral Vectors 446 Vector used and sources: pAAV5-hsyn-DIO-hM3D(Gq)-mCherry (Addgene, Catalog No. 44361, 447 Titer: 1.8 x 1013 GC/ml), pAAV-h8yn-DIO-hM4D(Gi)-mCherry (Addgene, Catalog No. 44362, 2.5x1013 448 GC/mL), AAV9. syn.flex.GcaMP8s (Addgene, Catalog No. 162377, Titer: 2.7 x 1013 GC/ml), 449 450 Stereotaxic injections 451 Mice we re anes thetized with 2 % isoflur a ne/oxyg en be fo re a nd du ring the su rgery . An incision 452 was made to expos e the skull, and subse quently, the skull was aligned to the horiz ontal plane . 453 Cranioto my was p er for med at the ma rked point using a han d-held mic ro-d rill (RWD ). A Ha milton sy ringe 454 (10 ul ) with a glass pulled needle was u s ed to infu se 3 00 nL o f viral pa rticles (1 :1 in saline) at a ra te o f 455 100 nL /min . Th e following coo rdinates we re u sed to intro duce the viru s: LPBN - AP : −5.3 4, M L: ±1 .00 , 456 DV: −3.15 .Pos t-h oc his tological ex amina t ion of each injected mouse was used to c onfir m tha t vi ral-457 mediated ex pres sion was re st ricted to th e ta rge t nu clei. 458 459 Itch TRAPing 460 4-Hydroxytamoxifen (4-OHT; Hello Bio, UK, Catalog No. H6040) was prepared by dissolving it in 461 ethanol at a concentration of 20 mg/ml. The solution was subsequently aliquoted and stored at -40°C. 4-462 OHT was redissolved just before use and mixed with corn oil in a 1:1 ratio. 4-OHT (50 mg/kg body weight) 463 was intraperitoneally administered to the mice, and 15 minutes later, the mice were subjected to 464 chloroquine mediated acute itch in the nape. All the behavioural and anatomical studies were done one 465 week after the Itch TRAPing. 466 467 Videotaping Box 468 A rectangular acrylic box with dimensions identical to the homecage that the mice are housed in 469 was designed to ensure naturalistic cage behaviour. The acrylic box was designed such that the interior 470 of the box has a matte finish in order to ensure diffused luminance with no abnormally bright spots. This 471 also ensures that no reflections arise that could interfere with the model’s detection or training. The 472 dimensions of the box are as follows: 17cm (height) x 20cm (length) x 20 cm (breadth)(Indus Biosolutions, 473 Bengaluru). The videotaping camera used was a Logitech C920e Business Webcam. The video recording 474 software used was Logitech Capture 2.06.12 Software, using the following parameters during recording: 475 Brightness 50, Contrast 50, Resolution 1920x1080, Frame rate 30 fps. An additional LED attachment with 476 a moving arm was also installed for ambient lighting. The lighting was always maintained at 477 approximately. 300 lumens are placed at a distance of 14 cm above the highest point of the videotaping 478 box. 479 480 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 13 Chloroquine-induced itch assay 481 The nape of the neck of mice was shaved 2–3 days before behavioural experimentation, and the 482 mice were habituated in the behaviour room. On the day of experimentation, mice were individually 483 placed in our custom videotaping box and habituated to it for 15 minutes. Chloroquine (375 µg/75 µl) was 484 administered intradermally into the nape of the neck of the mice, and the subsequent scratching 485 behaviour was recorded for 45 min (acute itch) or 3 hours, for acute and chronic recordings, respectively. 486 The PC with the following specifications: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz, 64.0 GB RAM, 487 4GB NVIDIA GeForce GT 730, Windows 10 Education. For chemogenetic activation and inactivation 488 experiments, DCZ (2 µg/kg of body weight) was administered intraperitoneally (i.p.) 15 min before 489 chloroquine injection(Nagai et al., 2020). Hind leg-directed scratching of the nape was characterized as a 490 scratch. 491 492 Fiber optic cannula implantation 493 Fiber op tic c annula fro m RWD ( Ø1 .25 m m Ce ra mic Fe rrule , 30 0 μ m Core , 0.39N A, L = 6 m m , 494 Catalog No . R -FOC -BL300C -39NA) were implan ted a t AP: −5 .34 , ML : ±1.0 0, DV: −3.15 in the LPBN o f 495 the AAV -DI O- GCa MP8s itch TRAPed mi ce. A nimals we re allowed t o recove r fo r a t leas t 1 week be fore 496 perfo r ming beha vioural tes ts . Su ccess ful labeling and fiber i mplant ation were con firmed pos t hoc by 497 staining for GFP for viral exp ression and injury c aused by the fibe r, r espec tively. O nly animals with viral-498 mediated gene exp res sion and fibe r i mpl antation s a t the intende d loca tions, as ob served in po st hoc 499 test s, were included in the a nalysis. 500 501 Fiber photometry 502 A single-channel fiber photometry system from RWD (R810) was used to collect the data. The 503 light from two light LEDs (410 and 470 nm) was passed through a fiber optic cable coupled to the cannula 504 implanted in the mouse. Fluorescence emission was acquired through the same fiber optic cable onto a 505 CMOS camera through a dichroic filter. The photometry data was analyzed using the RWD photometry 506 software, and .csv files were generated. All trace graphs were plotted from .csv files using GraphPad 507 Prism software version 8. 508 509 Immunostaining and fluorescence microscopy 510 Mice were anesthetized with isoflurane and perfused transcardially with 1X Phosphate Buffered 511 Saline (PBS) (Takara catalog No. T9181) and 4 % Paraformaldehyde (PFA) (Ted Pella, Inc. Catalog No. 512 18505). Harvested brains were further fixed in 4 % PFA overnight and subsequently transferred to 15 % 513 and 30 % sucrose for serial dehydration. Brain tissues were placed in the Cryo-Embedding Compound 514 (Ted Pella, Inc.) and frozen at -40°C. Subsequently, 50 µm-thick coronal brain sections were cut using a 515 cryostat (RWD Minux FS800). For immunostaining experiments, tissue sections were rinsed in 1X PBS (3 516 times) and incubated in the blocking buffer (5 % Bovine Serum Albumin (BSA) + 0.5 % Triton X-100 + 1X 517 PBS) (BSA- HIMEDIA Catalog No. TC194, Triton X-100 SRL Catalog No. 64518) for one hour at room 518 temperature. Sections were then incubated in the primary antibody (dilution 1:1000 X in blocking buffer) 519 at room temperature overnight. Sections were rinsed 3 times with 1X PBS + 0.5 % Triton X-100 solution 520 and incubated for two hour in Alexa Fluor conjugated goat anti-rabbit/ chicken or donkey anti-goat/rabbit 521 secondary antibodies (dilution 1:1000 X in blocking buffer) along with DAPI (SRL Catalog No.18668) at 522 room temperature. Then sections were washed with 1X PBS + 0.5 % Triton X-100, and mounted onto 523 charged glass slides (Ted Pella, Inc. Catalog No. 260382-3). Citifluor AF-1 mounting media (Ted Pella, 524 Inc. Catalog No. 19470-1) was used to cover-slip (Blue star Microscope cover glass 24 x 60 mm 10 Gms) 525 the slides. Subsequently, sections were imaged on the upright fluorescence microscope (Khush 526 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 14 Enterprises, Bengaluru) (2X, 4X, and 10X lenses). ImageJ/FIJI processing software was used to process 527 the images 528 529 Dataset Creation and Augmentation 530 A curated behavioural video dataset was assembled to train and evaluate Scratcher, consisting of 531 top-down recordings of mice engaged in acute, or spontaneous itch-related behaviours. Videos were 532 captured using a custom-built videotaping chamber equipped with uniform backlighting to produce high-533 contrast silhouettes and recorded at 30 frames per second. A total of 17 behaviour videos were selected 534 from independent experiments involving different itch models (chloroquine-induced acute itch and 535 spontaneous behaviour). Scratches other than those directed towards the nape, such as those towards 536 the cheeks, thorax, ears, etc., were labelled as “Others”. Subsequently, frames were extracted from these 537 videos, and frames were annotated manually as "Locomotion", “Others”, or "Itch" by two trained human 538 annotators using Roboflow, an internet-browser-based labeling interface. Scratching was defined by 539 rhythmic hindlimb movement when approaching or otherwise in contact with the nape, based on both 540 speed and posture cues. Annotators labelling the videos were blind to the itch model in order to minimize 541 and avoid any form of bias. To increase classifier robustness, we implemented the following 542 augmentations to output 3 augmented images per training example - Flip (Horizontal, Vertical), 90° 543 Rotate (Clockwise, Counter-Clockwise, Upside Down), Grayscale, Horizontal and Vertical flipping, 544 Brightness (Between -15% and +15%) and Exposure (Between -10% and +10%). The full labeled dataset 545 was then stratified and split into a training set (70%), a validation set (20%) and a test set (10%), while 546 also ensuring that the class distribution of “Itch” versus Non-Itch (“Locomotion” and “Others”) was 547 preserved in both subsets. The weights used in the initial phases of training were acquired from 548 YOLOv8’s proprietary pre-trained models. Subsequent rounds of training were performed after giving due 549 consideration to how Box_loss, Class_Loss and DFL_Loss evolved across epochs, depending on which, 550 various parameters, including the training dataset, were shuffled and altered. Once the dataset was pre-551 processed and augmented, we exported the dataset in the JSON COCO segmentation format(Lin et al., 552 2014) with the training, validation, and test splits mentioned above. Additionally, given that the YOLOv8 553 architecture employs a “one-shot” detection algorithm, the dataset had to be curated such that it covers a 554 diverse range of instances for each of the classes with as little redundancy as possible in order to avoid 555 overfitting and overlearning. Therefore, to ensure that such instances are minimized, an early learning 556 cutoff was set to prevent models from reaching asymptote training values. 557 558 Heuristic for temporal Aggregation and Majority Classification implemented in Scratcher 559 To convert high-resolution frame-wise behavioural annotations into temporally aggregated 560 second-wise summaries, a custom Python function (filter_behaviours) was implemented. This function 561 processes frame-by-frame behavioural classifications obtained from the YOLOv8 detections model 562 (recorded at 30 frames per second) and assigns a single behaviour label per second using a majority vote 563 scheme, followed by heuristic corrections for composite behaviours. The input to the function is an .xlsx 564 file containing frame-level behavioural annotations, with behaviours listed in the second column. A rolling 565 bin of 30 consecutive rows (corresponding to one second of video at 30 fps) was used to segment the full 566 dataset temporally. Within each one-second bin, a majority voting strategy determined the dominant 567 behaviour. In cases where the most frequent behaviour was "Others" but the second most frequent was 568 "Itch", the behaviour was reassigned to "Itch" to account for the underrepresentation of transient itch 569 events. Composite or co-occurring labels (e.g., "Itch, “Locomotion," or "Locomotion ,Others") were 570 clarified via empirically derived rule-based logic that favored biologically relevant prioritization (e.g., "Itch" 571 was given precedence over "Others"). The aggregated behaviour labels were stored in a new DataFrame 572 with columns "Seconds" (representing elapsed time in seconds from video start) and "Behaviour" 573 (dominant behaviour during that second). This output was saved to a new Excel file with multiple sheets 574 using pandas and openpyxl. A second sheet ("Behaviour Durations") was generated to quantify the 575 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 15 cumulative duration (in seconds) of each behaviour across the entire session. Behaviours not present in 576 the session were explicitly added with a zero duration to ensure consistent output formatting across 577 multiple files. The output included "Locomotion", "Others", "Itch", and "no_detection" as predefined 578 behaviour categories. To quantify itch-related activity over time, a binary vector (itch_counts) was created 579 where each second was marked as 1 if "Itch" was the assigned label, and 0 otherwise. Rolling sum 580 windows were applied to this binary vector to compute average itch occurrence per minute and per 3-581 minute intervals. These statistics were stored in a third sheet ("Itch Statistics"), which reported the 582 average number of detected itch events per minute and per 3-minute bin across the full duration of the 583 video. 584 585 Gaussian Hidden-Markov Model Heuristic 586 This method leverages several Python libraries for data preprocessing, modeling, and evaluation. 587 Pandas was used for structured data handling and merging the frame-wise predictions with second-wise 588 ground truth. NumPy enabled efficient numerical operations and reshaping of label arrays. Scikit-learn 589 (sklearn.preprocessing.LabelEncoder) was used to encode categorical behaviour labels into numerical 590 form compatible with modeling tools. hmmlearn was employed to construct and train the Gaussian 591 Hidden Markov Model, and scikit-learn.metrics provided functions such as accuracy_score and 592 classification_report for model evaluation. We trained the Gaussian Hidden Markov Model (HMM) to infer 593 the underlying behavioural state sequence for each 30-frame window. Each 30-frame behaviour 594 sequence was encoded as integers using a fitted LabelEncoder. These were flattened and reshaped into 595 a single column vector suitable for hmmlearn's GaussianHMM, which models each observed behaviour 596 as a Gaussian-distributed emission from a hidden state. The model was trained with the number of 597 components set to the number of unique behaviours, using the lengths parameter to maintain the 598 segmentation between 30-frame windows. For inference, we predicted the most frequent hidden state 599 among the last five frames of the decoded sequence, providing a temporally smoothed and noise-robust 600 prediction for the second-wise behaviour label. Per-frame behavioural predictions were first grouped into 601 non-overlapping 1-second bins (30 frames per bin) based on frame indices. Ground-truth labels for each 602 second were derived from manually annotated data. Bins were aligned such that only those with a 603 corresponding ground truth label were used for training and evaluation. The full dataset contained 15,804 604 1-second bins, from which a subset was used in this experiment. After discarding frames from initial 605 sections of the video to align with ground truth, 1-second bins were extracted from frame 81,000 onwards 606 for predicted labels, and from second 2700 onwards for ground-truth annotations. Behaviours were string-607 labeled and mapped to integer-encoded states using a LabelEncoder. All unique behaviours from both 608 the frame-wise predictions and ground-truth were used to fit the encoder. An unsupervised Gaussian 609 HMM was trained using the hmmlearn library, with the following specifications: Number of hidden states - 610 equal to the number of unique behaviours present, Covariance type - diagonal for assuming uncorrelated 611 features, Observations - each 30-frame sequence was flattened and treated as a 1D time series of 612 discrete behaviour encodings, Training input: all sequences were concatenated, and the lengths 613 parameter was used to denote segment boundaries corresponding to each bin. The model was trained for 614 100 iterations with a fixed random seed for reproducibility (random_state=42). For each 30-frame input 615 sequence, the trained HMM was used to infer the most probable state sequence using the Viterbi 616 algorithm. To obtain a robust summary behaviour for the entire second, we employed a frequency-based 617 heuristic: the most frequent state among the last 5 frames was selected as the representative behaviour 618 for that 1-second bin. This tail-weighted heuristic biases the prediction toward the end of the second, 619 reflecting our observation that scratch bouts often begin or end mid-window. Predicted state indices were 620 then converted back into human-readable behaviour labels using the inverse transform of the fitted 621 LabelEncoder. Accuracy was computed by comparing predicted 1-second behaviours against the ground-622 truth labels. We also computed a full classification report including precision, recall, and F1-score for each 623 behaviour class. To ensure valid reporting, label-wise metrics were restricted to only those behaviours 624 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 16 that were present in both the predictions and ground truth. A standalone utility function 625 predict_behaviour() was implemented to allow prediction on novel 30-frame sequences. This function 626 takes in raw per-frame behaviour labels, encodes them, and returns the predicted behaviour for the 627 window based on the last inferred hidden state. 628 629 Bayesian Model Heuristic 630 This method also employed a suite of Python libraries for data processing and statistical 631 modeling. Pandas handled CSV loading and grouping of frame-wise behaviours into 30-frame windows. 632 NumPy facilitated the manipulation of label arrays and ensured compatibility with evaluation metrics. 633 scikit-learn (sklearn.preprocessing.LabelEncoder) was used to encode categorical labels into a numeric 634 form. The Counter and defaultdict classes from Python’s built-in collections module were used to compute 635 prior distributions and frame-wise behaviour counts. Model performance was assessed using 636 accuracy_score and classification_report from scikit-learn.metrics. The Bayesian heuristic treated the 637 prediction of a second-order behaviour as a classification task based on frame-wise counts in a 30-frame 638 window. Prior probabilities for each behaviour were computed from the full dataset as the proportion of 639 frames labeled with that behaviour. For each 30-frame window, we computed a pseudo-posterior 640 probability for each candidate behaviour by multiplying the prior with a simple likelihood: if the behaviour 641 was observed in the window, a proportional score based on its frequency (count / 30) was applied; if not, 642 a small penalty factor (0.01) was used to reduce its likelihood. The behaviour with the highest resulting 643 score was selected as the predicted label for that second. The resulting models were evaluated by 644 comparing their second-wise predictions to the ground truth annotations. Accuracy and detailed class-645 wise metrics were computed using accuracy_score and classification_report from scikit-learn. To ensure 646 fair comparison, only behaviour labels present in both predictions and ground truth were included in the 647 evaluation. 648 649 Aggregation heuristic using a sliding window, non-overlapping average probability 650 We implemented a heuristic method to assign second-wise behaviour labels based on confidence 651 scores extracted from a YOLOv8-based behaviour detection pipeline. The process utilized a non-652 overlapping sliding window approach with a window size of 30 frames (corresponding to one second of 653 video at 30 fps), ensuring that each behavioural prediction was derived from a distinct, non-overlapping 654 chunk of time. The procedure was executed using various Python libraries. Pandas was used for CSV 655 data manipulation, time binning, and group-level aggregation.NumPy (numpy)was used for array 656 operations and imported wherever matrix-level operations were necessary. Matplotlib.pyplot and Seaborn 657 were used for generating evaluation figures such as confusion matrices, metric bar plots, and scatter 658 plots. Scikit-learn was utilized to compute evaluation metrics, including accuracy, precision, recall, and F1 659 score. The raw input generated from a YOLOv8 object detection model consisted of a CSV file with 660 frame-wise behaviour predictions. Each row of the file included three fields: Frame (frame number), 661 Behaviour (categorical label), and Confidence (YOLO-assigned score for detection reliability). 662 For each second, all rows corresponding to the 30 frames in that second were grouped using group 663 by('Seconds'). Each second of video (corresponding to 30 frames at 30 frames per second) was treated 664 as a discrete bin. Within each one-second window, we grouped the frames and calculated the average 665 confidence score for each behaviour. The behaviour with the highest average confidence was selected as 666 the representative label for that second. The behaviour with the highest average confidence was selected 667 to represent that second. This rule maximized reliability by accounting for both frequency and confidence 668 of detection within the window, thus increasing robustness to momentary misclassifications. The final 669

Result

was a dataframe containing second-wise predictions, saved as a CSV file. The process was 670 repeated for the entire video, producing a sequence of second-wise behaviour predictions. These were 671 compared against ground truth annotations to evaluate performance. 672 673 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 17 Aggregation heuristic using an overlapping sliding window 674 Frame-wise behavioural predictions were generated using YOLOv8, with each frame annotated 675 with a behaviour label and corresponding confidence score. To convert these frame-level annotations into 676 temporally smoothed predictions, we implemented a majority-vote-based sliding window approach using 677 Python. This method aimed to reduce noise and transient misclassifications by leveraging the temporal 678 continuity of behaviour. All analyses were performed in Python, utilizing the pandas library for data 679 manipulation and the scipy.stats module to compute statistical modes. The raw output, comprising 680 individual frame numbers and their corresponding predicted behaviour classes, was first preprocessed to 681 ensure proper data types and sorted in order by frame index. Only frames with valid numerical indices 682 were retained. A fixed length sliding window of 30 frames (equivalent to one second of video at 30 frames 683 per second) was moved across the entire dataset with a stride of 1 frame. For each window, the mode 684 (i.e., most frequently occurring behaviour) was computed. If a unique mode was found, it was assigned as 685 the behaviour prediction for the window; in the rare event of a tie, the first occurring mode was selected. 686 This behaviour label was then assigned to the frame at the center of the window, and the corresponding 687 second was calculated based on its frame index. The process was repeated across the full length of the 688 video data, generating a list of second-wise predictions smoothed by overlapping windowed voting. The 689 resulting DataFrame, consisting of center-frame indices, their associated second, and predicted 690 behaviours, was saved as a CSV file for downstream evaluation and comparison with ground truth 691 annotations. These were compared against ground truth annotations to evaluate performance. 692 693 Graphical User Interface (GUI) 694 A custom graphical user interface (GUI) was developed using Python's tkinter library to 695 streamline three sequential processes for rodent behaviour analysis from video data: (1) object detection 696 using a YOLO-based model, (2) behaviour filtering from annotated frames, and (3) downstream behaviour 697 analysis. The interface allows users to perform end-to-end processing, prediction, and training of YOLO 698 models with minimal programming knowledge.YOLO Model Integration. Object detection was performed 699 using the Ultralytics YOLO implementation. The GUI loads our custom-trained YOLO model using 700 ultralytics.YOLO(model_path). Video files (in .mp4 format) from a user-specified input directory are 701 sequentially processed with this model. The function process_video - defined externally - handles frame-702 by-frame inference and result saving. Users can specify a confidence threshold (default 0.6), which 703 determines the minimum detection probability for a prediction to be accepted. The results, typically 704 exported as Excel spreadsheets containing frame-wise predictions, are saved to an output directory as 705 specified by the user. Post-detection, output files from the inference step are processed by the function 706 filter_behaviours, which applies user-defined rules to consolidate frame-wise labels into temporally 707 contiguous behavioural bouts. The filtered outputs are saved as new Excel files prefixed with 708 raster_plot_input_. The processed and filtered files are then passed to analyse_behaviours, a third 709 function that performs downstream quantitative analyses such as bout duration calculations, transition 710 probabilities, visualization of behavioural timelines, and a suite of other quantitative plots. This function is 711 modular and can be tailored to the experimental context. Prediction Mode. For ad hoc predictions, a 712 separate GUI tab enables inference on individual video files using a YOLO model. Users can optionally 713 change the working directory before prediction. Output visualization is handled natively by YOLO.predict() 714 method, with results saved if the “Save Output” checkbox is enabled. Training Mode. The interface also 715 provides a tab for training custom YOLO models. The user specifies: A working directory where model 716 weights and logs will be saved, A base model checkpoint (.pt format) to initialize training, A data.yaml file 717 conforming to the Ultralytics YOLOv8 data format, which specifies training/validation paths and class 718 names, and the number of training epochs. The training function uses 719 YOLO(model_path).train(data=data_path, epochs=n) to initiate training. Time taken for training is logged 720 to a text file (Time_taken.txt) in the working directory. All GUI components are built using tkinter and ttk, 721 with structured layout management and modal dialogs for file selection, error handling, and user 722 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 18 feedback. Error-checking routines are included to ensure path validity and input type correctness (e.g., 723 float parsing for confidence, integer parsing for epochs). Hardware Requirements. CPU: Minimum 4-core 724 processor (Intel i5/Ryzen 5 or higher recommended). RAM: Minimum 8 GB (16 GB recommended for 725 large video processing or model training). GPU: NVIDIA GPU with CUDA support (Compute Capability ≥ 726 6.1) is highly recommended for YOLO inference and training. Models run significantly faster on a GPU 727 compared to a CPU. Software Requirements. Operating System: Windows 10/11, macOS (with limitations 728 on YOLO training), or any modern Linux distribution. Python Version: Python 3.8 or later. Python Package 729 Dependencies: ultralytics (for YOLOv8): Install via pip install ultralytics, tkinter: Included by default with 730 most Python distributions.pandas: For spreadsheet manipulation. Install via pip install pandas, openpyxl: 731 Required for .xlsx I/O. Install via pip install openpyxl, opencv-python: Required for video processing if not 732 handled inside process_video. Install via pip install opencv-python. Additional Files/Modules: 733 video_processing.py: Must define the process_video function, accepting model, video path, output folder, 734 video name, and confidence threshold.behaviour_filtering.py: Must define the filter_behaviours function. 735 behaviour_analysis.py: Must define the analyse_behaviours function. 736 737 Slope Plot 738 The dataset was stored in a Microsoft Excel spreadsheet, with the first column representing time 739 (in minutes) and each subsequent column corresponding to scratch duration values for individual mice 740 across multiple time points. All analyses and visualizations were conducted using Python, employing the 741 following libraries: pandas (for data ingestion and handling), numpy (for numerical computations), 742 matplotlib.pyplot (for plotting), and scipy.stats.linregress (for performing linear regression). The data were 743 first imported using pandas.read_excel, assuming that the first row contained column headers. Time 744 values from the first column were extracted as the independent variable, while each of the remaining 745 columns was interpreted as the scratch behaviour profile of a single mouse. For each mouse, linear 746 regression was performed using scipy.stats.linregress, modeling scratch duration as a linear function of 747 time. The slope and intercept obtained from this regression were then used to compute predicted values 748 across the observed time range. Only the regression lines were plotted, omitting raw scatter points to 749 improve visual clarity and emphasize overall behavioural trends. The x-axis represented elapsed time in 750 minutes and was fixed between 0 and 45 minutes, while the y-axis showed predicted scratch durations. 751 Y-axis limits were dynamically scaled to exceed the maximum regression value by 10%, allowing for 752 adequate separation of plotted lines. 753 754 Peak Scratching Duration 755 To generate the scatter plot of peak scratching durations for individual mice, we used Python 756 (version 3.10.12) along with the pandas (version 1.5.3), matplotlib (version 3.7.1), and openpyxl (for 757 reading .xlsx files) libraries. The input was a Microsoft Excel spreadsheet with time-series data where the 758 first column denoted time in minutes, and each subsequent column represented scratch duration data for 759 an individual mouse. The dataset was loaded using pandas.read_excel() with the assumption that the first 760 row of the file contained headers. The first column was parsed as the independent variable (time), while 761 the rest of the columns were treated as dependent variables representing scratch durations for each 762 mouse over time. For each mouse, the index corresponding to the maximum value in its respective 763 column was computed using the idxmax() method, and both the peak scratching duration and the 764 corresponding time point were extracted. These were stored as x- and y-coordinates for plotting, with 765 mouse identifiers retained from the column headers for labeling. A scatter plot was constructed using 766 matplotlib.pyplot, with each mouse’s peak duration represented as a single point, positioned according to 767 the time since injection (x-axis) and peak scratch duration in seconds (y-axis). Distinct colors were 768 assigned to each data point using the viridis colour map from matplotlib.cm, with the number of color bins 769 matching the number of mice. The point size was fixed at 100 for visual clarity. The y-axis was scaled 770 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 19 dynamically to accommodate 10% more than the maximum observed peak duration, while the x-axis was 771 fixed from 0 to 45 minutes to reflect the duration of the behavioural assay. 772 773 LOESS-Smoothened Time-Course Line Plots with SEM Shading 774 To examine the temporal dynamics of scratching behaviour across control and experimental 775 groups when assaying for scratching behaviour, time-series data were processed and visualized using 776 Python (version 3.10.12) with pandas (version 1.5.3), numpy (version 1.22.4), matplotlib (version 3.7.1), 777 and scipy (version 1.10.1). Data were loaded from two Microsoft Excel files corresponding to baseline 778 (control) and DCZ-treated (experimental) conditions. Each file contained columns for time (minutes), 779 mean scratching duration, standard error of the mean (SEM), and the number of observations per time 780 point. After loading the data using pandas.read_excel(), vectors corresponding to time, mean, and SEM 781 were extracted for each group. To reduce noise and enhance the interpretability of behavioural trends, a 782 cubic spline-based smoothing function was applied. Specifically, scipy.interpolate.make_interp_spline() 783 was used to fit a third-degree spline to the data, and numpy.linspace() was used to interpolate 300 evenly 784 spaced time points within the original range, yielding high-resolution smoothed curves. Smoothed mean 785 scratching trajectories were plotted using matplotlib.pyplot.plot() with the control and experimental curves 786 displayed in different colours. Shaded regions representing SEM around the original unsmoothed means 787 were rendered using plt.fill_between() to visualize variability over time. Axes were labeled to indicate 788 minutes post-injection and scratching duration in seconds. The figure was configured with a size of 8×5 789 inches, and a legend was included to distinguish between conditions. Plot styling followed the default 790 matplotlib configuration, and grid lines were disabled for maximum visual clarity. 791 792 Linear Regression and Correlation Analysis 793 To evaluate the agreement between human-annotated and model-annotated scratching 794 durations, Pearson's correlation coefficient was computed and visualized using a scatter plot. Data were 795 imported from an Excel spreadsheet where the first and second columns represented the human and 796 model annotations on the x and y axes, respectively. The Pearson correlation coefficient (/i4 ) was 797 calculated to quantify linear agreement between the two sets of annotations. A scatter plot was generated 798 in which each point represented a paired human-model measurement, and an identity line (slope = 1, 799 intercept = 0) was overlaid to visualize perfect agreement. The Pearson /i4 value was displayed within the 800 plot area, and a minimalistic style was maintained with semi-transparent data points, gridlines, and 801 appropriate axis labeling to facilitate interpretability. 802 803 Heat-Map plot 804 To visualize the time-resolved changes in calcium activity, or scratching duration, across 805 subjects, Δ F/F or scratching duration values were plotted as heatmaps using the Seaborn data 806 visualization library in Python. Fluorescence data was imported from an Excel file, where the first column 807 represented time points (in seconds/minutes) and each subsequent column contained the Δ F/F trace or 808 the scratching duration for one subject (e.g., mouse). The data matrix was transposed such that rows 809 represented individual subjects and columns corresponded to time points. This format enabled visual 810 comparison of fluorescence/scratching dynamics across subjects over time. Heatmaps were generated 811 using the seaborn.heatmap() function with a variety of diverging color palettes ('coolwarm', 'seismic', 812 'RdBu_r', 'BrBG', 'PiYG', and 'Reds') to emphasize both increases and decreases in fluorescence or 813 scratching durations. Depending on the user’s needs, colour maps that are sensitive to colour blind 814 people have also been included. The diverging point of the colormap was explicitly set to zero to ensure 815 symmetric visualization around baseline activity. Each heatmap was plotted with a color bar labeled 816 “Δ F/F” or ”Scratching Duration” to indicate the normalized intensity of either fluorescence or scratching 817 duration. The x-axis was labeled with time (in seconds/minutes), and the y-axis denoted individual 818 subjects. The matplotlib.pyplot library was used to configure the figure size and layout. 819 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 20 Bland-Altman Analysis of Agreement 820 To assess the agreement between human-annotated and model-annotated scratching durations, 821 a Bland-Altman analysis was performed. Scratch duration values were extracted from a spreadsheet 822 containing paired annotations, with the second and third columns representing human and model values, 823 respectively. The data were imported into Python using the pandas library. For each pair of values, the 824 average was calculated as the mean of the human and model annotations, and the difference was 825 calculated by subtracting the human annotation from the model prediction. These average and difference 826 values formed the basis of the Bland-Altman plot, where each point represented a paired observation. 827 The mean difference was computed to evaluate systematic bias between the two methods. Additionally, 828 the standard deviation of the differences was calculated using a sample standard deviation (ddof=1). 829 Limits of agreement were established at ±1.96 times the standard deviation around the mean difference, 830 representing the 95% confidence interval assuming a normal distribution of differences. A scatter plot was 831 then generated using matplotlib, with the average of the two methods on the x-axis and the difference 832 (model minus human) on the y-axis. The plot included horizontal dashed lines representing the mean 833 difference (bias) and the upper and lower limits of agreement. Points were displayed with semi-834 transparent teal colouring and outlined in black to ensure visibility. Grid lines were lightly overlaid to 835 improve visibility 836 837 False Positive rate and False Negative Rate 838 To assess the class-wise error characteristics of the model, false negative rates (FNR) and false 839 positive rates (FPR) were computed individually for each behavioural class using Python 3.10 and the 840 libraries pandas, matplotlib, and seaborn. This analysis was carried out using the merged frame-wise 841 prediction dataframe (comparison_df), which contains the ground truth labels (Behaviour_truth) and 842 model-predicted labels (Behaviour_test) for each time point. For each unique behaviour present in the 843 ground truth, the False Negative Rate (FNR) was calculated by first identifying all instances where the 844 behaviour was correctly annotated in the ground truth. The number of false negatives was then defined 845 as the count of time points where the ground truth label matched the behaviour of interest but the model-846 predicted label did not. FNR for that class was calculated as the ratio of false negatives to the total 847 number of ground truth instances for that class: 848 849 FNR = False Negatives / (False Negatives + True Positives) 850 851 In parallel, the False Positive Rate (FPR) for each behaviour was computed by counting all instances 852 where the behaviour was not present in the ground truth (i.e., all negative examples), and among them, 853 how many times the model falsely labeled that behaviour. The FPR was thus calculated as: 854 855 FPR = False Positives / (False Positives + True Negatives) 856 857 Both FNR and FPR values were aggregated into dictionaries indexed by behaviour class. These were 858 subsequently visualized as bar plots using seaborn.barplot(). The FNR bar plot used the "Blues_d" 859 colormap, while the FPR plot used "Reds_d", visually separating the two error modalities. All plots were 860 rendered using matplotlib.pyplot with a standard figure size of 10×5 inches, x-axis labels rotated for 861 readability, and layout adjustments applied via plt.tight_layout(). 862 863 Area under the curve 864 To quantify cumulative scratching behaviour over time, the area under the curve (AUC) was 865 calculated for each subject using Simpson’s rule for numerical integration. Scratch duration data were 866 collected at regular time intervals for multiple animals and organized into a Microsoft Excel spreadsheet. 867 The first column represented time (in minutes), while subsequent columns contained time-series scratch 868 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 21 data for individual mice. The dataset was imported into Python using the pandas library. Time values 869 were extracted as the shared x-axis, and each mouse’s scratch duration data was treated as an 870 independent signal. Simpson’s rule, implemented via the simps function from the scipy.integrate module, 871 was used to compute the AUC of each signal. Simpson’s rule was chosen over simpler numerical 872 integration methods, such as the trapezoidal rule, because it fits a second-order (parabolic) polynomial to 873 every pair of adjacent intervals. This makes it especially suitable for biological data that tends to exhibit 874 curvature or non-linear transitions, as it captures the underlying dynamics more accurately than linear 875 approximations. Compared to the trapezoidal method, Simpson’s rule reduces integration error when the 876 signal contains smooth, continuous fluctuations, which is typical of time-resolved behavioural measures 877 like scratching. The computed AUC values represent the total scratching activity integrated across the 878 entire observation window for each animal. These values were visualized using bar plots generated with 879 the matplotlib library. Each bar corresponded to an individual subject, the y-axis denoted the AUC, and 880 the x-axis labeled each mouse. To ensure visual clarity, the y-axis was scaled to 10% of the maximum 881 AUC, and x-axis labels were rotated to prevent overlap where necessary. 882 883 Temporal Accuracy Analysis of Predicted behaviours 884 To quantitatively evaluate the performance of a behavioural classification algorithm, second-by-885 second predicted behaviour labels were compared against manually annotated ground truth labels over a 886 2700-second recording period. The analysis was implemented using Python (v3.10) with the pandas, 887 matplotlib, and seaborn libraries. Two comma-separated value (CSV) files were loaded: one containing 888 manually annotated behaviours (ground truth) and the other containing algorithmically predicted 889 behaviours (test file). Both files were expected to include a time-aligned “Seconds” column and a 890 categorical behaviour label column. The test file was truncated to the first 2700 rows to match the 891 relevant temporal segment of the ground truth. Due to potential inconsistencies in timestamp indexing, 892 the test file’s “Seconds” column was programmatically overwritten to ensure a sequential range from 1 to 893 2700, corresponding to one label per second. The ground truth and test datasets were then merged using 894 an inner join on the “Seconds” column to align behaviour labels on a per-second basis. To avoid 895 ambiguity from automatic merging suffixes, the resulting columns were explicitly renamed: the ground 896 truth label was stored in Behaviour_truth and the predicted label in Behaviour_test. A new Boolean 897 column, correct, was computed to denote whether the predicted label matched the ground truth at each 898 time point. The overall classification accuracy was calculated as the mean of the correct column, 899 representing the proportion of time points at which the prediction matched the annotated behaviour. 900 Additionally, behaviour-wise accuracies were computed by grouping the merged dataframe by the ground 901 truth label and calculating the mean correctness within each group. This allowed for the identification of 902 differential model performance across behaviour categories. To visualize prediction reliability over time, a 903 scatter plot was generated using matplotlib, where the x-axis represented time in seconds and the y-axis 904 indicated whether each prediction was correct (1) or incorrect (0). This temporal representation helped 905 identify regions of sustained accuracy or systematic misclassification. The plot was saved at 300 DPI 906 resolution using lossless PNG format for high-quality reproduction in reports or publications. 907 908 Confusion Matrix Analysis 909 To evaluate the categorical performance of the behaviour prediction model, a confusion matrix 910 was constructed by comparing the predicted behaviour labels to ground truth annotations. The predicted 911 labels were obtained from a CSV file containing model-inferred behaviours at each second 912 (Predicted_Behaviour), while the ground truth labels were obtained from a corresponding CSV file 913 annotated manually (Behaviour). The confusion matrix was computed using the confusion_matrix function 914 from the scikit-learn (sklearn.metrics) library. Prior to comparison, both dataframes were temporally 915 aligned using the Seconds column as a key, ensuring one-to-one correspondence between ground truth 916 and predicted labels. The labels for the confusion matrix were explicitly defined using the unique set of 917 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 22 behaviours present in the ground truth annotation to ensure consistent axis ordering and completeness in 918 representation. The matrix was then visualized using a heatmap generated with the seaborn library 919 (sns.heatmap). This heat map displayed the count of occurrences for each true vs. predicted label pair, 920 with annotations enabled (annot=True) and formatted as integers (fmt='d'). Color encoding was applied 921 using the Blues colormap to enhance visual interpretation, and axis labels were set to reflect actual (y-922 axis) and predicted (x-axis) behaviour categories. The figure was saved at high resolution (dpi=300) in 923 PNG format to a designated directory (save_dir), with tight bounding box settings to avoid truncation of 924 labels or titles. 925 926 Visualization of Class Distribution 927 To assess the class distribution and detect potential imbalances between annotated (ground 928 truth) and model-predicted behavioural categories, horizontal count plots were generated for each 929 dataset. This visualization aids in qualitative evaluation of class frequency agreement between manual 930 annotations and automated predictions. Two CSV files were used as input: one containing the ground 931 truth behaviour annotations (ground_truth) with a column labeled 'Behaviour', and the other containing the 932 model-predicted behaviours (test_file) also under a 'Behaviour' or equivalent column. Both data frames 933 were assumed to be temporally aligned at the per-second resolution. The class order for both plots was 934 standardized by using the frequency-sorted order of behaviours from the ground truth dataset. This was 935 accomplished by passing order=ground_truth['Behaviour'].value_counts().index to the sns.countplot() 936 function, ensuring consistent axis alignment and facilitating direct visual comparison. Visualization was 937 performed using seaborn in conjunction with matplotlib. A side-by-side subplot layout (plt.subplot(1, 2, i)) 938 was used to juxtapose the ground truth distribution against the model prediction distribution. Both plots 939 were set to horizontal orientation (y='Behaviour') to maximize readability of categorical labels, especially 940 when label names are long or numerous. The combined figure was rendered at a width of 12 inches and 941 height of 6 inches (figsize=(12, 6)), and exported at 300 DPI resolution in PNG format to a specified 942 directory (save_dir) using plt.savefig(). A tight layout adjustment (plt.tight_layout()) was applied to prevent 943 overlapping of elements. 944 945 Classifier Performance Evaluation and Visualization 946 To quantitatively assess the performance of the behavioural classification algorithm, standard 947 supervised classification metrics—accuracy, precision, recall, and F1-score—were computed using the 948 merged ground truth and prediction dataset (comparison_df). These metrics provide a comprehensive 949 overview of both the overall and class-specific predictive quality of the model. All calculations were 950 conducted using functions from the sklearn.metrics module (Scikit-learn version ≥ 0.24 recommended). 951 The accuracy_score() function was used to determine the proportion of correctly predicted labels across 952 all classes. Weighted versions of precision_score(), recall_score(), and f1_score() were employed using 953 average="weighted" to account for class imbalance by weighting each class's contribution by its support 954 (i.e., number of true instances). The ground truth labels (Behaviour_truth) and predicted labels 955 (Behaviour_test) were compared at each time point (typically seconds), and correctness was stored as a 956 boolean column (correct) in the merged DataFrame. The values of all four metrics were rounded to two 957 decimal places and printed for inspection. To enhance interpretability and facilitate presentation, the 958 computed metrics were visualized using an interactive bar plot generated via plotly.express (Plotly 959 version ≥ 5.0). A separate DataFrame (metrics_df) was created with two columns: "Metric" and "Value", 960 listing the four performance indicators. The px.bar() function was used to render the plot with distinct color 961 encoding (color="Metric") and the Vivid color scheme from px.colors.qualitative to ensure high contrast 962 and clarity. Metric values were annotated directly above each bar using textposition="outside" and 963 displayed as percentages by formatting the y-axis with yaxis_tickformat=".0%". The resulting figure was 964 exported as a high-resolution PNG image using fig.write_image() and saved to the user-specified output 965 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 23 directory (save_dir). 966 967 Peri-event aligned extraction of fluorescence data from annotated scratching events 968 This was done using custom Python scripts (Python ≥ 3.8, pandas v1.5+, numpy v1.22+). 969 Fluorescence signals were acquired from CSV files containing timestamped CH1 (GCaMP) Z-score 970 values, recorded via fiber photometry. The timestamps, originally in milliseconds, were converted to 971 seconds to match the temporal resolution of the behavioural annotations generated by our automated 972 labeling tool, Scratcher. These annotations consisted of second-level behavioural labels, including the 973 "Itch" class. We extracted all timepoints labeled as "Itch" and performed a peri-event windowing 974 procedure around each instance. To prevent over-representation of closely spaced itch events, we 975 defined bouts of scratching by grouping consecutive "Itch" events occurring within 3 seconds of each 976 other. If a gap of more than 3 seconds occurred between two events, a new bout was initiated.The first 977 scratch in each (sub-)bout was used as the alignment point for peri-event analysis. For every itch event, 978 we defined a symmetric window spanning from 5 seconds before to 5 seconds after the onset of 979 scratching (-5s to +5s relative to event time). Since the fiber photometry system recorded at 980 approximately 30 Hz, each second-long bin was expected to contain up to 30 data points. To ensure 981 consistency, all fluorescence timepoints were rounded to six decimal places. For each second in the 10-982 second window, CH1 values were grouped by their integer second value. If more than 30 samples were 983 available for a given second, only the first 30 were retained. If fewer than 30 samples were present, the 984 row was padded with NaN values to maintain consistent dimensionality. These values were stored in row-985 wise dictionaries, mapping each aligned second to its vector of fluorescence values. The resulting output 986 was stored as a tabular file, with each row representing a peri-event window aligned to an individual itch 987 event. 988 989 Raster Plot 990 To visualize the temporal distribution of discrete behavioural events across multiple subjects, a 991 behavioural raster plot was generated using custom Python scripts. This method allowed for the 992 simultaneous representation of distinct behaviours for multiple animals over a shared time axis, aiding in 993 qualitative inspection of behavioural patterns, co-occurrence, and transitions. A behavioural log 994 containing timestamped event information was prepared in Microsoft Excel format. The first column 995 contained timepoints (in seconds), and each subsequent column represented the binary state (1 for event 996 occurrence, 0 for absence) of a specific behaviour in an individual mouse. The dataset was imported 997 using the pandas library, and temporal boundaries were identified by computing the minimum and 998 maximum time values from the “Time” column. The behavioural raster was created using the matplotlib 999 plotting library, with each subject represented by a horizontal row stacked vertically. The broken_barh 1000 function was employed to render behaviour-specific segments as horizontal bars aligned with their 1001 corresponding time intervals. For each subject, a list of (start time, duration) tuples was constructed from 1002 the raw data, where event durations were inferred from consecutive non-zero entries in the time series. 1003 Each behaviour was color-coded using a predefined colormap, ensuring visual distinction between 1004 behavioural states. The vertical height of each raster row was controlled using a row_height parameter, 1005 and the behaviours were labeled on the y-axis using plt.yticks, corresponding to the stacking order. The 1006 x-axis denoted the shared temporal domain (in seconds), with ticks placed at regular intervals. The plot 1007 was rendered with a dark background using the plt.style.use('dark_background') setting to enhance visual 1008 contrast. All other font elements, including tick labels and axis titles, were bolded for legibility. 1009 1010 Statistical analysis 1011 All statistical analyses were performed using GraphPad PRISM 8.0.2 software. Student t-tests 1012 were performed wherever applicable. ns > 0.05, ∗ P ≤ 0.05, ∗∗ P ≤ 0.01, ∗∗∗ P ≤ 0.001, ∗∗∗∗ P ≤ 0.0005. 1013 1014 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 24 Illustration drawing 1015 Cartoons with mice were made partially in BioRender (BioRender, 2022). 1016 1017 Data Availability 1018 The codes for installing the GUI and generating the analyses can be downloaded from GitHub 1019 https://github.com/BarikLab-IISc/Scratcher 1020 1021

Acknowledgements

1022 We thank the Barik lab members for their help and support. We would also like to thank Mr. 1023 Annappaswamy for his continued help with animal colony management. This work was supported by 1024 IndiaAlliance Intermediate Fellowship awarded to A.B. and IISc. 1025 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 25

References

1026 Argiento R, Lanzarone E, Villalobos IA, Mattei A, editors. 2017. Bayesian statistics in action, 1st ed, 1027 Springer proceedings in mathematics & statistics. Cham, Switzerland: Springer International 1028 Publishing. doi:10.1007/978-3-319-54084-9 1029 Beyer HL, Morales JM, Murray D, Fortin M-J. 2013. The effectiveness of Bayesian state-space models for 1030 estimating behavioural states from movement paths. Methods Ecol Evol 4:433–441. 1031 doi:10.1111/2041-210x.12026 1032 Brash HM, McQueen DS, Christie D, Bell JK, Bond SM, Rees JL. 2005. A repetitive movement detector 1033 used for automatic monitoring and quantification of scratching in mice. J Neurosci Methods 142:107–1034 114. doi:10.1016/j.jneumeth.2004.08.001 1035 Chen H, Feng R, Wu S, Xu H, Zhou F, Liu Z. 2022. 2D Human Pose Estimation: A Survey. arXiv [csCV]. 1036 Chen X-J, Sun Y-G. 2020. Central circuit mechanisms of itch. Nat Commun 11:3052. 1037 doi:10.1038/s41467-020-16859-5 1038 Chun KS, Kang YJ, Lee JY, Nguyen M, Lee B, Lee R, Jo HH, Allen E, Chen H, Kim J, Yu L, Ni X, Lee K, 1039 Jeong H, Lee J, Park Y, Chung HU, Li AW, Lio PA, Yang AF, Fishbein AB, Paller AS, Rogers JA, Xu 1040 S. 2021. A skin-conformable wireless sensor to objectively quantify symptoms of pruritus. Sci Adv 7. 1041 doi:10.1126/sciadv.abf9405 1042 Dang M, Liu G, Xu Q, Li K, Wang D, He L. 2024. Multi-object behavior recognition based on object 1043 detection for dense crowds. Expert Syst Appl 248:123397. doi:10.1016/j.eswa.2024.123397 1044 DeNardo LA, Liu CD, Allen WE, Adams EL, Friedmann D, Fu L, Guenthner CJ, Tessier-Lavigne M, Luo L. 1045 2019. Temporal evolution of cortical ensembles promoting remote memory retrieval. Nat Neurosci 1046 22:460–469. doi:10.1038/s41593-018-0318-7 1047 Deuis JR, Dvorakova LS, Vetter I. 2017. Methods used to evaluate pain behaviors in rodents. Front Mol 1048 Neurosci 10:284. doi:10.3389/fnmol.2017.00284 1049 Doğ an NÖ. 2018. Bland-Altman analysis: A paradigm to understand correlation and agreement. Turk J 1050 Emerg Med 18:139–141. doi:10.1016/j.tjem.2018.09.001 1051 Elliott GR, Vanwersch RA, Bruijnzeel PL. 2000. An automated method for registering and quantifying 1052 scratching activity in mice: use for drug evaluation. J Pharmacol Toxicol Methods 44:453–459. 1053 doi:10.1016/s1056-8719(01)00111-3 1054 Elliott P, G’Sell M, Snyder LM, Ross SE, Ventura V. 2017. Automated acoustic detection of mouse 1055 scratching. PLoS One 12:e0179662. doi:10.1371/journal.pone.0179662 1056 Ge F, Xuan K, Lou P, Li J, Jiang L, Wang J, Lin Q. 2024. Multi-object detection and behavior tracking of 1057 sea cucumbers with skin ulceration syndrome based on deep learning. Front Mar Sci 11. 1058 doi:10.3389/fmars.2024.1365155 1059 Guenthner CJ, Miyamichi K, Yang HH, Heller HC, Luo L. 2013. Permanent genetic access to transiently 1060 active neurons via TRAP: targeted recombination in active populations. Neuron 78:773–784. 1061 doi:10.1016/j.neuron.2013.03.025 1062 Hussain M. 2024. YOLOv5, YOLOv8 and YOLOv10: The go-to detectors for real-time vision. arXiv 1063 [csCV]. 1064 Hu Y, Ferrario CR, Maitland AD, Ionides RB, Ghimire A, Watson B, Iwasaki K, White H, Xi Y, Zhou J, Ye 1065 B. 2023. : Quantification of user-defined animal behaviors using learning-based holistic assessment. 1066 Cell Rep Methods 3:100415. doi:10.1016/j.crmeth.2023.100415 1067 Kielbinski M, Bernacka J. 2024. Fiber photometry in neuroscience research: principles, applications, and 1068 future directions. Pharmacol Rep 76:1242–1255. doi:10.1007/s43440-024-00646-w 1069 Kobayashi K, Matsushita S, Shimizu N, Masuko S, Yamamoto M, Murata T. 2021. Automated detection of 1070 mouse scratching behaviour using convolutional recurrent neural network. Sci Rep 11:658. 1071 doi:10.1038/s41598-020-79965-w 1072 Le Bras A. 2023. A new system to study mouse scratching behavior. Lab Anim (NY) 52:32. 1073 doi:10.1038/s41684-023-01114-3 1074 Li J-N, Ren J-H, He C-B, Zhao W-J, Li H, Dong Y-L, Li Y-Q. 2021. Projections from the lateral 1075 parabrachial nucleus to the lateral and ventral lateral periaqueductal gray subregions mediate the 1076 itching sensation. Pain 162:1848–1863. doi:10.1097/j.pain.0000000000002193 1077 Lin T-Y, Maire M, Belongie S, Hays J, Perona P, Ramanan D, Dollár P, Zitnick CL. 2014. Microsoft 1078 COCO: Common objects in contextComputer Vision – ECCV 2014, Lecture Notes in Computer 1079 Science. Cham: Springer International Publishing. pp. 740–755. doi:10.1007/978-3-319-10602-1_48 1080 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 26 Ludbrook J. 2010. Confidence in Altman-Bland plots: a critical review of the method of differences. Clin 1081 Exp Pharmacol Physiol 37:143–149. doi:10.1111/j.1440-1681.2009.05288.x 1082 Macdonald IL, Raubenheimer D. 1995. Hidden Markov models and animal behaviour. Biom J 37:701–1083 712. doi:10.1002/bimj.4710370606 1084 Mathis A, Mamidanna P, Cury KM, Abe T, Murthy VN, Mathis MW, Bethge M. 2018. DeepLabCut: 1085 markerless pose estimation of user-defined body parts with deep learning. Nat Neurosci 21:1281–1086 1289. doi:10.1038/s41593-018-0209-y 1087 McNamara JM, Green RF, Olsson O. 2006. Bayes’ theorem and its applications in animal behaviour. 1088 Oikos 112:243–251. doi:10.1111/j.0030-1299.2006.14228.x 1089 Mu D, Deng J, Liu K-F, Wu Z-Y, Shi Y-F, Guo W-M, Mao Q-Q, Liu X-J, Li H, Sun Y-G. 2017. A central 1090 neural circuit for itch sensation. Science 357:695–699. doi:10.1126/science.aaf4918 1091 Nagai Y, Miyakawa N, Takuwa H, Hori Y, Oyama K, Ji B, Takahashi M, Huang X-P, Slocum ST, DiBerto 1092 JF, Xiong Y, Urushihata T, Hirabayashi T, Fujimoto A, Mimura K, English JG, Liu J, Inoue K-I, 1093 Kumata K, Seki C, Ono M, Shimojo M, Zhang M-R, Tomita Y, Nakahara J, Suhara T, Takada M, 1094 Higuchi M, Jin J, Roth BL, Minamimoto T. 2020. Deschloroclozapine, a potent and selective 1095 chemogenetic actuator enables rapid neuronal and behavioral modulations in mice and monkeys. 1096 Nat Neurosci 23:1157–1167. doi:10.1038/s41593-020-0661-3 1097 Oksuz K, Cam BC, Kalkan S, Akbas E. 2021. Imbalance problems in object detection: A review. IEEE 1098 Trans Pattern Anal Mach Intell 43:3388–3415. doi:10.1109/TPAMI.2020.2981890 1099 Onishi T, Hirose K, Sakaba T. 2024. Molecular tools to capture active neural circuits. Front Neural Circuits 1100 18:1449459. doi:10.3389/fncir.2024.1449459 1101 Patterson TA, Basson M, Bravington MV, Gunn JS. 2009. Classifying movement behaviour in relation to 1102 environmental conditions using hidden Markov models. J Anim Ecol 78:1113–1123. 1103 doi:10.1111/j.1365-2656.2009.01583.x 1104 Pavlenko D, Ishida H, Markan A, Akiyama T. 2025. A subpopulation of projections from the parabrachial 1105 nucleus to the central amygdala mediates itch. Sci Rep 15:26432. doi:10.1038/s41598-025-08612-z 1106 Pereira TD, Tabris N, Matsliah A, Turner DM, Li J, Ravindranath S, Papadoyannis ES, Normand E, 1107 Deutsch DS, Wang ZY, McKenzie-Smith GC, Mitelut CC, Castro MD, D’Uva J, Kislin M, Sanes DH, 1108 Kocher SD, Wang SS-H, Falkner AL, Shaevitz JW, Murthy M. 2022. SLEAP: A deep learning system 1109 for multi-animal pose tracking. Nat Methods 19:486–495. doi:10.1038/s41592-022-01426-1 1110 Piyush Shah D, Barik A. 2022. The spino-parabrachial pathway for itch. Front Neural Circuits 16:805831. 1111 doi:10.3389/fncir.2022.805831 1112 Prajapati JN, Reddy P, Barik A. 2024. Neural pathways that compel us to scratch an itch. J Biosci 49. 1113 doi:10.1007/s12038-024-00452-9 1114 Prajapati JN, Shah DP, Barik A. 2025. An intra-brainstem circuitry for pain-induced inhibition of itch. 1115 Neuroscience 568:95–107. doi:10.1016/j.neuroscience.2025.01.008 1116 Redmon J, Divvala S, Girshick R, Farhadi A. 2016. You only look once: Unified, real-time object 1117 detection2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Presented at 1118 the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). IEEE. 1119 doi:10.1109/cvpr.2016.91 1120 Ren J, Shen X, Lin Z, Mech R. 2020. Best Frame Selection in a Short VideoProceedings of the IEEE/CVF 1121 Winter Conference on Applications of Computer Vision. pp. 3212–3221. 1122 Ren X, Liu S, Virlogeux A, Kang SJ, Brusch J, Liu Y, Dymecki SM, Han S, Goulding M, Acton D. 2023. 1123 Identification of an essential spinoparabrachial pathway for mechanical itch. Neuron 111:1812–1124 1829.e6. doi:10.1016/j.neuron.2023.03.013 1125 Sakamoto N, Haraguchi T, Kobayashi K, Miyazaki Y, Murata T. 2022. Automated scratching detection 1126 system for black mouse using deep learning. Front Physiol 13:939281. 1127 doi:10.3389/fphys.2022.939281 1128 Samineni VK, Grajales-Reyes JG, Grajales-Reyes GE, Tycksen E, Copits BA, Pedersen C, Ankudey ES, 1129 Sackey JN, Sewell SB, Bruchas MR, Gereau RW. 2021. Cellular, circuit and transcriptional 1130 framework for modulation of itch in the central amygdala. Elife 10. doi:10.7554/eLife.68130 1131 Samineni VK, Grajales-Reyes JG, Sundaram SS, Yoo JJ, Gereau RW 4th. 2019. Cell type-specific 1132 modulation of sensory and affective components of itch in the periaqueductal gray. Nat Commun 1133 10:4356. doi:10.1038/s41467-019-12316-0 1134 Schweihoff JF, Loshakov M, Pavlova I, Kück L, Ewell LA, Schwarz MK. 2021. DeepLabStream enables 1135 closed-loop behavioral experiments using deep learning-based markerless, real-time posture 1136 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 27 detection. Commun Biol 4:130. doi:10.1038/s42003-021-01654-9 1137 Segalin C, Williams J, Karigo T, Hui M, Zelikowsky M, Sun JJ, Perona P, Anderson DJ, Kennedy A. 2021. 1138 The Mouse Action Recognition System (MARS) software pipeline for automated analysis of social 1139 behaviors in mice. Elife 10. doi:10.7554/eLife.63720 1140 Shimada SG, LaMotte RH. 2008. Behavioral differentiation between itch and pain in mouse. Pain 1141 139:681–687. doi:10.1016/j.pain.2008.08.002 1142 Simpson EH, Akam T, Patriarchi T, Blanco-Pozo M, Burgeno LM, Mohebi A, Cragg SJ, Walton ME. 2024. 1143 Lights, fiber, action! A primer on in vivo fiber photometry. Neuron 112:718–739. 1144 doi:10.1016/j.neuron.2023.11.016 1145 Smolinsky AN, Bergner CL, LaPorte JL, Kalueff AV. 2009. Analysis of grooming behavior and its utility in 1146 studying animal stress, anxiety, and depressionMood and Anxiety Related Phenotypes in Mice, 1147 Neuromethods. Totowa, NJ: Humana Press. pp. 21–36. doi:10.1007/978-1-60761-303-9_2 1148 Sun G, Lyu C, Cai R, Yu C, Sun H, Schriver KE, Gao L, Li X. 2021. DeepBhvTracking: A novel behavior 1149 tracking method for laboratory animals based on deep learning. Front Behav Neurosci 15:750894. 1150 doi:10.3389/fnbeh.2021.750894 1151 Vasanthi P, Mohan L. 2024. Efficient YOLOv8 algorithm for extreme small-scale object detection. Digit 1152 Signal Process 154:104682. doi:10.1016/j.dsp.2024.104682 1153 Wen N, Guo R, Ma D, Ye X, He B. 2022. AIoU: Adaptive bounding box regression for accurate oriented 1154 object detection. Int J Intell Syst 37:748–769. doi:10.1002/int.22646 1155 Whoriskey K, Auger-Méthé M, Albertsen CM, Whoriskey FG, Binder TR, Krueger CC, Mills Flemming J. 1156 2017. A hidden Markov movement model for rapidly identifying behavioral states from animal tracks. 1157 Ecol Evol 7:2112–2121. doi:10.1002/ece3.2795 1158 Wimalasena NK, Milner G, Silva R, Vuong C, Zhang Z, Bautista DM, Woolf CJ. 2021. Dissecting the 1159 precise nature of itch-evoked scratching. Neuron 109:3075–3087.e2. 1160 doi:10.1016/j.neuron.2021.07.020 1161 Xu Z, Wang T, Skidmore AK, Lamprey R, Ngene S. 2025. Bounding box versus point annotation: The 1162 impact on deep learning performance for animal detection in aerial images. ISPRS J Photogramm 1163 Remote Sens 222:99–111. doi:10.1016/j.isprsjprs.2025.02.017 1164 Yu H, Xiong J, Ye AY, Cranfill SL, Cannonier T, Gautam M, Zhang M, Bilal R, Park J-E, Xue Y, Polam V, 1165 Vujovic Z, Dai D, Ong W, Ip J, Hsieh A, Mimouni N, Lozada A, Sosale M, Ahn A, Ma M, Ding L, 1166 Arsuaga J, Luo W. 2022. Scratch-AID, a deep learning-based system for automatic detection of 1167 mouse scratching behavior with high accuracy. Elife 11. doi:10.7554/eLife.84042 1168 Zhao Z-Q, Zheng P, Xu S-T, Wu X. 2019. Object detection with deep learning: A review. IEEE Trans 1169 Neural Netw Learn Syst 30:3212–3232. doi:10.1109/TNNLS.2018.2876865 1170 1171 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 28 Figure Legends 1172 1173 Figure 1. YOLOv8-Based Object Detection Pipeline employed in Scratcher for automated detection 1174 of scratching behaviours in various mice models of itch. 1175 (A) Schematic of the chloroquine-induced acute itch model, where intradermal injection of chloroquine at 1176 the nape of the neck evokes robust scratching behaviour. 1177 (B) Representative images of mice recorded from the top view in a standardized matte-black videotaping 1178 arena designed specifically for Scratcher. 1179 (C) Schematic of the video acquisition setup used in Scratcher. Mice were recorded under uniform 1180 lighting (≈ 300 lumens) using a Logitech 1080P business webcam mounted 19 cm above a custom matte-1181 finished behaviour arena (20 × 17 cm), illuminated at 300 lumens. Videos were captured at 30 frames per 1182 second using the proprietary recording service LogiCapture 2.08.11. This precise setup is necessary to 1183 replicate for seamless compatibility with Scratcher’s GUI-based analysis pipeline. 1184 (D) Architecture of the YOLOv8-based object detection network used in Scratcher, highlighting key 1185 components including the backbone, neck, and detection head. 1186 (E) Workflow for dataset preparation and augmentation. Frame extraction is done from raw videos and 1187 manually annotated into three behaviour categories: “Scratching,” “Locomotion,” and “Others.” These are 1188 then augmented using grayscale conversion, HSV manipulation, and geometric transforms to enhance 1189 training diversity and prevent model overfitting. 1190 (F) Summary of the annotated dataset used to train, validate, and test the Scratcher detection algorithm. 1191 Each set contains 7 videos (~45 minutes), with annotated frame counts per class and the relative 1192 proportion of the dataset across training, validation, and testing. 1193 1194 Figure 2. Quantitative evaluation and performance benchmarking of the YOLOv8 behaviour 1195 detection model and post-hoc binning strategies for obtaining second-wise behavioural 1196 classification 1197 (A) Plot showing the F1 score as a function of confidence threshold for each behaviour class ("Itch," 1198 "Locomotion," "Others") as well as the all-class average. 1199 (B) Precision vs. Confidence threshold curve across all behaviour classes. 1200 (C) Precision vs. Recall curve to benchmark the model’s capability to distinguish between behaviours in 1201 borderline confidence cases. 1202 (D) Recall vs. Confidence threshold curve for each behaviour class 1203 (E) Training loss curves over 50 epochs for bounding box regression loss (Box Loss), behaviour 1204 classification loss (Class Loss), and Distribution Focal Loss (DFL). 1205 (F) Validation loss curves for Box Loss, Class Loss, and DFL across 50 epochs. 1206 (G) Evolution of precision and recall metrics during training. 1207 (H) Mean Average Precision (mAP) curves during training, evaluated at IoU=0.5 (left) and at a stricter 1208 mAP@[0.5:0.95] standard (right). 1209 (I) Confusion matrix from the final YOLOv8 model output on the validation set. 1210 (J) Representative output from the trained YOLOv8 model. (Left) Single frame with predicted bounding 1211 box and class label (“Itch”) overlaid with confidence score. (Middle-left) Sample of raw frame-wise output 1212 showing predicted behaviour and corresponding confidence for each frame. (Middle-right) Probability 1213 traces of each class ("Itch," "Locomotion," "Others") across all frames of a representative video. (Right) 1214 Post-hoc binning strategy for second-wise behavioural labeling, where 30 consecutive frames are 1215 grouped and labeled using one of five heuristic methods to derive robust time-resolved annotations for 1216 downstream analysis across the three behaviour classes (“Itch", "Locomotion", “Others"). 1217 1218 1219 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 29 Figure 3. A rule-based majority voting algorithm of post-hoc binning for Frame-to-Second 1220 behavioural aggregation using empirically-derived tie-break rules 1221 (A) Heuristic algorithm schematic. A step-wise schematic of the post-hoc binning process is shown. 1222 Within each 30-frame window (1 second), the behaviour with the highest frequency is assigned. In cases 1223 of ties between "Itch," "Locomotion," and "Others," predefined rules prioritize assignment to "Itch" or 1224 "Locomotion" depending on the tie type. A representative bar plot of occurrences across three sample 1225 windows is included. 1226 (B) Confusion matrix comparing human-annotated ground truth with predicted labels. Rows represent true 1227 labels and columns represent predicted ones. 1228 (C) Accuracy of the temporal distribution of individual classes. Scatter plot showing the correctness of 1229 “Locomotion”, “Itch”, and “Others” (left to right) behaviour predictions over time, with y = 1 indicating 1230 agreement with ground truth (correct) and y = 0 indicating disagreement (incorrect). Each point 1231 represents a time-stamped prediction. 1232 (D) Temporal correctness across the test file. A dot is plotted for each second to denote whether the 1233 predicted label matches the ground truth (1 = correct, 0 = incorrect). Deviations from 1 indicate errors, 1234 allowing inspection of the temporal misclassification structure. 1235 (E) Classification metrics. Standard evaluation metrics—accuracy, precision, recall, and F1-score 1236 (F) Comparison of class-wise behaviour distributions. 1237 (G) Per-class Precision vs. Recall. Precision and recall values are plotted for each behavioural class 1238 (H) Correlation of estimated itch durations.A scatter plot comparing total itch duration per session 1239 between ground truth and test file 1240 (I) Bland–Altman analysis. Agreement between ground truth and test file is visualized via a Bland–Altman 1241 plot showing the mean difference and limits of agreement. 1242 (J) Bar graph displaying the False Negative Rate (FNR) and False Positive Rate (FPR) of the automated 1243 behavioural prediction system compared to human-annotated ground truth labels. The FNR bar, shown in 1244 blue, quantifies the fraction of actual “Itch” seconds that the model failed to detect. The FPR bar, shown in 1245 red, quantifies the proportion of seconds where the model falsely predicted “Itch” in the absence of a 1246 corresponding ground truth label. 1247 1248 Figure 4. Scratcher enables high-resolution behavioural analysis during extended recordings. 1249 (A) Schematic of experimental protocol. Mice were habituated to the videotaping chamber for 30 minutes, 1250 followed by intradermal chloroquine injection. Scratching behaviour was then recorded for 180 minutes. 1251 (B) Scratching duration across a 3-hour session. Minute-wise average scratching durations across 1252 animals (n=6) overlaid on the individual data points (shaded area: SEM). 1253 (C) Time of peak scratching bout per mouse. Each dot represents the time (in seconds) post-injection at 1254 which each mouse exhibited its highest scratching duration. 1255 (D) Area under the curve (AUC). Bar plots showing cumulative scratching time (in seconds) across the 1256 session lasting for 3 hours. 1257 (E) Slope of scratching duration curve. Linear fits across time for all mice. 1258 (F) Heatmaps of scratching events. Each row represents a mouse, and each column a time bin (1 minute) 1259 across a full 3-hour session. Each row represents one mouse, and each column represents a 1-minute 1260 bin. 1261 1262 Figure 5. Scratcher enables precise quantification of scratching behaviour across experimental 1263 manipulations, such as nail clipping. 1264 (A) Experimental design and manipulation. Mice were habituated to the videotaping arena, followed by 1265 chloroquine (CHQ)-induced acute nape itch to establish baseline scratching. The next day, all forepaw 1266 nails were carefully clipped (image in set: BEFORE vs. AFTER), followed by another CHQ injection 24 1267 hours later to assess changes in scratching behaviour due to mechanical alteration. 1268 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 30 (B) Group-wise time course of scratching bouts. Average scratch durations per minute across the session 1269 in control (pre-clipping, blue) versus experimental (post-clipping, red) groups. Shaded areas denote SEM. 1270 (n=8 mice) 1271 (C) Detailed scratch features for the control group (pre-clipping).Left: Peak scratch time per mouse. 1272 Middle: Total scratch duration per mouse in terms of Area under the curve (AUC) is relatively higher 1273 across all. Right: Linear slopes of scratching decay over time. Mice show individual variability, but overall 1274 maintain sustained scratching. 1275 (D) Detailed scratch features for the experimental group (post-nail clipping). 1276 (E) Heatmaps of scratching behaviour for individual mice before (left) and after (right) nail clipping. Each 1277 row represents a mouse; each column represents 1-minute bins. 1278 1279 Figure 6. High-resolution profiling of scratching behaviour of scratching behaviour using 1280 Scratcher’s GUI-based analysis: Example output from user-supplied video demonstrating 1281 chemogenetic activation of Itch TRAPed neurons using multi-metric readouts 1282 (A) Schematic of experimental design. AAV carrying Cre-dependent hM3D(Gq)-mCherry was injected into 1283 the parabrachial nucleus (PBN), and an itch TRAPing protocol was used to selectively express hM3D(Gq) 1284 in neurons active during chloroquine-induced itch. behavioural quantification was performed after saline 1285 injection and later after DREADD activation using DCZ 1286 (B) Histological validation of Itch TRAPed neurons. Representative sections show hM3D(Gq)-mCherry 1287 expression (red) and cFos (green) in the LPBN. 1288 (C) Average scratch bouts per minute across saline and DCZ conditions across all mice (n=5 mice, p < 1289 0.05, paired t-test). Each dot represents one animal; red squares denote individual values in the DCZ 1290 condition. 1291 (D) Time-resolved scratch duration profile. Second-wise scratching duration over 45 minutes post-1292 chloroquine injection across mice administered with saline(blue) and DCZ(red), respectively. Mean traces 1293 and shaded SEMs are plotted for all animals. 1294 (E) Peak scratching duration. Dot plots show the highest single-second scratching duration per mouse 1295 under saline (top) and DCZ (bottom) conditions. 1296 (F) Area under the curve (AUC). Bar plots showing cumulative scratching time (in seconds) across the 1297 session. 1298 (G) Slope of scratching duration curve. Linear fits across time show varying scratching trends for saline 1299 (top) and DCZ (bottom) conditions. 1300 (H) Heatmaps of scratching events. Saline (left) and DCZ (right), with each row representing a mouse, 1301 and each column a time bin (1 minute). 1302 1303 1304 Figure 7. High-resolution profiling of scratching behaviour of scratching behaviour using 1305 Scratcher’s GUI-based analysis: Example output from user-supplied video demonstrating 1306 chemogenetic inactivation of Itch TRAPed neurons using multi-metric readouts 1307 (A) Schematic of experimental design. AAV carrying Cre-dependent hM4Di-mCherry was injected into the 1308 parabrachial nucleus (PBN), and an itch TRAPing protocol was used to selectively express hM4Di in 1309 neurons active during chloroquine-induced itch. Behavioural quantification was performed before and 1310 after DREADD activation using DCZ. 1311 (B) Histological validation of Itch TRAPed neurons. Representative sections show hM4Di-mCherry 1312 expression (red) in the LPBN 1313 (C) Average scratch bouts per minute compared to saline controls across all mice (n=4 mice, p < 0.05, 1314 paired t-test). Each dot represents one animal; red squares denote individual values in the DCZ condition. 1315 (D) Time-resolved scratch duration profile. Second-wise scratching duration over 45 minutes post-1316 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 31 chloroquine injection across DCZ (red) condition compared to saline controls (blue). Mean traces and 1317 shaded SEMs are plotted across animals. 1318 (E) Peak scratching duration. Dot plots show the highest single-second scratching duration per mouse 1319 under saline (top) and DCZ (bottom) conditions. 1320 (F) Area under the curve (AUC). Bar plots showing cumulative scratching time (in seconds) across saline 1321 (top) and DCZ (bottom) 1322 (G) Slope of scratching duration curve. Linear fits across time show varying scratching trends, saline (top) 1323 and DCZ administration (bottom). 1324 (H) Heatmaps of scratching events. Each row represents a mouse, and each column a time bin (1 1325 minute). Saline (left) shows optimum scratching, whereas DCZ (right) reveals temporally sparse and 1326 minimal scratching episodes, captured with high temporal resolution by Scratcher. 1327 1328 Figure 8. Scratcher integrates seamlessly with fiber photometry setups to automate behavioural 1329 alignment and neural activity analysis. 1330 (A) Schematic of the experimental timeline and viral targeting. Mice were injected with AAV9-Syn-Flex-1331 GCaMP6s in the lateral parabrachial nucleus (LPBN), followed by habituation to the videotaping box, itch 1332 TRAPing, fiber optic cannulation, and performing fiber photometry recordings after injecting chloroquine 1333 to induce acute itch over the course of several weeks. 1334 (B) Histological validation of virus expression in the LPBN. Coronal section showing GCaMP6s 1335 expression (green) localized to the PBN, counterstained with DAPI (blue). Scale bar: 100 μ m. 1336 (C) Automated peri-scratch event alignment by Scratcher. Top: Raster plot showing the time of start of 1337 individual scratching bouts across a 45-minute session. Bottom: Aligned fluorescence (Δ F/F) heatmap 1338 showing GCaMP6s activity 10 seconds before and after each scratching bout. Each row represents a 1339 single bout, while each column represents fluorescence values, automatically detected and aligned by 1340 Scratcher. 1341 (D) Averaged peri-bout GCaMP6s activity across all scratching events. Mean Δ F/F trace (green) shows a 1342 rise in LPBN activity leading up to a scratching bout, followed by a gradual return to baseline levels of 1343 fluorescence. The shaded region indicates SEM. Time zero denotes the onset of each scratching bout. 1344 1345 Supplementary Figure 1. Graphical overview of the input-control-output architecture across the 1346 DETECT, ANALYSE, and TRAIN modules of the automated scratching detection and behavioral 1347 analysis tool. 1348 (A) The DETECT module allows users to input a video file and YOLO-based model weights to perform 1349 frame-wise behavioral classification, with adjustable parameters such as confidence thresholds, model 1350 selection, and frame rate settings. The output includes label and confidence score files in CSV format. 1351 (B) The ANALYSE module enables parameterized behavioral analysis using model outputs and raw 1352 fluorescence data. Controls include heuristic selection, analysis window configuration, and plotting 1353 options. Outputs include summary behavioral metrics such as scratching duration, onset latency, session 1354 slope, and photometry-based peri-event measures. 1355 (C) The TRAIN module provides customization for training object detection models using user-annotated 1356 datasets. Inputs include COCO-formatted datasets and custom training parameters. Outputs are user-1357 trained YOLO models and associated weights. 1358 1359 Supplementary Figure 2. Performance evaluation of the Bayesian Inference heuristic for post-hoc 1360 binning for Frame-to-Second behavioural aggregation using YOLOv8 frame-wise outputs 1361 (A) Bayesian inference-based aggregation schematic. A diagram illustrating the Bayesian approach to 1362 second-wise classification. Each sliding window aggregates YOLO detections to compute likelihoods, 1363 which are then combined with empirical priors to calculate posteriors. The behaviour with the highest 1364 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 32 posterior is assigned to the window. A representative table shows sample priors and posteriors for each 1365 class. 1366 (B) Confusion matrix comparing ground truth vs. test file labels. Class-wise distribution of predictions from 1367 the Bayesian method against ground truth annotations. 1368 (C) Accuracy of temporal distribution of individual classes. Scatter plot showing the correctness of 1369 “Locomotion”, “Itch” and “Others” (left to right) behaviour predictions over time, with y = 1 indicating 1370 agreement with ground truth (correct) and y = 0 indicating disagreement (incorrect). Each point 1371 represents a time-stamped prediction. 1372 (D) Temporal accuracy over the session. Each blue dot represents a second where the predicted label 1373 matches the ground truth (1 = correct, 0 = incorrect). The pattern reveals moments of behavioural 1374 misclassification and overall temporal fidelity. 1375 (E) Aggregate classification metrics. Accuracy, precision, recall, and F1-score are shown. 1376 (F) behavioural distribution comparison. Bar plots showing the total count of each behaviour type in the 1377 ground truth and test file. 1378 (G) Per-class precision vs. recall. Scatter plot showing precision and recall for each behavioural class. 1379 1380 Supplementary Figure 3. Performance evaluation of the Gaussian Hidden Markov Model (HMM) 1381 heuristic for post-hoc binning for Frame-to-Second behavioural aggregation using YOLOv8 frame-1382 wise outputs 1383 (A) Workflow and state transition diagram for HMM-based inference. A schematic describing the HMM-1384 based approach. Frame-wise YOLOv8 predictions are converted to one-hot encoded vectors, used to 1385 train a Gaussian HMM. The Viterbi algorithm infers the sequence of hidden states, estimating the most 1386 probable behavioural labels. The right sub-panel shows the learned state transition probabilities between 1387 "Locomotion," "Itch," and "Others." 1388 (B) Confusion matrix comparing ground truth vs. HMM-based predictions. 1389 (C) Accuracy of the temporal distribution of individual classes. Scatter plot showing the correctness of 1390 “Locomotion”, “Itch” and “Others” (left to right) behaviour predictions over time, with y = 1 indicating 1391 agreement with ground truth (correct) and y = 0 indicating disagreement (incorrect). Each point 1392 represents a time-stamped prediction. 1393 (D) Temporal classification accuracy across the session. Binary sequence indicating per-second 1394 correctness (1 = correct, 0 = incorrect). 1395 (E) Aggregate classification metrics. Accuracy, precision, recall, and F1-score are shown. 1396 (F) Behavioural distribution comparison. Bar plots comparing the total number of each behaviour in the 1397 ground truth (left) and HMM output (right). 1398 (G) Per-class performance comparison. Scatter plot of precision vs. recall for each behavioural class. 1399 1400 Supplementary Figure 4. Performance evaluation of the overlapping sliding window heuristic for 1401 post-hoc binning to achieve Frame-to-Second behavioural aggregation using YOLOv8 frame-wise 1402 outputs 1403 (A) Workflow of the overlapping sliding window heuristic. A 30-frame overlapping window moves across 1404 YOLOv8 frame-wise outputs (n to n+29). For each window, the mode of the behaviour classes is 1405 computed and assigned as the second-wise label. The accompanying table shows an example of frame 1406 counts per class and how "Itch" is chosen by majority. 1407 (B) Confusion matrix comparing ground truth vs. heuristic predictions. This panel shows the number of 1408 true vs. predicted behaviour labels. 1409 (C) Accuracy of the temporal distribution of individual classes. Scatter plot showing the correctness of 1410 “Locomotion”, “Itch”, and “Others” (left to right) behaviour predictions over time, with y = 1 indicating 1411 agreement with ground truth (correct) and y = 0 indicating disagreement (incorrect). Each point 1412 represents a time-stamped prediction. 1413 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 33 (D) Temporal classification accuracy across the session. Binary sequence indicating per-second 1414 correctness (1 = correct, 0 = incorrect). 1415 (E) Aggregate classification metrics. Accuracy, precision, recall, and F1-score are shown. 1416 (F) Comparison of behavioural distribution. The left panel shows the ground truth behaviour counts, while 1417 the right panel shows the distribution produced by the sliding window method. 1418 (G) A per-class scatter plot of precision vs. recall. 1419 1420 Supplementary Figure 5. Performance evaluation of a non-overlapping sliding window-based 1421 probability averaging heuristic for post-hoc binning to achieve Frame-to-Second behavioural 1422 aggregation using YOLOv8 frame-wise outputs 1423 (A) Schematic of the non-overlapping sliding window-based probability averaging heuristic. YOLOv8 1424 frame-wise confidence values for each behaviour class are grouped into non-overlapping windows of 30 1425 frames. For each window, average confidence scores are computed for all classes, and the class with the 1426 highest average is selected. An example shows how three consecutive windows yield predictions of 1427 "Locomotion," "Others," and "Itch." 1428 (B) Confusion matrix comparing predicted vs. true behaviours. 1429 (C) Accuracy of the temporal distribution of individual classes. Scatter plot showing the correctness of 1430 “Locomotion”, “Itch”, and “Others” (left to right) behaviour predictions over time, with y = 1 indicating 1431 agreement with ground truth (correct) and y = 0 indicating disagreement (incorrect). Each point 1432 represents a time-stamped prediction. 1433 (D) Second-wise correctness trace over time. A plot marking correct (1) or incorrect (0) predictions per 1434 second across a 2500-second test segment. 1435 (E) Aggregate classification metrics. 1436 (F) Comparison of behaviour distributions. The left panel shows ground truth counts for each behaviour; 1437 the right panel shows predictions using this heuristic. 1438 (G) Class-wise precision vs. recall scatter plot. Each dot represents a behaviour class. 1439 1440 Supplementary Figure 6. Latency to Itch Across Experimental Conditions 1441 Plots showing the latency to first itch response following chloroquine injection across multiple 1442 experimental groups. 1443 (A) Comparison between Hm3Dq-expressing mice administered DCZ versus saline. 1444 (B) Comparison between Hm4Di-expressing mice administered DCZ versus saline. 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 34 Figure 1 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 35 Figure 2 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 36 Figure 3 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 37 Figure 4 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 38 Figure 5 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 39 Figure 6 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 40 Figure 7 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 41 Figure 8 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 42 Supplementary Figure 1 (S1) 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 43 Supplementary Figure 2 (S2) 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 44 Supplementary Figure 3 (S3) 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 45 Supplementary Figure 4 (S4) 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 46 Supplementary Figure 5 (S5) 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint 47 Supplementary Figure 6 (S6) 2100 2101 .CC-BY-NC 4.0 International licenseavailable under a (which was not certified by peer review) is the author/funder, who has granted bioRxiv a license to display the preprint in perpetuity. It is made The copyright holder for this preprintthis version posted August 18, 2025. ; https://doi.org/10.1101/2025.08.18.670778doi: bioRxiv preprint

Text is read by the "Ask this paper" AI Q&A widget below. Extraction quality varies by source — PMC NXML preserves structure cleanly, OA-HTML may include some navigation residue, and OA-PDF can have broken hyphenation. The publisher copy (via DOI) is the canonical version.

My notes (saved in your browser only)

Ask this paper AI returns verbatim quotes from the full text · source: oa-pdf

Answers must be backed by verbatim quotes from this paper's full text. Hallucinated quotes are dropped automatically; if no verbatim passage answers the question, we say so. How this works

Citation neighborhood (no data yet)

We don't have any in-corpus citations linked to this paper yet. This is a recent paper (2025) — citers typically take a year or two to land, and the OpenAlex reference graph may still be filling in.

Source provenance

europepmc
last seen: 2026-05-20T01:45:00.602351+00:00
unpaywall
last seen: 2026-05-24T02:00:01.246996+00:00
License: CC-BY-NC-4.0