Figures and data

Behavioral procedure and apparatus.
(A) Schematic of the arena showing major sections: N, nest zone; F, foraging zone; E, encounter zone. At the end of the E-zone, the Lobsterbot (red) guards the sucrose delivery port (green). (B) Rendered 3-D image of the Lobsterbot. The sucrose port is positioned between the “claws”. Two red lines indicate infrared detectors: a short line for lick detection (short line) and a long line for E-zone entry detection. (C) Experimental schedule. (D) Example snapshots of avoidance withdrawal (AW) and escape withdrawal (EW). In an AW trial, the rat typically retracts its head in advance and observes the Lobsterbot attack. In an EW trial, the rat reflexively flees from the attack. (E) Example behavior data containing two consecutive trials (Trials 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) Summary of the AW trial rates for each animal during Losterbot sessions. Points for Lob2 of Rat2 and Rat3 are omitted because they did not approach the robot during the entire Lob2 session.

Ensemble activity in the mPFC predicts distance from the goal.
(A) Electrode implantation and recording sites. 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 distance regressor. Mean Absolute Error (MAE) was significantly smaller for the original dataset (16.61 cm, Original) compared to the shuffled dataset (Shuffled), and below the rat’s body length, suggesting that the mPFC ensembles encode spatial correlates of the 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. Prediction accuracy was highest in the F-zone and lower in the N- and E-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. Errors were significantly larger when the rat was engaged in non-navigational behaviors within the N-zone. (E) Comparison between regressors trained with vs. without data from non-navigational behaviors. The overall decoding error was significantly smaller when the regressor was trained without the data from non-navigational behaviors.

PCA results reveal distinctive population activity in the E-zone
(A) Representative recording session depicting the first two principal components of population neural activity. Each dot represents a 50-ms segment of multi-unit activity, color-coded by the rat’s location. Diamonds mark the centroids of neural representations for each zone. To clustering, only data points near each centroid have been plotted. (B) Distances between all centroid pairs across recording sessions. The centroid of the E-zone is distinctly separated from those of the other two zones, indicating a unique neural state within the E-zone. The triangle above the bar plot illustrates the relative distances between the centroids of each zone; Longer edges indicate greater dissimilarity between neural ensemble activities. Error bars represent 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 shows no evidence of dedicated neural subsets for distance or event encoding.
(A) Schematic of the computational protocol for the feature importance analysis. (B) Frequency distribution of all recorded units for their feature importance (measured as error increase) in distance encoding. Only a few units produced non-negligible increase in error when removed, indicating no dedicated distance-encoding neurons. The red line marks the 95th percentile. (C) Accuracy of distance regressor after removing the 20% of high-importance units. Even without these units, the regressor accurately decoded the rat’s location. (D) Frequency distribution of all recorded units by their feature importance (measured in accuracy drop) in event classification. Only a few units caused a non-negligible accuracy decrease when removed, indicating no dedicated event-encoding neurons. Shuffling unit data resulted in a small decrease in accuracy, and even some cases, an increase. The red line marks the 95th percentile. (E) Accuracy of the event classifier after removing the top 20% of high-performance units. Even without these units, the classifier decoded the type of the event (AW vs. EW). (F) Correlation between feature importance scores for the distance regressor and the event classifier. No correlation was found between the two measures.

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) Three 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. A third possibility is that both signals compete to gain control.

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 with drawals around the 3-second mark, indicating that the rats did not rely on a 3-second countdown. Inst ead, they exhibited a relatively stable distribution leading up to the 6-second attack.

Foraging-related behavioral indices fluctuate upon the initial encounter w ith the Lobsterbot but stabilize after 3 sessions.
(A) Number of approaches. The number of approaches, measured in total trials, decreased after the in itial encounter with the Lobster (Lob1), but later increased after 3 Lob sessions. (B) Number of lickin g behaviors. The number of licking behaviors significantly decreased during the first encounter but re turned after 3 sessions. (C) Number of licks per trial. The number of licking behaviors per trial was d ecreased after the encounter. (D) Lick latency. The lick latency increased after encounter but returne d 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” defined 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 represent SE M.

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 groups
(A) Confusion matrix comparing the Head Entry and Head Withdrawal groups. A large proportion of units fall into either the HE1-HW1 category (n=299) or the HE2-HW2 category (n=94). (B) Normali zed 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.
