An amygdalar neural ensemble that encodes the unpleasantness of pain

Pain is an unpleasant experience. How the brain’s affective neural circuits attribute this aversive quality to nociceptive information remains unknown. By means of time-lapse in vivo calcium imaging and neural activity manipulation in freely behaving mice encountering noxious stimuli, we identified a distinct neural ensemble in the basolateral amygdala that encodes the negative affective valence of pain. Silencing this nociceptive ensemble alleviated pain affective-motivational behaviors without altering the detection of noxious stimuli, withdrawal reflexes, anxiety, or reward. Following peripheral nerve injury, innocuous stimuli activated this nociceptive ensemble to drive dysfunctional perceptual changes associated with neuropathic pain, including pain aversion to light touch (allodynia). These results identify the amygdalar representations of noxious stimuli that are functionally required for the negative affective qualities of acute and chronic pain perception.


Stereotaxic injections and surgical procedures Injection procedures for TRAP study animals
We conducted all surgeries under aseptic conditions using a digital small animal stereotaxic instrument (David Kopf Instruments). We anaesthetized mice with isoflurane (5% induction, 1-2% maintenance) in the stereotaxic frame for the entire surgery and maintained their body temperature using a heating pad. We injected mice with a beveled 33G needle facing medially, attached to a 10-μL microsyringe (Nanofil, WPI) for delivery of viral reagents at a rate of 20 nL/min for more precise targeting (e.g. of DREADD(hM4) expression) using a microinjection unit (Model 5000, Kopf). After reagent injection, the needle was raised 100 μm for an additional 10 min to allow the virus to diffuse at the injection site and then slowly withdrawn over an additional 3 min. After surgery, we maintained the animal's body temperature using a radiant heat lamp until fully recovered from anesthesia. encoder (Signswise 600P/R Incremental Rotary Encoder). We then lowered a custom-designed 1.0-mm-diameter microendoscope probe based on a gradient refractive index (GRIN) lens (Grintech GmBH) into the stainless steel cannula using forceps or a 27G needle attached to a vacuum line. We attached the miniature microscope onto a holder (Inscopix, Gripper Part, ID: 1050-002199) connected to a goniometer (Thorlabs, GN1) that allowed us to tilt the miniature microscope in x-z and y-z planes. We connected the holder to a three-axis micromanipulator and used it to lower the miniature microscope until we were in the microendoscope's focal plane. To determine an optimal part of the microendoscope to image neural activity, we made minor position adjustments of the miniature microscope in the x-y plane using the micromanipulator. To ensure the entire field-of-view was in focus, we adjusted the miniature microscope's tilt relative to the microendoscope. We used the imaging software (Inscopix, nVista 2.0) to display incoming imaging frames in units of relative fluorescence changes (∆F/F); this allowed us to observe Ca 2+ transient activity in the awake behaving mice. We checked for time-locked responses to both auditory (e.g. clap) and sensory (e.g. tail pinch) stimuli, along with any signs of indicator overexpression (i.e. brightly fluorescent neurons lacking Ca 2+ transient activity). Mice passing both tests moved onto mounting of the miniature microscope baseplate.

Miniature microscope baseplate mounting
In anesthetized (2% isoflurane in oxygen) mice that met the criteria described above, we fixed the microendoscope in place with UV curable epoxy (Loctite(R) Light-Activated Adhesive #4305) and stereotaxically lowered the miniature microscope, with the baseplate attached, toward the top of the microendoscope until the brain tissue was in focus. To ensure that the entire field-of-view was in focus, we used a goniometer (Thorlabs, GN1) to adjust the orientation of the miniature microscope until it was parallel to that of the microendoscope. To fix the baseplate onto the skull, we built a layer of blue-light curable composite (Pentron, Flow-It N11VI) from the dental cement on the mouse's skull toward, but not touching, the baseplate, followed by a layer of UV-curable epoxy (Loctite(R) Light-Activated Adhesive #4305) that affixed the baseplate to the composite. To prevent external light from contaminating the imaging field-of-view, we coated the outer layer of the composite and UV glue with black nail polish (OPI, Black Onyx NL T02). We attached a custom-designed cover (LaserAlliance, 16G thickness stainless steel) to the baseplate to protect the microendoscope. After surgery, mice recovered from anesthesia on a heating pad (FHC, DC Temperature Regulation System). For animals run through the protocol of Fig. S3B, we implanted the microendoscope and mounted the baseplate as described in (19); we had previously run these mice (n = 8), and only these mice of Fig. S3B, through a behavioral and imaging protocol as described in (19).

Integrated miniature microendoscope imaging and animal test procedure
Miniature microscope behavioral protocol After mounting the miniature microscope onto a mouse and checking for adequate GCaMP6m expression, we habituated each mouse to the testing environment for at least three days prior to imaging. To preclude any emotional contagion between mice, we brought only one mouse into the isolated, light-, sound-and temperature-controlled testing environment. Further, we housed mice individually.
The experimental procedure for mice (n = 9) analyzed in Figs. 1 and 3 is described below. A general outline is shown in Fig. S3A, C. The experimenter stayed in the testing environment throughout habituation to limit variations related to stress. The main protocol consisted of three or four imaging sessions performed on non-consecutive days (days -7, -5, -3, -1 or -6, -4, -2 pre-SNI) to allow animals to recover, and to reduce photobleaching resulting from long imaging sessions.
At the start of each imaging session, we head-fixed the mouse (using a Siskiyou CC-1), mounted the miniature microscope, checked for GCaMP6m fluorescence, aligned the field of view (FOV) to the previous session FOV, and placed the mouse within the test chamber. Before sensory stimulation, we measured spontaneous neural activity by recording Ca 2+ activity for 10 min while the mouse habituated to, and freely moved within, the testing box. The mouse received no explicit experimenter-delivered sensory stimuli during this period. After baseline recording, the mouse had 15 min of access to an incentive (sucrose) to capture BLA neural responses to positive valence stimuli. To induce mice to lick without needing prior water deprivation, we used a 10% sucrose solution. We detected licks and delivered sucrose using a custom-built circuit based on a previous design (69). A custom electronic circuit (built using Arduino elements) collected lick data and synchronized all incoming data using output TTL pulses from the miniature microscope DAQ. Control signals from this circuit drove a solenoid (NResearch, 161P011) that delivered 10% sucrose instantly after the 1 st lick in a bout. We programmed a 5-s-period between liquid deliveries. Thus, even if the mouse licked continuously, this approach provided a sufficient interval between incentive deliveries to relate the evoked neural activity with specific delivery time points.
Next, the mouse began the sensory testing protocol, in which the experimenter delivered a battery of stimuli: 0.07g and 1.4-or 2.0-g von Frey hairs (light and mild touch); 25G needle (noxious pin prick); water drops at 5ºC or acetone (noxious cold), 30ºC (innocuous liquid, for Fig. S3A animals [n = 2]), and 55ºC (noxious heat) delivered via applying a small drop from a 1-mL syringe; fake-out stimuli where no contact was made ("Approach/No contact"); and noise (startle response control). We delivered all stimuli 15 times per session, except "Approach/No contact" and noise, which we delivered 9 times each. See Fig. S3 for details about timing information related to individual stimuli and stimuli blocks. We wrote custom code in the R computing environment to design a randomized stimulus delivery protocol for each session, subject to the following constraints: light touch, noxious cold, mild touch, and innocuous liquid or noxious heat had a set order at the beginning; the same stimuli could not have adjacent stimuli blocks; and "Approach/No contact" stimuli blocks would occur during the first 3 main stimuli super-blocks. We measured withdrawal reflexes and affective-motivational behaviors (attending and escape) using high-speed cameras (AVT Guppy Pro F-125 1/3" CCD Monochrome Camera #68-567 or The Imaging Source DMK 23FM021) and accelerometers (Sparkfun ADXL335 or ADXL345, with data collected using an Arduino Uno or Saleae Logic 8). We included "Approach/No contact" trials to detect possible BLA responses related to expectation of stimulus delivery and error-prediction. These "Approach/No contact" imaging trials consisted of bringing either a 0.07-g von Frey hair, a 25G needle, 1-mL syringe, or a 85-dB noise delivery device toward the animal but neither making contact nor turning on the noise. We randomly interspersed "Approach/No contact" trials between other stimuli blocks. To control for the possibility that the BLA hindpaw stimuli responses were startle-induced, we used a loud tone (~80-85 dB) as an aversive but non-nociceptive sensory stimuli. We delivered the tone (centered around 4 kHz) for 300 ms by triggering an Arduino, loaded with custom code, to drive a TDK PS1240 Piezo Buzzer.
Subsequently, Fig. S3A, C mice underwent a modified spared nerve injury (SNI) surgery (see 'Chronic neuropathic pain model' below for a description of the surgical procedure) (70). We then repeated the sensory testing protocol and recording of neural activity at 3, 7, 14, 21, 28, 35, 42 days post-surgery, as thermal and mechanical hypersensitivity developed and persisted ( Fig. S4E-F). After SNI, mice started showing pain affective-motivational responses such as attending or escape behaviors when experimenters stimulated the injured paw with an innocuous 0.07-g von Frey hair (mechanical allodynia) or 5ºC water droplet (cold allodynia). At times, mice also displayed increased pain affective-motivational responses when stimulated with a sharp pin (mechanical hyperalgesia) or 55ºC water (heat hyperalgesia).
For mice given the procedure in Fig. S3B, a simplified protocol allowed assessment of the interaction between BLA neuron response to innocuous and noxious stimuli. Before stimulation, we measured background neural activity by recording Ca 2+ activity for 15 min while each mouse freely explored a 17.78 cm × 19.05 cm box. We then transferred each mouse to the behavior testing chamber (10.16 cm × 15.24 cm) where it habituated for ~5 min. We then delivered a battery of stimuli starting with three superblocks, in which 0.07-g (light touch), 0.4-g (moderate touch), and 2.0-g (mild touch) von Frey filament stimuli were each given ten times at intervals of 30 s with 60 s between stimuli blocks and 3 min between superblocks. Next, we applied drops of acetone (noxious cold) 10 times at 60 s intervals followed by pricking the skin with a 25G needle (noxious pin) 10 times. Mice then underwent the SNI surgery and were imaged at days 3, 7, 14, and 21 post-surgery.

Miniature microscope behavior recording hardware
For animals run through the procedure in Fig. S3A, C, we synchronized all incoming data in the following manner. The miniature microscope acted as the master controller of event timing as we considered time locking to Ca 2+ activity the most critical feature. We had two hardware setups for collecting all relevant behavior videos, stimulus delivery times, and accelerometer data: one relied on a set of Arduino microcontrollers and the other one used two Saleae Logic 8 (SL8) along with helper Arduinos. In both setups two cameras recorded mouse behavior and were positioned either below the mouse, to capture stimulus delivery and reflexive responses, or facing the test chamber, to capture the mouse's affective-motivational behaviors. In the first setup ( Fig. S3A mice), the miniature microscope DAQ output a TTL that drove both cameras by triggering interrupt pins on an Arduino Uno, which then drove each camera, allowing us to synchronize each camera video frame with the Ca 2+ imaging data. We used the Image Acquisition Toolbox in MATLAB (Mathworks) to collect TTL triggered video frames from each camera. A separate Arduino Mega element collected information on stimulus delivery times via a custom circuit that allowed the experimenter to select the current stimuli, using a keyboard (Adafruit, Product ID #1824) and LCD display (Adafruit, Product ID #772), and to click a button upon stimulus application to record the delivery time for later analysis. A third Arduino Uno measured the analog voltage signal from the accelerometer (Sparkfun ADXL335 or ADXL345) attached to the miniature microscope. The last Arduino measured the onset of licks and sent control signals to open a solenoid (NResearch, 161P011) to release sucrose. Both accelerometer and stimulus Arduino outputs had internal session times based off of each Arduino's internal clock as well as from the miniature microscope frame number (via the TTL) included in their output; we used the miniature microscope frame numbers to do the final synchronization in later analyses with the miniature microscope Ca 2+ imaging data. Each data-collecting Arduino received a synchronizing TTL signal from the miniature microscope's DAQ and streamed data to a PC where we saved the information using a custom MATLAB script.
In the second setup ( Fig. S3C mice), the first SL8 measured analog outputs from the miniature microscope attached accelerometer (100 Hz sample rate, see Fig. 1A), connected via a four-(Daburn Electronics & Cable, #2714/4) or a five-(Daburn Electronics & Cable, #2714/5 or Cooner Wire Company NMUF5/36-2550SJ) conductor wire; simultaneously, we recorded in the same SL8 timestamps for the onsets of licks and control signals for sucrose delivery (triggered on the rise of each signal pulse to obtain exact timing information). To collect the latter data, we designed a separate circuit consisting of two Arduinos (Uno and Mega) and a custom lick detector that measured the mouse's licks (signal #1) and sent a control signal (signal #2) to turn on a solenoid. The first SL8 recorded both signals #1 and #2. The second SL8 collected stimulusonset times from a custom-designed circuit that allowed experimenters to select a stimulus and press a button to timestamp when they delivered a particular stimulus. Saleae software (Logic 1.2.xx) recorded and saved all data from each SL8. We wrote custom Python and MATLAB scripts to extract the data for use in subsequent analysis.
For all mice, we manually checked each session's annotated stimulus-onset time, using a custom MATLAB program to scroll manually through a video recorded from a camera positioned below the mouse. Using this program, we corrected instances in which the annotation did not match the actual onset time of stimulus delivery. To ensure accuracy, we frame-locked this camera to the miniature microscope by triggering each video frame collected by the microscope's DAQ 'sync out' TTL line. We used the stimulus timestamps collected in the imaging sessions of Fig. S3A, C mice to automatically jump to the estimated stimulus onset time frame in the behavioral video, which facilitated the manual determinations of stimulus onset-times.

Miniature microscope recording parameters
We recorded all miniature fluorescent microscope videos at a frame rate of 10 or 20 Hz using between 213 ± 3 and 390 ± 7 μW LED light intensity (measured from miniature microscope GRIN with a Thorlabs PM100D and S120C) and saved each frame as a 12 bit image (of varying size, analyzed in a range of 250-275 × 250-270 pixels after down-sampling in each spatial dimension by a factor of 4 from the raw data). We used a stage micrometer (WARD's Natural Science, 94 W 9910) to empirically calculate each pixel to be 2.51 μm × 2.51 μm.

Noxious and aversive stimuli experiments
We delivered a range of noxious, aversive, and appetitive stimuli to animals (Fig. S8): noxious cold (acetone), noxious heat (~55°C water), noxious pin (25G needle), air puff (300 ms), isopentylamine (~85 mM in H 2 O, delivered via 300-ms air puff), loud noise (~85 dB for 300 ms, same as previously described), electric footshock (0.6 mA for 2 s), quinine (0.06 mM), and 10% sucrose. We habituated mice to a fear conditioning test chamber, similar to our previous setup (19), for 30 min on four consecutive days prior to conducting experiments. After mounting of the miniature microscope, we allowed mice to habituate for 10 min to the test chamber, followed by an additional 10 min of ad libitum access to 10% sucrose. We then followed the test procedure outlined in Fig. S8A and used the same data collection hardware as in Fig. S3C. Because the main behavior chamber and the fear conditioning chambers were in separate rooms, we allotted time for the mouse to re-habituate to the fear conditioning chamber for 10 min after the ad libitum quinine access. We cleaned all chambers with 70% ethanol before each experimental procedure.
We delivered noxious cold (acetone), noxious heat (~55°C water), noxious pin (25G needle), and loud noise (~85 dB) as described above. Isopentylamine (Sigma-Aldrich SKU #126810, CAS #107-85-7) is an odor shown to be aversive in multiple previous studies (71)(72)(73). We placed 50 µL of isopentylamine onto a small piece of tissue paper (Kimtech, #05511) and placed this immediately into a 10-mL blood serum tube (Fisher # 02685A) and re-capped. We then inserted two 16G needles through the tube cap and attached these to a valve (Gems Sensors and Controls, MB202-VB30-L203) controlling air delivery to a metal tube used to manually direct odorant to animals in the test chamber. We delivered air puffs through a blunt, 16G needle. We delivered both isopentylamine and air puff for 300 ms with medical-grade compressed air (UN1002) at between 20 to 30 PSI. We aimed isopentylamine and air puff stimuli during delivery at the nose and front half of the face, respectively. Mice received quinine (0.06 mM in deionized water (74)) after licking a metal tube in an identical manner as 10% sucrose but through a different tube to avoid contamination. For footshock trials, we habituated mice for 10 min followed by five deliveries of a 0.6-mA electric footshock, with 2 min between each stimulation. To synchronize the onset time of each footshock with Ca 2+ imaging data and each behavior cameras' videos, we collected TTLs output by the miniature microscope DAQ and footshock software (Freeze Frame, Actimetrics) on a Saleae Logic 8 DAQ box, which allowed us to determine the specific image frames of the Ca 2+ video that were synchronous with each footshock. We collected all subsequent data, processed the Ca 2+ videos, and performed analyses as in the main protocol used in Fig.  S3.

Clozapine-N-oxide control experiments
To check for possible alterations of neural activity in the presence of CNO alone (i.e. no hM4 expression), we conducted a shortened version of the main protocol ( Fig. S11D-G). We injected mice with CNO (10 mg/kg), then placed them back in their home cage. After approximately 25 min, we mounted the miniature microscope on the mouse's head and placed them within the test chamber. They habituated for 10 min followed by ad libitum access to 10% sucrose solution delivered in the same manner as previously described. Mice then received a battery of stimuli: light touch (0.07-g von Frey filament), noxious pin (25G needle), or a loud noise (~85 dB, same as previously described). We collected all subsequent data, processed Ca 2+ imaging movies, and performed analysis similar to the main protocol used in Fig. S3.

Processing Ca 2+ imaging videos and identifying neurons
Pre-processing of Ca 2+ movies We processed all Ca 2+ imaging data in the MATLAB software environment using methods similar to previous studies (19,20). To reduce computational processing times and boost signal-to-noise, we down-sampled imaging movies collected from the miniature microscope in both x and y lateral spatial dimensions using 4 × 4 bi-linear interpolation. To remove motion artifacts, we registered all frames in an imaging session to a chosen reference frame using Turboreg (75). Rather than register the entire frame, we selected and registered a sub-region of the field-of-view; this allowed us to choose a region with high-contrast features and without artifacts (e.g. dust particles on the optics) that could impede registration.
To improve the performance of motion correction, we first normalized the image frames by subtracting from each frame its mean value. We then spatially bandpass-filtered each frame of the movie (cutoff frequency: ~0.10-0.16 cycle/μm using a Gaussian cut-off filter, which highlighted spatial features at the ~6-10 μm scale). We performed an image complement operation on each frame, by subtracting each pixel value from the maximum pixel value in that frame (i.e. dark areas became light, and vice versa); this inverted the image and generally made the blood vessels and other dark static features appear more prominently, which benefited image registration. We obtained two-dimensional spatial translation coordinates from Turboreg by having the algorithm compare each processed frame to a reference frame (the 100 th movie frame). We then used the translation values so obtained for each image frame to register the raw Ca 2+ movie, but pre-processed in a different manner so as to aid cell extraction, rather than spatial registration.
To facilitate cell extraction, we divided each frame of the raw Ca 2+ movie by a low-frequency bandpass-filtered version of itself (cutoff frequency: ~0.0014-0.0063 or ~0.0014-0.01 cycle/μm using a Gaussian cut-off filter). This served to diminish neuropil and other background fluctuations. We then registered the resulting image frames using the two-dimensional spatial translation coordinates obtained previously.
Since motion correction can cause the movie edges to take on inconsistent borders due to variable translations, we determined the maximum amount all frames were translated during the motion correction procedure in each dimension (t max ) and then added a border of size t max pixels extending from the edge of each frame toward the middle of the frame. We set a maximum border size (t max ) of 14 pixels (~35 μm). We converted each movie frame to relative changes in fluorescence using the following formula: , where F 0 was the mean image over the entire movie. Lastly, we temporallysmoothed each movie by down-sampling from the original 20 or 10 Hz to 5 Hz; specifically, for a x × y × t movie, we bilinearly down-sampled in x × t to reduce computational processing times, which is equivalent to performing a 1D linear interpolation in time of the intensity values at each pixel.

Extraction of neuron shapes, locations, and activity traces
After processing each session's Ca 2+ imaging videos, we computationally extracted individual neurons and their activity traces using the PCA-ICA algorithm (76). We used the following parameters for PCA-ICA: μ = 0.1 and a maximum of 750 iterations. The parameter μ is the relative weight of temporal information in ICA, and μ = 0.1 indicates we performed a spatio-temporal ICA with greater weight given to the spatial than to the temporal skewness. The algorithm output a series of candidate spatial filters (x × y × n) and temporal traces (n × t)-where n is the number of neurons, t is the frame, and (x, y) are spatial dimensions-associated with temporally varying sources, which we then manually verified as neurons.

Manual neuron identification
For all imaging sessions analyzed in this study, we used neurons manually identified by a single human scorer. For each imaging session, we loaded a custom MATLAB GUI that displayed the spatial filter and activity trace of each candidate cell, along with the candidate cell's average Ca 2+ transient waveform. The human scorer also viewed a maximum projection image of all output spatial filters (Fig. S2F), on which the currently selected candidate cell was highlighted.
In addition, we noted that ICA (and other neuron extraction algorithms) often yielded candidate sources with images and activity traces that look highly similar to those of real neurons but that are actually associated with neuropil or other sources of contamination in the movie. Thus, we added another GUI interface to avoid including these false positives. Specifically, we cropped the movie to a 31 pixel × 31 pixel (~78 μm × ~78 μm) region centered on the centroid of each candidate cell; we then created movies containing 10 frames before and after the onset of an individual peak in the candidate Ca 2+ activity trace to help visualize actual transient-related activity in the movie. Each ICA output had up to 24 of these movies created based on each output's highest signal-to-noise (SNR) peaks. We spatially concatenated all of these movies associated with a specific ICA output to create a montage movie that allowed the human scorer to view movie data associated with peaks in the activity trace for each output at once, which eased decision-making. We used several criteria to classify an ICA output as a neuron: minimal overlap of an output's spatial filter with blood vessels or other contaminating signal sources, resemblance of each output's spatial filter to a 2D Gaussian or an expected neuron shape based on prior knowledge (Fig. S2E, "spatial filters"), similarity of the spatial filter to activity within the movie and proximity of output's centroid to movie activity (Fig. S2E, "activity in movie"), and similarity of the average transient waveform to a typical Ca 2+ transient waveform as observed using GCaMP6, such as a fast rise time followed by a slow decay (Fig. S2E, "activity traces"). Using these criteria, on average a human scorer manually determined 39 ± 1.4% (n = 138 imaging sessions) of ICA outputs to be neurons (Fig. S2F).
For animals in which the internal capsule was present and neurons from the piriform cortex were within the imaging plane, we used a custom MATLAB GUI to manually selected a region corresponding to the location of putative BLA neurons and excluded all other neurons in the imaging plane not within this region (Fig. S2D). We used an additional criterion regarding the cellular activity rate, since the piriform cortex often had higher overall rates of activity than BLA neurons that made them distinguishable. All references to 'neurons' within the context of miniature microscope imaging in this study refers to these manually curated BLA neurons from PCA-ICA and subsets therein ( Fig. S2D-F).

Ca 2+ transient detection and activity trace binarization
To detect Ca 2+ events (used in analysis of movement-related, stimulus-induced, and spontaneous neuronal activity), we used a threshold-crossing algorithm similar to previously described methods (20). To reduce detection of spurious, high SNR noise, we spatially smoothed the signal by averaging over a 600 ms sliding window. To remove baseline fluctuations, we calculated a sliding median (40 s window) and subtracted this from the activity trace. To capture transient events during the rise time, we took the time-derivative of the resulting trace, calculated the standard deviation (σ) for each signal, and identified any peaks that were ≥2.5 s.d. above baseline noise while enforcing a limit of a minimum inter-event time of >10 frames (2 s). We created a binarized activity vector for each neuron in which all frames associated with candidate peaks were assigned values of one and all other non-event frames assigned values of zero. We concatenated all n neurons binarized activity vectors into an n × f matrix that we used in subsequent analysis, where indicated.

Calculation of spontaneous firing rate
To assess whether the spontaneous firing rate of BLA neurons changed. For all mice run through the Fig. S3 protocols and with available baseline miniature microscope imaging session data (either 10 or 15 min), we calculated the mean event rate irrespective of the animal's movement, or other states, during the baseline period. For all mice, we defined Ca 2+ transients as in "Ca 2+ transient detection and activity trace binarization" and determined the mean Ca 2+ event rate by calculating the mean rate of Ca 2+ transients during the baseline period for each neuron. To calculate the mean Ca 2+ event rate across the neuron population, we took the mean over all neurons' spontaneous rates. To compare spontaneous rates across mice, and before and after the mice were in a neuropathic state, we first calculated the mean population firing rate of all pre-SNI orsham surgery sessions for each mouse individually. We then used this mean value to normalize the spontaneous Ca 2+ population event rates measured for the same animal during all subsequent imaging sessions (Fig S15A-B). We calculated the nociceptive ensemble firing rate (Fig S10A-B) identically, but the final population rate only included neurons within that session that were classified as within the nociceptive ensemble (see Definition and calculation of nociceptive ensemble).

Identification of responsive neurons
To determine which neurons significantly responded to a given stimuli, we took neuronal activity data (PCA-ICA output traces) from a 2-s-post-stimulus interval for all trials (creating a n × t × f matrix, where n = number of neurons, t = number of trials, and f = number of frames per trial) and binned it into 1-s bins by taking the mean of each bin's ∆F/F activity. For each cell, we then compared the binned activity response values to those in an identically binned 2-s window from -5 s to -3 s before the stimuli. We pooled this activity across all presentations of a specific stimulus and calculated a p-value for each neuron using a one-tailed Wilcoxon rank-sum. We designated any neurons for which P < 0.01 as being significantly responsive to a given stimulus.

Definition and calculation of nociceptive ensemble
We defined the BLA nociceptive ensemble in two ways throughout this study. For studies of mice in a normal, non-neuropathic state (Fig. 1), we defined the nociceptive ensemble as consisting of neurons responsive to noxious pin (25G needle), noxious heat (55°C water), or noxious cold (5°C water). When mice were in a neuropathic state or had undergone a sham surgery (Fig. 3), we defined the nociceptive ensemble as neurons responsive to either noxious pin or noxious cold (5°C water or acetone) (Fig. S3A, C animals) or to either noxious pin or acetone (Fig. S3B animals). In all cases, we separately assigned stimuli responsive neurons to the nociceptive ensemble for each session using the above definitions. First, we identified significantly responding neurons (see Calculation of stimuli responsive neurons) for each stimulus individually, and then we identified neurons responding to any stimuli within the above definitions as part of that session's nociceptive ensemble. For specific cases as noted within the text, we restricted subsequent analyses to neurons within the nociceptive ensemble.

Spatial distributions of significantly responsive neurons
To calculate the spatial distributions of significantly responsive neurons, we first computed each neuron's centroid location. For each neuron's x × y spatial filter output by PCA-ICA, we binarized the image by calculating the maximum value and set all values below 50% of this value to 'zero' (not part of the neuron) and the remainder to 'one' (part of the neuron). We then set to 'zero' any pixels not connected to the maximum value using a union-finding algorithm implemented in a standard MATLAB function. The x and y coordinates for all parts of each neuron's spatial filter image that are still labeled 'one' were found and multiplied by their true values in the original spatial filter imaged. We then calculated the arithmetic mean of each dimension's weighted coordinate vector and rounded it to the nearest whole pixel value. This allowed us to obtain centroids that are centered closer to the peak intensity of the spatial filter. We converted all neuron centroid pixel values to metric units (2.51 μm/pixel) and computed the full pairwise Euclidean distance matrix for all neuron-neuron pairs in a session. We then binned distances in 1-μm increments and the empirical cumulative distribution calculated for both all neurons and only for neurons significantly responsive to each stimuli (Fig. S5H).

Cross-day analysis of BLA neuronal activity
To match neurons across days we implemented a multi-step algorithm similar to previously published work (19,20). We thresholded spatial filters from PCA-ICA by setting to zero any values below 40% the maximum for each spatial filter and used these thresholded filters to calculate each neuron's centroid, see "Spatial distribution of significantly responsive neurons and neuron centroid calculation". We modified that procedure for cross-day alignment by not rounding each neuron's centroid coordinates to the nearest pixel value in order to improve accuracy of cross-day alignment. We created simplified spatial filters that contained a 10-pixel-radius circle centered on each neuron's centroid location; this allowed us to register different days while ignoring any slight day-to-day differences in PCA-ICA's estimate of each neuron's shape even if the centroid locations were similar.
For each animal, if we had N sessions to align, we chose the N/2 session (rounded down to the nearest whole number) to align to (align session) in order to compensate for any drift that may have occurred during the course of the imaging protocol. For all other imaging sessions, we first created two neuron maps based on the thresholded spatial ("thresholded neuron maps") and 10-pixel-radius circle ("circle neuron maps") filters described above (see Fig. S6A) by taking a maximum projection across all x and y pixels and spatial filters (max in 3 rd dimension of x × y × n neuron filter matrix, where n = neuron number). We registered these neuron maps to the align session using Turboreg (75) with rotation enabled for all animals and isometric scaling enabled for a subset of animals in cases where that improved results. First, we registered the thresholded neuron maps for a given session to the align session. Second, we used the output 2D spatial transformation coordinates to also register the circle neuron maps followed by registration of the circle neuron map with that animal's align session. We applied the resulting 2D spatial transformation coordinates to the thresholded neuron map. We repeated this procedure at least five times (Fig. S6A). We used the final registration coordinates to transform all spatial filters from that session so they matched the align session's spatial filters and repeated this process for all sessions for each animal individually.
After registering all sessions to the align session, we then re-calculated all the centroid locations as described above. We set the align session centroids as the initial seed for all global cells. Global cells are a tag to identify which neurons are matched across imaging sessions; for example, global cell #1 might be associated with neurons #1, #22, #300, #42, and #240 across each of five imaging sessions, respectively. Starting with the first imaging session for an animal, we calculated the pairwise Euclidean distance between all global cells' and the selected session's neurons' centroids. We then determined any cases in which a global cell was within 5 μm (nominally ~2 pixels) of a selected session's neurons. In such cases, the algorithm added that neuron to that global cell's pool of neurons, the global cell's centroid re-calculated as the mean location between all associated session neurons' centroid locations, and any unmatched neurons in that session annotated as new candidate global cells. We repeated this process for all sessions associated with a given animal (see Fig. S6A-C).
After assigning all neurons across all animal's imaging sessions to a global cell, we then conducted a manual visual inspection of each animal's cross-day registration. We removed imaging sessions that did not align well with other sessions associated with a particular animal. This lead to us removing n = 42 sessions from this analysis across all Fig. S3 mice. In addition, to quantify our alignment accuracy, we calculated the pairwise distance between all session neurons' centroid locations that are associated with a common global cell and showed that the majority of alignment was below 5 μm ( Fig.  S6D-E). We further confirmed this by taking all global cells associated with at least two or more neurons and comparing their associated neurons' centroid location with the global cell's centroid location (Fig. S6F).
To calculate the number of sessions a global cell responded to specific stimuli, we used the classification of significantly coding neurons in "Determination of significantly responding stimuli neurons". We then checked for each global cell the number of sessions it responded to a given stimuli while ignoring any global cells who only had activity on a single session ( Fig. S6G-I). To calculate maximum duration of stimulus responsivity, and because not all sessions were run exactly on the specified protocol days, we used the actual date the imaging session took place on to calculate both the earliest and latest date that a global cell significantly responded to each stimuli and took the difference to obtain a measure for how long a neuron stably coded for said stimuli (Fig. S6J).

Analysis of the overlap in neural ensembles responsive to different stimuli
We sought to determine whether the neuronal ensembles responsive to two different stimuli were consistent with a hypothesis of statistical independent coding channels. To test this hypothesis, we needed to compute the likelihood that statistically independent assignments of cells' coding identities would yield the observed level of overlap in the two coding ensembles. There are two ways to calculate the expected level of overlap under an assumption of independence. Prior methods used bootstrapping to estimate an empirical null distribution and compared the actual overlap to that. Here we introduce an alternative, exact solution.
We calculated the extent to which the observed overlap was unexpected by chance as a specific instance of the classic statistics thought-experiment of drawing without replacement balls from an urn containing black and white balls. In our case, we had a population of N neurons and were seeking the probability, p, of having k successes (number of significant neurons for stimulus #2) in a population with pre-defined K successes (number of significant neurons for stimulus #1) in n drawings (number of significant neurons for stimulus #2). Using the hygecdf and hygestat functions in MATLAB, we calculated p and the expected number of overlap neurons given the actual number of significantly responsive neurons observed for stimuli #1 and #2 (Fig S9C). We validated the results through comparisons to shuffle tests based on the same parameters and using 1,000 rounds of 1,000,000 shuffles to construct bootstrapped distributions (Fig. S9D). Because the two methods attained nearly identical results, we used the hypergeometric distribution instead of shuffle tests to reduce computational processing times and to obtain an exact p-value.
To determine whether the overlap in coding ensembles became more expected than chance, either before or after spared nerve injury (Fig. S15E), we performed Wilcoxon rank-sum tests in the R programming language using a Benjamini-Hochberg multiple comparisons correction (77) to identify whether the overlap differed significantly that expected by chance (see Fig. S9E).

Analysis of accelerometer traces
We collected quantitative measurement of animal movement in response to stimuli using a custom 3D printed part (Stratasys Objet30 printer, VeroBlackPlus material) to attach a tri-axial accelerometer (Sparkfun, ADXL345 or ADXL335 accelerometer) to the miniature microscope body (Fig. 1A). We recorded accelerometer x, y, and z channel data using either an Arduino running custom code (20-Hz sample rate) or a Saleae data acquisition device (Logic 8, 100-Hz sample rate) and synchronized each with Ca 2+ imaging data using TTL pulses from the miniature microscope DAQ box. We store the output voltage from the accelerometer for later analysis at 10-bit resolution (1024 value range, for both Arduino and Saleae setups). For accelerometer data recorded with the Saleae box, we down-sampled to 20 Hz by slicing the 100-Hz data into 50-ms bins and taking the mean value within each bin. We used a median filter (4 frames wide) to remove noise in each accelerometer channel. As we did not know the orientation of the accelerometer at all times, and to remove the static acceleration due to gravity (78), we high-pass filtered (zero-phase 3rd-order Butterworth, 0.5-Hz cut-off frequency) the entire accelerometer x, y, and z channel digital signal. We then computed total acceleration (A t ) using the following equation: Where a x , a y , and a x indicate the x, y, and z accelerometer output channels. To reduce noise, we zero-phase lowpass filtered the total acceleration in MATLAB (butterworth, 1-Hz cut-off, 3 rd order). We down-sampled the resulting total acceleration from 20 Hz to 5 Hz by binning the 20-Hz data into 200-ms sections and calculating the mean acceleration within each section. For cases in which we used Z-scored acceleration, we calculated the mean ( ) and standard deviation ( ) response for 3-5 s before the stimuli and computed the Z-score for the 5 s before and after the stimuli using the following equation: Where t is the frame relative to stimulus onset. We then compiled acceleration data for all animals (n = 9, 8-11 sessions each) before and after spared nerve injury (Fig. S4A, C-E). To determine whether animals had moved statistically more than chance, before and after spared nerve injury, we calculated the mean session response per animal in a 2-s window after each stimulus and compared it to a baseline from 3-5 s before each stimulus. We determined significance by calculating all p-values < 0.05 using a Wilcoxon rank-sum test with Benjamini-Hochberg multiple comparison correction. When calculated across all eight stimuli (plus background), we found that light touch showed significant increases in behavioral responses (Fig. S4D, E).
We compared accelerometer data for each stimulus from Fig. S3A, C mice to human scored data (see below and Fig. S4C) by calculating the % of that stimuli's trials in a session the animal scored as responding to a stimulus and comparing this to the mean acceleration for that stimuli across all trials in the same session. For the comparison for sessions pre-SNI or -sham surgery (Fig. 1E), we found that the two measures were highly correlated (Spearman's ρ = 0.79, p-value < 0.001) and that in the case of both no injury and neuropathic mice that the accelerometer offered a greater dynamic range to separate noxious stimuli that otherwise saturate with the binary human behavior scoring measure (see inset in Fig. S4C).

Manual scoring of miniature microscope behavior videos
We visually identified nociceptive reflex responses in each mouse's video session recordings obtained in the miniature microendoscope studies. We used a similar identification procedure to that outlined in "Behavioral quantification of acute and chronic pain behaviors". We used these behaviors and associated video frame annotations for both behavioral analysis and time-locking of Ca 2+ data to behavior.

Decoding of stimuli based on BLA neuron activity
To test the specificity of the neural code in response to various stimuli delivered to animals run through the protocol in Fig.  S3A, C, we implemented naïve Bayes classifiers in the MATLAB programming environment using standard MATLAB libraries. Naïve Bayes classifiers assume statistical independence between predictors (in this study, BLA neurons), but they also work well when this is not the case (20). The goal of a naïve Bayes classifier is to predict the response, y (stimuli given at time point t) based on predictors, x 1-n (BLA neurons), where n is the number of neurons in our case. Formally: Where t is a particular post-stimulus frame during the session, P(y(t)) is the probability of a stimulus at a given time point, P(x|y) is the probability of activity in neurons (x) given a stimulus was present (y), and P(x) is the probability of a neuron being activated at time t. Thus P(y|x) gives us the probability of stimulus y given we observe x activity pattern within the entire BLA neural ensemble. We then use the following classification rule under the assumption of statistical independence between predictors (e.g. BLA neurons or x): This rule allowed us to predict at each time point, t, the most likely stimulus (class of ( )) given the observed response of all n neurons. We first split the neural data into testing and training sets on a per trial basis with 70% of trials for training and 30% for testing. We performed 50-fold cross validation by training a new decoder using randomly picked set of training trials and testing that decoder on a non-overlapping set of test trials from the entire set of stimuli trials. Crucially, since we created decoders that had to simultaneously predict either nine ( Fig. 1L) or ten ( Fig. S8E) stimuli, we sought to avoid biases due to some stimuli appearing on more trials than others. To correct for this, we limited the number of each stimuli's trials used for testing and training to whichever stimuli in that session had the minimum number of trials, but we still allowed sampling from the full range of trials for each stimulus during each test round.
For the training set, we constructed a n × f matrix consisting of all n neurons in a session and f frames composed of all 10 frames in a 2-s window after stimulus delivery for all trials and stimuli (excluding 30°C water). The response was a 1×f vector composed of the same 2-s window after the stimulus for all chosen stimuli trials, marked to indicate which stimuli trial each frame was associated with. We used the predictor matrix and response vector to train a naïve Bayes classifier using the NaiveBayes MATLAB class with a Gaussian distribution assumed for ( ( ) , … , ( ) | ( )), seen as Where and are the mean and standard deviation estimates of neuron i response to a particular class in y. We ran each trained classifier on another n × f matrix containing the test set neural activity data and the resulting naïve Bayes classifiers predicted stimuli compared to the actual stimuli given during the test set time periods. We constructed a confusion matrix from the predicted and actual stimuli then normalized each column (corresponding to each actual stimuli) by the number of actual stimuli given to allow comparison of the decoder accuracy for each stimulus compared to others ( Fig. 1L and Fig.  S9B). To ensure that the decoding specificity was due to individual neurons' specific activity in response to each stimulus, we ran another 50 rounds where we shuffled the stimulus identities used to train the decoder but kept the testing set stimuli unchanged. This removed much of the predicted stimuli specificity (Fig. S9B). We used this same procedure to decode nociceptive from other aversive and incentivized stimuli (see Noxious and aversive stimuli experiments) in Fig. S8E.

Determinations of mouse locations
To determine the spatial trajectories of BLA-and DMS-implanted mice performing the open-field locomotor assay, we used custom ImageJ and MATLAB code to analyze video recordings of the mouse behavior (79). First, in ImageJ, for each video frame we extracted binary masks of the mouse by using manually-determined intensity thresholds. This allowed us to move the threshold higher or lower to ensure we captured the mouse on the maximal number of movie frames. To remove unwanted pixels from the resulting masks (black on white background) and to make later processing easier, the algorithm then performed a single round of erosion on each mask, by setting any pixels to white that did not have at least eight neighboring black pixels in a 3 × 3 grid. Subsequently, we spatially smoothed the mask to reduce jitter in the trajectory by thrice dilating each image, which involved setting any pixels to black with at least one pixel that was black in a 3 × 3 region. We used ImageJ's particle tracking algorithm (ParticleAnalyzer.java) to identify candidate animal locations. We restricted the algorithm to finding objects whose area was between 100 and 20,000 pixels and identified the centroid locations.
Because the particle tracking algorithm output multiple candidates for each imaging frame, we then used custom MATLAB code to identify and retain the largest particle (assumed to be the mouse) identified in each frame. For any frames missing tracking (for example, an animal was obscured from the FOV or left the imaged area) we assigned missing values. To validate the accuracy of mouse tracking, for a subset of behavior videos we added to each frame a marker corresponding to the animal's calculated position on that frame and visually inspected any deviations from the animal's true location in the video. In the movies inspected in this way, we rarely saw the animal's extracted trajectory deviate suddenly or substantially from the animal's actual location, which was consistent with the smooth trajectories seen when visually inspecting locomotor trajectories across the entire behavioral session. Using the spatial trajectories of each mouse (Fig. S7C), we then analyzed the behavior and compared it to BLA and DMS neuron activity ( Fig. S7A-E).
We calculated the mouse's speed (s) at a given frame, f , of the behavioral video by using the following equation where x f and y f are the mouse's x and y coordinates in video frame f. We linearly down-sampled each mouse's spatial trajectory trace s from 20 Hz to 5 Hz to match imaging data and temporally smoothed by a 1-s (5-frame) moving mean. We identified movement bouts by finding all movements of >0.75 cm/s on spatial trajectory traces. We then searched for all transition times when the mouse either initiated or ceased periods of movement. To identify periods of movement initiation, we identified times when the mouse's speed stayed below 0.75 cm/s for 4 s before and above 0.75 cm/s for 4 s after a given time point. The converse was true for movement offsets. We removed any candidates that did not meet these criteria and the final animal movement onset and offset times used in subsequent analysis.

Alignment of locomotor and Ca 2+ imaging data
To analyze the possible modulation of BLA activity by generic movements of the mouse, as opposed to movements that were specifically evoked by noxious stimuli, we examined mouse locomotor speed as a function of the percent of active neurons in mice imaged within the BLA or DMS (see Fig. S7A). We found that both D 1 and D 2 dopamine-receptor expressing medium spiny neurons in mice imaged in the DMS were modulated by movement, in line with recent results (21). To account for the ~1-s timescale of GCaMP6m synchrony between neurons, as we have observed in the DMS previously (21), we first took the binarized neuron activity trace (see Ca 2+ transient detection and activity trace binarization) and computed the mean activity over a 1-s sliding window. We then calculated the percentage of active neurons in the population ("population activity") by taking the mean over the n dimension of the n × f binarized activity trace (where n = # of neurons and f = number of frames). We then grouped and calculated the mean population activity of all frames in which the animal achieved an instantaneous speed within a defined interval; in this case, we made 0.1-cm/s intervals starting from 0 to the maximum speed of the animal during that session. To compare the degree to which movement modulated neural activity across animals and to control for differences in baseline activity between mice, we normalized by dividing the percentage of active neurons for each mouse's open field session by their mean activity during rest (<0.5 cm/s). Using this procedure, we found that movement speed modulated neural activity in the DMS, but not in the BLA (see Fig. S7A).
To characterize neural activity at movement initiation and termination, we used the frames annotated for movement onset and offset (see Calculation of miniature microscope open field movement bouts) and the mean percentage of neurons active (without the temporal smoothing done previously to preserve precise onset and offset timing information). We then pulled out from the population-activity trace all frames associated with a 6-s window centered on each movement onset. This produced a m o × f o matrix where m o is each movement onset bout and f o is the frames in a 6-s window (3 s before and 3 s after) around the movement onset. We then computed the mean of all these windows at each frame relative to movement onset for each animal's open field session (mean in the 1 st dimension of the m o × f o matrix). Lastly, we calculated the mean of all animal mean movement onset responses. We conducted the same procedure for movement offset (Fig. S7B).

Statistical analyses
We performed all statistical analyses within the R or MATLAB (2015b or 2017a) software environments, unless otherwise noted. Throughout the text, "signed-rank" and "rank-sum" tests refer to Wilcoxon signed-rank and rank-sum tests, respectively. We used the Benjamini-Hochberg (B-H) procedure for all non-ANOVA multiple comparisons correction (77). For ANOVA analyses, we performed either a one-way or two-way repeated measures ANOVA via the aov function in R followed by a Tukey test, when appropriate. When comparing specific hypotheses, we ran the necessary pairwise statistical test followed by a B-H correction. We did not blind the experimenters performing the imaging analyses regarding the cohorts (neuropathic or uninjured) or pain states (pre-or post-SNI) of the mice. However, we used identical code and analysis methods for all cohorts throughout the study. Unless otherwise noted, values and error bars in the text denote means ± SEM.

Code and data availability
For Ca 2+ imaging video motion correction, the C code is available on the author's website (75). Our MATLAB implementation of the image registration is also available upon request. Code used for pre-processing Ca 2+ imaging data, neuron identification and activity trace extraction, ICA output manual cell classification GUI, and animal behavior tracking is available at (46). Any other code used in this study's findings, to generate graphs and perform statistical analysis, are available upon reasonable request.
The datasets of this study, approximately 43 TB in size, are available upon reasonable request to the corresponding authors.

Histology for miniature microscope mice tissue
We transcardially perfused all mice used in the imaging protocol in Fig. S3A, C with 4% formalin in PBS (Fisher Scientific, NC0238527). We stored brains in 4% formalin in PBS and sectioned them at 100 μm using a vibratome (Leica VT1000S). For staining tissue sections, we washed sections three times in PBS with 0.3% Triton-X100 for 5 min each, blocked with 10% Donkey Serum (Jackson Immunoresearch, 017-000-121 Normal Donkey Serum) in 0.3% Triton-X100 in PBS for 1 hr at room temperature, and stained with primary antibody (Invitrogen α-GFP A11122 rabbit at 1:1000 dilution) overnight at 4°C . The following day (all procedures at room temperature), we washed sections three times for 5 min each in 0.3% Triton-X100 in PBS, stained with secondary antibody (DyLight 549 Donkey α-rabbit at 1:500) for 90 min, stained with DNA stain (AppliChem DAPI BioChemica, 50 nm/mL in 1x PBS) for 20 min, and performed a final wash in 1x PBS. We mounted slices onto glass coverslips with mounting media (SouthernBiotech, Fluoromount-G cat no. 0100-01). We acquired large field-of-view images (Fig. S2B) with a standard fluorescence macroscope (Z16, Leica) while we collected zoomed in images (Fig. S2C) with a two-photon (Prairie Technologies, Ultima Multiphoton Microscopy System using Olympus LUCPLFLN 20x objective). Where applicable, we only adjusted raw miniature microscope histology images with linear manipulations of contrast and brightness.

Chronic neuropathic pain model
To induce a chronic pain state, we used a modified version of the Spared Nerve Injury (SNI) model of neuropathic pain, as previously described (70). This model entails surgical section of two of the sciatic nerve branches (common peroneal and tibial branches) while sparing the third (sural branch). Following SNI, the receptive field of the lateral aspect of the hindpaw skin (innervated by the sural nerve) displays hypersensitivity to tactile and cool stimuli, eliciting pathological reflexive and affective-motivational behaviors (allodynia). To perform this peripheral nerve injury procedure, anesthesia was induced and maintained throughout surgery with isoflurane (4% induction, 1.5% maintenance in oxygen). The left hind leg was shaved and wiped clean with alcohol and betadine. We made a 1-cm incision in the skin of the mid-dorsal thigh, approximately where the sciatic nerve trifurcates. The biceps femoris and semimembranosus muscles were gently separated from one another with blunt scissors, thereby creating a <1-cm opening between the muscle groups to expose the common peroneal, tibial, and sural branches of the sciatic nerve. Next, ~2 mm of both the common peroneal and tibial nerves were transected and removed, without suturing and with care not to distend the sural nerve. The leg muscles are left uncultured and the skin was closed with tissue adhesive (3M Vetbond), followed by a Betadine application. During recovery from surgery, mice were placed under a heat lamp until awake and achieved normal balanced movement. Mice were then returned to their home cage and closely monitored over the following three days for well-being.

Targeted Recombination in Active Populations (TRAP) of BLA neural ensembles
For all TRAP procedures, stereotaxic bilateral injections of viral reagents occurred 3-5 weeks prior to TRAP. Please see Fig. S10D and S16A for schematic experimental timelines. Acute nociceptive TRAP (noci-TRAP) We habituated mice to a first testing room (room-A) for three consecutive days. Execution of all TRAP procedures occurred in Room-A. During these habituation days, no nociceptive stimuli were delivered and no baseline thresholds were measured (i.e. mice were naïve to pain experience before the TRAP procedure). In room-A, we placed individual mice within red plastic cylinders (10.16-cm D), with a red lid, on a raised perforated, flat metal platform (60.96-cm H). The male experimenter's lab coat was present in the testing room for the first 30 min of acclimation, and then the experimenter entered the room for the final 30 min of habituation; this was done to mitigate potential alterations to the animal's stress and endogenous antinociception levels. To execute the TRAP procedure, we placed mice in their habituated cylinder for 60 min, and then a 25G sharp pin was applied to the central-lateral plantar pad of the left hindpaw (tibial-sural nerve paw innervation territory), once every 30 s over 10 min. This stimulus frequency was selected to closely match the protocols used in the microendoscope imaging experiments in which significant Ca 2+ transients were reliably detected in BLA Camk2a+ neurons. Following the pin stimulations, the mice remained in the cylinder for an additional 60 min before injection of 4-hydroxytamoxifen (20 mg/kg in ~0.25-mL vehicle; subcutaneous). After the injection, the mice remained in the cylinder for an additional 2 hrs to match the temporal profile for c-FOS expression, at which time the mice were returned to the home cage (Note: an immediate return to the home cage following the pin stimulations was considered, but ultimately avoided as potential safety-related neural activity could occur and thus TRAP BLA neurons of putative positive valence in addition to the nociceptive ensemble). To mitigate the influence of contextual memory recall from the noxious TRAP procedure, all subsequent behavioral assays occurred in a second testing room (room-B). In room-B, we placed the noci-TRAP mice within different holding chambers (7.62 × 15.25 × 15.25 cm plastic chamber [white opaque walls]), atop a different metal platform floor (smooth hexagon-hole perforated sheet, McMaster-Carr, #92725T22). Furthermore, the experimenter wore daily disposable lab coats; different from the coat used in the room-A context. After completion of all experiments, we perfused mice and dissected the brains for verification of hM4-mCherry expression in the BLA. We excluded mice with off-target viral expression in the central amygdalar nucleus from the behavioral analysis. Based on this criteria, n = 7 mice study were removed from the final analysis.

Chronic neuropathic pain TRAP (neuropathic-TRAP)
We habituated mice inside individual red plastic cylinders (10.16-cm D) on a raised flat, perforated metal platform (60.96cm H) for 3 days prior to the start of behavioral sensory testing. After basal thermal and mechanical thresholds were measured, mice underwent a peripheral nerve injury surgery (Spared Nerve Injury, SNI; see "Chronic neuropathic pain model" above for details of the surgical procedure). At Day 21 post injury, when mice display significant mechanical and thermal hypersensitivity at the plantar surface of the left hindpaw, we habituated mice as stated above (see "Acute nociceptive TRAP (noci-TRAP)"). To execute the light touch-TRAP procedure, a von Frey filament (0.07-g) was lightly applied to the lateral aspect of ventral hindpaw (sural nerve innervation receptive field) with enough force to cause a slight bend of the filament for up to 1 s before being retracted. The filament stimulus was applied once every 30 s over 10 min. We selected this stimulus frequency to closely match the protocols used in microendoscope imaging experiments. Following the filament stimulations, the mice remained in the cylinder for an additional 60 min before injection of 4-hydroxytamoxifen (20 mg/kg in ~0.25-mL vehicle; subcutaneous). After the injection, the mice remained in the cylinder for an additional 2 hrs, at which time the mice were returned to the home cage. At Day 28 post injury, we confirmed neuropathic hypersensitivity persisted. Subsequent behavioral studies to assess chronic neuropathic hypersensitivity and affective-motivational behaviors were conducted beginning at Day 42 post SNI in order to allow sufficient expression of the viral DREADD cargo. After completion of all experiments, we perfused mice and dissected the brains for verification of hM4-mCherry expression in the BLA. We excluded mice with off-target viral expression in the central amygdalar nucleus from the behavioral analysis. Based on this criteria, n = 5 mice were removed from the final analysis.

Optogenetic nociception TRAP (o-TRAP)
Different AAV serotypes display unique infection tropisms. In particular, serotype-6 shows a preferential infection of peripheral primary afferent nociceptor populations (80). To express the light-sensitive cation channel channelrhodopsin2 (ChR2) in putative primary afferent nociceptors, we intrathecally injected AAV6-hSyn-ChR2(H134R)-eYFP immediately following the i.c. BLA injections of AAV-DIO-DREADD(Gi)-mCherry in TRAP mice while remaining anesthetized under isoflurane (1-2% maintenance). Specifically, we shaved a small patch of fur on the back, wiped with alcohol and Betadine, and then inserted a 33G beveled needle connected to a WPI Nanofil syringe between the L5/L6 vertebrae and through the dura (confirmation by presence of reflexive tail flick). We slowly administered the virus was over 20 s. We retuned mice to their home cage for 4-6 weeks before behavioral verification of ChR2 expression. In pilot studies, we observed that intrathecal delivery of AAV6 does not uniformly infect all dorsal root ganglion (DRG) neurons across segmental levels. As we sought expression in lumbar DRGs for the purposes of our behavioral experiments that involve sensory testing on the hind limbs, we performed a behavioral screening of each mouse for transdermal light-responsivity when light was applied to the hindpaw. We placed mice inside individual red plastic cylinders (10.16-cm D) on a thin glass surface. A remotely movable fiber optic arm, connected to an 453-nm LED light source (SugarCube) below the glass (~8 mm from the fiber tip to the plantar surface of the paw), was positioned under the heel of the left hindpaw, and a 453-nm ~1-s light pulse was delivered (3 mW/mm 2 ). We measured whether an immediate nociceptive hindpaw reflex and/or pain affective-motivational behaviors (described below) occurred in response to the light indicated ChR2 expression in nociceptors. If no immediate responses were observed, the fiber optic was moved distally toward the toes and the stimulation was repeated; the location of light-responsivity on the paw was noted for future targeting during the TRAP protocol. We excluded mice from this experiment that exhibited no light-evoked pain behaviors. One week later, we habituated mice on the glass surface for 3 consecutive days (no blue light stimulus was given). Next, on the day of the TRAP procedure, we placed mice inside the cylinders for 30 min. The fiber optic was positioned under the left hindpaw at the previously noted light-responsive site, and we then delivered transdermal light pulses (1 s, 3 mW/mm 2 ) once every 30 s over 10 min. Following light stimulations, mice remained in the cylinder for an additional 60 min before injection of 4-hydroxytamoxifen (20 mg/kg in ~0.25-mL vehicle; subcutaneous). After the injection, mice remained in the cylinder for an additional 2 hrs, at which time we returned mice to their home cage. Subsequent behavioral experiments were performed 5-8 weeks later.

Behavioral quantification of acute and chronic pain behaviors
For all behavioral tests the experimenter was blind to either the SNI vs. sham procedure, or the injection of CNO vs. saline.

Classification of mouse pain behaviors into reflex and affective-motivational behaviors
In mice, we previously reported our observation that a cutaneous noxious stimulus can elicit several distinct behavioral responses (81, 82): 1. Withdrawal reflexes: rapid reflexive retraction or digit splaying of the paw that occur in response to noxious stimuli, but cease once the noxious stimulus is removed; and 2. Affective-motivational behaviors: temporally-delayed (relative to the noxious stimulation), directed licking and biting of the paw (termed "attending"), extended lifting or guarding of the paw, and/or escape responses characterized by hyperlocomotion, rearing or jumping away from the noxious stimulus. Please see Fig. S11A for an illustrative example of these nociceptive reflex and affective-motivational behaviors. Paw withdrawal reflexes are classically measured in studies of sensitivity, and involve spinal cord and brainstem circuits (as these behaviors are observed in decerebrated rodents (83)). In contrast, affective-motivational responses are complex behaviors requiring processing of nociceptive information by brain limbic and cortical circuits. The presence of these complex behaviors indicates the subject's motivation to make the aversive sensation cease, by licking the affected tissue, protecting the tissue, or seeking an escape route (83)(84)(85)(86)(87)(88)(89)(90)(91)(92).

Pain affective-motivational and nociceptive reflex behavioral assays
To evaluate mechanical reflexive sensitivity, we used a logarithmically increasing set of 8 von Frey filaments (Stoelting), ranging in gram force from 0.07-to 6.0-g (93). These filaments were applied perpendicular to the plantar hindpaw with sufficient force to cause a slight bending of the filament. A positive response was characterized as a rapid withdrawal of the paw away from the stimulus within 4 s. Using the Up-Down statistical method, the 50% withdrawal mechanical threshold scores were calculated for each mouse and then averaged across the experimental groups. The response frequency was calculated as the number of positive responses out of 10 stimulations, delivered at 30-s intervals.
To evaluate affective-motivational responses evoked by mechanical stimulation, we used three von Frey filaments (0.07-g, 0.4-g, and 2.0-g) and a sharp 25G syringe needle (pin prick) (94). Each filament was applied for 1 s and the pin prick was applied as a sub-second poke to the hindpaw, and the duration of attending behavior was collected for up to 30 s after the stimulation. Only one stimulation per filament was applied on a given testing session.
To evaluate affective-motivational responses evoked by thermal stimulation (81), we applied either a single, unilateral 50-μL drop of water (5, 30, or 55°C ) or acetone (evaporative cooling) to the left hindpaw, and the duration of attending behavior was collected for up to 60 s after the stimulation. Only one drop stimulation was applied on a given testing session.
To evaluate adaptive thermal avoidance and temperature preference, we placed mice in the center of a linear Thermal Gradient Track (121.92-cm L × 8.25-cm W metal alloy floor; 15.24-cm H black plastic walls), with the floor featuring a temperature gradient along the long axis. Mice freely explored the track for 60 min. To create the temperature gradient, we placed either heating or cooling plates (Bioseb) under the outermost 16.51 cm of the metal floor, with one plate set to 50.0°C and the other set to 0.0°C , creating an actual floor gradient of 48°C → 5°C , respectively. The track was subdivided into 25 temperature zones (4.8-cm D per zone), and we assessed the temperature at the center of each zone by a K-probe thermocouple. "Noxious zone blocks" were designated based on the temperature thresholds for nociceptive behaviors (> 42°C and < 17°C ). The track was illuminated by a centered, overhead light (104 lux), and the ambient room temperature was ~26°C . Only one mouse was present in the room during all trials. A video camera placed above the track recorded the position of the mouse within the temperature zones, and videos were later analyzed using a video-tracking software (Ethovision, Noldus) for duration of zone occupancy, zone visits, distance, velocity, and acceleration.
To evaluate active avoidance and escape behaviors to optogenetically driven nociception, mice expressing ChR2 in peripheral primary afferent nociceptors freely explored a custom-built two-choice chamber with LED-lit floor panels. A 32 × 32 LED array (8 × 8 cm) illuminated half the array in blue light, and the other half in red light (~0.3 mW/mm 2 ). A thin glass surface (0.5 cm thick) covered the array floor, upon which we fitted a black plastic chamber (38 cm H) with a center divider wall containing a square passage hole (5-cm D) raised 2.5 cm from the array floor. The entire LED chamber was maintained in a quiet room with low ambient light (~5 lux). We first placed mice in the red light chamber and then allowed them to freely explore the chambers for 15 min. A camera placed above the chamber recorded the location of the mouse in the apparatus. We manually scored the videos to determine the time spent by the mouse in each chamber (automated tracking was not possible given the light from the LED floor). Only one mouse was present in the room during all trials.
To evaluate neuropathic adaptive cool/cold avoidance behavior, mice with SNI freely explored a two temperature choice chamber. The chamber was constructed from adjoining two thermal plates (Bioseb): one reference plate set at 30°C , and a test plate with the temperature adjusted to either 30, 25, 20, 15, or 10°C for independent trials. The test plate temperature order was randomized for each trial within the day. The chamber (white opaque plastic with no distinguishing features and no divider, 30.48 × 15.24 × 15.24 cm) was fitted onto the conjoined plates. At Day 56 post SNI and at 30-min post CNO injection, we placed mice on the reference plate facing the back wall. Mice then freely explored the chamber for 5 min, while an overhead camera recorded the chamber position and locomotion. After each trial, the mouse was returned to the holding cylinder, while the test plate temperature was rapidly cooled or heated to the next randomly assigned temperature trial. This procedure was repeated until all temperature trials were collected (6 temperature trials total). Video files for each trial were later analyzed using automated tracking software (Ethovision, Noldus) for path tracking, time spent on the test plate, and number of entries onto the test plate. The open field chamber (circular, 60.96-cm D, 38.1-cm H, opaque white polyethylene walls and floor) was divided into a central zone (center, 25-cm D) and an outer zone (peripheral). We placed individual mice in the peripheral zone, facing toward the chamber wall as an overhead video camera recorder the locomotor paths throughout the 15-min trial. A diffuse overhead fluorescent light (102 lux) illuminated the track, and the ambient room temperature was ~26°C . Only one mouse was present in the room during all trials. Videos were later analyzed using a video-tracking software (Ethovision, Noldus) for total distance traveled, total time spent in the center zone, and mean locomotion velocity as the mouse exited the center zone.

Sucrose-Water Preference assay
To evaluate incentive motivational behavior, we placed mice in a custom made plastic chamber (7.62 × 15.25 × 15.25 cm, 3 white opaque walls, 1 clear plastic wall for video monitoring) with two rounded gavage syringe spouts protruding from small holes in one of the two side walls: one spout dispensed room temperature water, while the other dispensed a room temperature 10% sucrose solution (in water). Mice then had 20 min to freely sample the spouts. A custom microprocessor controlled release of either solution, which were set to dispense 12 μL of solution upon the first lick, with a minimum 1-s interval between all subsequent lick-induced dispensions. An Arduino using a custom circuit design described previously recorded the number of licks and lick rate while experimenters recorded consumption volume for each spout. To enhance the propensity of mice to actively sample the lick spouts, mice were water deprived 5-8 hr prior to the start of experiments. We repeated the protocol for 7 consecutive days to determine whether any changes in sucrose preference occurred.

Histology for BLA, dorsal root ganglion, and spinal cord tissue Immunohistochemistry
Anesthetized mice (Fatal-PLUS, Vortech Pharmaceuticals) were transcardially perfused with room temperature 0.1 M phosphate buffered saline (PBS), followed by 10% formalin in 0.1 M PBS. The brain, DRG (L3-L5), and/or spinal cord (lumbar cord L3-L5 segments) were dissected, post-fixed overnight (brains) or for 4 hrs (DRG or cord) at 4°C , and cryoprotected in 30% sucrose in PBS. Tissues were then frozen in O.C.T. (Sakura Finetek, Inc.). Tissue sections (50 μm for brains; 30 μm for spinal cord; and 10 μm for DRG) were prepared using a cryostat (Leica Biosystems) and blocked with PBS containing 5% normal donkey serum and 0.3% Triton X-100 for 1 hr at room temperature. The sections were then incubated overnight with primary antibodies at 4°C . For the chicken anti-GFP antibody, the incubation was performed at 37°C for 2 hrs. After extensive wash with PBS containing 1% normal donkey serum and 0.3% Triton X-100, sections were incubated with appropriate secondary antibody conjugated to AlexaFluor for 2 hrs at room temperature. Sections were then mounted in the glass slide with Fluoromount (Southern Biotech) after washing with PBS for 3 times for 5 min. Images were collected under a Leica TCS SP5II confocal microscope with LAS AF Lite software (Leica Microsystems).

In Situ Hybridization
Anesthetized mice (C57Bl/6J, male, 5 -8 weeks, Fatal-PLUS (Vortech Pharmaceuticals)) were transcardially perfused with 0.1 M PBS followed by 10% formalin in 0.1 M PB. Brains were dissected, cryoprotected in 30 % sucrose overnight, and then frozen in OCT. Frozen tissue was cut into 14 μm thick slices, placed onto Superfrost Plus slides, and kept at −80°C . Tissue was thawed from −80°C , washed with PBS at room temperature, and subsequently processed according to the Advanced Cell Diagnostics RNAscope Technology protocol (ACD Bioscience). We first washed the tissue with solutions from the pretreatment kit to permeabilize the tissue, incubated with protease for 30 min followed by the hybridization probe(s) for 2 hr at 40°C . Images were collected under a Leica TCS SP5II confocal microscope with LAS AF Lite software (Leica Microsystems).
The following RNAscope probes were used: Mm-Camk2a-C1 (# 445231), Mm-Slc32a1-C1 (#319191), Mm-Sst-C1 (#404631), Mm-Pvalb-C2 (#421931), Mm-Vip-C2 (#502231), Mm-Rspo2-C2 (# 402001), and Mm-Ppp1rb-C3 (# 405901).   Fig. 3. A subset of mice contained miniature microscope fields of view divided into BLA and piriform cortex portions separated by a fibre tract (external capsule) that was darker (due to a lack of GCaMP6m expression). We manually selected piriform neurons based on location and differential activity compared to BLA neurons then excluded them from further analysis. Scale bar, 100 µm. (E) Example PCA-ICA neuron extraction outputs from a single mouse (same as in Fig. 1C-D) showing accepted and rejected ICA outputs. We manually classified all neurons used in imaging-related aspects of this study based on a variety of parameters, such as the PCA-ICA filter shape, the event triggered movie activity (e.g. whether it confirmed to prior expectation of one-photon neuron morphology and GCaMP activity), location within the imaging field of view (e.g. not within a blood vessel), and the shape of the transient having characteristic GCaMP dynamics. No automated heuristics were used to further remove accepted neurons. "Spatial filters" are the PCA-ICA output filters, "Activity in movie" is a 31 × 31 pixel square region cropped from the movie around the candidate neuron's centroid location during that candidate neuron's transients (black outlines are "Spatial filter" derived neuron contours), and "Activity traces" shows the mean (black) and per transient (gray) PCA-ICA activity of a candidate neuron from the imaging session. Scale bars, 25 µm. (F) Example neuron map (same animal and imaging session as Fig. 1C-D) showing accepted (green) and rejected (red) filters using criterion in (E). Scale bar, 100 µm.  Fig. S3. Associate data for Fig. 1 and 3. Experimental protocol for stimulus delivery during BLA microendoscopy imaging. (A) Experimental timeline and daily imaging protocol for miniature microscope imaged BLA-implanted mice before and after Spared Nerve Injury surgery (SNI). Each session begins with imaging basal neural activity in the BLA without explicit sensory stimulation (Habituation). Next, mice have free access to a lick port delivering ad libitum 10% sucrose (Incentive), which was removed after 15 min. We do not water deprived imaged mice during this or any parts of the protocol. Next, we applied somatosensory stimuli to the hindpaw. The first four stimulus blocks always occur in the same order across days in order to track daily pain behaviors and the development of chronic neuropathic pain. All subsequent stimulus blocks are semi-randomized computer generated sequences within and across days with the conditions that the same stimulus block does not occur twice in sequence, nor does the same daily protocol repeat on any given day. We designed this protocol to be less than 2.5 hr for each animal's imaging session; to give enough stimuli to have sufficient statistical power to identify stimulus-respon-sive neurons; and to incorporate sufficient "down time" between stimuli, in order to avoid potential photobleaching of imaging area or animal exhaustion. During "Approach" trials either a von Frey filament, water droplet, pin, or noise device was moved toward the animal similar to other trials but with no actual contact or stimulus delivery. Open field imaging sessions consist of 30 min sessions of animals exploring a 2 m diameter circle or 2 m square open field apparatus, see Fig. S7 for additional details and results. (B) Similar experimental timeline and daily imaging session layout as in (A). The protocol was simplified to directly assess relationship between innocuous and nociceptive ensembles before and after nerve injury.(C) Similar experimental timeline and daily imaging session layout as in (A). In addition, these imaging mice had two additional experimental days. "CNO" was a control imaging session in which CNO was injected and 30 min later mice imaged in response to sensory stimuli, see Fig. S11D-G for additional details and results. "Aversion" tested responses of BLA neurons to noxious and aversive stimuli, see Fig. S8 for additional details and results. "Habituation" involved mice being habituated to the fear conditioning chambers used in "Aversion" imaging sessions.  Fig. S4. Associate data for Fig. 1 and 3. Normal and neuropathic pain behaviors to innocuous and noxious stimuli using qualitative and quantitative measures. (A) A miniature microscope mounted accelerometer (Sparkfun, ADXL335 or ADXL 345) measured quantitative affective escape or reactive measures of animals' responses to various innocuous (0.07-g and 1.4-or 2.0-g von Frey filaments), noxious (55°C water, 5°C water, acetone, and 25G pin prick), and control ("Approach/No contact" and noise) stimuli. Mean session acceleration for 2 s after stimulus onset before nerve injury is plotted (n = 9 mice). Noxious stimuli all showed significantly more movement than light touch stimuli (One-way ANOVA, Tukey post-hoc). Stars, at least P < 0.05. (B) Behavior videos for the same animals as in (A) were manually scored to identify whether animals exhibited reflexive, whole-body, or head-jerk responses after stimulus application (note: this was not a measure of nocifensive paw withdrawal responses). Similar to (A), noxious stimuli (55°C water, 5°C water, acetone, and pin prick) all showed significantly (Oneway ANOVA, Tukey post-hoc) greater responses than innocuous stimuli. Stars, at least P < 0.05. (C) To validate that both the quantitative and manual behavior measures produced similar results, data from (A) and (B) were combined on a per session basis for each stimuli. Before nerve injury (circles and diamonds), both metrics are positively correlated (Spearman's ρ = 0.72 [normal] and 0.59 [neuropathic and uninjured], p-value < 0.001). After nerve injury (squares), light touch stimuli (0.07-g, orange) show increased behavioral responses in both metrics that was not seen in uninjured animals (triangles). Inset, zoomed in section (from dotted regions) to better illustrate differences in noxious stimuli responses. (D) Using the same metric as in (A), the responses to noxious stimuli showed similar onset dynamics while light touch stimuli induced minimal behavioral response. Light touch showed a marked increase in onset, in peak reflexive behavior, and in continued escape dynamics after nerve injury (top row) that was not seen in uninjured mice (bottom row), suggesting the presence of neuropathic hypersensitivity and affective allodynia. Further, noxious pin and mild touch stimuli showed heightened responses immediately post-stimulus delivery, suggesting strong neuropathic hypersensitivity has developed, while the lack of an enhanced affective escape response might indicate a saturation or ceiling effect for this measure. The motion responses to "Approach/No contact", Noise, 10% sucrose, and background are anticipatory escape behavior, startle response followed by escape behavior, head motion toward lick port, and mean movement during random times in the trial when explicit stimuli are not being given, respectively. Baseline (black horizontal line), threshold for movement (gray horizontal line, see Fig. 1M and S7G, I analysis), and stimulus onset time (black vertical tick) are indicated.

Supplemental Figures
Stars, at least P < 0.05. (E) Using data in (D), the mean accelerometer response (2 s window after stimuli, red right axis) and human scored reflexive withdrawal (left axis, cyan, same measure as (B)) in uninjured (grey) and neuropathic (red) animals for all stimuli was calculated. Innocuous stimuli showed a signifi-       Fig. 1 and 3. BLA neural activity is correlated with increased motivated escape behaviors, but not general movement. (A) Both dorsomedial striatum-(DMS) (red, n = 9 mice, 13 sessions total) and BLA-implanted (blue, n = 9 mice, 3-4 sessions each) animals freely explored either a square (60.96 × 60.96 cm) or circular (60.96 cm diameter) open field for 20-30 min. For each frame in a trial, we calculated the corresponding Ca 2+ event-based population activity, the mean taken over specific velocity bins, and the final curve normalized by the mean velocity between 0 and 0.5 cm/s (threshold for movement). DMS, but not BLA, neuron activity showed a modulation in firing rate with velocity. ( .001] for [no injury, injury] cases). Graph shows the means ± SEM for population response at various levels of animal movement on a per trial basis as recorded from an accelerometer during pain trials as in Fig. 1E, G, and M and protocol in Fig. S3A, C. Neuron activity was normalized to trials with less than 0.01 g acceleration (the same acceleration threshold as used to indicate no response in (G), also see Fig. S4D Fig. S8. Associate data for Fig. 1. BLA nociceptive ensemble overlaps with, but is distinguishable from, aversive ensembles. (A) To compare BLA neuron responses to noxious and aversive stimuli, we adapted our protocol in Fig. S3C to study the response of animals to noxious (noxious heat, cold, and pin), five commonly used aversive (air puff [to the face], isopentylamine [odor], loud noise [~85 dB], quinine [bitter taste], and 0.6 mA footshock), and a positive valence (10% sucrose) stimuli. (B) Mean stimulus response across all trials for all BLA neurons during a single imaging session in an uninjured mouse (n = 162 neurons). Neuron identifications across different stimuli are consistent, demonstrating that some neurons encode multiple different types of noxious and aversive stimuli, while a separate neuron population uniquely encodes nociception (see Fig. 1J). The first three stimuli (noxious heat, cold, and pin) are considered noxious, the next five are aversive (air puff, isopentylamine, noise, quinine, and footshock), 10% sucrose is positive valence, and background is a negative control showing average response during random trial time points at least 10 seconds away from any defined stimuli. (C) Temporal dynamics of the mean ∆F/F of neurons within the nociceptive ensemble (cyan) and mean affective escape acceleration (red) for all imaging sessions and mice (n = 6 mice, 1 session each). (D) Probability of expecting overlap between two stimuli given total and stimuli responsive number of neurons was calculated using the hypergeometric distribution (see Fig. S9C-E and Supplemental Methods). Lower p-values (red) indicate the given overlap between stimuli was less likely to be due to chance. N = 6 mice, 1 session each. Symbols indicate various p-value thresholds using the same values used to color code the diagrams. (E) We constructed naïve Bayes decoders as described in Fig. S9A and applied them to the noxious vs. aversive stimuli experiments (n = 6 mice, 1 session each). The procedure, color coding, and symbols are as described in Fig. S9B, and see Supplemental Methods. The decoder tended to incorrectly predict one noxious stimuli as another based on the population activity but not the other aversive stimuli. Air puff and isopentylamine may have a high degree of neural ensemble overlap due to a similar method of stimulus delivery. Shuffled stimuli identities indicates that all trends are eliminated when the decoder was trained with the incorrect stimulus labels. (F) The nociceptive ensemble, as defined in Fig 1H, show less overlap with consummatory stimuli (10% sucrose and quinine) as compared to those stimuli with one another. (G) Increased response to either noxious or aversive stimuli (as defined in (A)) was predictive of amount of neural activity in the BLA (Spearman's ρ = 0.47, p < 0.001). Analysis same as in Fig. S7F Fig. S9. Associate data for Fig. 1. BLA stimuli ensembles overlap and exhibit combinatorial coding of nociceptive information. (A) To test out the specificity of the neuronal ensemble dynamics between stimuli, we constructed a nine-way naïve Bayes decoder. For cross-validation, we split data each round 70:30 between training and test datasets using 2 seconds from each trial. After training the decoder, it was run on the test neuron activity data and the predicted stimuli state compared to the actual stimuli delivered (see (B)). The decoder was run through 50 rounds subsampling different sets of trials for use in training and test datasets. (B) The naïve Bayes decoder constructed in (A) was applied to sessions from Fig. 1 (n = 9 mice, 3-4 sessions each). The decoder was then run on neural activity data for a new subset of stimuli and the actual stimuli at those frames compared to those predicted. We then normalized each actual stimuli column by the number of total actual stimuli to allow comparisons of how accurate the decoder was. Better performance (red/orange) occurred on noise and 10% sucrose than on innocuous (light purple) or noxious (blue and dark purple) stimuli. Symbols in the off-diagonal indicate whether prediction of correct stimuli was significantly higher than prediction of that stimuli (Wilcoxon sign-rank, Benjamini-Hochberg). Shuffled matrix indicates that all trends are eliminated when the decoder was trained with the incorrect stimuli labels. (C) How unexpected the overlap was in neurons activated by two stimuli depended on the total number of neurons activated by each stimuli, the amount of co-active neurons, and the total number of neurons. To quantify this, either a numerical (shuffling neuron identities and seeing how often they overlap) or exact analytical (using the hypergeometric distribution) solution can be used (see Supplemental Methods). Circles indicate numbers of neurons with gray circles indicating the total population. Number of stimuli activated neurons (red and blue circles) and number of co-activated neurons is the same in columns and rows, respectively. The hypergeometric distribution p-values are shown below each example of stimuli population overlaps. (D) To validate the use of the hypergeometric distribution, we ran 1,000 rounds of 1,000,000 shuffles for the estimated numerical distribution. Using the same number of total neurons, stimuli #1 responsive neurons, stimuli #2 responsive neuron, and overlap neurons, we also calculated the p-values, mean, and standard deviation using the hypergeometric distribution. For the mean and standard deviation the numerical and analytical solutions were not significantly different (Wilcoxon sign rank, p = 0.68 and 0.37 for mean and standard deviation). Paired difference in predicted mean were small (bottom right histogram), likely owing to precision error in numerical calculations since only 1 million shuffles were used. For the p-values, we found a high degree of agreement (95.6%) between overlap identified as significant by numerical and analytical methods (e.g. unexpected given the input parameters). (E) Probability of expecting overlap between two stimuli given total and stimuli responsive number of neurons was calculated using the hypergeometric distribution, see (C-D) and Supplemental Methods.
Lower p-values (red) indicate the given overlap between stimuli was less likely to be due to chance. All the noxious stimuli are significantly unexpected in the amount of overlap with one another (top left). N = 9 mice, 3-4 sessions each. Symbols indicate various p-value thresholds using the same values used to color code the diagrams.  Expanded view of same image as in Fig. 2B. Coordinates and structure demarcations from the mouse brain atlas of the Allen Institute for Brain Science. (G) Anatomical maps displaying the area of hM4-mCherry expression across the anterior-posterior amygdala in noci-TRAP mice. The AAV-hSyn-DIO-mCherry was injected at the A-P coordinate, -1.20 mm. On every brain slice illustration each red overlay shows the approximate medial-lateral spread of hM4-mCherry expressing neurons for an individual noci-TRAP mouse with a successful on-target TRAP (i.e. only BLA neurons were TRAP'd); the A-P spread for each mouse is illustrated across the different coordinate brain slices (n = 7 mice). The blue overlays on each brain slice indicate mice with off-target TRAP outside the BLA, primarily in the CeA. Based on this criteria n = 7 mice were excluded from the data set in Fig. 2.   Fig. 2F and 2G are shown, but we display here the separate scores for subcategories of affective-motivational behaviors: attending (top rows) or escape behavior (bottom rows). N = 14 mice / group. (C) Lack of effect of clozapine-N-oxide (CNO, 10 mg/kg) on reflexive (left green y-axis) or affectivemotivational (right red y-axis) behaviors in control mice expressing eYFP in the BLA nociceptive ensemble (AAVDJ-Ef1α-DIO-eYFP). N = 6 mice/group. (D) To compare BLA neuron responses before and after CNO application, we adapted our protocol in Fig. S3C to study the responses of animals 30 min after CNO (10 mg/kg) injection. Mice were then tested on a simplified version of protocol in Fig. S3C. (E) Lack of behavioral effect of CNO (F(1,60) = 0.016, p = 0.90, One-way ANOVA) and absence of statistical interaction between CNO and stimulus (F(2,60) = 0.14, p = 0.87, Two-way ANOVA). N = 6 mice, 1 session each, n.s. = no significant difference before and after CNO injection (Wilcoxon rank-sum). (F) Mean stimulus response across all trials for all BLA neurons during a single imaging session in an uninjured mouse (n = 104 neurons). Neuron identification across different stimuli are consistent, demonstrating that some neurons encode different types of stimuli. Stimuli are the same as in Fig. S5B    Error bars, ± SEM. (C) Daily incentive approach behavior during exposure to an unconditioned sucrose-water preference task. Left: Daily cumulative lick bouts at either a 10% sucrose port or a water port over a 7 day trail period. noci-TRAP hM4 mice were given either saline or CNO 60 min prior to the start of the daily trial. Right: Daily consumption of water and sucrose displayed as a % sucrose preference over water. Boxplots display the 1 st , 2 nd , and 3 rd quartiles with whiskers indicating 1.5*IQR.
Stars, P < 0.05. Note that on the first and second days (Sessions 1 and 2) of conditioning the noci-TRAPhM4 mice treated with CNO displayed a significant sucrose preference over mice treated with saline.      The AAV-hSyn-DIO-mCherry was injected at the A-P coordinate, -1.20 mm. On every brain slice illustration each red overlay shows the approximate medial-lateral spread of hM4-mCherry expressing neurons for an individual light touch-TRAP mouse with a successful on-target TRAP (i.e. only BLA neurons were TRAP'd); the A-P spread for each mouse is illustrated across the different coordinate brain slices (n = 7 mice). The blue overlays on each brain slice indicate mice with off-target TRAP outside the BLA, primarily in the CeA. Based on this criteria n = 5 mice were excluded from the data set in Fig. 4. The underlying histogram displays the means ± SEM. quantification of light touch-TRAP hM4 neurons along the anterior-posterior axis of the BLA (n = 7 ontarget TRAP mice).   Table S1. Associated data for Fig. 1 and S3. Last two columns ("% of nociceptive ensemble as a function of % total neurons") are a measure of columns 5 and 6 ("% of nociceptive ensemble") neurons within the total population.  2 N = 5 mice, analysis from 3 or 4 (uninjured) and 5 or 7 (neuropathic) sessions per mice. All values mean ± s.e.m.
4 Consist of cells responsive to Acetone and Pin prick.