Figures and data

Behavioral procedure and apparatus.
(A) Schematic illustration of the arena showing major sections (N: nest zone, F: foraging zone, E: encounter zone). At the end of the E-zone, Lobsterbot (red) is situated, guarding the sucrose delivery port (green). (B) A rendered 3-D image of Lobsterbot. The sucrose port is located between the “claws”. The two red lines indicate infrared detectors, one for lick detection (short line) and the other for the entry to the E-zone (long line). (C) The experimental schedule. (D) Sample snapshots of Avoidance Withdrawal (AW) and Escape Withdrawal (EW). In an AW trial, the rat typically retracts its head ahead of time and watches the Lobsterbot attack. In an EW trial, the rat reflexively flees from the attack. (E) Example behavior data containing two consecutive trials (Trial 15 and 16). Each trial started with a reentry to the N zone which triggers gate opening. The rat leaving the N zone typically moves toward the E-zone across the F-zone. The entry to the E zone is detected by an IR beam sensor (blue shade). Within the E zone, the rat starts licking (green lines) until being attacked by Lobsterbot (red line) 3 or 6 s after the first lick. The rat shows voluntary withdrawal behavior (AW; Trial 15) or forced escape behavior (EW; Trial 16). (F) A summary of the AW trial rates for each animal during the Losterbot sessions. Points for Lob2 of Rat2 and Rat3 are omitted because they did not approach to robot during the entire Lob2 session.

Ensemble activity from the mPFC predicts distance from the goal.
(A) Schematic diagram of electrode implantation and estimated recording site. Top: A movable 4-tetrode microdrive was initially implanted in the PL region and lowered ventrally toward the IL after every recording session. Bottom: Representative recording tracks from all five animal are superimposed over an image of a stained coronal section of the frontal brain. Histological examination of all brain sections confirmed that the electrode tracks spanned the dorsoventral axis between the PL and IL. (B) Modulation of unit firing showing place-cell like activities. Units 66 and 125 exhibit fragmented place fields in all over the arena, while Units 56 and 26 display relatively large place fields surrounding particular spots such as the gates. Heat maps are calculated from z-scored spatial tuning curves. (C) Schematics of the ensemble decoding analysis. The 4-layer deep artificial neural network (ANN) receives populational neural data during 50ms-timewindow and is trained to predict the rat’s current distance from the center of the E-zone. The example data depicted in the figure is a sample recording from 20 units when the rat is at a particular distance away from the center of the E-zone, indicated by the white bold line. (D) Accuracy of the regressor. Mean Absolute Error (MAE) was calculated for the two types of regressor: one with the original dataset (Original) and another with the shuffled dataset (Shuffled). The average MAE was 16.61 cm for the Original, which was significantly smaller than that for the Shuffled and smaller than the rat’s body size. This suggests that the mPFC might encode the spatial correlates reflecting distance from the goal. (E) Prediction accuracy in the F-zone during outbound/inbound paths. Decoding accuracy in the F-zone was calculated separately for the outbound (from the N-zone to the E-zone) and inbound (from the E-zone to the N-zone) paths. The decoding accuracy remained unchanged despite the differences in motivation and perceived visual cues due to the movement direction. (F) Comparison of the regressor’s accuracy from the control experiment. When the Lobsterbot was removed from the robot compartment, reverting the task back to simple shuttling, the mPFC distance regressor’s performance significantly decreased compared to the Lobsterbot phase.

Spatial encoding is disrupted by non-navigational behaviors
(A) Spatial distribution of the prediction accuracy. The heatmap indicates MAE of a fully trained ANN, superimposed over the entire foraging arena. The prediction accuracies were lower in the N- and E-zone than that in the F-zone. (B) Mean prediction accuracy by the zones. The MAE in F-zone was significantly lower than the other zones. Error bars represent the SEM. (C) Examples of the non-navigational behaviors in the N-zone. The top three snapshots depict grooming, rearing and sniffing. The bottom three snapshots show typical goal-directed navigational movements. (D) Comparison of decoding errors (N-zone) during navigational vs. non-navigational behaviors. The error was significantly larger when the rat was engaged in non-navigational behaviors within the N-zone. (E) Comparison between regressors trained with and without non-navigational behaviors. The overall decoding error was significantly smaller when the regressor was trained without the data during non-navigational behaviors.

PCA results reveals distinctive population activity in the E-zone
(A) Representative recording session depicting the first two dimensions of the PCA result. Populational neural activities are projected onto a virtual space. Each dot represents 50 ms-long neural activity from multiple units. The color of the dots indicates the rat’s location during the corresponding neural activity. Diamonds represent the centroids of neural representations for each zone. To visually emphasize each cluster, data points close to centroids are selectively plotted. (B) Distances between each centroid pairs from all recording sessions. The centroid of the E-zone is distinctly positioned compared to the centroids of the other two zones, indicating a unique neural state within the E-zone. The triangle above the bar plot represents the relative distance between the centroids of each zone’s neural ensemble activity. Longer edges signify greater dissimilarity between the neural ensemble activities of two zones. Error bars represent the SEM.

Multiple subpopulations in the mPFC react differently to head entry and head withdrawal.
(A) Top: The PETH of head entry-responsive units is color-coded based on the Z-score of activity. Bottom: The red vertical lines mark the timing of the head-entry. The peak latency of each unit varies from as early as 2 s before and to 1∼2 s after the head-entry. (B) Functional segregation of all recorded units. Top and middle: Two sub-populations of units based on hierarchical cell clustering analysis. Bottom: The averaged activity for each sub-population. (C) The PETH of head withdrawal-responsive units is color-coded based on the Z-score of activity. (D) Functional segregation of all recorded units. Top and middle: Three sub-populations of units based on hierarchical cell clustering analysis. Bottom: The averaged activity for each sub-population.

Neural ensemble activity predicts failure and success of avoidance response.
(A) Schematics of the event decoding analysis. The Naïve Bayesian decoders are trained with 2 s window of neural activity to discriminate avoidance or escape on every trial (AW/EW classifier). The grayscale image depicts an example firing pattern of 17 units on a given trial, arranged to the onset of the withdrawal response. The decoder classifies whether this trial is AW or EW based on this data. (B) Accuracy of the naïve Bayesian classifier. The decoding accuracy of the classifier was significantly higher than that from the shuffled data. (C) Temporal characteristics of prediction accuracy of the naïve Bayesian classifier. Prediction accuracy was significantly higher at the time points as early as 5-7 s before the head-withdrawal. (D) Class discrimination index by the two sub populations of neurons. The class discrimination index indicates that the Type 2 neurons showed a significant discriminatory power towards AW. Neurons in the Type 2 and the Others group did not exhibit significant discriminatory power.

Feature importance analysis found no evidence of dedicated neural subset for Distance/Event encoding.
(A) Schematic diagram showing computational protocols for the feature importance analysis
(B) Frequency distribution of all recorded units for their feature importance (measured in error increase) in distance encoding. Only a few units produced non-negligible increase in error when removed from the data indicating the absence of dedicated distance-encoding neurons. Red line indicates 95th percentile.
(C) Accuracy of distance regressor without top 20% of high-performance units. Even when 20% of units with high feature importance score were removed, the distance regressor could decode rat’s location.
(D) Frequency distribution of all recorded units for their feature importance (measured in accuracy drop) in event classification. Only a few units produced non-negligible decrease in accuracy when removed from the data indicating the absence of dedicated event-encoding neurons. Shuffling unit’s data resulted small decrease in error, and even some showed increase in accuracy. Red line indicates 95th percentile.
(E) Accuracy of event classifier without top 20% of high-performance units. Even when 20% of units with high feature importance score were removed, the event classifier could decode the type of rat’s defensive behavior.
(F) Correlation between distance regressor’s feature importance score and event classifier’s feature importance score. There was no correlation between feature importance of two types of decoding

Hypothetical control models by which mPFC neurons assume different functional states.
(A) In the F-zone, navigational behaviors enhance the mPFC’s encoding of spatial information compared to other zones. In the N-zone, spatial coding diminishes when the rat engages in non-navigational behaviors. However, in the E-zone, these neurons shift their encoding strategy and become involved in coding for active foraging. We did not find a subset of neurons dedicated exclusively to either spatial coding or active foraging throughout the session. Instead, neurons changed their encoding scheme in a population-wide manner.
(B) Two hypotheses about how the switch is manifested. In this example, most mPFC neurons encode spatial information (blue circles). Information encoded in the mPFC can be regulated by internal/external arbitration signal (top-bottom blue arrow from green circles), or influenced by direct sensory inputs and navigation-related signals (left-right blue arrow) that prompt mPFC neurons to encode spatial information.

Head withdrawal time distribution across all subjects, categorized by trial type
Despite the use of two distinct attack times (3s and 6s), there was no noticeable increase in head withdrawals around the 3-second mark, indicating that the rats did not rely on a 3-second cou ntdown. Instead, they exhibited a relatively stable distribution leading up to the 6-second attac k.

Foraging-related behavioral indices fluctuate upon the initial encoun ter with the Lobsterbot but stabilize after 3 sessions.
(A) Number of approaches. The number of approaches, measured in total trials, decreased afte r the initial encounter with the Lobster (Lob1), but later increased after 3 Lob sessions. (B) Nu mber of licking behaviors. The number of licking behaviors significantly decreased during the first encounter but returned after 3 sessions. (C) Number of licks per trial. The number of licki ng behaviors per trial was decreased after the encounter. (D) Lick latency. The lick latency incr eased after encounter but returned to pre-encounter level after 3 sessions. The black dotted line indicates the timepoint of surgery. Error bars represent SEM.

Comparison between distance regressor algorithms
A comparison of distance regressors using the same dataset showed that the artificial neural network (ANN) and the random forest regressor outperformed the others, but ANN was chosen for its strong generalization to noisy neural data and robustness to hyperparameters. Error bars represent SEM.

Distances between each centroid pairs from all recording sessions. Figure 4B result was reanalyzed using partial dataset which excluded “critical event times” defi ned as ±1 second from head-entry and head-withdrawal. Even removing behaviorally significant data, E-zone’s populational activity was distinctly positioned compare to other zones. Error bars repres ent SEM.

A run-and-stop event (sudden velocity drop outside the E-zone) does not evoke neural modulation.
Normalized activity of HE1 and HE2 units during run-and-stop events (colored; HE1-r&s and HE2-r&s) show no modulation of neural activity compared to highly modulated activity around the head-entry (black and gray; HE1-HE and HE2-HE). Gray shadings indicate SEM.

Most units are classified into either the HE1-HW1 or HE2-HW2 gro ups
(A) Confusion matrix comparing the Head Entry and Head Withdrawal groups. A large propo rtion of units fall into either the HE1-HW1 category (n=299) or the HE2-HW2 category (n=94).
(B) Normalized neural activity of Type 1 (HE1-HW1) and Type 2 (HE2-HW2) neurons during the head-entry and the head-withdrawal. Gray shadings represent SEM.

Type1 and Type 2 neurons’ PETHs around head withdrawal separated by AW and EW
(A) (Top) Type1 neurons’ PETH around head withdrawal separated by AW and EW. Each PETH is sorted by neuron’s peak timepoint. (Bottom) Average of PETH. (B) Same as (A) with Type 2 neurons.

Hierarchical clustering results with different hyperparameter sets Hierarchical clustering uses two hyperparameters: cutoff limit and the number of initial clusters. These variables were varied to assess the clustering results’ dependence on them.
While changes in these variables affected the number of groups, the response characteristics of the top two groups (which were used to further classify Type 1 and Type2) remained consistent. Gray shadings represent SEM.
