Two-photon (2P) imaging was performed using a laser scanning microscope (Ultima 2p plus Bruker, MA) equipped with a 16’ water immersion objective (numerical aperture of 0.8, Nikon, NY) and an ultrafast laser tuned to 920 nm for fluorescence Ca2+ excitations (InSight X3, Spectra-Physics). After initial habituation, z-stack 2P imaging was performed, for which mice were awake and head-restrained on a home-constructed low-friction rodent-driven belt treadmill following the design of HHMI Janelia (https://www.janelia.org/open-science/low-friction-rodent-driven-belt-treadmill). Each imaging session lasted up to 3 hours and contained multiple replicants. Each replicant contained alternating stimulation and baseline (no stimulation) trials from randomized stimulation sites and currents. 512 × 512 images of a field of view up to 1 mm × 1 mm were acquired at 30 fps using galvo-resonant scanners. The duration of a typical z-stack, referred to as an imaging trial, was about 30 s for a depth of 400 μm at the z-spacing of 2 μm. An inter-trial period of 2 to 5 seconds was implemented for data saving. Electrical stimulation was delivered via a custom Pico32+Stim front end with a Grapevine neural interface processor (Ripple Neuro, Salt Lake City, UT). During stimulation trials, 50 Hz electrical stimulation pulse trains of biphasic, charge-balanced cathode-leading square pulses at 167 μs per phase and 67 μs inter-phase interval were provided. The current amplitudes were 2, 5, 7, and 10 μA, resulting in a maximum charge injection of 1.67 nC/ph per phase and a maximum charge density of 369.5 μC/cm2. According to the Shannon criteria, the largest stimulation current gave a K=0.48, smaller than the threshold of 1.85 for tissue compatible/safe neural stimulation. Customized MATLAB (MathWorks, MA) scripts were developed to randomize stimulation parameters and control data acquisition. Stimulation and 2P imaging were synchronized via TTL signals generated by a PulsePal (Sanworks, NY) unit.