示例#1
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();
        }
示例#2
0
    // Start is called before the first frame update

    void Start()
    {
        try
        {
            BoardShim.enable_dev_board_logger();

            BrainFlowInputParams input_params = new BrainFlowInputParams();
            int board_id = (int)BoardIds.MINDROVE_BLUETOOTH_BOARD;//= parse_args(args, input_params);

            board_shim = new BoardShim(board_id, input_params);
            board_shim.prepare_session();

            board_shim.start_stream(); // use this for default options
                                       //board_shim.start_stream(450000, "file://file_stream.csv:w");

            BrainFlowModelParams concentration_params = new BrainFlowModelParams((int)BrainFlowMetrics.CONCENTRATION, (int)BrainFlowClassifiers.REGRESSION);
            concentration = new MLModel(concentration_params);
            concentration.prepare();
            sampling_rate = 250;//BoardShim.get_sampling_rate(board_id);
            eeg_channels  = BoardShim.get_eeg_channels(board_id);
        }
        catch (BrainFlowException ex)
        {
            Debug.Log(ex);
        }
    }
示例#3
0
        static void Main(string[] args)
        {
            try
            {
                BoardShim.enable_dev_board_logger();

                BrainFlowInputParams input_params = new BrainFlowInputParams();
                int board_id = (int)BoardIds.MINDROVE_WIFI_BOARD;//= parse_args(args, input_params);

                board_shim = new BoardShim(board_id, input_params);
                board_shim.prepare_session();

                board_shim.start_stream(); // use this for default options
                                           //board_shim.start_stream(450000, "file://file_stream.csv:w");

                board_shim.config_board(BoardShim.MindroveWifiConfigMode.EEG_MODE);
                BrainFlowModelParams concentration_params = new BrainFlowModelParams((int)BrainFlowMetrics.CONCENTRATION, (int)BrainFlowClassifiers.REGRESSION);
                concentration = new MLModel(concentration_params);
                concentration.prepare();

                sampling_rate = BoardShim.get_sampling_rate(board_id);
                eeg_channels  = BoardShim.get_eeg_channels(board_id);
                counter_idx   = BoardShim.get_package_num_channel(board_id);
            }
            catch (BrainFlowException ex)
            {
                Console.WriteLine(ex);
            }
            while (Update() >= 0)
            {
            }

            if (board_shim != null)
            {
                try
                {
                    board_shim.release_session();
                    concentration.release();
                }
                catch (BrainFlowException e)
                {
                    Console.WriteLine(e);
                }
                Console.WriteLine("Brainflow streaming was stopped");
            }
            Console.ReadLine();
        }