diff --git a/csharp-package/brainflow/brainflow/board_shim.cs b/csharp-package/brainflow/brainflow/board_shim.cs index b4ee6caf8..bab95f272 100644 --- a/csharp-package/brainflow/brainflow/board_shim.cs +++ b/csharp-package/brainflow/brainflow/board_shim.cs @@ -147,11 +147,11 @@ public static int get_num_rows (int board_id) /// /// array of 10-20 locations /// If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR - public static string[] get_eeg_names(int board_id) + public static string[] get_eeg_names (int board_id) { int[] len = new int[1]; byte[] str = new byte[4096]; - int res = BoardControllerLibrary.get_eeg_names(board_id, str, len); + int res = BoardControllerLibrary.get_eeg_names (board_id, str, len); if (res != (int)CustomExitCodes.STATUS_OK) { throw new BrainFlowException(res); @@ -461,11 +461,11 @@ public static int[] get_temperature_channels (int board_id) /// /// array of row nums /// If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR - public static int[] get_resistance_channels(int board_id) + public static int[] get_resistance_channels (int board_id) { int[] len = new int[1]; int[] channels = new int[512]; - int res = BoardControllerLibrary.get_resistance_channels(board_id, channels, len); + int res = BoardControllerLibrary.get_resistance_channels (board_id, channels, len); if (res != (int)CustomExitCodes.STATUS_OK) { throw new BrainFlowException(res); diff --git a/csharp-package/brainflow/brainflow/data_filter.cs b/csharp-package/brainflow/brainflow/data_filter.cs index edcbbe7ea..ece3dbc46 100644 --- a/csharp-package/brainflow/brainflow/data_filter.cs +++ b/csharp-package/brainflow/brainflow/data_filter.cs @@ -178,11 +178,11 @@ public static double[] perform_rolling_filter (double[] data, int period, int op /// /// /// data with removed trend - public static double[] detrend(double[] data, int operation) + public static double[] detrend (double[] data, int operation) { double[] new_data = new double[data.Length]; - Array.Copy(data, new_data, data.Length); - int res = DataHandlerLibrary.detrend(new_data, new_data.Length, operation); + Array.Copy (data, new_data, data.Length); + int res = DataHandlerLibrary.detrend (new_data, new_data.Length, operation); if (res != (int)CustomExitCodes.STATUS_OK) { throw new BrainFlowException(res); @@ -291,11 +291,11 @@ public static double[] perform_wavelet_denoising (double[] data, string wavelet, /// data for csp /// labels for each class /// Tuple of two arrays: [n_channels x n_channels] shaped array of filters and n_channels length array of eigenvalues - public static Tuple get_csp(double[,,] data, double[] labels) + public static Tuple get_csp (double[,,] data, double[] labels) { - int n_epochs = data.GetLength(0); - int n_channels = data.GetLength(1); - int n_times = data.GetLength(2); + int n_epochs = data.GetLength (0); + int n_channels = data.GetLength (1); + int n_times = data.GetLength (2); double[] temp_data1d = new double[n_epochs * n_channels * n_times]; for (int e = 0; e < n_epochs; e++) @@ -338,7 +338,7 @@ public static Tuple get_csp(double[,,] data, double[] label /// window function /// len of the window /// array of the size specified in window_len - public static double[] get_window(int window_function, int window_len) + public static double[] get_window (int window_function, int window_len) { double[] window_data = new double[window_len]; 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) /// end pos, end_pos - start_pos must be a power of 2 /// window function /// complex array of size N / 2 + 1 of fft data - public static Complex[] perform_fft(double[] data, int start_pos, int end_pos, int window) + public static Complex[] perform_fft (double[] data, int start_pos, int end_pos, int window) { if ((start_pos < 0) || (end_pos > data.Length) || (start_pos >= end_pos)) { @@ -391,7 +391,7 @@ public static Complex[] perform_fft(double[] data, int start_pos, int end_pos, i /// /// data from perform_fft /// restored data - public static double[] perform_ifft(Complex[] data) + public static double[] perform_ifft (Complex[] data) { int len = (data.Length - 1) * 2; double[] temp_re = new double[data.Length]; @@ -464,13 +464,13 @@ public static void write_file (double[,] data, string file_name, string file_mod /// /// /// nearest power of two - public static int get_nearest_power_of_two(int value) + public static int get_nearest_power_of_two (int value) { int[] output = new int[1]; - int res = DataHandlerLibrary.get_nearest_power_of_two(value, output); + int res = DataHandlerLibrary.get_nearest_power_of_two (value, output); if (res != (int)CustomExitCodes.STATUS_OK) { - throw new BrainFlowException(res); + throw new BrainFlowException (res); } return output[0]; } @@ -483,7 +483,7 @@ public static int get_nearest_power_of_two(int value) /// sampling rate /// apply bandpass and bandstop filters before calculation /// Tuple of avgs and stddev arrays - public static Tuple get_avg_band_powers(double[,] data, int[] channels, int sampling_rate, bool apply_filters) + public static Tuple get_avg_band_powers (double[,] data, int[] channels, int sampling_rate, bool apply_filters) { double[] data_1d = new double[data.GetRow (0).Length * channels.Length]; for (int i = 0; i < channels.Length; i++) @@ -493,7 +493,7 @@ public static Tuple get_avg_band_powers(double[,] data, int[ double[] avgs = new double[5]; double[] stddevs = new double[5]; - int res = DataHandlerLibrary.get_avg_band_powers(data_1d, channels.Length, data.GetRow(0).Length, sampling_rate, (apply_filters) ? 1 : 0, avgs, stddevs); + int res = DataHandlerLibrary.get_avg_band_powers (data_1d, channels.Length, data.GetRow (0).Length, sampling_rate, (apply_filters) ? 1 : 0, avgs, stddevs); if (res != (int)CustomExitCodes.STATUS_OK) { throw new BrainFlowException(res); @@ -511,26 +511,26 @@ public static Tuple get_avg_band_powers(double[,] data, int[ /// sampling rate /// window function /// Tuple of ampls and freqs arrays of size N / 2 + 1 - public static Tuple get_psd(double[] data, int start_pos, int end_pos, int sampling_rate, int window) + public static Tuple get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, int window) { if ((start_pos < 0) || (end_pos > data.Length) || (start_pos >= end_pos)) { - throw new BrainFlowException((int)CustomExitCodes.INVALID_ARGUMENTS_ERROR); + throw new BrainFlowException ((int)CustomExitCodes.INVALID_ARGUMENTS_ERROR); } int len = end_pos - start_pos; if ((len & (len - 1)) != 0) { - throw new BrainFlowException((int)CustomExitCodes.INVALID_ARGUMENTS_ERROR); + throw new BrainFlowException ((int)CustomExitCodes.INVALID_ARGUMENTS_ERROR); } double[] data_to_process = new double[len]; Array.Copy(data, start_pos, data_to_process, 0, len); double[] temp_ampls = new double[len / 2 + 1]; double[] temp_freqs = new double[len / 2 + 1]; - int res = DataHandlerLibrary.get_psd(data_to_process, len, sampling_rate, window, temp_ampls, temp_freqs); + int res = DataHandlerLibrary.get_psd (data_to_process, len, sampling_rate, window, temp_ampls, temp_freqs); if (res != (int)CustomExitCodes.STATUS_OK) { - throw new BrainFlowException(res); + throw new BrainFlowException (res); } Tuple return_data = new Tuple(temp_ampls, temp_freqs); return return_data; @@ -545,7 +545,7 @@ public static Tuple get_psd(double[] data, int start_pos, in /// sampling rate /// window function /// Tuple of ampls and freqs arrays - public static Tuple get_psd_welch(double[] data, int nfft, int overlap, int sampling_rate, int window) + public static Tuple get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window) { if ((nfft & (nfft - 1)) != 0) { @@ -554,10 +554,10 @@ public static Tuple get_psd_welch(double[] data, int nfft, i double[] temp_ampls = new double[nfft / 2 + 1]; double[] temp_freqs = new double[nfft / 2 + 1]; - int res = DataHandlerLibrary.get_psd_welch(data, data.Length, nfft, overlap, sampling_rate, window, temp_ampls, temp_freqs); + int res = DataHandlerLibrary.get_psd_welch (data, data.Length, nfft, overlap, sampling_rate, window, temp_ampls, temp_freqs); if (res != (int)CustomExitCodes.STATUS_OK) { - throw new BrainFlowException(res); + throw new BrainFlowException (res); } Tuple return_data = new Tuple(temp_ampls, temp_freqs); return return_data; @@ -570,14 +570,14 @@ public static Tuple get_psd_welch(double[] data, int nfft, i /// lowest frequency of band /// highest frequency of band /// band power - public static double get_band_power(Tuple psd, double start_freq, double stop_freq) + public static double get_band_power (Tuple psd, double start_freq, double stop_freq) { double[] band_power = new double[1]; - int res = DataHandlerLibrary.get_band_power(psd.Item1, psd.Item2, psd.Item1.Length, start_freq, stop_freq, band_power); + int res = DataHandlerLibrary.get_band_power (psd.Item1, psd.Item2, psd.Item1.Length, start_freq, stop_freq, band_power); if (res != (int)CustomExitCodes.STATUS_OK) { - throw new BrainFlowException(res); + throw new BrainFlowException (res); } return band_power[0]; } diff --git a/csharp-package/brainflow/brainflow/data_handler_library.cs b/csharp-package/brainflow/brainflow/data_handler_library.cs index 93b5be6c4..01b44d68f 100644 --- a/csharp-package/brainflow/brainflow/data_handler_library.cs +++ b/csharp-package/brainflow/brainflow/data_handler_library.cs @@ -71,17 +71,17 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] public static extern int perform_ifft (double[] re, double[] im, int data_len, double[] data); [DllImport("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_nearest_power_of_two(int value, int[] output); + public static extern int get_nearest_power_of_two (int value, int[] output); [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_psd(double[] data, int data_len, int sampling_rate, int window, double[] ampls, double[] freqs); + public static extern int get_psd (double[] data, int data_len, int sampling_rate, int window, double[] ampls, double[] freqs); [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_band_power(double[] ampls, double[] freqs, int data_len, double freq_start, double freq_end, double[] res); + public static extern int get_band_power (double[] ampls, double[] freqs, int data_len, double freq_start, double freq_end, double[] res); [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_psd_welch(double[] data, int data_len, int nfft, int overlap, int sampling_rate, int window, double[] ampls, double[] freqs); + public static extern int get_psd_welch (double[] data, int data_len, int nfft, int overlap, int sampling_rate, int window, double[] ampls, double[] freqs); [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int detrend(double[] data, int len, int operation); + public static extern int detrend (double[] data, int len, int operation); [DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_avg_band_powers(double[] data, int rows, int cols, int sampling_rate, int apply_filters, double[] avgs, double[] stddevs); + public static extern int get_avg_band_powers (double[] data, int rows, int cols, int sampling_rate, int apply_filters, double[] avgs, double[] stddevs); } class DataHandlerLibrary32 @@ -124,17 +124,17 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] public static extern int perform_ifft (double[] re, double[] im, int data_len, double[] data); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_nearest_power_of_two(int value, int[] output); + public static extern int get_nearest_power_of_two (int value, int[] output); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_psd(double[] data, int data_len, int sampling_rate, int window, double[] ampls, double[] freqs); + public static extern int get_psd (double[] data, int data_len, int sampling_rate, int window, double[] ampls, double[] freqs); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_band_power(double[] ampls, double[] freqs, int data_len, double freq_start, double freq_end, double[] res); + public static extern int get_band_power (double[] ampls, double[] freqs, int data_len, double freq_start, double freq_end, double[] res); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_psd_welch(double[] data, int data_len, int nfft, int overlap, int sampling_rate, int window, double[] ampls, double[] freqs); + public static extern int get_psd_welch (double[] data, int data_len, int nfft, int overlap, int sampling_rate, int window, double[] ampls, double[] freqs); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int detrend(double[] data, int len, int operation); + public static extern int detrend (double[] data, int len, int operation); [DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int get_avg_band_powers(double[] data, int rows, int cols, int sampling_rate, int apply_filters, double[] avgs, double[] stddevs); + public static extern int get_avg_band_powers (double[] data, int rows, int cols, int sampling_rate, int apply_filters, double[] avgs, double[] stddevs); } class DataHandlerLibraryLinux