| 456 | } |
| 457 | |
| 458 | int perform_downsampling ( |
| 459 | double *data, int data_len, int period, int agg_operation, double *output_data) |
| 460 | { |
| 461 | if ((data == NULL) || (data_len <= 0) || (period <= 0) || (output_data == NULL)) |
| 462 | { |
| 463 | data_logger->error ("Period must be >= 0 and data and output_data cannot be NULL."); |
| 464 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 465 | } |
| 466 | double (*downsampling_op) (double *, int); |
| 467 | switch (static_cast<AggOperations> (agg_operation)) |
| 468 | { |
| 469 | case AggOperations::MEAN: |
| 470 | downsampling_op = downsample_mean; |
| 471 | break; |
| 472 | case AggOperations::MEDIAN: |
| 473 | downsampling_op = downsample_median; |
| 474 | break; |
| 475 | case AggOperations::EACH: |
| 476 | downsampling_op = downsample_each; |
| 477 | break; |
| 478 | default: |
| 479 | data_logger->error ( |
| 480 | "Invalid aggregate opteration:{}. Must be mean,median, or each", agg_operation); |
| 481 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 482 | } |
| 483 | int num_values = data_len / period; |
| 484 | for (int i = 0; i < num_values; i++) |
| 485 | { |
| 486 | output_data[i] = downsampling_op (data + i * period, period); |
| 487 | } |
| 488 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 489 | } |
| 490 | |
| 491 | // https://github.com/rafat/wavelib/wiki/DWT-Example-Code |
| 492 | int perform_wavelet_transform (double *data, int data_len, int wavelet, int decomposition_level, |
no outgoing calls
no test coverage detected