Whether you are awake or in deep sleep, many conditions can affect your ability to breathe normally.
As a general rule, if your inability to breathe properly is an aspect of a generalized pathology, the diagnosis will be formulated as part of this pathology. Your doctor or healthcare provider will determine the best diagnostic method for your condition and will tell you the next steps for your treatment.
In case you suffer from obesity-hypoventilation syndrome (SOH), your obesity causes strong pressure on the muscles around your lower airways and limits your ability to breathe enough air. If you have restrictive lung disease, the muscles and nerves used during breathing are affected and you have trouble breathing properly on your own.

Sleep tests
If your inability to breathe at night causes apnea (read more here: http://oxygena.tn/sleep-lab-treatment/), your health care provider can refer you to sleep recording. . Sleep recordings are used to assess whether or not you have sleep apnea and, if so, how severe it is. You can perform sleep recording in a hospital setting or at home. Learn more about sleep exams.
Blood gas analysis
The proper way to diagnose respiratory failure is through a blood gas analysis. A blood sample is taken by your doctor to determine your O2 and CO2 levels.
Transcutaneous CO2 measurement
If you are already on CPP treatment for your OSA, transcutaneous CO2 measurement makes it easy to identify respiratory failure while you sleep.

Source: www.resmed.com/en-us/consumer/diagnosis-and-treatment/respiratory-care.html