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

Function perform_downsampling

src/data_handler/data_handler.cpp:458–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458int 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
492int perform_wavelet_transform (double *data, int data_len, int wavelet, int decomposition_level,

Callers 2

perform_downsamplingMethod · 0.50
mainFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected