Permalink
Browse files

Added the REM-detection algorithm.

  • Loading branch information...
IAmCoder committed Jun 2, 2013
1 parent 362c36b commit 5aec1557c03a2a9332d5c4cbe87242d47962314b
@@ -970,14 +970,14 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe OpenEEG"
"ProductCode" = "8:{B02E40C9-5CBE-4A5D-ACD1-8FFA3BFCB998}"
"PackageCode" = "8:{8A60C85A-92D5-4BD0-A415-B6DE2CCAE716}"
"ProductCode" = "8:{84193568-D3FD-4AE6-8867-86A1387F97B9}"
"PackageCode" = "8:{6D2DE3EC-2701-4523-81F0-44551808716D}"
"UpgradeCode" = "8:{D21B48DC-E942-48EA-9916-C569C46778E4}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:0.9.3"
"ProductVersion" = "8:0.9.4"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucid-code.com/Support"
Binary file not shown.
@@ -257,12 +257,95 @@ public override bool Initialize()
}
}

List<int> m_arrHistory = new List<int>();

public override double Value
{
get
{
// This is where we will detect patterns indicative of REM sleep
double eegValue = Device.GetEEG();


// Update the mem list
m_arrHistory.Add(Convert.ToInt32(Device.GetChannel1()));
if (m_arrHistory.Count > 512) { m_arrHistory.RemoveAt(0); }

// Check for 3 blinks
int intBlinks = 0;
bool boolBlinking = false;

int intBelow = 0;
int intAbove = 0;

bool boolDreaming = false;
foreach (Double dblValue in m_arrHistory)
{
if (dblValue > 800)
{
intAbove += 1;
intBelow = 0;
}
else
{
intBelow += 1;
intAbove = 0;
}

if (!boolBlinking)
{
if (intAbove >= 2)
{
boolBlinking = true;
intBlinks += 1;
intAbove = 0;
intBelow = 0;
}
}
else
{
if (intBelow >= 28)
{
boolBlinking = false;
intBlinks += 1;
intBelow = 0;
intAbove = 0;
}
else
{
if (intAbove >= 12)
{
// reset
boolBlinking = false;
intBlinks = 0;
intBelow = 0;
intAbove = 0;
}
}
}

if (intBlinks > 10)
{
boolDreaming = true;
break;
}

if (intAbove > 12)
{ // reset
boolBlinking = false;
intBlinks = 0;
intBelow = 0;
intAbove = 0; ;
}
if (intBelow > 80)
{ // reset
boolBlinking = false;
intBlinks = 0;
intBelow = 0;
intAbove = 0; ;
}
}

if (boolDreaming)
{ return 888; }

return 0;
}
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.3.0")]
[assembly: AssemblyFileVersion("0.9.3.0")]
[assembly: AssemblyVersion("0.9.4.0")]
[assembly: AssemblyFileVersion("0.9.4.0")]

0 comments on commit 5aec155

Please sign in to comment.