An approach for automatic sleep stage scoring and apnea-hypopnea detection