I've done some work on algorithms to detect REM from video:

https://github.com/lucidcode/LucidScribe-Halovision