@@ -178,11 +178,11 @@ public static double[] perform_rolling_filter (double[] data, int period, int op
178
178
/// <param name="data"></param>
179
179
/// <param name="operation"></param>
180
180
/// <returns>data with removed trend</returns>
181
- public static double [ ] detrend ( double [ ] data , int operation )
181
+ public static double [ ] detrend ( double [ ] data , int operation )
182
182
{
183
183
double [ ] new_data = new double [ data . Length ] ;
184
- Array . Copy ( data , new_data , data . Length ) ;
185
- int res = DataHandlerLibrary . detrend ( new_data , new_data . Length , operation ) ;
184
+ Array . Copy ( data , new_data , data . Length ) ;
185
+ int res = DataHandlerLibrary . detrend ( new_data , new_data . Length , operation ) ;
186
186
if ( res != ( int ) CustomExitCodes . STATUS_OK )
187
187
{
188
188
throw new BrainFlowException ( res ) ;
@@ -291,11 +291,11 @@ public static double[] perform_wavelet_denoising (double[] data, string wavelet,
291
291
/// <param name="data">data for csp</param>
292
292
/// <param name="labels">labels for each class</param>
293
293
/// <returns>Tuple of two arrays: [n_channels x n_channels] shaped array of filters and n_channels length array of eigenvalues</returns>
294
- public static Tuple < double [ , ] , double [ ] > get_csp ( double [ , , ] data , double [ ] labels )
294
+ public static Tuple < double [ , ] , double [ ] > get_csp ( double [ , , ] data , double [ ] labels )
295
295
{
296
- int n_epochs = data . GetLength ( 0 ) ;
297
- int n_channels = data . GetLength ( 1 ) ;
298
- int n_times = data . GetLength ( 2 ) ;
296
+ int n_epochs = data . GetLength ( 0 ) ;
297
+ int n_channels = data . GetLength ( 1 ) ;
298
+ int n_times = data . GetLength ( 2 ) ;
299
299
300
300
double [ ] temp_data1d = new double [ n_epochs * n_channels * n_times ] ;
301
301
for ( int e = 0 ; e < n_epochs ; e ++ )
@@ -338,7 +338,7 @@ public static Tuple<double[,], double[]> get_csp(double[,,] data, double[] label
338
338
/// <param name="window_function">window function</param>
339
339
/// <param name="window_len">len of the window</param>
340
340
/// <returns>array of the size specified in window_len</returns>
341
- public static double [ ] get_window ( int window_function , int window_len )
341
+ public static double [ ] get_window ( int window_function , int window_len )
342
342
{
343
343
double [ ] window_data = new double [ window_len ] ;
344
344
int res = DataHandlerLibrary . get_window ( window_function , window_len , window_data ) ;
@@ -357,7 +357,7 @@ public static double[] get_window(int window_function, int window_len)
357
357
/// <param name="end_pos">end pos, end_pos - start_pos must be a power of 2</param>
358
358
/// <param name="window">window function</param>
359
359
/// <returns>complex array of size N / 2 + 1 of fft data</returns>
360
- public static Complex [ ] perform_fft ( double [ ] data , int start_pos , int end_pos , int window )
360
+ public static Complex [ ] perform_fft ( double [ ] data , int start_pos , int end_pos , int window )
361
361
{
362
362
if ( ( start_pos < 0 ) || ( end_pos > data . Length ) || ( start_pos >= end_pos ) )
363
363
{
@@ -391,7 +391,7 @@ public static Complex[] perform_fft(double[] data, int start_pos, int end_pos, i
391
391
/// </summary>
392
392
/// <param name="data">data from perform_fft</param>
393
393
/// <returns>restored data</returns>
394
- public static double [ ] perform_ifft ( Complex [ ] data )
394
+ public static double [ ] perform_ifft ( Complex [ ] data )
395
395
{
396
396
int len = ( data . Length - 1 ) * 2 ;
397
397
double [ ] temp_re = new double [ data . Length ] ;
@@ -464,13 +464,13 @@ public static void write_file (double[,] data, string file_name, string file_mod
464
464
/// </summary>
465
465
/// <param name="value"></param>
466
466
/// <returns>nearest power of two</returns>
467
- public static int get_nearest_power_of_two ( int value )
467
+ public static int get_nearest_power_of_two ( int value )
468
468
{
469
469
int [ ] output = new int [ 1 ] ;
470
- int res = DataHandlerLibrary . get_nearest_power_of_two ( value , output ) ;
470
+ int res = DataHandlerLibrary . get_nearest_power_of_two ( value , output ) ;
471
471
if ( res != ( int ) CustomExitCodes . STATUS_OK )
472
472
{
473
- throw new BrainFlowException ( res ) ;
473
+ throw new BrainFlowException ( res ) ;
474
474
}
475
475
return output [ 0 ] ;
476
476
}
@@ -483,7 +483,7 @@ public static int get_nearest_power_of_two(int value)
483
483
/// <param name="sampling_rate">sampling rate</param>
484
484
/// <param name="apply_filters">apply bandpass and bandstop filters before calculation</param>
485
485
/// <returns>Tuple of avgs and stddev arrays</returns>
486
- public static Tuple < double [ ] , double [ ] > get_avg_band_powers ( double [ , ] data , int [ ] channels , int sampling_rate , bool apply_filters )
486
+ public static Tuple < double [ ] , double [ ] > get_avg_band_powers ( double [ , ] data , int [ ] channels , int sampling_rate , bool apply_filters )
487
487
{
488
488
double [ ] data_1d = new double [ data . GetRow ( 0 ) . Length * channels . Length ] ;
489
489
for ( int i = 0 ; i < channels . Length ; i ++ )
@@ -493,7 +493,7 @@ public static Tuple<double[], double[]> get_avg_band_powers(double[,] data, int[
493
493
double [ ] avgs = new double [ 5 ] ;
494
494
double [ ] stddevs = new double [ 5 ] ;
495
495
496
- int res = DataHandlerLibrary . get_avg_band_powers ( data_1d , channels . Length , data . GetRow ( 0 ) . Length , sampling_rate , ( apply_filters ) ? 1 : 0 , avgs , stddevs ) ;
496
+ int res = DataHandlerLibrary . get_avg_band_powers ( data_1d , channels . Length , data . GetRow ( 0 ) . Length , sampling_rate , ( apply_filters ) ? 1 : 0 , avgs , stddevs ) ;
497
497
if ( res != ( int ) CustomExitCodes . STATUS_OK )
498
498
{
499
499
throw new BrainFlowException ( res ) ;
@@ -511,26 +511,26 @@ public static Tuple<double[], double[]> get_avg_band_powers(double[,] data, int[
511
511
/// <param name="sampling_rate">sampling rate</param>
512
512
/// <param name="window">window function</param>
513
513
/// <returns>Tuple of ampls and freqs arrays of size N / 2 + 1</returns>
514
- public static Tuple < double [ ] , double [ ] > get_psd ( double [ ] data , int start_pos , int end_pos , int sampling_rate , int window )
514
+ public static Tuple < double [ ] , double [ ] > get_psd ( double [ ] data , int start_pos , int end_pos , int sampling_rate , int window )
515
515
{
516
516
if ( ( start_pos < 0 ) || ( end_pos > data . Length ) || ( start_pos >= end_pos ) )
517
517
{
518
- throw new BrainFlowException ( ( int ) CustomExitCodes . INVALID_ARGUMENTS_ERROR ) ;
518
+ throw new BrainFlowException ( ( int ) CustomExitCodes . INVALID_ARGUMENTS_ERROR ) ;
519
519
}
520
520
int len = end_pos - start_pos ;
521
521
if ( ( len & ( len - 1 ) ) != 0 )
522
522
{
523
- throw new BrainFlowException ( ( int ) CustomExitCodes . INVALID_ARGUMENTS_ERROR ) ;
523
+ throw new BrainFlowException ( ( int ) CustomExitCodes . INVALID_ARGUMENTS_ERROR ) ;
524
524
}
525
525
double [ ] data_to_process = new double [ len ] ;
526
526
Array . Copy ( data , start_pos , data_to_process , 0 , len ) ;
527
527
double [ ] temp_ampls = new double [ len / 2 + 1 ] ;
528
528
double [ ] temp_freqs = new double [ len / 2 + 1 ] ;
529
529
530
- int res = DataHandlerLibrary . get_psd ( data_to_process , len , sampling_rate , window , temp_ampls , temp_freqs ) ;
530
+ int res = DataHandlerLibrary . get_psd ( data_to_process , len , sampling_rate , window , temp_ampls , temp_freqs ) ;
531
531
if ( res != ( int ) CustomExitCodes . STATUS_OK )
532
532
{
533
- throw new BrainFlowException ( res ) ;
533
+ throw new BrainFlowException ( res ) ;
534
534
}
535
535
Tuple < double [ ] , double [ ] > return_data = new Tuple < double [ ] , double [ ] > ( temp_ampls , temp_freqs ) ;
536
536
return return_data ;
@@ -545,7 +545,7 @@ public static Tuple<double[], double[]> get_psd(double[] data, int start_pos, in
545
545
/// <param name="sampling_rate">sampling rate</param>
546
546
/// <param name="window">window function</param>
547
547
/// <returns>Tuple of ampls and freqs arrays</returns>
548
- public static Tuple < double [ ] , double [ ] > get_psd_welch ( double [ ] data , int nfft , int overlap , int sampling_rate , int window )
548
+ public static Tuple < double [ ] , double [ ] > get_psd_welch ( double [ ] data , int nfft , int overlap , int sampling_rate , int window )
549
549
{
550
550
if ( ( nfft & ( nfft - 1 ) ) != 0 )
551
551
{
@@ -554,10 +554,10 @@ public static Tuple<double[], double[]> get_psd_welch(double[] data, int nfft, i
554
554
double [ ] temp_ampls = new double [ nfft / 2 + 1 ] ;
555
555
double [ ] temp_freqs = new double [ nfft / 2 + 1 ] ;
556
556
557
- int res = DataHandlerLibrary . get_psd_welch ( data , data . Length , nfft , overlap , sampling_rate , window , temp_ampls , temp_freqs ) ;
557
+ int res = DataHandlerLibrary . get_psd_welch ( data , data . Length , nfft , overlap , sampling_rate , window , temp_ampls , temp_freqs ) ;
558
558
if ( res != ( int ) CustomExitCodes . STATUS_OK )
559
559
{
560
- throw new BrainFlowException ( res ) ;
560
+ throw new BrainFlowException ( res ) ;
561
561
}
562
562
Tuple < double [ ] , double [ ] > return_data = new Tuple < double [ ] , double [ ] > ( temp_ampls , temp_freqs ) ;
563
563
return return_data ;
@@ -570,14 +570,14 @@ public static Tuple<double[], double[]> get_psd_welch(double[] data, int nfft, i
570
570
/// <param name="start_freq">lowest frequency of band</param>
571
571
/// <param name="stop_freq">highest frequency of band</param>
572
572
/// <returns>band power</returns>
573
- public static double get_band_power ( Tuple < double [ ] , double [ ] > psd , double start_freq , double stop_freq )
573
+ public static double get_band_power ( Tuple < double [ ] , double [ ] > psd , double start_freq , double stop_freq )
574
574
{
575
575
double [ ] band_power = new double [ 1 ] ;
576
576
577
- int res = DataHandlerLibrary . get_band_power ( psd . Item1 , psd . Item2 , psd . Item1 . Length , start_freq , stop_freq , band_power ) ;
577
+ int res = DataHandlerLibrary . get_band_power ( psd . Item1 , psd . Item2 , psd . Item1 . Length , start_freq , stop_freq , band_power ) ;
578
578
if ( res != ( int ) CustomExitCodes . STATUS_OK )
579
579
{
580
- throw new BrainFlowException ( res ) ;
580
+ throw new BrainFlowException ( res ) ;
581
581
}
582
582
return band_power [ 0 ] ;
583
583
}
0 commit comments