Background. The neuronal cortical network generates slow (<1 Hz) spontaneous rhythmic activity that emerges from the
recurrent connectivity. This activity occurs during slow wave sleep or anesthesia and also in cortical slices, consisting of
alternating up (active, depolarized) and down (silent, hyperpolarized) states. The search for the underlying mechanisms and
the possibility of analyzing network dynamics in vitro has been subject of numerous studies. This exposes the need for
a detailed quantitative analysis of the membrane fluctuating behavior and computerized tools to automatically characterize
the occurrence of up and down states. Methodology/Principal Findings. Intracellular recordings from different areas of the
cerebral cortex were obtained from both in vitro and in vivo preparations during slow oscillations. A method that separates up
and down states recorded intracellularly is defined and analyzed here. The method exploits the crossover of moving averages,
such that transitions between up and down membrane regimes can be anticipated based on recent and past voltage dynamics.
We demonstrate experimentally the utility and performance of this method both offline and online, the online use allowing to
trigger stimulation or other events in the desired period of the rhythm. This technique is compared with a histogram-based
approach that separates the states by establishing one or two discriminating membrane potential levels. The robustness of the
method presented here is tested on data that departs from highly regular alternating up and down states. Conclusions/
Significance. We define a simple method to detect cortical states that can be applied in real time for offline processing of
large amounts of recorded data on conventional computers. Also, the online detection of up and down states will facilitate the
study of cortical dynamics. An open-source MATLABH toolbox, and Spike 2H-compatible version are made freely available.