Skip to content

Commit

Permalink
fixing code style for c#
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Parfenov <[email protected]>
  • Loading branch information
Andrey1994 committed Mar 8, 2021
1 parent 87291ce commit fa5c6fc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions csharp-package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ public static int get_num_rows (int board_id)
/// <param name="board_id"></param>
/// <returns>array of 10-20 locations</returns>
/// <exception cref="BrainFlowException">If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR</exception>
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);
Expand Down Expand Up @@ -461,11 +461,11 @@ public static int[] get_temperature_channels (int board_id)
/// <param name="board_id"></param>
/// <returns>array of row nums</returns>
/// <exception cref="BrainFlowException">If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR</exception>
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);
Expand Down
52 changes: 26 additions & 26 deletions csharp-package/brainflow/brainflow/data_filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ public static double[] perform_rolling_filter (double[] data, int period, int op
/// <param name="data"></param>
/// <param name="operation"></param>
/// <returns>data with removed trend</returns>
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);
Expand Down Expand Up @@ -291,11 +291,11 @@ public static double[] perform_wavelet_denoising (double[] data, string wavelet,
/// <param name="data">data for csp</param>
/// <param name="labels">labels for each class</param>
/// <returns>Tuple of two arrays: [n_channels x n_channels] shaped array of filters and n_channels length array of eigenvalues</returns>
public static Tuple<double[,], double[]> get_csp(double[,,] data, double[] labels)
public static Tuple<double[,], double[]> 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++)
Expand Down Expand Up @@ -338,7 +338,7 @@ public static Tuple<double[,], double[]> get_csp(double[,,] data, double[] label
/// <param name="window_function">window function</param>
/// <param name="window_len">len of the window</param>
/// <returns>array of the size specified in window_len</returns>
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);
Expand All @@ -357,7 +357,7 @@ public static double[] get_window(int window_function, int window_len)
/// <param name="end_pos">end pos, end_pos - start_pos must be a power of 2</param>
/// <param name="window">window function</param>
/// <returns>complex array of size N / 2 + 1 of fft data</returns>
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))
{
Expand Down Expand Up @@ -391,7 +391,7 @@ public static Complex[] perform_fft(double[] data, int start_pos, int end_pos, i
/// </summary>
/// <param name="data">data from perform_fft</param>
/// <returns>restored data</returns>
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];
Expand Down Expand Up @@ -464,13 +464,13 @@ public static void write_file (double[,] data, string file_name, string file_mod
/// </summary>
/// <param name="value"></param>
/// <returns>nearest power of two</returns>
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];
}
Expand All @@ -483,7 +483,7 @@ public static int get_nearest_power_of_two(int value)
/// <param name="sampling_rate">sampling rate</param>
/// <param name="apply_filters">apply bandpass and bandstop filters before calculation</param>
/// <returns>Tuple of avgs and stddev arrays</returns>
public static Tuple<double[], double[]> get_avg_band_powers(double[,] data, int[] channels, int sampling_rate, bool apply_filters)
public static Tuple<double[], double[]> 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++)
Expand All @@ -493,7 +493,7 @@ public static Tuple<double[], double[]> 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);
Expand All @@ -511,26 +511,26 @@ public static Tuple<double[], double[]> get_avg_band_powers(double[,] data, int[
/// <param name="sampling_rate">sampling rate</param>
/// <param name="window">window function</param>
/// <returns>Tuple of ampls and freqs arrays of size N / 2 + 1</returns>
public static Tuple<double[], double[]> get_psd(double[] data, int start_pos, int end_pos, int sampling_rate, int window)
public static Tuple<double[], double[]> 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<double[], double[]> return_data = new Tuple<double[], double[]>(temp_ampls, temp_freqs);
return return_data;
Expand All @@ -545,7 +545,7 @@ public static Tuple<double[], double[]> get_psd(double[] data, int start_pos, in
/// <param name="sampling_rate">sampling rate</param>
/// <param name="window">window function</param>
/// <returns>Tuple of ampls and freqs arrays</returns>
public static Tuple<double[], double[]> get_psd_welch(double[] data, int nfft, int overlap, int sampling_rate, int window)
public static Tuple<double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window)
{
if ((nfft & (nfft - 1)) != 0)
{
Expand All @@ -554,10 +554,10 @@ public static Tuple<double[], double[]> 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<double[], double[]> return_data = new Tuple<double[], double[]>(temp_ampls, temp_freqs);
return return_data;
Expand All @@ -570,14 +570,14 @@ public static Tuple<double[], double[]> get_psd_welch(double[] data, int nfft, i
/// <param name="start_freq">lowest frequency of band</param>
/// <param name="stop_freq">highest frequency of band</param>
/// <returns>band power</returns>
public static double get_band_power(Tuple<double[], double[]> psd, double start_freq, double stop_freq)
public static double get_band_power (Tuple<double[], double[]> 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];
}
Expand Down
24 changes: 12 additions & 12 deletions csharp-package/brainflow/brainflow/data_handler_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fa5c6fc

Please sign in to comment.