MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / main

Function main

cpp_package/examples/signal_processing/src/ica.cpp:17–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17int main (int argc, char *argv[])
18{
19 BoardShim::enable_dev_board_logger ();
20
21 struct BrainFlowInputParams params;
22 int res = 0;
23 int board_id = (int)BoardIds::SYNTHETIC_BOARD;
24 std::vector<int> eeg_channels = BoardShim::get_eeg_channels (board_id);
25 int channel_to_use = eeg_channels[4];
26 // use synthetic board for demo
27 BoardShim *board = new BoardShim (board_id, params);
28
29 try
30 {
31 board->prepare_session ();
32 board->start_stream ();
33
34#ifdef _WIN32
35 Sleep (10000);
36#else
37 sleep (10);
38#endif
39
40 board->stop_stream ();
41 BrainFlowArray<double, 2> data =
42 board->get_board_data (500, (int)BrainFlowPresets::DEFAULT_PRESET);
43 board->release_session ();
44
45 BrainFlowArray<double, 2> data_reshaped (data.get_address (channel_to_use), 5, 100);
46 std::tuple<BrainFlowArray<double, 2>, BrainFlowArray<double, 2>, BrainFlowArray<double, 2>,
47 BrainFlowArray<double, 2>>
48 returned_matrixes = DataFilter::perform_ica (data_reshaped, 2);
49 std::cout << std::get<3> (returned_matrixes) << std::endl;
50 }
51 catch (const BrainFlowException &err)
52 {
53 BoardShim::log_message ((int)LogLevels::LEVEL_ERROR, err.what ());
54 res = err.exit_code;
55 if (board->is_prepared ())
56 {
57 board->release_session ();
58 }
59 }
60
61 delete board;
62
63 return res;
64}

Callers

nothing calls this directly

Calls 13

enable_dev_board_loggerFunction · 0.85
whatMethod · 0.80
prepare_sessionMethod · 0.65
start_streamMethod · 0.65
stop_streamMethod · 0.65
get_board_dataMethod · 0.65
release_sessionMethod · 0.65
is_preparedMethod · 0.65
get_eeg_channelsFunction · 0.50
sleepFunction · 0.50
perform_icaFunction · 0.50
log_messageFunction · 0.50

Tested by

no test coverage detected