A scalable internal code for threat imminence in prefrontal ensembles
Data files
May 21, 2026 version files 2.62 GB
-
barplot_with_dots.m
650 B
-
color_psth.m
1.78 KB
-
coreg_pop_vector_across_days.m
29.84 KB
-
coreg_rat_grid.m
7.58 KB
-
coregistration.mat
13.76 KB
-
correlations_of_behaviorla_metrics.m
10.97 KB
-
create_continuous_behavior_traces.m
3.28 KB
-
find_fuga_bout.m
3.94 KB
-
freez_approach_corr.m
2.06 KB
-
freez_popvector_dist_to_neargrid_popvector.m
19.92 KB
-
fuga_cell_activity_corr_with_future_fuga3.m
36.91 KB
-
fuga_cell_corr_with_exploration_and_fuga_speed.m
11.36 KB
-
fuga_cell_slope_corr_fugalatency.m
7.34 KB
-
fuga_cells_coreg_hab_shock2.m
13.98 KB
-
fuga_k_means_clusters.m
8.82 KB
-
fuga_pop_vector_corr.m
7.98 KB
-
fuga_weigh_corr_dist_threat.m
8.82 KB
-
fugacell1_corr_approach.m
3.13 KB
-
GLM_avi2.m
41.88 KB
-
GLM_K_means_clusters.m
12.24 KB
-
grid_mov_onset_psth.m
20.25 KB
-
grid_mov_onset_psth3.m
7.37 KB
-
k_means_cluster_of_fugaplus_cells.m
5.83 KB
-
MG_A_00_baseline.mat
109.79 MB
-
MG_A_01_shock.mat
102.79 MB
-
MG_A_02_retrieval.mat
154.08 MB
-
MG_B_00_baseline.mat
137.91 MB
-
MG_B_01_shock.mat
166.51 MB
-
MG_B_02_retrieval.mat
204.34 MB
-
MG_C_00_baseline.mat
87.90 MB
-
MG_C_01_shock.mat
80.53 MB
-
MG_C_02_retrieval.mat
104.51 MB
-
MG_D_00_baseline.mat
136.29 MB
-
MG_D_01_shock.mat
137.25 MB
-
MG_D_02_retrieval.mat
191.17 MB
-
MG_E_00_baseline.mat
78.08 MB
-
MG_E_01_shock.mat
88.14 MB
-
MG_E_02_retrieval.mat
107.31 MB
-
MG_F_00_baseline.mat
122.49 MB
-
MG_F_01_shock.mat
126.82 MB
-
MG_F_02_retrieval.mat
164.27 MB
-
MG_G_00_baseline.mat
104.69 MB
-
MG_G_01_shock.mat
75.02 MB
-
MG_G_02_retrieval.mat
139.25 MB
-
pairwise_fugacell_corr2.m
13.40 KB
-
PCA_moving_grid.m
3.30 KB
-
PCA_ring5.m
14.72 KB
-
PCA_ring6.m
10.08 KB
-
piechart_fuga_cell_corr_score.m
9.80 KB
-
plot_std_fill.m
412 B
-
plot_xy_corr.m
1.01 KB
-
predatory_imminence_score.m
5.89 KB
-
predatory_score_corr_dfF.m
9.10 KB
-
predatory_score_stepwise_construction.m
6.53 KB
-
README.md
8.76 KB
-
reorder_corrmatrix.m
1.74 KB
Abstract
Survival in dynamic environments requires the integration of multisensory cues and movement into a unified estimate of risk, a process governed by the internal variable of threat imminence. While the medial prefrontal cortex (mPFC) is known to regulate defensive behaviors, how it represents threat imminence remains unresolved. Here, we developed the FUGA task, in which mice are fear conditioning to a moving shock grid, eliciting the full topography of defensive actions, including avoidance, risk-assessment, freezing and flight upon grid approach (FUGA). Using longitudinal calcium imaging of mPFC excitatory ensembles, we show that following fear acquisition, mPFC activity patterns representing threat proximity became significantly correlated with the representation of the shock, revealing a learned neural association between shock and grid. Additionally, mPFC population trajectories tracked threat imminence, reflecting internal state rather than specific behaviors or kinematics. We also identified two non-overlapping ensembles that multiplex kinematic and contextual variables and that are respectively activated by high and low threat imminence states. Furthermore, ensemble synchrony and imminence encoding predicted the execution of successful escape trials prior to flight onset. Finally, optogenetic inhibition revealed that mPFC activity is essential for both the acquisition and expression of learned escape and avoidance. These discoveries identify the mPFC as a critical substrate for representing learned threat imminence to guide flexible behavior.
Dataset DOI: 10.5061/dryad.3tx95x6x9
Description of the data and file structure
Behavioral and neural data .mat Files
These are mPFC miniscope recordings of mice exposed to the moving grid FUGA assay, similar to depicted in figure 1 shown in figure 1 of this paper https://www.jneurosci.org/content/early/2025/04/01/JNEUROSCI.1806-24.2025
Briefly, a shock grid moves back and forth in a corridor. During baseline, grid is turned off. During shock day, grid is turned on. During retrieval day, grid is turned off.
Each .mat file contains the data for one recording session. All .mat files have a name structure like: MG_B_02_retrieval.mat
All .mat files start with MG, which is not relevant. In the example above, the important information is that this name 'MG_B_02_retrieval.mat' is retrieval session from mouse 'B'. All other .mat files follow the same naming structure, and have baseline, shock and retrieval sessions for mice labelled 'A' to 'G'.
These are the names of all the variables contained in a .mat file. All the .mat files contain only these variables.
Sampling frequency for all data is 20 Hz. Distances are in cm, and time is in sec, speed in cm/s. Neural activity is z-scored gcamp calcium transients for each mPFC camk2a cell. Timepoints are always in the x (row) dimension.
%behaviors: these are 1 x T vectors, where T is the number of recorded timepoints. These vectors show occurrence of behavior with '1', and non occurrence with 0 for each timepoint.
The behavior vectors are: fuga, freeze, approach, stretch and rearing. These have binary 0 or 1 for each timepoint showing if these behaviors happened. fuga is flight upon grid approach, freeze is freezing in fear, approach is mouse approaching the grid, stretch are risk assessment stretch attend postures and rearing is standing on two hind legs.
bar_start - indices in which the grid starts moving
bar_stop - indices in which the grid stops moving
bar_mov - binary vector with 0 or 1 for every timepoint indicating if the grid is moving or not
bar_vel - velocity of grid at each timepoint in cm/s
bar_x - position of the grid at each timepoint in cm
cluster_ind - one element per cell, showing if that cell belongs to cluster 1 or 2 defined by K means clustering using GLM behavioral weights
cluster_inds_fuga - one element per cell, showing if that cell belongs to cluster 1-4 determined by K means using their response pattern centered at FUGA escape onset
df - one row per cell, one timepoint per column with zscored gcamp activity of miniscope recorded mpfc cmak2a cell in this mouse
dist_threat - distance to the grid in cm for each timepoint
t - time vector in second that goes from 0 to the end of the recording, in increments of 1/20, as 20 Hx is the sampling rate. t is in seconds
x- x position of the mouse at each timepoint in cm
y-y position of the mouse at each timepoint in cm
x_vel - velocity in the x axis of the mouse at each timepoint
%GLM variables. These were generated by the script GLM_avi2.m, which is included in this dataset
glm_coef - one row per cell, one column per GLM variable, containing the GLM Weights for each variable per cell.
glm_pval - one row per cell, one column per GLM variable containing the GLM p value for each variable
Columns 1-8 of these GLM variables correspond to the following 8 predictors:
% glm_coefs columns 1:8
% 1 fuga
% 2 freeze
% 3 approach
% 4 stretch
% 5 rearing
% 6 x speed
% 7 distance to threat (stationary)
% 8 distance to threat (moving)
Cell co-registration .mat file ('coregistration.mat')
In this .mat file there is a variable called 'coreg_all_3_days'. This variable has 4 columns with the identities of cells co-registered across all 3 days. column 1, 2 and 3 respectively are the ID #s of cells in habituation, shock and retrieval days. Column is the mouse kk number, where kk=1,2,3 represents mouse A B, C and so on. For example, the 4th line in coreg_all_3_days is :15, 8, 16, 1
The 4th number (1) indicates this is information about mouse 1 (a.k.a mouse 'A'). This shows the identity of the same cell co-registered across the 3 days of recordings. Cell #15 from mouse A in baseline is cell# 8 from mouse A in 8 and that is the same as cell #16 in the retrieval session.
Files and variables
The files below are .m matlab scripts that can run on the .mat files described above
File: correlations_of_behaviorla_metrics.m
Description: calculates correlations between behavioral metrics of miniscope mice
File: fuga_cell_slope_corr_fugalatency.m
Description: calculates relation between fuga latency and fuga+ ensemble activity
File: fuga_pop_vector_corr.m
Description: calcualtes distance between fuga population vector and other behaviors
File: coreg_pop_vector_across_days.m
Description: Calculates shock population vector and compares it to grid near vectors across days
File: pairwise_fuga_cell_corr_hab.m
Description: calcualtes pairwise correlations of fuga + and - ensembles
File: color_psth.m
Description: creates color psth
File: coreg_rat_grid.m
Description: finds cells recorded also in the rat experiment
File: PCA_ring5.m
Description: calculates correlation between neural data projected into principal component 1 and the predatory imminence score
File: PCA_ring6.m
Description: this script is called by PCA_ring5
File: plot_xy_corr.m
Description: plots r and p values for linear correlation in a plot
File: predatory_imminence_score.m
Description: calculates predatory imminence score
File: piechart_fuga_cell_corr_score.m
Description: pie chart of gua ensembles
File: plot_std_fill.m
Description: plots mean plus minus shaded SEM
File: find_fuga_bout.m
Description: identifies fuga behavior
File: predatory_score_corr_dfF.m
Description: calculates predatory score
File: predatory_score_stepwise_construction.m
Description: makes figure explaining predatory score calculation
File: reorder_corrmatrix.m
Description: reorders pairwise correlation matrix with hierarchical clustering
File: freez_popvector_dist_to_neargrid_popvector.m
Description: calculates similarity between population vector for bein near grid with population vector for each behavior
File: freez_approach_corr.m
Description: plots correlation between approach to grid and freeze behavior
File: fuga_cell_corr_with_exploration_and_fuga_speed.m
Description: plots example trial predatory imminence score along with related behavioral variables
File: fuga_cell_activity_corr_with_future_fuga3.m
Description: plots fuga+ cell activity separately for trials with and without fuga escapes
File: fuga_cells_coreg_hab_shock2.m
Description: plots correlation of fuga+ cells with predatory imminence score across days
File: fuga_k_means_clusters.m
Description: makes clusters of cells based on behavioral weights
File: GLM_K_means_clusters.m
Description: uses k means clustering to divide cells into 2 clusters based on their behavioral GLM values
File: create_continuous_behavior_traces.m
Description: preprocesses data
File: grid_mov_onset_psth.m
Description: plots glm weights for fuga+ and _ cells
File: GLM_avi2.m
Description: performs GLM for each cell using behavioral and kinematic predictors
File: grid_mov_onset_psth3.m
Description: plots activity for cells around grid movement onset for all cells co registered in the 3 recording sessions
File: barplot_with_dots.m
Description: plots bar plots
File: fuga_weigh_corr_dist_threat.m
Description: calculates correlation of fuga glm weights with distance to threat
File: k_means_cluster_of_fugaplus_cells.m
Description: performs k means clustering based on glm weights
File: fugacell1_corr_approach.m
Description: plots correlation between % of cells classified as fuga+ and freezing across mice
File: PCA_moving_grid.m
Description: plots rearing, freeze and fuga behavioral timepoints in principal component space in different colors for each behavior
File: pairwise_fugacell_corr2.m
Description: calculates pairwise cell activity correlation between all fuga+ cells in trials with and without fuga escape
Code/software
All the necessary code to analyze the data is in this dryad link, as .m matlab scripts
