| 387 | } |
| 388 | |
| 389 | int remove_environmental_noise (double *data, int data_len, int sampling_rate, int noise_type) |
| 390 | { |
| 391 | if ((data_len < 1) || (sampling_rate < 1) || (!data)) |
| 392 | { |
| 393 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 394 | } |
| 395 | |
| 396 | int res = (int)BrainFlowExitCodes::STATUS_OK; |
| 397 | |
| 398 | switch (static_cast<NoiseTypes> (noise_type)) |
| 399 | { |
| 400 | case NoiseTypes::FIFTY: |
| 401 | res = perform_bandstop (data, data_len, sampling_rate, 48.0, 52.0, 4, |
| 402 | (int)FilterTypes::BUTTERWORTH_ZERO_PHASE, 0.0); |
| 403 | break; |
| 404 | case NoiseTypes::SIXTY: |
| 405 | res = perform_bandstop (data, data_len, sampling_rate, 58.0, 62.0, 4, |
| 406 | (int)FilterTypes::BUTTERWORTH_ZERO_PHASE, 0.0); |
| 407 | break; |
| 408 | case NoiseTypes::FIFTY_AND_SIXTY: |
| 409 | res = perform_bandstop (data, data_len, sampling_rate, 48.0, 52.0, 4, |
| 410 | (int)FilterTypes::BUTTERWORTH_ZERO_PHASE, 0.0); |
| 411 | if (res == (int)BrainFlowExitCodes::STATUS_OK) |
| 412 | { |
| 413 | res = perform_bandstop (data, data_len, sampling_rate, 58.0, 62.0, 4, |
| 414 | (int)FilterTypes::BUTTERWORTH, 0.0); |
| 415 | } |
| 416 | break; |
| 417 | default: |
| 418 | data_logger->error ("Invalid noise type"); |
| 419 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 420 | } |
| 421 | |
| 422 | return res; |
| 423 | } |
| 424 | |
| 425 | int perform_rolling_filter (double *data, int data_len, int period, int agg_operation) |
| 426 | { |
no test coverage detected