This data collection contains spatially resolved single-cell transcriptomics datasets acquired using MERFISH on the mouse periaqueductal gray (PAG) from mice exposed to one of several different behavioral paradigms. Data were collected by the laboratories of Prof. Xiaowei Zhuang and Prof. Catherine Dulac at Harvard University and Howard Hughes Medical Institute. The data collection is composed of 27 experiments. In each experiment the brain of a naive adult mouse or a behaviorally-stimulated adult mouse was imaged using MERFISH, collecting data from 10-µm thick coronal slices taken at evenly-spaced intervals across the extent of the PAG. Most experiments were performed using slices spaced apart by 200 µm, and all slices were placed on a single coverslip and imaged together. For some experiments, a higher slice density was used, with slices spaced by 100 µm, and in these cases the anterior slices were placed on one coverslip and the posterior slices were placed on another coverslip, and they were imaged separately. In all cases 12-13 slices were placed on a coverslip, and each slice was imaged with 81 fields-of-view (FOV) arranged as a 9-by-9 array centered on the aqueduct. Each FOV covers 223 µm by 223 µm in x and y, and the centers of each FOV were separated by 200 µm. Each experiment imaged 262 marker genes and 26 activity-related genes. Of the marker genes, 258 were imaged using MERFISH, with each gene encoded by a unique, error-robust barcode using a 20 bit binary encoding scheme. The barcodes were imprinted onto the RNAs using a complex pool of encoding probes. The 20 bits were imaged using 10 rounds of two-color imaging. The remaining 4 marker genes were imaged with sequential FISH, using two rounds of two-color imaging, plus an additional round acquired using no fluorescent probes to estimate local background. The 26 activity-related genes were imaged using MERFISH as described for the marker genes, but only 10 bits were used for error-robust encoding of these genes. These 10 bits were imaged using 5 rounds of two-color imaging. All bits used for MERFISH imaging of the 258 marker genes were imaged in 6 z-planes spaced apart by 1.5 µm, starting at 0 µm and ending at 7.5 µm above the surface of the coverglass. All bits used for sequential marker gene imaging or MERFISH imaging of activity-related genes were imaged in a single z-plane 4.5 µm above the surface of the coverglass. The raw and deconvolve MERFISH image data are deposited at ftp://download.brainimagelibrary.org:8811/biccn/zeng/zhuang/merfish/PAG/. At this site, the "image_data" folder contains the MERFISH image data. Experiments are organized into folders based on the behavioral condition. In each behavioral condition folder, each experiment is contained within a folder named according to the behavioral condition and biological replicate number (e.g. Male_naive_animal_2, Male_naive_animal_3, Female_naive_animal_1, etc). In the cases where the imaging was split across two coverslips, data are organized as above but with "anterior" or "posterior" appended to the name. Each experiment contains an "Aligned_images" and a "Deconvolved_images" folder. In the "Aligned_images" folder, each FOV is present as a single file, with the images from all the bits and z planes combined into a single multi-frame tiff file that was then compressed with zstandard. Each image has been corrected for x-y drift that occurred during the rounds of imaging using fiducial beads. Aligned images are named aligned_images{FOV}.tif.zstd, where {FOV} is the number of the FOV used for that set of images. In the "Deconvolved_images" folder, the files are the same as described for the aligned images, but with the additional processing step in which the images were high-pass filtered and deconvolved using parameters described in preprocessing_parameters.json. These processed images are named processed_images{FOV}.tif.zstd, where {FOV} is the number of the FOV used for that set of images. The supplementary_files folder at this site contains the files listed in the "Sample analysis metadata" section of the dataset_metadata_June 2020.csv, including lists of the genes analyzed, encoding probe sequences, codebooks, and the data organization file. In the same site as the raw and deconvolve image data, the "fov_coordinates" folder contains a csv file for each experiment, named according to the behavioral condition and biological replicate number of the animal as described above. Each file contains three columns, the first column is the number of the FOV, the second and third columns are the x and y coordinates of the fov (in µm), respectively. These coordinates can be used to arrange the FOVs of an experiment as they were arranged on the coverslip. This current site contains the processed data for the above imaging data. The processed_data folder contains files generated through analysis of the raw image data using MERlin (doi:10.5281/zenodo.3758540). The directory structure of the processed data mirrors that of the image data described above, with experiments organized based on the behavioral condition. The folder for each experiment contains 6 files: 1) cell_segmentation_boundaries.csv.gz contains the exterior boundary of all cells after removing overlapping features. The first column (feature_ID) is a unique cell identifier, the second column (for) is the FOV the cell is found in, the third and fourth columns (x_0 and y_0) are the x and y coordinates of the cell boundary, respectively, arranged as a list of lists, for the first z plane (z = 0 µm). The remaining columns are x and y coordinates for the subsequent z planes (fifth and sixth column (x_1.5 and y_1.5) correspond to z = 1.5 µm, etc, up through the last z plane at 7.5 µm). In cases where a cells boundary was split into two discrete areas in a given z plane, the two boundaries for that FOV are contained as separate lists within that element of the table. Note that the same coordinate system is used for the cell boundaries and barcodes. 2) barcodes_marker_genes.csv.gz contains all the barcodes from combinatorial marker genes that were decoded and passed filtering for a given experiment. The first column is the barcode id corresponding to an entry in codebook_combinatorial_marker_genes.csv, the second column is the gene name for that barcode id, the third through fifth columns are the mean x, y, and z coordinates of the barcode, and the sixth column is the FOV the barcode was detected in. The x, y, and z coordinates are in the units of microns. The z coordinate is the position of the z plane in which the barcode is imaged. 3) barcodes_activity_genes.csv.gz contains all the barcodes from combinatorial activity-related genes that were decoded and passed filtering for a given experiment. The columns are as described for barcodes_marker_genes.csv.gz. 4) sequential_marker_genes.csv contains the fluorescence intensity detected for the sequential marker genes in each cell. The first column is a unique cell identifier, the second through fifth columns correspond to the signal detected for Snap25, Cartpt, Ucn, and Hepacam respectively. The sixth and seventh columns, blank1 and blank2, are the background intensity detected in the 650 and 750 channels, respectively. The eighth and ninth columns, polyT and DAPI, are the intensity for the total poly(A) RNA probe and DAPI, respectively. All intensities are normalized to the number of pixels that contributed to the signal, and came from a single z plane (z = 4.5 µm). If a cell was not found to have any boundary at z = 4.5 µm then no value was entered into each column. 5) fov_to_slice.csv provides the set of FOVs that correspond to each slice, and the position of the slices relative to the anterior-most slice imaged for that animal. 6) cell_by_gene.csv.gz contains a cell-by-gene matrix, filtering out cells that are <100 or >3000 µm^3. The cell-by-gene matrix contains columns for cell ID, fov, cell volume (in µm^3), fov_x (cell centroid in pixel coordinates), fov_y (cell centroid in pixel coordinates), global_x (cell centroid in µm coordinates), global_y (cell centroid in µm coordinates), mRNA_counts (sum of combinatorial marker gene counts), Brain_pos (the number of the slice, lowest is anterior-most, highest is posterior-most), median_total_density (the median density of the barcodes for all cells in the specific experiment prior to rescaling), and additional columns that describe the expression data of individual genes. Expression data of individual genes based on combinatorial measurements are volume normalized. Expression measurements were then rescaled so that all experiments had the same median density. The scaling factor was calculated by taking 250 divided by the sum of the volume normalized expression for all combinatorial marker genes. Each combinatorial marker gene and combinatorial activity-related gene was multiplied by this scaling factor. The activity-related genes were thus scaled in accordance with the overall experiment performance as assessed by the marker genes, but did not influence the scaling as they were expected to change across different experimental conditions. The rescaled expression was log transformed as log10(x + 1), which is reported in the cell-by-gene matrix. The volume-normalized sequential measurements were log-transformed as log10(x + 1) and then the blank measurement from the corresponding color channel was subtracted. The combined_data folder contains the file cell_by_gene.h5ad, which is the aggregated results of each experiment's cell-by-gene matrix. The expression measurements are exactly as described above for each experiment's cell-by-gene matrix. In the final anndata object, the cells are stored as the index of the observations dataframe, the marker genes are stored as the index of the variables, and the marker gene expression measurements for each cell are stored as the data of the object. All metadata are stored as columns in the observations dataframe. The metadata include: Sample_name, Condition, Sex, fov, volume, fov_x, fov_y, global_x, global_y, rotated_x (coordinates determined by manually assessing slice morphology to orient dorsal-ventral axis as vertically as possible) , rotated_y (as for rotated_x), Z_position (the z-position for the slice that the cell was found in), mRNA_counts, Brain_pos, and median_total_density. poly(T) and DAPI contain the volume normalized intensity of the total poly(A) RNA stain and DAPI stain for each cell. There are 27 "blank" barcodes from the combinatorial marker gene measurements that are also stored in the metadata. The 26 activity-related expression measurements are stored here as well, normalized as described above for the experiment cell-by-gene matrix, along with the 4 blank barcodes for the combinatorial activity-related gene measurement. The same folder also contains the same cell-by-gene data in csv.gz format. The csv file contains the metadata columns followed by the columns for the expression data of the combinatorial marker genes. The metadata columns include Sample_name, Condition, Sex, fov, volume, fov_x, fov_y, global_x, global_y, rotated_x, rotated_y, Z_position, mRNA_counts, Brain_pos, median_total_density, poly(T), DAPI, the expression data of the 27 blank barcodes for combinatorial marker gene measurements, the expression data of the 26 activity-related genes, and the expression data of 4 blank barcodes for the combinatorial activity-related gene measurement.