Smoothed out the Zeo EEG channel by finding the greatest peak or trough in steps of 16 in the 128 data points in a packet:

            int[] eigths = new int[8];
            for (int x = 0; x < 8; x++)
            {
              float maximum = 0;
              float minimum = 0;

              for (int y = 0; y < 16; y++)
              {
                int index = (x * 16) + y;
                if (channels[index].Values[0] > maximum)
                {
                  maximum = channels[index].Values[0];
                }
                if (channels[index].Values[0] < minimum)
                {
                  minimum = channels[index].Values[0];
                }
              }

              float greatest = maximum;
              if (minimum * -1 > maximum)
              {
                greatest = minimum;
              }

              eigths[x] = Convert.ToInt32((greatest * 10) + 3000) / 6;
            }

That creates 8 values which can be fetched asynchronously by Lucid Scribe’s internal clock at 10 Hz by dividing the current millisecond by 125:

      double eigth = DateTime.Now.Millisecond / 125;
      return eigths[(int)(Math.Round(eigth))];

All that because I couldn’t evenly divide 128 by 10! The end result looks a little better from afar (when looking for eye movements) with one sixteenth of the data:

ZeoSync

View code changes

Advertisements