Low-complexity algorithms for automatic detection of sleep stages and events for use in wearable EEG systems