Ejemplo n.º 1
0
        static int Update()
        {
            if ((board_shim == null) || (concentration == null))
            {
                Console.ReadLine();
                return(-1);
            }
            int number_of_data_points = sampling_rate * 4; // 4 second window is recommended for concentration and relaxation calculations


            double[,] data = board_shim.get_current_board_data(number_of_data_points);

            if (data.GetRow(0).Length < number_of_data_points)
            {
                // wait for more data
                return(0);
            }

            // prepare feature vector
            Tuple <double[], double[]> bands = DataFilter.get_avg_band_powers(data, eeg_channels, sampling_rate, true);

            double[] feature_vector = bands.Item1.Concatenate(bands.Item2);
            // calc and print concetration level
            // for synthetic board this value should be close to 1, because of sin waves ampls and freqs
            Console.WriteLine("Concentration: " + concentration.predict(feature_vector));


            return(0);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // use synthetic board for demo
            BoardShim.enable_dev_board_logger();
            BrainFlowInputParams input_params = new BrainFlowInputParams();
            int       board_id      = parse_args(args, input_params);
            BoardShim board_shim    = new BoardShim(board_id, input_params);
            int       sampling_rate = BoardShim.get_sampling_rate(board_shim.get_board_id());
            int       nfft          = DataFilter.get_nearest_power_of_two(sampling_rate);

            int[] eeg_channels = BoardShim.get_eeg_channels(board_shim.get_board_id());

            board_shim.prepare_session();
            board_shim.start_stream(3600);
            System.Threading.Thread.Sleep(10000);
            board_shim.stop_stream();
            double[,] data = board_shim.get_board_data();
            board_shim.release_session();

            Tuple <double[], double[]> bands = DataFilter.get_avg_band_powers(data, eeg_channels, sampling_rate, true);

            double[]             feature_vector = bands.Item1.Concatenate(bands.Item2);
            BrainFlowModelParams model_params   = new BrainFlowModelParams((int)BrainFlowMetrics.CONCENTRATION, (int)BrainFlowClassifiers.REGRESSION);
            MLModel concentration = new MLModel(model_params);

            concentration.prepare();
            Console.WriteLine("Concentration: " + concentration.predict(feature_vector));
            concentration.release();
        }
Ejemplo n.º 3
0
    void Update()
    {
        if ((board_shim == null) || (concentration == null))
        {
            Debug.Log("Not initialized");
            return;
        }
        int number_of_data_points = sampling_rate * 4; // 4 second window is recommended for concentration and relaxation calculations

        double[,] data = board_shim.get_current_board_data(number_of_data_points);
        if (data.GetRow(0).Length < number_of_data_points)
        {
            // wait for more data
            Debug.Log("Not enough data, data available: " + (data.GetRow(0).Length).ToString());
            return;
        }
        // prepare feature vector
        Tuple <double[], double[]> bands = DataFilter.get_avg_band_powers(data, eeg_channels, sampling_rate, true);

        double[] feature_vector = bands.Item1.Concatenate(bands.Item2);
        // calc and print concetration level
        // for synthetic board this value should be close to 1, because of sin waves ampls and freqs
        Debug.Log("Concentration: " + concentration.predict(feature_vector));
    }
        public static double predicts(float bpm, float zcr, float spectirr)
        {
            double p = m.predict(bpm, zcr, spectirr);

            return(p);
        }