Figure 1). In order to select only large-extended slow waves, an additional criterion was used to confirm the simultaneous presence of the slow components on intracranial contacts. According to that, we only kept waves for which the average of all intracranial negative peaks (when presented in at least 30% of the total number of contacts) during the scalp positive peak was #260 mV. Finally, we rejected slow waves presenting interictal epileptic discharges inside a window of 2 seconds around the minimal scalp negative peak. Automatic detection of gamma oscillations An automatic detection of high-frequency events was performed separately for each intracranial contact and for the whole sleep- wake cycle and independently of the presence of slow waves. In order to detect oscillations, the whole gamma range was subdivided in consecutive sub-bands of 20-Hz each (f22f1 = 20 Hz, f2.f1), from 30 to 120 Hz. For each one of these sub-bands, oscillations were detected according to a similar procedure than those presented in [15]: First, the envelope of the bandpass-filtered signal was obtained via the Hilbert transform. Then, a threshold for detection was defined consisting on all successive envelope values with amplitudes .3s above the mean amplitude of the envelope signal (the mean and the standard deviation (s) computed from free-of-artifacts periods, selected along the whole night by visual inspection). From all detected events, we selected only events having more than 6 oscillatory cycles (calculated from the mean frequency (f1+f2)/2 of the current frequency band), and presenting more than 5 local maxima in both original and filtered signals (see Figure 1). Oscillation analysis The central frequency of each detected oscillation was determined by the frequency at which a peak appeared in the power spectral density (PSD) obtained via the Burg method. The corresponding signals were zero-padded to the next higher power of two, but in all cases the resulting length was $512 points. The order of the autoregressive model was set to 10. Time-frequency representations Time-frequency transformations for power and phase estima- tions were obtained through a Gabor wavelet, implemented with a modulated Gaussian window [54]. The number of cycles of the wavelet was set to 5. Phasic modulation of gamma oscillations by the slow waves In order to determine possible patterns of phasic modulation by the slow waves, we estimated separately for each intracranial contact the distribution in time of gamma events detected inside a window of 2 seconds around the minimal scalp negative peak of the slow waves. Only intracranial contacts presenting slow waves were analyzed by requesting that the absolute value of the cross- correlation coefficient between the scalp slow wave and the related intracranial one was $0.6 since these values allowed the simultaneous analysis of scalp and intracranial slow wave activity. For all these investigated intracranial contacts, these distributions were then grouped in different patterns following a criterion of similarity, consisting in grouping the most similar among them. For this, we calculated the cross-correlation between all possible distributions and we considered a group when all the cross- correlation coefficients between their distributions had a minimal value of 0.76, corresponding to the value at which the number of elements inside one of the groups became stable. Human Gamma Oscillations during Slow Wave Sleep Co-detection probability and distribution fitting For every pair of intracranial contacts, we estimated the probability of detecting a gamma event in one contact given that an event, in the same frequency band and for the same time, has been also detected in another contact. Co-detection was defined when both events had an overlapping of at least 50% respect to the total event duration (Dtw in Figure 1). Probability estimation was performed only for frequency bands presenting at least 25 events. In order to fit the statistical distribution given by the co-detection probability, we tested the following known distributions: Expo- nential, Poisson, Gamma, Chi-squared, Rayleigh and Weibull. Synchronization between two gamma oscillations Synchronization between pairs of co-detected gamma events was estimated by the cross-correlation coefficient (CC) and the windowed phase-locked value (PLV). Their analysis followed two steps: First, pairs of signals were narrow-band filtered in the corresponding co-detection frequency band. Second, the following two measures were calculated: 1) CC: For the pair of filtered signals, the cross-correlation coefficient was estimated by CC = C(s1, s2)/(C(s1, s1) C(s2, s2))1/2, where C corresponded to the covariance function (at zero-lag) and sk for k = 1,2 to signal k. Thus, C(s1, s2) corresponded to the cross-covariance at zero-lag between the pair of signals in the co-detected event and C(s1, s1) and C(s2, s2) to the variance for each signal respectively. 2) PLV: This analysis was introduced to overcome some limitations of correlation methods which do not disentangle amplitudes and phases [55]. The phases of both filtered signals were calculated via the Hilbert transform and the difference between them was then calculated. The phase locking was next estimated by PLV ~ ð1=NÞ P kN~1ejYk , where YK is the phase difference (mod 2p) for the corresponding k time and N the total number of phase difference values inside the time window corresponding to the co-detection event (Dtw in Figure 1). In order to further test for statistical significance, surrogate data was generated from each one of both measurements and a permutation test was then performed [56]. Phase-locking of gamma activations and slow waves In order to examine the relationship between the phases of the slow wave and the activation or the co-activation of gamma oscillations, we used following procedure: First, the phases of the slow waves were estimated through the Hilbert transform of the filtered signals in the low frequency band (0.1–4 Hz). Second, the phase value QK (mod 2p) of the slow waves corresponding to the detection or the co-detection times were computed (depending on the analysis, it could be to or tm in Figure 1). Finally, from the first trigonometric moment defined by M~ð1=NÞ P kN~1ejqk , a phase modulation index was estimated across all corresponding slow waves by the modulus of M, where N was the total number of phase values. Given the Rayleigh statistic Z = N |M|2, the probability that the hypothesis of sample uniformity holds was given by P = e2Z [1+(2Z2Z2)/(4N)2(24Z2132Z2+76Z329Z4)/ 2 (288N )] [57]. The preferred phase was estimated by the phase of M and the corresponding preferred time was approximated by a slow wave of frequency 0.85 Hz. Phasic modulation of gamma phase synchronization by the slow waves In order to examine the relationship between the phases of the slow wave and the phase synchronization between gamma oscillations, we used a similar procedure than those previously used [55]: First, the phases of both signals were calculated through a Gabor wavelet between 30–120 Hz and inside the 2-seconds PLoS ONE | www.plosone.org 12 April 2012 | Volume 7 | Issue 4 | e33477