NEURAL DATA PREPROCESSING All neural data are preprocessed using the scripts in preprocessing_code (detailed instructions and descriptions) neural_preprocessing: 1. Raw neural data are acquired as movies and have filetype .cxd 2. These movies are converted to .tif, and then motion-corrected. 3. Fluorescence is extracted from ROIs corresponding to fiber tops, and delta-F-over-F is calculated. 4. The resulting preprocessed data is a .mat struct with the following fields: *ROIs: the centers of the ROIs *datapath: the path to the associated .tif file *snapshot: a snapshot of a frame from the .tif movie *radius: the radius of the ROIs *ROImasks: an m x n x p matrix of p binary ROI masks *FtoFcWindow: the window used to calculate baseline *F: the extracted raw fluorescence *Fc: the calculated ΔF/F *Fc_baseline: the calculated baseline *Fc_center: the calculated center, which becomes 0 fiber_localization: For fiber localization, mouse brains are CT-scanned with the implant intact. Then the CT scan is registered to the Allen Brain Mouse CCF Atlas, and then fiber tips are localized. This is done via the scripts in https://github.com/HoweLab/MultifiberLocalization. The final fiber .mat table contains location and atlas information for each fiber. *CT_dicom_align_and_convert.fig & CT_dicom_align_and_convert.m & CT_dicom_align_and_convert_guide.png: convert CT dicoms to .tif and orient it *load_fiji_landmarks.m: loads landmark files generated from FIJI's Name Landmarks and Register plugin *register_ct_to_ccf_affine.m: landmark-based registration *manual_refine_registration.m & manual_refine_registration.fig: manually refine the registration LOCALIZE_FIBERS.fig & LOCALIZE_FIBERS.m: the main GUI to run the localization, and calls the following steps *visualize_grid_top.m & visualize_grid_top.fig: find the axial slice with visible grid organization *assign_grid_top.m & assign_grid_top.fig: map the grid top with the calibration grid file *axial_fiber_polygon_roi.m & axial_fiber_polygon_roi.fig: define, axially, the area containing the implated fibers *make_fiber_mask.m & make_fiber_mask.fig: create an intensity-based mask of the fibers *identify_and_map_fibers.m: from the fiber mask, identify fibers and map them to the grid *separate_multifibers.m: automated separation of multifibers (multiple fibers being grouped as 1, usually because they touch) verify_multifibers.m & verify_multifibers.fig: manual verification of multifibers *further_separate_multifibers.m: further separation of multifibers based on manual verification add_atlas_info.m: add atlas information from Allen Brain Mouse CCF Atlas and Kim Lab Atlas verify_labels.m & verify_labels.fig: manual verification of assigned atlas labels behavioral_preprocessing Behavioral data is collected at 2kHz via a programmable digital acquisition card (NIDAQ, National Instruments PCIe 6343) controlled via custom MATLAB programs. TTL pulses sent from the imaging cameras enable syncing of behavioral recordings with neural, i.e., imaging, data (see split_and_bin_grid_behav_files.m). The resulting "binned" behavioral data measures have one datapoint (calculated via averaging, and for binary variables, subsequently rounded) corresponding to one frame of the recorded neural data movie. The preprocessed data (.mat) files have the following fields: *mouse: the name of the file *starttime: the timestamp of the beginning of the recording *otherVars: other task-related variables (the mapping of the NIDAQ channels, etc) *timestamp: the time (s) elapsed since the start of the recording *ballSensor1_x: raw voltage reflecting the magnitude of the x-velocity coming from optical mouse sensor placed behind the mouse on the ball treadmill *ballSensor1_y: raw voltage reflecting the magnitude of the y-velocity coming from optical mouse sensor placed behind the mouse on the ball treadmill *ballSensor1_xsign: the sign (direction) of the x-velocity coming from optical mouse sensor placed behind the mouse on the ball treadmill *ballSensor1_ysign: the sign (direction) of the y-velocity coming from optical mouse sensor placed behind the mouse on *ballSensor2_x: raw voltage reflecting the magnitude of the x-velocity coming from optical mouse sensor placed to the side of the mouse on the ball treadmill *ballSensor2_y: raw voltage reflecting the magnitude of the y-velocity coming from optical mouse sensor placed to the side of the mouse on the ball treadmill *ballSensor2_xsign: the sign (direction) of the x-velocity coming from optical mouse sensor placed to the side of the mouse on the ball treadmill *ballSensor2_ysign: the sign (direction) of the y-velocity coming from optical mouse sensor placed to the side of the mouse on the ball treadmill *ballYaw: conversion to yaw velocity; see ball2xy.m *ballPitch: conversion to pitch velocity; see ball2xy.m *ballRoll: conversion to roll velocity; see ball2xy.m *reward: (binary) reward trigger *lick: (binary) lick touch sensor *ttlOut: (binary) TTLs sent from the program (user determined) *ttlIn1: (binary) TTLs coming in from neural imaging camera #1 (if applicable) *ttlIn2: (binary) TTLs coming in from neural imaging camera #2 (if applicable) *ttlIn470: (binary) duplicate of TTLs sent to trigger 470nm LED (if applicable) *ttlIn1_x_ttlIn470: (binary) the product of ttlIn1 and ttlIn470 *ttlIn3: TTLs coming in from behavioral camera #1 (if applicable) *ttlIn4: TTLs coming in from behavioral camera #2 (if applicable) The following fields are in the "binned" behavioral data and are the sums per bin of the binary digital signals of the corresponding fields. *reward_count *lick_count *ttlOut_count *ttlIn1_count *ttlIn2_count: *ttlIn470_count: *ttlIn1_x_ttlIn470_count: *ttlIn3_count: *ttlIn4_count: