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

Function main

cpp_package/examples/signal_processing/src/downsampling.cpp:19–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19int main (int argc, char *argv[])
20{
21 BoardShim::enable_dev_board_logger ();
22
23 struct BrainFlowInputParams params;
24 int res = 0;
25 int board_id = (int)BoardIds::SYNTHETIC_BOARD;
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 (5000);
36#else
37 sleep (5);
38#endif
39
40 board->stop_stream ();
41 BrainFlowArray<double, 2> data = board->get_board_data ();
42 board->release_session ();
43
44 double *downsampled_data = NULL;
45 int filtered_size = 0;
46 std::vector<int> eeg_channels = BoardShim::get_eeg_channels (board_id);
47
48 for (int i = 0; i < eeg_channels.size (); i++)
49 {
50 std::cout << "Data from :" << eeg_channels[i] << " before downsampling " << std::endl;
51 print_one_row (data.get_address (eeg_channels[i]), data.get_size (1));
52
53 // just for demo apply different downsampling algorithms to different channels
54 // downsampling here just aggregates data points
55 switch (i)
56 {
57 case 0:
58 downsampled_data =
59 DataFilter::perform_downsampling (data.get_address (eeg_channels[i]),
60 data.get_size (1), 2, (int)AggOperations::MEAN, &filtered_size);
61 break;
62 case 1:
63 downsampled_data =
64 DataFilter::perform_downsampling (data.get_address (eeg_channels[i]),
65 data.get_size (1), 3, (int)AggOperations::MEDIAN, &filtered_size);
66 break;
67 default:
68 downsampled_data =
69 DataFilter::perform_downsampling (data.get_address (eeg_channels[i]),
70 data.get_size (1), 2, (int)AggOperations::EACH, &filtered_size);
71 break;
72 }
73
74 std::cout << "Data from :" << eeg_channels[i] << " after downsampling " << std::endl;
75 print_one_row (downsampled_data, filtered_size);
76 delete[] downsampled_data;

Callers

nothing calls this directly

Calls 15

enable_dev_board_loggerFunction · 0.85
get_sizeMethod · 0.80
whatMethod · 0.80
print_one_rowFunction · 0.70
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
sleepFunction · 0.50
get_eeg_channelsFunction · 0.50

Tested by

no test coverage detected