Permalink
Browse files

Added trigger algorithms and charted the eye movement count before th…

…e audio track is triggered.
  • Loading branch information...
IAmCoder committed Nov 25, 2013
1 parent 3a6e368 commit 6aa5c0b484d1f6cfeb6bc6da53ff4b9f97ff1e4e
@@ -970,14 +970,14 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe OpenEEG"
"ProductCode" = "8:{EBDC52BA-A9EF-42C8-9601-9204D306C427}"
"PackageCode" = "8:{05ECB0EF-6F3A-4E64-B226-1A7EEB04F739}"
"ProductCode" = "8:{16B69B10-991C-49C4-920B-E9AB56A6D54B}"
"PackageCode" = "8:{3434653C-6FC8-47E7-AA7A-761D3312806C}"
"UpgradeCode" = "8:{D21B48DC-E942-48EA-9916-C569C46778E4}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:0.9.6"
"ProductVersion" = "8:0.9.8"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucid-code.com/Support"
BIN +0 Bytes (100%) Lucid Scribe - OpenEEG.suo
Binary file not shown.
@@ -20,7 +20,8 @@ public static class Device
static int[] buffer = new int[16];
static int index = 100;
static int lastByte = -1;
static int channels = 6;
static int channels = 2;
public static string Algorithm = "REM Detection";

public static Boolean Initialize()
{
@@ -35,6 +36,7 @@ public static Boolean Initialize()
{
// Set the amount of channels
channels = formPort.Channels;
Algorithm = formPort.Algorithm;

// Open the COM port
serialPort = new SerialPort(formPort.SelectedPort);
@@ -243,6 +245,9 @@ namespace REM
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{

static int TicksSinceLastArtifact = 0;
static int TicksAbove = 0;

public override string Name
{
get
@@ -270,88 +275,111 @@ public override double Value
get
{

if (Device.Algorithm == "REM Detection")
{
// Update the mem list
m_arrHistory.Add(Convert.ToInt32(Device.GetEEG()));
if (m_arrHistory.Count > 512) { m_arrHistory.RemoveAt(0); }

// Update the mem list
m_arrHistory.Add(Convert.ToInt32(Device.GetEEG()));
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;
// Check for blinks
int intBlinks = 0;
bool boolBlinking = false;

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

if (!boolBlinking)
bool boolDreaming = false;
foreach (Double dblValue in m_arrHistory)
{
if (intAbove >= 2)
if (dblValue > 600)
{
boolBlinking = true;
intBlinks += 1;
intAbove = 0;
intAbove += 1;
intBelow = 0;
}
}
else
{
if (intBelow >= 28)
else
{
boolBlinking = false;
intBlinks += 1;
intBelow = 0;
intBelow += 1;
intAbove = 0;
}

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

if (intBlinks > 10)
{
boolDreaming = true;
break;
}
if (intBlinks > 6)
{
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 (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; }

if (intBlinks > 10) { intBlinks = 10; }
return intBlinks * 100;
}
else if (Device.Algorithm == "Motion Detection")
{
if (Device.GetEEG() > 980)
{
TicksAbove++;
if (TicksAbove > 5)
{
TicksAbove = 0;
TicksSinceLastArtifact = 0;
if (TicksSinceLastArtifact > 19200)
{
return 888;
}
}
}

if (boolDreaming)
{ return 888; }
TicksSinceLastArtifact++;
return 0;
}

return 0;
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -16,6 +16,7 @@ public partial class PortForm : Form

public String SelectedPort = "";
public int Channels = 2;
public String Algorithm = "REM Detection";

private Boolean loaded = false;
private string m_strPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\lucidcode\\Lucid Scribe\\";
@@ -80,13 +81,22 @@ private void LoadSettings()
String defaultSettings = "<LucidScribeData>";
defaultSettings += "<Plugin>";
defaultSettings += "<Channels>2</Channels>";
defaultSettings += "<Algorithm>REM Detection</Algorithm>";
defaultSettings += "</Plugin>";
defaultSettings += "</LucidScribeData>";
File.WriteAllText(m_strPath + "Plugins\\OpenEEG.User.lsd", defaultSettings);
}

xmlSettings.Load(m_strPath + "Plugins\\OpenEEG.User.lsd");
cmbChannels.Text = xmlSettings.DocumentElement.SelectSingleNode("//Channels").InnerText;

if (xmlSettings.DocumentElement.SelectSingleNode("//Channels") != null)
{
cmbChannels.Text = xmlSettings.DocumentElement.SelectSingleNode("//Channels").InnerText;
}
if (xmlSettings.DocumentElement.SelectSingleNode("//Algorithm") != null)
{
cmbAlgorithm.Text = xmlSettings.DocumentElement.SelectSingleNode("//Algorithm").InnerText;
}
}

private void cmbChannels_SelectedIndexChanged(object sender, EventArgs e)
@@ -96,11 +106,19 @@ private void cmbChannels_SelectedIndexChanged(object sender, EventArgs e)
SaveSettings();
}

private void cmbAlgorithm_SelectedIndexChanged(object sender, EventArgs e)
{
if (!loaded) { return; }
Algorithm = cmbAlgorithm.Text;
SaveSettings();
}

private void SaveSettings()
{
String defaultSettings = "<LucidScribeData>";
defaultSettings += "<Plugin>";
defaultSettings += "<Channels>" + cmbChannels.Text + "</Channels>";
defaultSettings += "<Algorithm>" + cmbAlgorithm.Text + "</Algorithm>";
defaultSettings += "</Plugin>";
defaultSettings += "</LucidScribeData>";
File.WriteAllText(m_strPath + "Plugins\\OpenEEG.User.lsd", defaultSettings);
Oops, something went wrong.

0 comments on commit 6aa5c0b

Please sign in to comment.