Apnea–hypopnea index estimation using quantitative analysis of sleep macrostructure