For some time, I've been trying to build my own REM-detecting dream mask using the traditional "IR LED + IR sensor pointed at eyelid" technique that most such masks use. After many failed attempts, I've finally got something that's fairly comfortable and seems to collect fairly good data. My problem now is trying to use the data to figure out when I'm in REM.

I've tried a variety of methods - calculating standard deviations, counting peaks, and high-pass filters are my most recent attempts - but I can't find anything that reliably says "this part is a dream." Some of my attempts have been good enough for a human to identify the REM stages, but I'm no closer to figuring out how to train a computer to identify REM. I've been Googling with every search parameter I can think of, but I've found only a single detailed description of a REM-detecting algorithm, and while it's an improvement over my existing attempts it still isn't enough.

I'd be grateful if anyone could provide some pointers, guidance, or assistance in figuring this stuff out. I'll be happy to provide any details or data that I can.

(Mods, if you think this is Research or Lucid Aid material, I won't object; but I put it in Science and Math since I think I'm looking for help with statistical analysis)