a, Example video frame showing estimates of resident and intruder poses and centroids (red bounding boxes and points, respectively) produced by an automated tracker34. Green, grey, and purple bars mark the inter-mouse distances (relative to the resident) categorized as close, intermediate and far. b, Percentage of time animals spent either interacting with conspecifics or present within the three zones. Time points in which animals have recently interacted (that is, interaction has occured within ±1 s) are shown as their own category as a control for the effect of slow GCaMP dynamics. c, PCC between trials of the same intruder sex, or between male and female trials, where representations of intruders are computed by averaging each cell’s ΔF(t)/F0 across the indicated subsets of imaging time points. d, Accuracy of a linear SVM decoder for intruder sex, using representations computed as in c. Decoder accuracy was not significantly affected by distance. e, Top, the distance modulation index (m), a measurement of the extent to which cell activity is modulated by inter-animal distance, is computed from rclose (the average response of a cell when animals are close but have not recently interacted (within ±1 s)), and rfar (the average response of that cell when animals are far apart and have not recently interacted). e, Bottom, example ΔF/F traces (black) from two cells that have a high (e1, m = 0.89) and low (e2, m = 0.08) distance modulation index, and corresponding inter-animal distances (brown). f, Histograms of values of m observed in all cells that are significantly excited (above) or inhibited (below) during interaction with males or females. Note that inhibited cells are less sensitive to inter-animal distance than are excited cells, and that the distribution of m is similar for cells that are responsive to male and female intruders.