예제 #1
0
        public static void CollectData(string File)
        {
            const int samples_to_collect = 20000;
            EEG       eeg = new EEG(COM);

            eeg.Start();
            Console.WriteLine("Connected");
            List <FatSample> all_samples = new List <FatSample>();

            for (int j = 0; j < samples_to_collect; j++)
            {
                FatSample f = new FatSample(eeg.ReadSample(), eeg.ReadSample());
                Console.WriteLine(j);
                //Console.WriteLine("INDEX: " + index);
                all_samples.Add(f);
                //Console.WriteLine(f);
                //Console.WriteLine();
            }
            var filestream = System.IO.File.AppendText(File);

            foreach (var i in all_samples)
            {
                filestream.Write(i.ToSpaceSeparated());
            }
            filestream.Flush();
            filestream.Close();
            eeg.Stop();
        }
예제 #2
0
        static void EEGTestWithNN2()
        {
            Console.WriteLine("Training Neural Network");
            var n = NNCollectedData2();

            Console.WriteLine($"Percent correct: {n.PercentCorrect()}");
            Console.WriteLine("Awaiting Connection");
            EEG eeg = new EEG(COM);

            eeg.Start();
            Console.WriteLine("Connected");
            Stopwatch s = new Stopwatch();

            s.Start();
            while (s.ElapsedMilliseconds < 60000)
            {
                FatSample[] f = new FatSample[chunk_size];
                for (int i = 0; i < f.Length; i++)
                {
                    f[i] = new FatSample(eeg.ReadSample(), eeg.ReadSample());
                }
                Console.WriteLine(n.Predict(FatSamplesToPackedNNData(f)) == 0 ? "Up" : "Down");
            }
        }