-
-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrey Parfenov <[email protected]> Signed-off-by: Andrey Parfenov <[email protected]>
- Loading branch information
1 parent
7064ad5
commit 8b8f804
Showing
21 changed files
with
663 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
cpp_package/examples/signal_processing/src/peaks_detection.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <iostream> | ||
#include <stdlib.h> | ||
#include <string> | ||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#else | ||
#include <unistd.h> | ||
#endif | ||
|
||
#include "board_shim.h" | ||
#include "data_filter.h" | ||
|
||
using namespace std; | ||
|
||
void print_one_row (double *data, int num_data_points); | ||
|
||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
BoardShim::enable_dev_board_logger (); | ||
|
||
struct BrainFlowInputParams params; | ||
int res = 0; | ||
int board_id = (int)BoardIds::SYNTHETIC_BOARD; | ||
// use synthetic board for demo | ||
BoardShim *board = new BoardShim (board_id, params); | ||
|
||
try | ||
{ | ||
board->prepare_session (); | ||
board->start_stream (); | ||
|
||
#ifdef _WIN32 | ||
Sleep (5000); | ||
#else | ||
sleep (5); | ||
#endif | ||
|
||
board->stop_stream (); | ||
BrainFlowArray<double, 2> data = board->get_board_data (); | ||
board->release_session (); | ||
|
||
double *peaks = new double[data.get_size (1)]; | ||
std::vector<int> eeg_channels = BoardShim::get_eeg_channels (board_id); | ||
|
||
for (int i = 0; i < eeg_channels.size (); i++) | ||
{ | ||
DataFilter::restore_data_from_wavelet_detailed_coeffs ( | ||
data.get_address (eeg_channels[i]), data.get_size (1), (int)WaveletTypes::DB4, 6, 4, | ||
peaks); | ||
DataFilter::detect_peaks_z_score (peaks, data.get_size (1), 20, 3.5, 0.0, peaks); | ||
} | ||
delete[] peaks; | ||
} | ||
catch (const BrainFlowException &err) | ||
{ | ||
BoardShim::log_message ((int)LogLevels::LEVEL_ERROR, err.what ()); | ||
res = err.exit_code; | ||
if (board->is_prepared ()) | ||
{ | ||
board->release_session (); | ||
} | ||
} | ||
|
||
delete board; | ||
|
||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using BrainFlow | ||
|
||
BrainFlow.enable_dev_logger(BrainFlow.BOARD_CONTROLLER) | ||
|
||
params = BrainFlowInputParams() | ||
board_shim = BrainFlow.BoardShim(BrainFlow.MUSE_S_BOARD, params) | ||
|
||
BrainFlow.prepare_session(board_shim) | ||
BrainFlow.config_board("p61", board_shim) # to enable ppg only use p61, p50 enables aux(5th eeg) channel, ppg and smth else | ||
BrainFlow.add_streamer("file://default4.csv:w", board_shim, BrainFlow.DEFAULT_PRESET) | ||
BrainFlow.add_streamer("file://aux4.csv:w", board_shim, BrainFlow.AUXILIARY_PRESET) | ||
BrainFlow.add_streamer("file://anc4.csv:w", board_shim, BrainFlow.ANCILLARY_PRESET) # this preset contains ppg data and not available for Muse 2016 | ||
BrainFlow.start_stream(board_shim) | ||
sleep(24000) | ||
BrainFlow.stop_stream(board_shim) | ||
BrainFlow.release_session(board_shim) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using BrainFlow | ||
|
||
# enable logs | ||
BrainFlow.enable_dev_logger(BrainFlow.BOARD_CONTROLLER) | ||
BrainFlow.enable_dev_logger(BrainFlow.DATA_HANDLER) | ||
|
||
params = BrainFlowInputParams() | ||
board_shim = BrainFlow.BoardShim(BrainFlow.SYNTHETIC_BOARD, params) | ||
sampling_rate = BrainFlow.get_sampling_rate(BrainFlow.SYNTHETIC_BOARD) | ||
|
||
BrainFlow.prepare_session(board_shim) | ||
BrainFlow.start_stream(board_shim) | ||
sleep(10) | ||
BrainFlow.stop_stream(board_shim) | ||
data = BrainFlow.get_current_board_data(1024, board_shim) | ||
BrainFlow.release_session(board_shim) | ||
|
||
eeg_channels = BrainFlow.get_eeg_channels(BrainFlow.SYNTHETIC_BOARD) | ||
data_first_channel = data[eeg_channels[1], :] | ||
|
||
restored_data = BrainFlow.restore_data_from_wavelet_detailed_coeffs(data_first_channel, BrainFlow.DB4, 4, 2) | ||
peaks = BrainFlow.detect_peaks_z_score(restored_data, 20, 3.5, 0.0) |
Oops, something went wrong.