We present an open system for sleep staging, based explicitly on the criteria used in visual EEG analysis. Slow waves, theta and alpha waves, sleep spindles and K-complexes are parameterized in terms of time duration, amplitude, and frequency of each waveform by means of the matching pursuit algorithm. It allows the detection of these structures using mostly the criteria from visual EEG analysis. For example, within this framework for the first time we compute directly the relative duration of slow waves, which is a basic parameter in recognition of deep sleep stages. Performance of the system is evaluated on 20 polysomnographic recordings, scored by experienced encephalographers. Seven recordings were scored by more than one expert. Proposed system gives concordance with visual staging close to the inter-expert concordance. The algorithm is implemented in a user-friendly software system for display and analysis of polysomnographic recordings, freely available with complete source code from http://signalml.org/svarog.html .