{'fraction_non_alphanumeric': 0.025007248477819658, 'fraction_numerical': 0.038706871556973034, 'mean_word_length': 5.011546840958606, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Rapid reformatting of the cortical code during active tactile discrimination

Abstract Touch-based object recognition relies on perception of compositional tactile features like roughness, shape, and orientation. However, it remains unclear how the underlying spatio-temporal information from tactile sensors is integrated to form such percepts. Here, we establish a barrel cortex-dependent perceptual task in which mice use their whiskers to discriminate tactile gratings based on orientation. Multi-electrode recordings in barrel cortex during task performance reveal weak orientation tuning in the firing rate of single neurons during grating exploration despite high cortical firing rates. However, population-based classifiers decode grating orientation in line with concurrent psychophysical measurements and correlate with decisions on a trial-by-trial basis. For better decoding performance, the precise temporal sequence of population activity is necessary during grating exploration but becomes dispensable after decision. Our results suggest that temporal sequences of activity in barrel cortex carry orientation information during exploration. This code is reformatted around decision time to make firing rates more informative.

like roughness, shape, and orientation. However, it remains unclear how the 23 underlying spatio-temporal information from tactile sensors is integrated to form such 24 percepts. Here, we establish a barrel cortex-dependent perceptual task in which mice 25 use their whiskers to discriminate tactile gratings based on orientation. Multi-26 electrode recordings in barrel cortex during task performance reveal weak orientation 27 tuning in the firing rate of single neurons during grating exploration despite high 28 cortical firing rates. However, population-based classifiers decode grating orientation 29 in line with concurrent psychophysical measurements and correlate with decisions on 30 a trial-by-trial basis. For better decoding performance, the precise temporal sequence 31 of population activity is necessary during grating exploration but becomes 32 Introduction 37 Touch-based object recognition is essential for guiding behavior in a wide 38 variety of environmental conditions. Reliable recognition generally depends on tactile 39 search behavior executed with appendages like fingers for humans or the mystacial 40 vibrissae for rodents 1 . The vibrissae, or whiskers, are rooted on the rodent snout in 41 densely innervated follicles, where mechano-sensitive cells transduce whisker 42 bending and contact forces into electrical signals 2 . The resulting sensory information 43 has spatial (across whiskers) and temporal aspects that are integrated as it passes 44 through several distinct somatosensory pathways before reaching barrel cortex and 45 other areas 3 . As the foremost recipient of primary somatosensory thalamic afferents 4 , 46 barrel cortex is seen as the major cortical hub for the processing of whisker-based 47 tactile information 5 . However, its precise functional roles remain poorly understood, 48 as it has been difficult to disentangle the multiplexed encoding of whisker touches 49 and self-generated movement 6 . 50 Extensive studies on how barrel cortex neurons respond to simple, reliably 51 targeted whisker stimuli have revealed a somato-topographical code based on high 52 velocity deflections of one or several whiskers 7 . However, behavioral studies suggest 53 this simple coding framework is not sufficient to support some of the perceptual 54 functions of barrel cortex. In head-fixed mice, barrel cortex indispensably encodes 55 the precise location of an object in a task requiring whisker search behavior 8,9 . This 56 simple feature, location, is already beyond what a code based purely on velocity can 57 represent for a single whisker. Although barrel cortex is essential to precisely localize 58 objects, it is not required to actively detect the presence or absence of objects in the 59 proximal surroundings 10,11 . This simpler detection process can likely be supported by 60 other brain areas. In more demanding task conditions like the discrimination of 61 sandpapers [12][13][14][15] or in situations that require cognitive planning like whisker-mediated 62 gap crossing 10 , barrel cortex is once again essential. Taken together, perceptual 63 studies suggest that barrel cortex is critical for precisely placing and recognizing 64 tactile objects, especially in conditions that demand spatial and temporal integration 65 of tactile inputs. The simple coding schemes generated from reliably targeted whisker 66 stimuli do not shed light on how barrel cortex serves these perceptual processes. 67 To better understand the neural underpinnings of tactile object recognition, it is 68 thus crucial to study how barrel cortex integrates tactile information across space 69 (whiskers) and time to encode segregating tactile features. In this pursuit, many 70 studies have focused on how the coarseness of anisotropic surface textures 71 (sandpapers) is encoded during exploration with one or a few whiskers 12-16 . These 72 studies have suggested that object coarseness is encoded by temporal integration of 73 whisker slip events, with higher rates of slip events causing higher firing rates in 74 barrel cortex [15][16][17][18] . While these studies have given important insights, coarseness is 75 just one feature that can differ between objects. Along with variations in coarseness, 76 natural objects also exhibit unique combinations of large-scale isotropic features, 77 which means they can be decomposed into an arrangement of oriented surfaces. 78 While it is documented that rats can discriminate oriented tactile gratings with their 79 whiskers 19 , it is not known if and how information about grating orientation is encoded 80 in barrel cortex during active sensation. To study this, we developed a barrel cortex-81 dependent Go/NoGo task in which head-fixed mice discriminate tactile gratings 82 based on orientation with their whiskers. Multi-electrode recordings during task 83 performance revealed that during peak cortical firing rates in the early phase of 84 grating exploration, few single neurons showed any orientation selectivity. However, 85 support vector machine (SVM) classifiers based on the time course of population 86 8 whisker movements throughout a trial, we defined the whisking envelope as the 161 rectified and smoothed centroid velocity of the binarized whisker image within a 162 manually traced ROI around the whisker bases (Fig. 2c, See Methods). This 163 envelope showed that whisking behavior is most pronounced between trial onset 164 (trial start sound cue) and the time when the grating is fixed and within reach of the 165 whiskers (Fig. 2d). Surgery affected the average whisking envelope in both sham 166 and lesion groups of animals, as quantified by the total whisking at trial onset ( Fig.  167 2e, area under the whisking envelope curve). By day 3 after surgery, the total 168 whisking of both groups returned to pre-surgical levels, but the behavioral 169 performance recovered only in the sham group. Therefore, the drop in task 170 performance after lesion cannot be explained by deficiencies in global whisker 171 control. Barrel cortex removal also did not impact performance by abolishing licking. 172 On day 3 after surgery, hit rates and false alarm rates were equal in the lesioned 173 animals (both at ~50%), indicating that mice randomly licked rather than never licking 174 at all, which would both produce chance level performance (Fig. 2f). These results 175 indicate that intact barrel cortex is required to discriminate grating orientations with 176 the whiskers, and this cannot be explained by changes in global whisker search 177 behavior or licking ability. To study the encoding of grating orientation in mouse barrel cortex during 182 active discrimination, we made acute extracellular recordings (9 recordings, 74 single 183 unit and 274 multi-units) during the psychometric Go/NoGo version of the task (Fig.  184 3a, Supplementary Fig. 3). Silicon probes with linearly spaced electrodes (spanning 9 775 μm) were lowered to 1 mm depth from the surface of the contralateral barrel 186 cortex (targeted C2 whisker A/P: -1.5mm, M/L: 0/3.3mm). Electrode placement in the 187 barrel cortex was histologically verified in tangential sections after the experiments 188 ( Supplementary Fig. 3), and most of the active cells that were recorded resided in 189 deeper layers (Supplementary Fig. 3). All recorded mice showed stable task 190 performance above 70% correct on the day before the recording, but only some of 191 them went on to perform during the recording (n=5 discriminating mice), while others 192 did not (n=4 non-discriminating mice). This is likely due to the anesthesia, durotomy, 193 and electrode descent preceding behavioral measurements in these acutely recorded 194

animals. 195
In an example hit trial from a discriminating animal (Fig. 3b), the mouse 196 initiated whisking before the grating came into reach and spiking activity increased 197 once the grating was close enough to touch the whiskers. After ~500 ms of 198 exploration, the mouse decided to lick and received a water reward, which triggered 199 prolonged licking. In an example correct rejection trial (Fig. 3c), the same mouse also 200 whisked into the grating, which produced spiking activity in the last ~250 milliseconds 201 before the grating stabilized at its fixed position in reach. Then, the mouse correctly 202 withheld licking to avoid punishment. This same behavioral sequence was apparent 203 when averaging across all trials in this animal (Fig. 3d) or across all discriminating 204 animals (Fig. 3e). As the grating approached the mice, they executed whisker search 205 behavior, which was followed by a burst of spiking activity in barrel cortex neurons 206 that peaked just before the grating stopped near the snout. Licking was initiated after 207 the grating stopped and became discriminative ~590 ms after the peak of population 208 activity (Fig. 3e). After the decision to lick, low whisking levels were maintained and, 209 in some mice, a rebound of whisking and barrel cortex activity was observed when 210 the texture moved out of reach (Fig. 3e). 211 These patterns of behavior were much less discernible in animals that did not 212 discriminate the gratings during the recording (Fig. 3f-g). In these animals, licking 213 was initiated earlier, even before the grating came to a halt, indicating that their 214 choice behavior did not take the grating into account. Whisking levels and spiking 215 activity were also reduced, especially during the early interactions with the grating. 216 However, the population firing rates still peaked just before the grating arrived at its 217 fixed position, suggesting that there could be orientation-related information present 218 in the barrel cortex at that time point even if these animals did act on it. These data 219 indicate that patterned behavior and spiking activity in barrel cortex are associated 220 with task performance. We next quantified the information about grating orientation that is present in 225 sample populations of barrel cortex neurons during task performance. To do this, we 226 trained support vector machine (SVM) classifiers using a leave-one-trial-out cross-227 validation procedure for each mouse based on the activity of simultaneously recorded 228 single and multi-units (Fig. 4a). The classifiers were then applied to decode the 229 orientation category of the left-out trial (>45° or <45°), and this procedure was 230 repeated until every trial had been left-out. Because tactile inputs occur in a series of 231 multi-whisker contacts that evoke dynamic cortical responses, we examined whether 232 a temporal code was present by basing the classifiers on population vectors 233 spanning 5 consecutive 100 ms time bins of spiking activity (Fig. 4a). To assess the 234 4b, average firing rate). At trial onset, there was no information about grating 236 orientation in the barrel cortex spiking activity and both types of classifiers performed 237 at chance levels (50%). As the texture moved into range of the whiskers, 238 performance improved rapidly for the temporal decoders, and sluggishly for the 239 average firing rate decoders ( Fig. 4a-b). This improvement happened well before 240 discriminative licking for the temporal decoders ( Fig. 4a-b), and therefore cannot be 241 related to lick-induced whisker movements against the gratings. The elevated early 242 performance of temporal decoders was consistent across many bin sizes that could 243 be chosen for the population vectors ( Supplementary Fig. S4, 50 ms and 25 ms). 244

If the grating orientation information encoded in barrel cortex is relevant for 245
orientation perception, the decoders should produce neurometric functions that 246 resemble the psychophysics exhibited by the animals. To check this, we computed 247 classifier neurometric functions by examining performance across grating orientation 248 angles (Fig. 4c). In the 500 ms period before discriminative licking (See Methods), 249 which we defined as the early period (always portrayed in blue comprising the end of 250 whisker search, which is shown in pale blue), the temporal decoders generated 251 neurometric functions that were more similar to the psychometric behavior than the 252 average firing rate decoders (Fig. 4c left). After feedback in the form of reward or 253 punishment (late period), both types of decoders performed equally well in matching 254 the psychometric behavior ( Fig. 4c right). To confirm the temporal nature of the code 255 while controlling for the number of dimensions in the classifiers, we shuffled the 256 temporal order of the population vector bins for the tested trial and examined how 257 that affected classifier performance. The correct bin order had a clear advantage 258 during the early period, but during the late period temporal shuffling had no effect on 259 classifier performance (Fig. 4d). Shuffling the cell identities in the same fashion 260 abolished almost all classifier performance at any time relative to trial onset, 261 indicating that unit identity is also important for grating orientation encoding (Fig. 4d). 262 Another way to verify that spike timing is important during the early period is to 263 vary the training and testing times of the classifiers and observe how the shifts 264 degrade the classifier performance. We trained temporal decoders at one time point 265 and tested them at all other time points. During the early period, small misalignments 266 in time completely abolished the decoding power of the classifiers (Fig. 4e, left) 267 indicative of a code in which latency and/or temporal sequences are paramount. 268 During the late period, the classifier was much more robust to time shifts indicating a 269 more stable code, consistent with the decreased role of temporal information in this 270 period. Taken together, these analyses suggest that at the onset of object search, 271 information about grating orientation is present in the temporal sequence of 272 population activity, and with time this code stabilizes into a firing rate code. These 273 relationships do not hold in animals that do not discriminate the gratings (Fig. 4e). orientation. Looking at some single unit activity, some discharged many spikes at the 284 onset of whisker interactions with the grating, and their firing rates then adapted 285 when the grating reached its fixed position (Fig. 5a, Supplementary Fig. 3

, Single 286
Unit 1). Other neurons had less pronounced onset responses, but still had elevated 287 firing rates while the grating was within reach (Fig. 5a, Supplementary Fig. 3, Single 288 Unit 2). To quantify these responses, we constructed orientation tuning curves in 500 289 ms windows at different latencies with respect to trial onset (Fig. 5b,  of the window (500 ms) (Fig. 5b, Supplementary Fig. 5, 6 examples). The mean 294 and standard deviation of these firing rates across trials for Single Unit 1 (same unit 295 as Fig. 5a top) showed little selectivity for grating orientation during the peak firing of 296 the early response ( Fig. 5b top left, blue) or the late period after discriminative choice 297 ( Fig. 5b top left, magenta). To assess turning significance, we expressed the tuning 298 curves in polar form and compared the magnitude of the vector sum to the vector 299 sums obtained from shuffling the trial labels 200 times (Fig. 5b bottom left). If the 300 actual tuning vector was further away from the mean of the shuffles than 95% of the 301 shuffles, it was considered significant (False positive rates 5%). For Single Unit 2 302 (same unit as Fig. 5a bottom), orientation tuning was significant according to our 303 shuffling procedure (Fig. 5b right). This unit had delayed responses compared to the 304 peak of population activity that occurred just before the grating halted within range of 305 the whiskers. The orientation tuning originated in the second 500 ms time bin after 306 the start of the search period, and it persisted through discriminative choice and 307 feedback. Examining the orientation tuning across time for all single and multi-units, 308 we found that tuning was not above chance levels during the peak of firing that 309 occurs just before grating halt, and started to appear in the short period between 310 grating halt and discriminative licking (Fig. 5c). Temporal decoders already have 311 performance above chance and average firing rate decoders perform poorly during 312 this period (Fig. 4b-c). These analyses suggest that during object search, information 313 about grating orientation is not well-encoded by the firing rate of single neurons. False Alarms and Correct Rejections (Fig. 6a, example animal). Because most 331 animals performed very few Misses, we concentrated on Hit, False Alarm, and 332 Correct Rejections for this analysis (Fig. 6b, example animal). Looking at a single 333 discriminating mouse, the trial-averaged whisking envelopes and population firing 334 rates differed across time for different trial outcomes (Fig. 6a-b). When examining the 335 cortical activity in this animal using principal components analysis (PCA), Hits and 336 Correct Rejections showed some segregation in the space defined by the first 3 337 principal components. However, the False Alarms seemed to be less clustered in the 338 space during both the early and late periods (Fig. 6b right). When averaging across 339 all discriminating animals, differences in whisking behavior and population spiking 340 activity were negligible in the early grating interaction, however there was increased 341 whisking and increased barrel cortex activity after punishment for False Alarms (Fig.  342   6c). We used the temporal decoders to examine if False Alarms were less discernible 343 from Hits based on the cortical activity alone in the early period, which would be 344 indicative that the cortical activity is relevant for orientation perception. Temporal 345 decoders performed much worse in the early period at decoding the orientation 346 category in Hit vs. False Alarm trials than they did for Hit vs. Correct Rejection trials 347 (Fig. 6d). One explanation for this is that licking alone could drive the cortical 348 neurons via induced whisker movements against the gratings, and the classifiers use 349 this information to decode. If this was the case, the classifiers should also 350 discriminate between False Alarms and Correct Rejections of a fixed stimulus, 351 because in this situation only the licking behavior is different and not the stimulus. 352 However, temporal decoders also performed much worse at discriminating False 353 Alarms vs. Correction Rejections for matched stimuli than they did for discriminating 354 Hits vs. Correct Rejections (Fig. 6e). There was an elevated baseline for 355 discriminating False Alarms vs. Correct Rejections that could be related to task 356 engagement, but after controlling for this baseline there was significantly less 357 decoding in the early period than there was for Hits vs. Correction Rejections. In 358 summary, on trials where the mice discriminate the gratings (HvCR), decoders also 359 performed best at discriminating the gratings (better than HvFA or FAvCR). These 360 analyses thus establish a trial-by-trial link between discrimination in the barrel cortex 361 population activity and correct decisions. 362 363

364
We have shown that, like freely moving rats 19 , head-fixed mice can be trained 365 to discriminate tactile gratings based on orientation using only their whiskers (Fig. 1), 366 and this perceptual process is barrel cortex-dependent (Fig. 2) To perform grating orientation discrimination in head-fixed conditions, mice 382 need to execute a sequence of appropriate behaviors, much like humans do in object 383 manipulation tasks 27 . The first action is to detect the incoming grating. In this pursuit, we found that discriminating mice whisked vigorously when the grating was 385 approaching (Fig. 3), which generated dynamic responses in barrel cortex neurons 386 (Figs. 3, 5a). This anticipatory whisking behavior has also been reported during 387 sandpaper discrimination in head-fixed mice 12,13 . Freely moving rodents also use 388 goal-directed head movements along with exploratory whisking to perform tactile 389 search 28 , so the level of vigorous whisking observed here might be an adaptation to 390 head-fixed task conditions. Once the approaching grating is localized, the mice must 391 then refine their search behavior to adaptively sample the stimulus. During this 392 period, the first traces of orientation tuning begin to appear in single neurons in the 393 barrel cortex population (Figs. 4-6). Our results suggest that during detection and 394 then search refinement, barrel cortex implements a flexible representation of grating 395 orientation that starts as a temporal code, and as search is refined and decisive 396 action is taken, stabilizes into a firing rate code. In the early grating interaction, 397 temporal decoders outperformed rate decoders and mirrored concurrent 398 psychophysical measurements (Fig. 4). Single neuron orientation tuning was rare 399 and increased as licking set in (Fig. 5). This transformation from temporal to rate 400 coding might depend on higher cortical areas or thalamocortical loops 29 that support 401 information accumulation as the mouse interacts with the stimulus. Evidence 402 accumulation models have recently been employed to study sandpaper 403 discrimination in freely moving rats 18 . To apply these models to sandpaper 404 discrimination, downstream processing beyond primary and secondary 405 somatosensory cortex was postulated to integrate the information across volleys of 406 incoming sensory information, each volley associated with a pump of the whiskers 407 into the stimulus. Posterior parietal cortex (PPC) is an area downstream that might be 408 the locus of this temporal integration. Electrophysiological recordings in PPC during 409 grating orientation discrimination in rats revealed that choice-related activity is 410 present in single neurons 19 , as well as graded orientation tuning similar to what we 411 found in barrel cortex neurons (Fig. 5, Supplementary Fig. 5). The fine connectivity 412 between PPC and the primary and secondary whisker areas is not well-documented 413 but could provide blueprints on which to establish mechanistic models for tactile 414 evidence accumulation, refinement, and decision. 415 The final action that the mouse needs to take after detection and search 416 refinement is discriminative choice. When we examined orientation encoding by trial 417 outcome instead of only by stimulus orientation, we found that false alarms were less 418 distinguishable from Hits than Correct Rejections just before discriminative licking, 419 and this could not be explained by differences in licking behavior alone (Fig. 6). 420 Taken together, these observations indicate that the discriminability of the early 421 temporal code in the barrel cortex mirrors the choice behavior of the animal on a trial-422 by-trial basis. Another report looking at the mouse's ability to detect single whisker 423 deflections also found that barrel cortex neurons responded differently for different 424 trial outcomes 30 . However, detection of a single whisker sinusoidal stimulus can be 425 coded simply as the presence or absence of activity, and other studies have found 426 that this kind of detection can be performed and even learned in the absence of 427 barrel cortex 10,11 . Grating orientation is a tactile feature on a much different scale than 428 the sinusoidal vibration of a single whisker, and the temporal population code that we 429 uncover likely reflects the combination of grating contacts across whiskers and time, 430 which is the raw information that needs to be integrated in order to recompose the 431 orientation of the grating. The necessity of barrel cortex to discriminate gratings 432 based on their orientation indicates that this integration relies on barrel cortex, and 433 barrel cortex is dispensable for object detection. The fact that perceptual decisions 434 are predicted on a trial-by-trial basis by barrel cortex activity is in line with its causal 435 involvement and indicates that significant transformation of the raw stimulus 436 information is occurring from whiskers to cortex in this case, which is not the case in 437 detection tasks. 438 In summary, our results establish a cortex-dependent tactile discrimination 439 task in which the fine temporal dynamics of neural activity are informative, and 440 precisely define the timeline on which the temporal information is integrated to form a 441 percept. There is much to learn about the circuits that are responsible for this multi-442 contact temporal integration and how they contribute to tactile object recognition. firing rates below. The early period is defined as the 500 ms before discriminative 502 licking (across all trials) and the late period is the same size window but after reward 503 or punishment has been given. b. Two classifier types defined by their bin 504 arrangements were tested on both the discriminating and the non-discriminating 505 groups of mice: temporal (black) and average firing rate (purple). Performance, 506 licking behavior and population firing rates are shown for the discriminating (left, n=5) 507 and non-discriminating (right, n=4) groups of mice. c. Psychometric and neurometric 508 functions for each classifier type based on the population activity in the early period 509   with food available ad libitum on a 12/12 light-dark cycle with temperature kept at 23° 636 C. 637

Behavioral Setup 638
Mice were trained in a custom-built behavioral setup that was interfaced using a 639 National Instruments (NI) card (USB-6343) to control a linear stage (Newmark eTrack 640 series) that brought the gratings within reach of the whiskers and an Arduino Uno to 641 control stepper motors (Makeblock) for adjusting the orientation angle of the grating 642 and a solenoid valve (LVM10R1-6B-1-Q, SMC) for delivering water rewards (5-8 μL). 643 Sound cues were played with loudspeakers (Labtec Spin 85 speakers). Licking 644 signals were acquired and digitized using a capacitive sensor (Sentronic AG, SK-3-645