The test that records your sleep data is called polysomnography. It will record a wide array of body functions: heart rate and rhythm, breathing, snoring, airflow, the levels of oxygen in your blood, brain activity, and sleep position. You are not attached to any machine beside your bed, and so doing toilet trips won’t be a problem.  If you know you are a restless sleeper, all you need to do is make sure that the sensors are firmly attached.

 
Below is an example of the sleep study summary graph.