Scientists have created an algorithm that analyzes RF signals in order to monitor you in your sleep. It uses a device similar to a Wi-Fi router to determine everything from how shallow your breathing is to whether you’re having a dream or not.

The study was conducted by a group consisting of researchers from MIT and Massachusetts General Hospital’s Division of Sleep Medicine. MIT Professor Dina Katabi says:

Imagine if your Wi-Fi router knows when you are dreaming, and can monitor whether you are having enough deep sleep, which is necessary for memory consolidation. Our vision is developing health sensors that will disappear into the background and capture physiological signals and important health metrics, without asking the user to change her behavior in any way.

The sensor works by sending out low-level RF signals that bounce off of people. The subtle movements of the human body are detected by an RF device similar to a router and analyzed by the algorithm. This AI gathers the same diagnostic measurements and information obtained by attaching electrode sensors directly to a subject, without wires.

In fact, this line of research previously yielded a similar device that could be used to detect human emotions wirelessly.

The AI-powered device has the potential to revolutionize sleep disorder research; instead of forcing patients into unfamiliar environments, the laptop-sized device could be discretely deployed in a person’s bedroom. It doesn’t take a scientist to figure out that sleep research would be easier to conduct if doctors could simply monitor a patient’s normal sleep routine remotely while the patient rested in their normal sleeping environment, all without sticky electrodes attached to wires or noisy machines.

In the US alone, an estimated 50 million people — nearly 16 percent of the population — suffer from a sleep disorder. That’s a lot of people working, driving, parenting, and studying without a good night’s rest. A breakthrough in the ability to monitor and and analyze the way people sleep, in real-time, could benefit everyone.

Some day soon your Wi-Fi router will let your doctor know if you aren’t sleeping well. Better yet – perhaps it’ll sense you’re having a bad dream and play some Jack Johnson to soothe you back to a deep restful sleep.

Read next: Remote working trends in 2017