bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

A machine-vision approach for automated measurement at millisecond timescales

Jessica Jones1,4, William Foster1,4, Colin Twomey1,4, Justin Burdge1, Osama Ahmed2, Jessica A. Wojick3, Gregory Corder3, Joshua B. Plotkin1, Ishmail Abdus-Saboor1,5

1 Department of Biology, University of Pennsylvania, Philadelphia, PA, USA 2 Princeton Neuroscience Institute, Princeton University, Princeton NJ, USA 3 Departments of Psychiatry and Neuroscience, University of Pennsylvania, Philadelphia, PA, USA 4 These authors contributed equally 5 Corresponding author: [email protected]

Objective and automatic measurement increase the ease and objectivity of of pain in mice remains a barrier for collecting rigorous behavioral data, and discovery in both basic and it is compatible with other neural translational neuroscience. Here we circuit dissection tools for determining capture rapid paw kinematics during the mouse pain state. pain behavior in mice with high-speed videography and automated paw INTRODUCTION tracking with machine and deep Numerous genetic and environmental factors approaches. Our statistical shape the subjective experience of pain. software platform, PAWS (Pain While humans can articulate the intensity Assessment at Withdrawal Speeds), uses and unpleasantness of their perceived pain a univariate projection of paw position in the form of pain scales and over time to automatically quantify fast questionnaires[1, 2], determining pain states paw dynamics at the onset of paw in non-verbal animals remains a significant withdrawal and also lingering pain- challenge. Rodents are the predominant related behaviors such as paw guarding model organism to study pain and there is an and shaking. Applied to innocuous and urgent need to develop high-throughput noxious stimuli across six inbred mouse approaches that accurately measure pain. The strains, a linear discriminant analysis past fifty years of pain research have relied reveals a two-dimensional subspace on the paw withdrawal reflex metric to that separates painful from non-painful measure pain-related behaviors in rodents, stimuli on one axis, and further which has contributed to important distinguishes the severity of pain on the discoveries about nociception[3, 4]. However, second axis. Automated paw tracking the traditional approach of manually scoring combined with PAWS reveals paw lifting suffers from an inability to behaviorally-divergent mouse strains determine whether paw movement away that display hypo- and hyper-sensitivity from a stimulus is motivated by the to mechanical stimuli. To demonstrate experience of pain. Improving the resolution, the efficacy of PAWS for detecting and increasing the dimensionality, of the hypersensitivity to noxious stimuli, we common paw withdrawal assay has the chemogenetically activated pain- potential to increase the predictive validity of aversion neurons in the amygdala, translational pain therapeutics, and to increase which further separated the behavioral the rate at which basic science findings are representation of pain-related translated to the clinic. behaviors along a low-dimensional Animals generate rapid motor path. Taken together, this automated responses to somatosensory stimuli at pain quantification approach should

Page 1 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

millisecond speeds that cannot be readily markerless automated tracking software detected by eye[5, 6]. Therefore, significantly ProAnalyst, tracks moving objects across increasing the recording rate of the motor high frame rate videography data [16, 17]. actions, coupled with sub-second mapping of This approach does not use deep learning but behavioral signatures, will sharpen the relies on built-in machine learning resolution and confidence for assessing an algorithms for automated tracking, which animal’s internal pain state. For example, provides an easier point of entry for researchers recorded optogenetically- researchers with limited time for software induced nociceptive behaviors at 240 frames development or computing power. per second (fps), which facilitated the precise Here, we present an automated mapping of nocifensive behaviors including mouse pain scale that combines videography paw withdrawal, paw guarding, jumping, at 2,000 fps, automated paw tracking with and vocalization [7]. Two additional studies ProAnalyst and Social LEAP, and new recording between 500-1,000 fps using both software called PAWS (Pain Assessment at natural and optogenetic nociceptive stimuli, Withdrawal Speeds), which scores eight demonstrated that nociceptive withdrawal defined behavioral endpoints. Beginning latencies were on the order of 20-130 with six commonly used genetically inbred milliseconds (ms)[8, 9]. More recently, we mouse strains we revealed stereotyped sub- recorded mouse somatosensory behaviors at second paw trajectory patterns, with simple 500-1,000 fps, coupled with manual up-down lifts typifying the response to behavioral mapping, statistical modeling, innocuous stimuli and elaborate sinusoidal and machine learning to create a more patterns typifying the responses to noxious objective “pain scale” [10]. Although these stimuli. By projecting paw position onto the studies provide a framework for using high- time-varying principal axis of paw speed videography for fine-assessment of movement, we identified shaking behavior as pain, a major limitation lies in the relatively simple sequences of peaks and valleys in this low-throughput nature of manual scoring of univariate time series, and paw guarding as the video frames, which adds potential extended periods of stasis devoid of shaking human error, and limits the ease of platform prior to returning the paw to the ground. adoption in other laboratories. After building an automated pain Recently, computational assessment platform, we used statistical platforms have introduced a modeling with linear discriminant analyses suite of machine learning and deep neural (LDA) and confirmed that the eight networks to automatically track animal body movement features we automatically parts during behavior for postural measured were sufficient to separate estimation [11]. Platforms such as Motion behavioral responses to innocuous touch Sequencing (MoSeq) use 3-dimensional from noxious pinprick stimuli. The LDA depth imaging, quantitative analyses, and further segregated noxious intensity. Cross- fitting with unsupervised computational validation of our LDA modeling confirmed models to estimate animal posture within an that PAWS performed better than an open arena and can automatically reveal ~60 unsupervised machine learning approach for unique sub-second behavioral signatures decoding the stimulus type and intensity [12]. DeepLabCut and LEAP, train deep based on the animal’s sub-second behavioral neural networks (DNN) with relatively responses. Lastly, using our recently limited training datasets, allowing the described protocol to gain genetic-access to computer to accurately track unlabeled body basolateral amygdala (BLA) neurons that parts such as a mouse paw, ear, or even a are responsive to pain [19], we single digit through many frames of chemogenetically activated the BLA pain videography data [14, 15]. Alternatively, the ensemble to validate our platform’s ability to

Page 2 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

detect pain hypersensitivity. Thus, we can Since mice will move their paw to both automatically measure increases in innocuous and noxious stimuli, it is hard to mechanical pain responsiveness to noxious determine if these differences in withdrawal stimuli while manipulating central pain frequencies are driven by genetic differences circuits. Taken together, this work reveals in susceptibility to pain. What these data that automating paw tracking and likely reveal using the common traditional subsequent quantification of pain behaviors approach is that this test in isolation may be with high frame rate videography provides a an inadequate measurement of pain at reliable method to objectively determine the baseline states. mouse pain state. Next we turned to automated tracking with the six mouse strains to RESULTS determine the X,Y coordinates of the paw across approximately 5,000 frames – High-speed videography and automated recording at 2,000 fps with total behavior paw tracking during evoked behaviors time from stimulus application to paw lift In order to capture sub-second behavioral and return back to the floor being ethograms during somatosensory behaviors approximately 2-3 seconds. Using machine in freely behaving mice, we recorded mice at learning algorithms embedded within the 2,000 fps, with a particular focus on the ProAnalyst motion tracking software, we stimulated paw. We reasoned that we could manually labeled the center of the develop a pipeline where we first performed stimulated paw in each video and the behavior experiments, followed by machine automatically tracked the paw automated paw tracking and automated pain throughout each additional frame (Figure scoring, and lastly statistical modeling to 2A-X) (see Movie 1). While observing the transform multidimensional datasets into a automated paw trajectory patterns we single dimension that separated touch from noticed that stereotyped motor sequences pain (Figure 1A). To begin, we used 10 mice defined the movement away from the four from six commonly used inbred lines and on stimuli, regardless of strain background separate days to avoid sensitization to the (Figure 2A-X). For example, the responses to stimuli, we applied to one hind paw a static the two innocuous stimuli were typically up- innocuous stimulus (cotton swab), a moving down C-shaped movements (Figure 2A-X). innocuous stimulus (dynamic brush), a weak Conversely, the responses to the two noxious noxious stimulus (light application of a stimuli were typically more elaborate pinprick), and an intense noxious stimulus movements, often accompanied by orbital (heavy application of a pinprick). Using tightening of the eye, which is a known facial traditional pain scoring, we noticed that the feature of intense pain (Figure 2A-X) [20]. In paw withdrawal frequencies to these four the majority of tested strains, we also noticed stimuli varied widely across these six that the paw trajectory pattern in response strains. For example, Balb/cJ, DBA1/J, and to a weakly painful stimulus (light pinprick) CBA/J displayed high paw withdrawal rates often resulted in a figure-eight like sequence to all mechanical stimuli, both the innocuous that may point towards a shared and the two noxious (Figure 1B). Conversely, sensorimotor neural circuit that governs how C57BL/6J and AKR/J displayed high paw animals respond to weakly painful stimuli withdrawal rates to both the noxious stimuli given their body posture and space and the innocuous dynamic brush, but not constraints (Figure 2A-X). the cotton swab (Figure 1B). Lastly, the A/J Next, using the AKR/J strain we used mice displayed high rates of paw lifting to a deep learning-based pose tracking both pinprick stimuli and low withdrawal algorithm called Social LEAP (in rates to the two touch stimuli (Figure 1B). preparation, based on[14]), to predict mouse

Page 3 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

toe and mid-paw positions during us confidence that we could use somatosensory behaviors recorded at high spatiotemporal data of paw position to speed (Figure 2Y-Z¢). Our mouse paw- automatically extract features that may be tracking model was generated from a small useful in determining the mouse pain state. training set of video frames collected from the four assays (~9.5% of video frames per Development of software to assay). In general, the paw trajectory automatically score pain behavioral patterns with Social LEAP resemble those of endpoints ProAnalyst, and the software package we We developed software to systematically describe below is compatible with automated quantify seven pain-relevant features of the tracking data from either tool. Taken paw position time series based on existing together, our ability to detect clear measurements in the literature. Maximum qualitative distinctions in paw movements paw height, lateral velocity, vertical velocity, with automated tracking approaches, gave and the total distance traveled by the paw, were all computed based on a polynomial

Page 4 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

smoothing (Savitsky-Golay filter of order 3) periods. We refer to this software package as of the original paw position time series. PAWS (Pain Assessment at Withdrawal These four features were computed for two Speeds). different windows of the paw trajectory time series: the time leading up to the initial paw Automated scoring of rapid paw peak (time t* in Figure 3A), and the time dynamics and lingering pain behaviors after the initial paw peak, which we refer to With software generated to automatically as pre-peak and post-peak, respectively. In measure paw movement features related to the post-peak time window we additionally the mouse pain state, we plotted and identified periods of “shaking” and analyzed the data across the six mouse “guarding” based on a threshold strains with the four mechanical stimuli displacement along the principal axis of paw described above. For plotting the individual movement (Figure 3B and C). We used this behavioral endpoints, we separated the paw delineation to quantify the total duration distance traveled measurement into pre- spent shaking or guarding as well as the total peak and post-peak distances. To number of paw shakes across shaking standardize across varying units and to

Page 5 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

appreciate individual deviation from the versus pain across six inbred mouse median, we transformed the raw output strains measurements into Z-scores (Figure 4). The We used linear discriminant analysis (LDA) first readily apparent feature we noticed was to identify a linear subspace of the quantified that all measurements across these six behavioral features that best separates the strains were interspersed without clear four pain treatments: CS, DB, LP, and HP. separation amongst strains, despite the vast We did this for two cases: first, restricting to differences in paw withdrawal frequencies to just four features quantifiable pre-peak these same stimuli (Figure 1B). In regards to (t

Page 6 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

inferring features from variability in the while LP and HP were kept separate, time series themselves (see Methods); and (2) resulting in three classes: non-pain, low pain, a null model that assigns pain classes and high pain. For predicting the pain state according to their probability in the training of a given mouse, or all the mice in a strain data, without reference to measured (generalizing across strains), post-peak paw behavioral features. For prediction, CS and features consistently performed best. The DB were treated as a single “non-pain” class, eight behavioral features we defined and

Page 7 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

extracted from paw-tracked videography strains that appeared to have atypical significantly outperform both a random null behavioral responses to our four model as well as the 23 features identified somatosensory stimuli. The first of these two automatically from the same data, in terms strains, 129S1, appeared to have a pain of cross-validated ability to discriminate pain hypo-sensitivity phenotype, responding to stimulus. both innocuous and noxious mechanical stimuli with the same basic up-down paw Validation of the automated tracking trajectory pattern, and not the elaborate paw and scoring approach with new mouse withdrawal pattern typically observed with lines noxious stimuli (Fig 6A-D) (compare to In the process of testing the six inbred lines Figure 2A-X). Prior studies using traditional described above, we tested an additional two unidimensional assays to compare the

Page 8 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

baseline mechanical pain sensitivity of

Page 9 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

different 129 sub-strains to C57BL/6J mice hM3q-mCherry) allows the specific revealed mixed results with some tests expression of the DREADD only in neurons showing no differences between the strains, responsive to the noxious pin prick stimulus and either greater or reduced sensitivity to (painTRAP2hM3; Figure 7A). We confirmed pain [21-23]. The second apparent outlier bilateral mCherry-labeled DREADD strain were the SJL mice, where we observe expression in the BLA with this strategy the opposite of what we found in 129S1, (Figure 7B,C). We first performed our where this strain appears hypersensitive to analysis on Cre-negative control animals and mechanical pain – responding to the soft observed no effects of CNO injections on dynamic brush as if it were pinprick and behavior. Next, we performed our behavioral having even more elaborate paw withdrawal analysis on painTRAP2hM3 mice at baseline (- stimuli (Figure 6E-H). The outlier patterns CNO) and after activation of the BLA pain of these two strains were observed when ensemble (+CNO) (Figure 7). Because scoring the individual eight pain behavioral activation of the BLA pain ensemble resulted endpoints (Table 1). Consistent with this in unilateral spontaneous guarding pain finding, when we perform our LOO behaviors, we waited until mice were calm, correlation testing to determine how not moving, and had all four paws on the accurate our training is from LDA modeling, surface before applying our sensory stimuli. for both 129 and SJL strains, our confidence We applied a cotton swab and dynamic brush in predicting the stimulus the animal on one day, and a light and heavy pinprick on received based on its response is low, proving a second day. We observed that the PAWS the nature of the outlier phenotypes in these measurements at baseline (-CNO) mirrored mice (Figure 6I). These data reveal that our those that we observed with the six strains automated pain assessment platform is described above, showing separation capable of detecting individual strain between innocuous and noxious stimuli. differences in susceptibility to mechanical Conversely, with activation of the BLA pain pain. ensemble in painTRAP2hM3 mice (+CNO), we noticed increased separation with the post PAWS reliably detects motivational paw peak pain measurements when changes in pain perception following delivering the heavy pinprick stimuli, most chemogenetic brain circuit noticeable in the combined shaking/guarding manipulation measurement (Figure 7I). When we used As another proof-of-principle to validate our LDA for statistical separation that combined ability to automatically measure acute our 8 behavioral endpoints, we clearly mechanical pain, we next asked if our observe the emergence of a group of mice platform could reliably measure experiencing a heightened pain state in hypersensitivity to the four somatosensory comparison to the other groups of mice stimuli used above during chemogenetic (Figure 7L-O). Thus, PAWS automatically activation of a neural ensemble encoding measures increased mechanical pain pain. To accomplish this, we focused our aversive responsiveness to noxious stimuli attention on manipulating pain circuits in during chemogenetic activation of the BLA the BLA[19]. Briefly, we used the activity- pain ensemble. dependent transgenic TRAP2 mice (Fos- FOS-p2A-iCre-ERT2) to gain permanent DISCUSSION genetic access to BLA neurons that are Here, we describe an automated approach to responsive to a noxious pin prick to the left quantify the most salient behavioral hind paw. The transgenic mice in endpoints following mechanical stimulation combination with an AAV expressing an of the mouse paw for separating responses excitatory DREADD (AAV5-hSyn-FLEx- according to stimulus intensity. Scoring the

Page 10 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

paw withdrawal reflex to a natural stimulus high-speed videography coupled with is the most commonly used assessment machine learning approaches, we reveal method in pre-clinical rodent models with stereotyped trajectory patterns in response yes/no responsiveness used as a proxy for to innocuous versus noxious stimuli inferring pain states. While this methodology spanning genetically diverse mice. With an for measuring pain in rodents is not accurate pinpoint of the paw at high fundamentally flawed, it lacks resolution – a spatiotemporal resolution, a freely available limitation that can now be overcome with software package we term PAWS advances in videography and automated automatically quantifies eight behavioral tracking. Here, by automatically tracking endpoints that help to define the mouse pain paw dynamics at sub-second speeds with state. Notably, the eight behavioral features

Page 11 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

we defined outperform both a random null extracted from the same data, in terms of model as well as 23 unsupervised features their ability to discriminate pain stimuli.

Page 12 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

Thus, although machine learning is critical with the automated pain assessment for the intermediate task of paw tracking, platform described here that focuses on the supervised feature definition still paw, for a comprehensive picture of both outperforms unsupervised learning for evoked and spontaneous behavioral discriminating pain stimuli, and it has the responsiveness. benefit of quantifying pain response in terms Here, with our platform we observed of intuitive behaviors (such as paw shakes, both homogeneity in behavioral responses guarding, etc). Demonstrating the across six genetically distinct mouse lines, as robustness of the platform, we identify two well as two outlier strains with responses outlier mouse strains that display reduced or that mapped outside the range of those six. heightened pain sensitivity, and we A wealth of prior literature demonstrated accurately measure a heightened pain state that individual differences in responsiveness when we simultaneously activate pain in the to pain in both mice and humans, are driven periphery and brain using chemogenetic and in part by allelic variation in genes natural stimuli. important for pain processing [28, 29]. In Behavioral neuroscience in model regards to the mouse, studies carried out organisms is undergoing a renaissance with twenty years ago testing pain sensitivity the emergence of new tools to automatically across 11 inbred lines using 12 behavioral track and measure behavior [11]. This read-outs, revealed that depending upon the renaissance is coincident with many in the sensory modality tested, and whether the research community questioning the test was performed before or after injury to robustness of rodent models of pain, the somatosensory system, genotype addiction, depression, anxiety, and other appeared to influence mouse pain behaviors neuropsychiatric disorders. In kind, many [30]. A meta-analysis from ten years ago researchers are taking steps backwards to described over 400 papers from mouse pain first properly understand the component research that implicated ~350 genes in pain parts of a complex behavioral sequence and analgesia [31]. However, with the before proceeding to identify the neuronal relatively limited resolution of some correlates that drive those motor patterns. conventional pain behavior assays, it Both supervised and unsupervised machine remains unclear how reliable some of these learning algorithms are now able to follow studies are and which potential target genes unlabeled individual limbs on an merit further development as novel experimental animal and automatically . This assertion is underscored by define behaviors of interest [12, 14, 15, 24- the fact that only a handful of targets that 26]. Although the majority of these tools have have shown promise in rodents, have made it yet to be adopted in mass by the pain to the clinic as novel therapeutics, causing research community, some of this technology many to question the robustness of the is already in use by pain researchers. For animal models used in pain testing [32, 33]. example, the automated grimace scale Here, we uncover a pain hypo-sensitive developed by the Mogil and Zylka labs uses a phenotype in 129S1 mice where the animals convolutional neural network trained with respond to pinprick stimuli similar to a soft 6,000 facial images of mice in “pain” or “non- brush or cotton swab. This finding could have pain”, to make accurate predictions of the major implications on transgenic mouse lines mouse pain state in novel datasets [27]. The built using embryonic stem cells from 129S1 automated grimace scale still requires mice, especially if sufficient backcrossing to additional customization to assess rodents of C57BL/6J is not performed. In other words, different coat colors and to measure chronic a pain phenotype may be mistakenly pain. Tools like the automated grimace scale attributed to knocking out a specific gene, that focus on the face, could be combined while the observed results may be the result

Page 13 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

of contamination by lingering DNA from the and to translate our basic science findings in 129S1 donor strain. pain research to improved patient outcomes, Conversely, we observe a phenotype the pain measurement tools in rodents must in the opposite direction, where SJL mice be robust. The platform described here respond to a soft brush as if it were a should aid in that pursuit. pinprick. To the best of our knowledge, this is the first report of a pain hyper-sensitivity FIGURE LEGENDS phenotype for SJL mice at baseline. Of note, SJL mice are known to be an aggressor Figure 1. Automated pain assessment mouse line and even in our studies some workflow in comparison to traditional animals had to be removed from testing due unidimensional pain scoring. a, to excessive fighting between cage mates Workflow pipeline in following order [34]. Therefore, future studies are necessary consisting of: 1) high-speed videography of to determine if the genetic repertoire that freely behaving mice, 2) machine/deep makes these mice aggressive also contributes learning based approaches for automatic to their heightened pain responses. Together, tracking of the stimulated paw, 3) PAWS with a more precise tool to measure acute software for automatic quantification of mechanical pain at baseline, we can begin to defined pain behavioral endpoints, 4) use this platform as a behavioral screening statistical modeling with LDA for separation tool followed by subsequent genetic mapping of touch versus pain on trial-by-trial basis. b, approaches. Traditional scoring focused on paw As a proof-of-principle to test the withdrawal frequencies to four mechanical robustness of our platform, we demonstrate stimuli: cs=cotton swab, db=dynamic brush, that we can chemogenetically activate the lp=light pinprick, hp=heavy pinprick. N=10 BLA pain ensemble and detect mice per strain. Images from Jackson hypersensitivity to peripheral stimuli. In laboratories. addition to confirming the precision of our technology, these experiments raise an Figure 2. Automated paw tracking with intriguing biological question: what is the high-speed recording of behavior. a-x, emotional and sensory experience of ProAnalyst machine learning based paw activating pain-responsive neurons without tracking. y-z¢, Social LEAP deep neural a peripheral injury? Would tonic activation of network based paw or toe tracking. All still this BLA pain ensemble be comparable to images represent a single frame of ~5,000 human experiences of ? Further total frames. Green and blue lines display studies to examine these questions are paw trajectory patterns during the entire ongoing. behavior. N=10/mice per stimulus and In summary, we have developed a images shown are representative of each rapid and user-friendly automated pain strain. assessment platform for measuring mechanical pain in mice. Since mechanical Figure 3. Quantification of behavioral stimulation of the rodent hind paw remains features for mouse pain state. a, Raw the most common method to measure pain in paw positions (x,y) measured in the camera mice, the tools described here, with the reference frame (anterior/posterior addition of a high-speed camera, are fully displacement and vertical height, compatible with the setups that most labs respectively) as a function of time, with the currently use. As such, we do not foresee time of first peak in paw height, t*, marked major hurdles in wide adoption of this in red. b, The principal axis of paw methodology. To increase our fundamental displacement in a moving time window, understanding of the neurobiology of pain, shown as a function of time. c, Displacement

Page 14 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

in the principal axis moving reference frame Figure 6. Automated pain assessment was used to quantify instances of paw platform uncovers two outlier strains. shaking in terms of sequences of a-d, ProAnalyst tracking showing 129S1 displacements above a given threshold mice responding with similar up-down paw relative to the maximum paw height lifts to all stimuli, both innocuous and displacement. noxious. e-h, ProAnalyst tracking showing SJL mice have pain-like response to dynamic Figure 4. Automated measurement of brush and heightened pinprick responses. i, pain behavioral endpoints across Leave-out-one (LOO) cross validation strains with new software PAWS. performs poorly in predicting the stimulus Measurements are converted to Z-score to received in 129 and SJL mice because their reveal deviation from mean of individual responses typically map outside of the measures and to standardize units across the normal range of the other 6 strains. eight measures. a-d, Pain measurements of the stimulated paw from lift to max height. Figure 7. Pain hypersensitivity with e-h, Pain measurements of the stimulated chemogenetic activation of the BLA paw from max height to paw return. pain ensemble automatically captured N=10/mice of each strain given each stimulus via PAWS. a, Schematic to permanently tag once. Statistical significance was computed pain-active neurons in the BLA with an by comparing CS+DB versus LP+HP with excitatory DREADD in transgenic Wilcoxon matched-pairs signed rank test. ** painTRAP2hM3 mice B. 4X image of specific represents p-value ≤ 0.01. **** represents p- and robust expression of m-Cherry-labeled value ≤ 0.0001. On the violin plots, black excitatory DREADD bilaterally in the BLA. horizontal lines represent quartiles and red c 20X image of BLA from b. Scale bars horizontal lines represent the median. represent 500µm. d-g, Automatic measurement of pre paw peak features Figure 5. a, First two linear discriminant comparing mice at baseline (-CNO) to mice dimensions that best separate the four pain administered CNO. (H-K) Automatic states studied: CS, DB, LP, and HP, for pre- measurement of post paw peak features peak features only. Ellipses show Gaussian comparing mice at baseline (-CNO) to mice 95% confidence region for each pain state. administered CNO. Stimulus abbreviations Univariate kernel density estimates for LD1 same as above. Statistical significance was and LD2 decomposed by pain state are computed with student’s t-test. *represents shown at top and right, respectively. b, Same p-value ≤ 0.05. ** represents p-value ≤ 0.01. as a but for post-peak paw features only. c, l-o, Linear discriminant analysis (LDA) Weights assigned to standardized (mean using similar factor loadings as described in subtracted, variance scaled) behavioral Fig.5 reveals separation of innocuous vs. features on the first linear discriminant noxious stimuli at baseline (-CNO) and a dimension (LD1) of the post-peak paw further segregation of the HP group after features LDA. d, Same as c but for LD2. e, CNO, only when using all 8 paw features. Leave-One-Out (LOO) cross-validation performance of the pre-peak and global METHODS LDAs, compared to automatically generated features via SVD, and a null model, for Mouse strains individual mice. f, Same as e, but leaving out an entire strain (colors) or an equivalent Mice for behavior testing were maintained in number of mice chosen uniformly at random a barrier animal facility in the Carolyn (gray). Lynch or Translational Research Laboratory

Page 15 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

(TRL) buildings at the University of hind paw proximal to the camera. Testing Pennsylvania. The Lynch and TRL only occurred when the camera’s view of the vivariums are temperature controlled and paw was unobstructed. Mice only received maintained under a 12 hour light/dark cycle one stimulus on a given testing day (cs, db, (7am/7pm) at 70 degrees Fahrenheit with ad lp, or hp) and were given at least 24 hours lib access to food (Purina LabDiet 5001) and between each stimulus session. Stimuli were tap water. All procedures were conducted tested from least painful to most: cotton according to animal protocols approved by swab, dynamic brush, light pinprick, heavy the university Institutional Animal Care and pinprick. Cotton swab tests consisted of Use Committee (IACUC) and in accordance contact between the cotton Q-tip and the with National Institutes of Health (NIH) hind paw until paw withdrawal. Dynamic guidelines. C57BL6/J, A/J, 129S1/SvlmJ, brush tests were performed by wiping a Balb/cJ, DBA/1J, AKR/J, CBA/J, SJL/J, and concealer makeup brush (e.l.f.TM, purchased TRAP2 mice (Fos-FOS-2A-iCre-ERT2) mice at the CVS) across the hind paw from back to were all purchased from Jackson front. Light pin prick tests were performed Laboratories. by touching a pin (Austerlitz Insect Pins®) to the hind paw of the mouse. The pin was High speed imaging withdrawn as soon as contact was observed. Heavy pinprick tests were performed by Mouse behaviors were recorded at 2000 sharply pressing this pin into the paw so that frames per second (fps) with a high-speed it was pushed upwards, without the breaking camera (Photron FastCAM Mini AX 50 the skin barrier. The pin was withdrawn as 170K-M-32GB - Monochrome 170K with soon as approximately 1/3 of the pin’s length 32GB memory) and attached lens (Zeiss had passed through the mesh. 2/100M ZF.2-mount). Mice performed

behavior in rectangular plexiglass chambers Automated paw tracking on an elevated mesh platform. The camera was placed at a ~45° angle at ~1-2 feet away We used ProAnalyst software to from the Plexiglas holding chambers on a automatically track hind paw movements tripod with geared head for Photron AX 50. following stimulus application. This software CMVision IP65 infrared lights that mice allowed us to integrate automated and cannot detect were used to adequately manually scored data, possible through the illuminate the paw for subsequent tracking ‘interpolation’ feature within ProAnalyst. We in ProAnalyst. All data were collected on a were able to define specific regions of interest Dell laptop computer with Photron FastCAM (paw), track, and generate data containing ‘x’ Analysis software. and ‘y’ coordinates of the paw through time, as well as velocity, speed, and acceleration Somatosensory behavior assays information. In a subset of videos, additional manual annotation was performed for Mice were habituated for a minimum of 5 increased accuracy. For deep learning-based days, for one hour each day, in the Plexiglas paw tracking with the Social LEAP holding chambers before testing commenced. algorithm, we pseudo-randomly chose a During baseline, mice were tested in groups small set of training frames from each video of five and chambers were placed in a row and hand-labelled the paw and toe. We with barriers preventing mice from seeing trained Social Leap to predict toe and paw each other. On testing day, mice were positions in unlabeled video frames (>~90% habituated for an additional ~10 minutes of total video frames). To generate before stimulation and tested one at a time. trajectories, we overlaid the inferred x, y Stimuli were applied through the mesh to the positions of the toe and paw in each video

Page 16 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

frame on a single still image corresponding paw height, t*, resulting in time series of to the apex of the mouse’s paw during the 4000 discrete measurements per paw assay. dimension (sampled at 2000fps). This representation was then compressed by a Development of PAWS software to factor of 87.5% by retaining only the first 500 quantify pain behaviors coefficients per spatial dimension of its discrete cosine transform (DCT-II), which Behavioral features were extracted from raw nonetheless maintained paw position paw position time series in an automated and accuracy to within 1.5 and 0.11cm RMSE in standardized procedure. First, the start and x (anterior/posterior) and y (height), end of paw movement (paw at rest on the respectively. A singular value decomposition ground) were identified, and analysis was of this compressed description (both x and y restricted to this time window. Peaks in paw dimensions combined per time series) was height were then determined based on used to load the correlated variation within Savitsky-Golay smoothed estimates of paw time series onto a small number of velocity, and the first peak identified. The dimensions ordered by decreasing variation time of the first peak (designated t*) was capture. The number of SVD dimensions used to separate pre-peak behavioral feature ultimately retained, 23, was determined by calculations from post-peak calculations. To choosing the dimensionality that maximized differentiate shaking from guarding in the the LDA probability correct under strain post-peak period, we constructed a moving leave-one-out cross-validation. reference frame based on the principal axis of paw displacement across a sliding window Drugs (0.04 seconds in duration) for each time 4-hydroxytamoxifen (Hello Bio, #HB2508) point, and identified periods of consecutive prepared in Kolliphor EL (Sigma, #27963), displacements above a specified threshold Clozapine-N-oxide (Hello Bio, #HB6149), and (35% of maximum paw height) as periods of 0.9% sodium chloride (Sigma, #S3014). shaking. Note that in the construction of the moving reference frame the principal axes of Viral Reagents variation were recovered via PCA, which is For chemogenetic manipulation of BLA pain- not invariant to the sign of the recovered active neurons, we intracranially injected axes. Since displacement is measured over 200 nL of AAV5-hSyn-DIO-hM3D(Gq)- time it is sensitive to reversals in sign along mCherry (Addgene, titer: 7 x 1012) into both the axis we measure it. We therefore ensured the left and right BLA at coordinates AP: -1.4 consistency by using the axis direction mm, ML: ±3.1 mm, DV: -4.2. minimizing the angular deviation from the axis recovered at the previous time step. Stereotactic injections and surgical procedures Automated behavioral feature selection We conducted surgeries under aspetic method using SVD conditions using a small stereotaxic As a point of comparison for the behavioral instrument (World Precision Instruments). measures quantified as pre- and post-peak We anesthetized mice with isofluorane (5% paw features using common measures from induction, 1-2% maintenance) during the the literature, we employed a simple, entire surgery and maintained body unsupervised machine learning technique to temperature using a heating block. We generate candidate behavioral features injected mice with a beveled 33G needle based directly on variation in the paw attached to a 10 µL syringe (Nanofil, WPI) for trajectory timeseries themselves. Time series delivery of 200 nL of viral reagent at a rate were aligned by the time of the first peak in of 40 nL/min. After viral injection, the needle

Page 17 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

remained at the injection depth for 10 7. Arcourt, A., et al., Touch Receptor- minutes before slow withdrawal over 2 Derived Sensory Information Alleviates minutes. After surgery, we maintained the Acute Pain Signaling and Fine-Tunes animal’s body temperature using a heating Nociceptive Reflex Coordination. Neuron, pad. 2017. 93(1): p. 179-193. 8. Blivis, D., et al., Identification of a novel

spinal nociceptive-motor gate control for Targeted recombination in active Adelta pain stimuli in rats. Elife, 2017: populations (TRAP) of BLA pain p. e23584. ensemble 9. Browne, L.E., et al., Time-Resolved Fast Transgenic female TRAP2 mice were injected Mammalian Behavior Reveals the with an AAV at P46-73. Two weeks after Complexity of Protective Pain Responses. injection, mice were stimulated with a Cell Rep, 2017. 20(1): p. 89-98. noxious pin prick on the left hind paw every 10. Abdus-Saboor, I., et al., Development of a 30 seconds for 10 minutes. One hour later, Mouse Pain Scale Using Sub-second mice were injected with 4-hydroxytamoxifen Behavioral Mapping and Statistical Modeling. Cell Rep, 2019. 28(6): p. 1623- (4-OHT) to induce genetic recombination. 1634 e4. Eight weeks following 4-OHT 11. Datta, S.R., et al., Computational administration, behavior of mice was Neuroethology: A Call to Action. Neuron, examined. Mice were sacrificed via 2019. 104(1): p. 11-24. transcardial perfusion 4 months after viral 12. Wiltschko, A.B., et al., Mapping Sub- injections. Brains were collected and Second Structure in Mouse Behavior. sectioned at 50 µm on a cryostat. Tissue was Neuron, 2015. 88(6): p. 1121-35. mounted and imaged on a fluorescent 13. Markowitz, J.E., et al., The Striatum Keyence microscope. Organizes 3D Behavior via Moment-to- Moment Action Selection. Cell, 2018. 174(1): p. 44-58 e17. REFERENCES 14. Pereira, T.D., et al., Fast animal pose estimation using deep neural networks. 1. Attal, N., D. Bouhassira, and R. Baron, Nature Methods, 2019. 16(1): p. 117-+. Diagnosis and assessment of neuropathic 15. Mathis, A., et al., DeepLabCut: pain through questionnaires. Lancet markerless pose estimation of user- Neurology, 2018. 17(5): p. 456-466. defined body parts with deep learning. 2. Melzack, R., The Short-Form Mcgill Pain Nature Neuroscience, 2018. 21(9): p. Questionnaire. Pain, 1987. 30(2): p. 191- 1281-+. 197. 16. Tiriac, A., et al., Rapid Whisker 3. Basbaum, A.I., et al., Cellular and Movements in Sleeping Newborn Rats. molecular mechanisms of pain. Cell, Current Biology, 2012. 22(21): p. 2075- 2009. 139(2): p. 267-284. 2080. 4. Deuis, J.R., L.S. Dvorakova, and I. 17. Libby, T., et al., Tail-assisted pitch Vetter, Methods Used to Evaluate Pain control in lizards, robots and dinosaurs. Behaviors in Rodents. Frontiers in Nature, 2012. 481(7380): p. 181-+. Molecular Neuroscience, 2017. 10. 18. Simpson, E.M., et al., Genetic variation 5. Severson, K.S., et al., Active Touch and among 129 substrains and its importance Self-Motion Encoding by Merkel Cell- for 'targeted mutagenesis' in mice. Brain Associated Afferents. Neuron, 2017. Research, 1998. 809(1): p. A20-A20. 94(3): p. 666-+. 19. Corder, G., et al., An amygdalar neural 6. Douglass, A.D., et al., Escape behavior ensemble that encodes the elicited by single, Channelrhodopsin-2- unpleasantness of pain. Science, 2019. evoked spikes in zebrafish somatosensory 363(6424): p. 276-+. neurons. Current Biology, 2008. 18(15): 20. Langford, D.J., et al., Coding of facial p. 1133-1137. expressions of pain in the laboratory

Page 18 of 19 bioRxiv preprint doi: https://doi.org/10.1101/2020.02.18.955070. this version posted February 19, 2020. The copyright holder for this preprint (which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission.

mouse. Nat Methods, 2010. 7(6): p. 447- 33. Woolf, C.J., Overcoming obstacles to 9. developing new analgesics. Nat Med, 21. Leo, S., et al., Differences in nociceptive 2010. 16(11): p. 1241-7. behavioral performance between 34. Miner, L.L., et al., Aggression Modulates C57BL/6J, 129S6/SvEv, B6129F1 and Genetic Influences on NMRI mice. Behavioural Brain Analgesia as Assessed Using a Classical Research, 2008. 190(2): p. 233-242. Mendelian Cross Analysis. 22. Lariviere, W.R., E.J. Chesler, and J.S. Psychopharmacology, 1993. 111(1): p. Mogil, Transgenic studies of pain and 17-22. analgesia: Mutation or background genotype? Journal of Pharmacology and Experimental Therapeutics, 2001. 297(2): p. 467-473. 23. Banik, R.K., et al., Strain and sex influence on pain sensitivity after plantar incision in the mouse. Anesthesiology, 2006. 105(6): p. 1246-1253. 24. Berman, G.J., et al., Mapping the stereotyped behaviour of freely moving fruit flies. J R Soc Interface, 2014. 11(99). 25. Graving, J.M., et al., DeepPoseKit, a software toolkit for fast and robust animal pose estimation using deep learning. Elife, 2019. 8. 26. Kabra, M., et al., JAABA: interactive machine learning for automatic annotation of animal behavior. Nature Methods, 2013. 10(1): p. 64-U87. 27. Tuttle, A.H., et al., A deep neural network to assess spontaneous pain from mouse facial expressions. Molecular Pain, 2018. 14. 28. Mogil, J.S., Pain genetics: past, present and future. Trends Genet, 2012. 28(6): p. 258-66. 29. Calvo, M., et al., The Genetics of Neuropathic Pain from Model Organisms to Clinical Application. Neuron, 2019. 104(4): p. 637-653. 30. Mogil, J.S., et al., Heritability of nociception I: Responses of 11 inbred mouse strains on 12 measures of nociception. Pain, 1999. 80(1-2): p. 67-82. 31. Lacroix-Fralish, M.L., J.B. Ledoux, and J.S. Mogil, The Pain Genes Database: An interactive web browser of pain-related transgenic knockout studies. Pain, 2007. 131(1-2): p. 3 e1-4. 32. Vardeh, D., R.J. Mannion, and C.J. Woolf, Toward a Mechanism-Based Approach to Pain Diagnosis. J Pain, 2016. 17(9 Suppl): p. T50-69.

Page 19 of 19