コード例 #1
0
ファイル: Program.cs プロジェクト: node9909/unity-biosignals
        private static void RunEEGCSV(string filepath)
        {
            EEGReader    reader    = new EEGFileReader(filepath);
            EEGProcessor processor = new EEGProcessor(reader, true);

            processor.Start();

            while (!processor.Finished)
            {
                processor.Update();
            }

            List <TrainingValue> results = processor.TrainingValues;


            StringBuilder csv = new StringBuilder();

            foreach (TrainingValue t in results)
            {
                csv.AppendLine(String.Format("{0},{1},{2}", (t.Features[0] + t.Features[1]) / 2, (t.Features[2] + t.Features[3]) / 2, t.State));
            }

            string filename = filepath.Split('.')[0] + ".csv";

            //string filename2 = filename + "-2.csv";

            //filename += "-1.csv";


            File.WriteAllText(filename, String.Empty);
            File.WriteAllText(filename, csv.ToString());
            //File.WriteAllText(filename2, String.Empty);
            //File.WriteAllText(filename2, csv2.ToString());
        }
コード例 #2
0
        internal static List <TrainingValue> getTrainingValues(string filepath)
        {
            EEGReader reader;

            reader = new EEGFileReader(filepath);
            EEGProcessor processor = new EEGProcessor(reader, true);

            processor.Training = true;

            processor.Start();
            while (!processor.Finished)
            {
                processor.Update();
            }

            return(processor.TrainingValues);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: node9909/unity-biosignals
        private static void RunEEG(string filepath = null)
        {
            EEGReader reader;

            if (filepath != null)
            {
                reader = new EEGFileReader(filepath);
            }
            else
            {
                reader = new EEGOSCReader(5005);
            }

            EEGProcessor processor = new EEGProcessor(reader);

            processor.Start();
            while (true)
            {
                processor.Update();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: node9909/unity-biosignals
        private static void RunEEGJoin(string file1, string file2, string newName)
        {
            EEGReader reader;

            reader = new EEGFileReader(file1);
            reader.Start();
            List <OSCPacket> packets = new List <OSCPacket>();
            OSCPacket        packet;

            while (reader.TryDequeue(out packet))
            {
                packets.Add(packet);
            }

            Console.WriteLine("Read " + packets.Count + " packages from " + file1);
            int prevCount = packets.Count;

            reader = new EEGFileReader(file2);
            reader.Start();
            while (reader.TryDequeue(out packet))
            {
                packets.Add(packet);
            }

            Console.WriteLine("Read " + (packets.Count - prevCount) + " packages from " + file2);

            FileStream stream = File.OpenWrite(newName);

            foreach (OSCPacket p in packets)
            {
                byte[] bytes = p.Pack();
                stream.Write(BitConverter.GetBytes(bytes.Length), 0, 4);
                stream.Write(bytes, 0, bytes.Length);
            }
            stream.Close();

            Console.WriteLine("Saved new dataset to: " + newName);
        }