예제 #1
0
 public BoardShim(int board_id, string port_name)
 {
     this.board_id          = board_id;
     this.port_name         = port_name;
     this.package_length    = BoardInfoGetter.get_package_length(board_id);
     this.fs_hz             = BoardInfoGetter.get_fs_hz(board_id);
     this.num_eeg_channels  = BoardInfoGetter.get_num_eeg_channels(board_id);
     this.first_eeg_channel = BoardInfoGetter.get_first_eeg_channel(board_id);
 }
예제 #2
0
        internal BoardData(int board_id, float[] raw_data, double[] ts_data)
        {
            this.board_id       = board_id;
            this.package_length = BoardInfoGetter.get_package_length(board_id);
            List <List <double> > temp_board_data = new List <List <double> > ();

            for (int i = 0; i < ts_data.Length; i++)
            {
                List <double> temp = new List <double> ();
                for (int j = 0; j < this.package_length; j++)
                {
                    temp.Add((double)raw_data[i * package_length + j]);
                }
                temp.Add(ts_data[i]);
                temp_board_data.Add(temp);
            }
            board_data = temp_board_data.Select(a => a.ToArray()).ToArray().ToMatrix();
        }
예제 #3
0
 public DataHandler(int board_id, double[,] data_from_board = null, string csv_file = null)
 {
     fs_hz             = BoardInfoGetter.get_fs_hz(board_id);
     first_eeg_channel = BoardInfoGetter.get_first_eeg_channel(board_id);
     last_eeg_channel  = first_eeg_channel + BoardInfoGetter.get_num_eeg_channels(board_id) - 1;
     if (data_from_board != null)
     {
         data = data_from_board.Copy();
     }
     else
     {
         if (csv_file != null)
         {
             List <List <double> > temp_board_data = new List <List <double> > ();
             StreamReader          sr = new StreamReader(csv_file);
             string   strline         = "";
             string[] values          = null;
             while (!sr.EndOfStream)
             {
                 List <double> temp = new List <double> ();
                 strline = sr.ReadLine();
                 values  = strline.Split(',');
                 for (int i = 0; i < values.Length; i++)
                 {
                     temp.Add(Convert.ToDouble(values[i], System.Globalization.CultureInfo.InvariantCulture));
                 }
                 temp_board_data.Add(temp);
             }
             sr.Close();
             data = temp_board_data.Select(a => a.ToArray()).ToArray().ToMatrix();
         }
         else
         {
             throw new MissingFieldException("nor data_from_board nor csv_file was specified");
         }
     }
 }