Animals

All experiments and procedures were approved by the veterinary office of the canton of Bern, Switzerland, and the veterinary office of Landesamtfür Gesundheit und Soziales (LaGeSo) regulation in Berlin, Germany. We used female Wistar rats (P28–P52, Charles River) for freely behaving experiments and male Wistar rats for juxtacellular recordings. For two-photon experiments, we used female (>P40) C57BL/6 (Charles River) or Rbp4-cre (031125-UCD, MMRRC) mice. All animals were group-housed on a 12:12 light/dark cycle with ad lib food and water.

In vivo loading of Ca2+-sensitive dyes

Activity from L2/3 and dendrites were monitored using the synthetic Ca2+ dye Oregon Green 488 BAPTA-1 (OGB-1)-AM (Molecular Probes, Eugene, OR, USA prepared as described in ref. 16) or the genetically encoded calcium indicator (GECI) GCaMP6s (AAV1.Syn.GCaMP6s.WPRE.SV40, PENN Vector Core). In the control group, half of the rats did not receive any injection and the other half received an injection of a control virus (AAV1.Syn.Flex.GCaMP6s.WPRE.SV40, PENN Vector Core) to mimic the injection procedure and potential follow-up effects (Supplementary Table 1). All injections were performed in the primary somatosensory cortex, centred on the hindlimb area as described in ref. 16. Injections of GCaMP6s were performed in rat pups (P11-P14, injection depths: L5=1.1 mm; L2/3 and Ctrl=200 µm; 1 mm posterior from bregma and 1 mm from midline) to allow diffusion and expression of the virus into dendrites (3–4 weeks). Animals that were imaged using OGB1-AM were injected on the day of recording (Fig. 1c) using the same procedure with slightly different coordinates and injection depths adjusted for age (L5=1.5 mm; L2/3=250 µm, 1.5 mm posterior to bregma and 2.2 mm from midline16). Rat were anaesthetised with isoflurane (1.5–3%) and place in a stereotaxic frame. Body temperature was maintained at ~37 °C using a heating pad. A small incision was made in the skin and a hole was drilled through the skull above the somatosensory cortex. Between 30 and 50 nl of dye was pressure injected over 1 min, followed by a waiting period of 5 min before the micropipette (5 µl calibrated micropipettes, Blaubrand®) was then slowly removed. After virus injection, the site was covered with silicone (Kwik-Cast™, World Precision Instruments, Inc.) and the skin was sutured. At the end of the surgical procedure, buprenorphine was administered as a long-lasting analgesic (0.01 to 0.05 mg/kg, intraperitoneal (IP)) and the pups were returned to the mother.

Surgeries for freely behaving recordings

At least 2 days before the recording session, rats underwent surgery for EEG/EMG implantation under isoflurane anaesthesia (1.5–3% in O 2 ). Rat were placed in a stereotaxic frame and controlled for body temperature. Headmounts (Pinnacle Technology, Inc.) were used for FF and FP EEG recordings (Fig. 1d). After skin, blood and tissue covering the skull were removed, the bone was covered with light-curing adhesive (OptiBond, Kerr, Orange, CA, USA). No adhesive was applied to parts of the skull that were later drilled through for placement of the EEG wires. Three silver wires were used as EEGs and two stainless steel wires were implanted in the nuchal muscles for EMG recordings (Pinnacle Technology, Inc., USA). Electrodes were affixed to the skull using bone screws and dental acrylic. The area of the skull above the imaged cortical region was left exposed and covered with a protective thin layer of dental cement for cannula implantation on the day of recording (Fig. 1c). At the end of the surgical procedure, buprenorphine was administered as a long-lasting analgesic (0.01 to 0.05 mg/kg IP) and the animals were allowed to recover for at least 2 days.

On the day of the experiment the animal was anaesthetised with isoflurane (1.5–3% in O 2 ) and placed in a stereotaxic frame for fibre-optic cannula placement. Virus-injected animals only underwent surgery for cannula implantation on that day. A small craniotomy was made (~1 mm2). After a careful incision of the dura was made to expose a small area of the cortical surface (<0.5 mm2), a subset of animals received an OGB1-AM injection (Fig. 1c). In all animals, a fibre-optic cannula was placed directly on the cortical surface with a micromanipulator, at least >0.5 mm away from the initial injection site. In the L5 injected group, some rats were imaged using a prism-like cannula inserted at a depth of 200–300 µm into the cortex (Fig. 1f). The craniotomy was then covered with a layer of silicon (Kwik-Cast™, World Precision Instruments, Inc.) and secured with dental cement. The animal was then placed in an arena of 40 × 30 × 20 cm3 (width, depth and height) with ad libitum food and water and connected to the setup via a flexible EEG/EMG recording cable (Pinnacle Technology, Inc.) and a fibre-optic patchcord (Doric Lenses) (Fig. 1a). Recording started typically after 1 to 2 h of recovery when the rats display normal waking EEG and behaviour (assessed by normal eating, drinking, grooming and alert exploration). A custom-build set-up was used for combined EEG/EMG and optical Ca2+ recordings (Fig. 1a). Excitation light from a LED (450–490 nm, 50–70 µW) is relayed by a series of multimode fibre patch cords (Doric Lenses, diameters 400 µm (NA=0.37)) to the implanted cannula (diameters 400 µm). Emitted fluorescence is then relayed by the same series of fibres, deflected by a dichroic mirror (filter 500–700 nm) and the green light is detected by a photodiode (DET36A, Thorlabs, Dachau, Germany). Electrical signals (Ca2+ and EEG/EMG) are then routed to an amplifier and collected by the commercially available sleep acquisition/analyses software VitalRecorder™ (Kissei Comtec, Irvine, CA, USA).

EEG and fibre-optic Ca2+ data processing and analysis

EEG/EMG and Ca2+ data were digitised at 200 Hz with a 0.5–100 Hz and a 0.1–30 Hz band-pass filters respectively. EMG was integrated using a 10–100 Hz band-pass filter. Offline, EEGs (FF and FP) and EMG signals were used to assign polygraphic data into 4 s epochs of AW, QW, IS, REM or NREM sleep (SleepSign for Animal; Kissei Comtec). Briefly, AW and QW were characterised by a high and variable EMG and desynchronised/low-amplitude EEG. AW was defined by the additional presence of high theta power (5–9 Hz) in the parietal EEG. NREM sleep was identified by low EMG, the presence of synchronised/high-amplitude EEGs and high sigma (9–16 Hz) activity. REM sleep displays the same EEG signature as AW but with no EMG activity typical of REM sleep muscle atonia. Finally, the IS was identified according to several criteria. A 4 s epoch was classified as IS if it presented a general increase in sigma activity and high theta power in the FP derivation as described in refs 23, 41, 42 (and see Supplementary Fig. 1). Because this EEG signature was quite common, we included additional criteria. An IS episode was defined as a sequence of at least 6 consecutive 4 s epochs and should follow a NREM sleep episode. Behavioural state scoring was done blind to the Ca2+ signal. Percentage of total recording time and bout duration (>5 epochs43) for each vigilance state was calculated for the entire recording period. Fast Fourier transforms were performed on EEG and Ca2+ signal for consecutive 4 s epochs. For each EEG, power was averaged within the slow oscillation (0.5–1.5 Hz), delta (1–4 Hz), theta (5–9 Hz), sigma (9–16 Hz), beta (16–30 Hz), slow gamma (Slow γ, 30–50 Hz) and fast gamma (Fast γ, 60–100 Hz) frequency bands. Ca2+ activity changes were measured the same way using the average power in the 0.1–1 Hz frequency band (Fig. 2b and Supplementary Fig. 2a). To correct for interindividual differences and compare changes in EEG and Ca2+ PD across behaviour states, all 4 s epoch PD values for a given frequency band (EEG and Ca2+) were normalised to the mean of this particular frequency band across all behavioural states in each animal. The normalised changes in PD allowed comparing individuals while preserving the dynamic and magnitude of the changes observed. Those values were then expressed as trend by applying a moving average of a 24 s period every 4 s. Correlation analysis between Ca2+ changes and EEG PD was done between 4 s epoch values.

Episode third analysis

Similar to previous published work26, a behavioural episode was defined as a sequence of at least 13 epochs (≥52 s) of a given state, not interrupted by more than 30% of epochs of any other state. We identified 346 wake (AW+QW, mean duration: 271 ± 22.3 s), 548 SWS (mean duration: 235 ± 14.2 s) and 95 REM (mean duration: 114 ± 8.87 s) episodes. There was no difference in episode number (one-way ANOVA, Wake: P = 0.724; SWS: P = 0.931; REM: P = 0.549) and duration (one-way ANOVA, Wake: P = 0.243; SWS: P = 0.419; REM: P = 0.278) between groups for each state. Since episodes have different lengths, the analysis was performed as in ref. 26 by normalising the duration of each episode between 0 and 1 and subdividing this normalised duration into three “third” segments (1st, 2nd and 3rd). We then calculated the mean normalised PD (EEG and Ca2+) within each third of individual behavioural state episodes. Those values were used to obtain the magnitude of PD changes within individual episodes, with ΔPD=PD in 3rd−PD in 1st (Fig. 4d).

Transient detection and time–frequency analysis

We developed a MATLAB-based software to perform additional analysis of EEG and Ca2+ signals. After extraction of the EEG and Ca2+ signals, raw data (5 ms temporal resolution, sampling rate 200 Hz) were processed for Ca2+ transient detection and time–frequency analysis.

The transient detection algorithm is a threshold algorithm using multiple pass. The signal was first normalised to obtain values between [0, 1] with the formula x_norm= [x−min(x)]/[max(x)−min(x)]. The algorithm performed a series of passes (step of 0.1), searching first for transients with maximum amplitude (i.e., 1) down to the last pass that was defined by a minimal amplitude set by a threshold, here set at 0.2. The minimum and maximum transient durations were set at 0.5 and 6 s, respectively. Detections of transients <1 s were very rare and transients >6 s were represented by large signal fluctuations that included often more than one transient. In addition to Duration, the Amplitude of each transients was measured vertically from the lowest to the highest part of the transient.

The time–frequency analysis is based on the work of Lachaux et al.28, adapted for continuous recordings and discrete frequency bands. For this analysis, we used the PD between 0.1 and 1 Hz for the Ca2+ channel and all the frequency bands described above for the EEG channels. Briefly, the electrophysiological signals in all channels were processed with a moving search window that was set at 4 s. In the search window, the time–frequency transform (TF) of each channel is computed using a short-term Fourier transform. The TF is then sliced into overlapping (50%) subregions of interest (TFROI) of 500 ms. The mean “energy”28 of each TFROI is then computed for each EEG channel except for the Ca2+ channel where only the mean “energy” of TFROI at time 0 (T0) of the search window is computed. The search window is then time shifted by the TFROI time length (i.e., 500 ms) minus a 50% overlap (of the TFROI). This process is repeated until the end of the signal is reached. The result is, for each TFROI, a series of mean “energy” values. For every possible pair between TFROIs at T0 on the Ca2+ channel and TFROIs on the EEG channels in the search window, Spearman’s rank correlation coefficient is calculated using those series of mean energy values. We obtained a heatmap of correlation coefficient between each EEG channels and the Ca2+ channel (Fig. 4c and Supplementary Fig. 5b). The x-axis of the heatmap is the time latency around T0 inside the search window on the EEG channels. The y-axis is the frequency bands chosen for the EEG channels.

Pharmacology in anaesthetised animals

To confirm that the optical signal recorded with the fibre-optic method reflected intracellular Ca2+ changes, we used 8 additional rats in which we recorded dendritic activity under anaesthesia (surface cannula=4, prism cannula=4). After a 20 min EEG/Ca2+ baseline recording, we applied 200 µl of Ni2+ (2 µM, Sigma Aldrich)/Cd2+ (1 µM, Santa Cruz Biotechnology) in rat ringer (135 mM NaCl, 5.4 mM KCl, 1.8 mM CaCl 2 , 1 mM MgCl 2 , 5 mM HEPES) on the surface of the cortex. The recording continued for additional 20 min (post-drug recording).

Surgery for two-photon Ca2+ imaging

On the day of surgery, wild-type and Rbp4-cre mice (~P40) underwent surgery for EEG/EMG, virus injection, head-post and chronic window implantation (Supplementary Fig. 7a, b). The EEG/EMG surgery procedure was similar to the one for rats with slight adjustments. We used a custom-made EEG/EMG implant for FF and FP EEG recordings (Supplementary Fig. 7b). Stainless steel EEG and EMG wires were used. Electrodes were affixed to the skull with bone screws and dental acrylic. For chronic two-photon imaging, a 4 mm circular craniotomy was made on the left hemisphere above the barrel cortex (~1.5 mm posterior and 3.4 mm lateral of bregma). The dura was left intact. The injection procedure of GCaMP6s (AAV1.Syn.GCaMP6s.WPRE.SV40 in wild-type mice or AAV2/1-Syn-Flex-GCaMP6s-WPRE in the Rbp4-cre mouse, PENN Vector Core) into L5 (depth: 550 to 700 µm) was the same as in rats. After injection, the craniotomy was covered with a 4 mm glass coverslip (CS-4R, Warner Instruments, Hamden, CT, USA) and sealed with glue. A lightweight custom-made aluminium head-post was glued to the centre of the skull, between the EEG and window implant (Supplementary Fig. 7b). Finally, dental cement was used to cover the exposed skull and fixate the head-post and the EEG/EMG implant. At the end of the surgical procedure, buprenorphine was administered as a long-lasting analgesic (0.01 to 0.05 mg/kg IP) and the animals were allowed to recover for at least 3 days.

Two-photon Ca2+ imaging and data analysis

Ca2+ imaging sessions were performed between ZT0 and ZT12 (Supplementary Fig. 7a). Mice in the head-fixation stage were positioned underneath a resonant scanning two-photon microscope (B-Scope, Thorlabs, Newton, NJ, USA) equipped with GaAsP photomultiplier tubes (Hamamatsu, Tokyo, Japan). GCaMP6s was excited at 940 nm with a Ti:Sapphire laser (Mai-Tai DeepSee, Spectra-Physics, Santa Clara, CA, USA) and imaged through a 16×, 0.8 NA water immersion objective (Nikon, Tokyo, Japan). Full-frame images (512 × 512 pixels) were acquired capturing Ca2+ activity. L5 cell bodies were imaged in three mice/depths between −450 and −600 µm (number of somata: 450 µm = 45; 500 µm = 22; 600 µm = 22) and apical shaft dendrites of L5 neurons were imaged in three mice/depths between −200 and −450 µm (number of dendrites: 200 µm = 47; 300 µm = 64; 450 µm = 24). For dendritic recordings, we followed dendrites down to L5 to control that they originate from the cell bodies in that layer. Single plane recordings of 4000 frames were continuously acquired over 1 to 2 h once the mouse started sleeping underneath the microscope. EEG signals were processed and analysed blindly to the Ca2+ data in the same way as for rats.

Analysis of two-photon data was performed using ImageJ and a custom written software in MATLAB. ROIs were drawn by hand for each cell body and dendrite. For each ROI, pixel values inside the ROI were averaged to obtain the time series of Ca2+ fluorescence. The raw fluorescence in each ROI was normalised using a 20 s sliding (5 ms) window on the continuous signal. Normalised fluorescence (ΔF/F 0 ) was calculated as (F−F 0 )/F 0 , where F 0 is the mean lower third of the raw fluorescence values within the sliding window. Ca2+ synchrony was calculated in 4 s epoch by calculating Pearson’s correlation coefficient between all possible combinations of ROIs for a given field of view. An average of all Fisher transformed (“r-to-z”) correlation coefficients was then made. The average underwent another Fisher transformation (“z-to-r”) to obtain the synchrony level (normalised between 0 and 1).

Juxtacellular recordings and data analysis

Rats (n = 2, P37 on the day of surgery) were implanted under ketamine/xylazine anaesthesia (100 mg/kg, 5 mg/kg, IP) with a metal bolt for head fixation and a recording chamber (2 mm posterior and 2 mm lateral from bregma) for chronic access to hindlimb somatosensory cortex. Once the animal was habituated to sleep while head-fixed, daily sessions (over 3–4 days) of juxtacellular single-cell recordings of L5 neurons started. The recordings were performed at a mean depth reading of 1525 ± 288 µm (n = 23 cells). The glass pipette was filled with Ringer’s solution containing NaCl 135, KCl 5.4, HEPES 5, CaCl 2 1.8 and MgCl 2 1 (pH 7.2). The juxtacellular signal was amplified and low-pass filtered at 3 kHz by a patch-clamp amplifier (Dagan, Minneapolis, MN, USA) and sampled at 25 kHz by a Power1401 data acquisition interface under the control of Spike2 software (CED, Cambridge, UK). State scoring was done blind to the firing pattern of cells using both LFP and EEGs signals. For cross-correlations, the EEG (FF and FP) and LFP signals was filtered for different frequency bands and cross-correlated with the instantaneous spike frequency of the recorded action potential train. To calculate the instantaneous spike frequency, the spike train was first converted into a modified sum of Dirac-delta functions, where the peak of each delta function was scaled to equal the acquisition frequency. This function was then convolved with a Gaussian function with s.d. of 20 ms (adapted from ref. 44). For each frequency band, the peak (maximum within a 10 s window:±5 s) value for each cell was normalised to the s.d. We used visual detection of spindles which are easily identifiable in the LFP (unlike in the EEG). The onset and offset of a spindle was determined by the beginning and end of the train of spindle oscillations which was often delimited by distinct UP states. A total of 476 spindles were detected across the 23 recordings. To measure the correlation between EEG/LFP and spindle density we used recordings of 17 out of the 23 cells as some recordings showed a drift in the LFP signal that could have biased the results. Recordings were broken up into 10 s consecutive windows with an overlap of 0.25 s between successive windows. Within each window, we calculated the spindle density and the EEG and LFP power for individual frequency bands (see above). Spindle density was measured as the cumulative duration of detected spindles during the 10 s window. For each recording and each frequency band, a scatter plot was generated plotting the total power of the frequency band against the spindle density of each 10 s window. A linear regression was performed on the scatter plot and the correlation was measures as the size of the slope factor.

Habituation to head fixation for rats and mice

Following surgery, mice and rats were trained to naturally sleep while being head-fixed. On the first day, animals were allowed to freely explore the head-fixation stage. Over the next days, the duration of head fixation was increased daily by 5, 15, 30 and 60 min to minimise stress. At the beginning and end of each session animals received condensed milk as reward. During head fixation, EEG/EMG was recorded to reveal naturally occurring periods of sleep. Mice usually started sleeping occasionally after 7 days of training and displayed consolidated sleep episodes after 2 to 3 weeks of surgery, when expression levels of GCaMP6s were also sufficient. Rats express consolidated sleep after only 1 week of training.

Brain slicing and imaging

Images from the injection sites were obtained from brain slices as previously described16. Briefly, after killing, the brain was rapidly removed into ice-cold, oxygenated artificial cerebrospinal fluid containing (in mM): 125 NaCl, 25 NaHCO 3 , 2.5 KCl, 1.25 NaH 2 PO 4 , 1 MgCl 2 , 25 glucose and 2 CaCl 2 (pH 7.4). Slices (300 µm) were cut with a vibrating microslicer on a block angled at 15° to horizontal and maintained at 37 °C in the preceding solution for 30 min before use. The fluorescence signal was obtained using an LED light source (CoolLED, 480 nm), standard epifluorescence filter sets for FITC used for OGB-1 AM and GCaMP6s and a CoolSNAP EZ CCD camera (Photometrics).

Statistics

All statistics were calculated using a commercial software (SigmaStat, Systat Software Inc., San Jose, CA, USA). All data were tested for normality and equal variance. Parametric data were assessed using Student’s t-tests for planned, single comparisons or one-, two- or three-way ANOVA and Holm–Sidak test for multiple post hoc comparisons. In cases where nonparametric statistics were required, Mann–Whitney rank sum tests were used for planned, single comparisons and Kruskal–Wallis one- or two-way ANOVA and Dunn’s tests for multiple post hoc comparisons. Correlations were calculated using Pearson’s correlation coefficient.

Code availability

All data codes are available from the corresponding authors on request.

Data availability

All data are available from the corresponding authors on request.