Connect Usage#

For more detailed examples please visit Python API documentation

Bandpass filter#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies a bandpass filter to time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal with low-frequency and high-frequency components.
 9//
10// Objective:
11// - Apply a bandpass filter to two predefined datasets using `ba_bci_connect_filter_bandpass()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with both low-frequency and high-frequency components.
14// - Compare the results of applying the bandpass filter on both datasets.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with both low-frequency and high-frequency components.
20// - Use `ba_bci_connect_filter_bandpass()` to apply the bandpass filter to each dataset.
21// - Print the filtered data for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) will likely be minimally affected by the bandpass filter,
25//   depending on the filter's cutoff frequencies.
26// - The noisy signal (`x2`) will likely have both its low-frequency and high-frequency components removed,
27//   leaving only the frequencies within the bandpass range.
28// ===================================================================================
29
30// Define constants for the number of channels, time steps, and filter parameters
31#define N_CHANS         2      // Number of channels (e.g., EEG channels)
32#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
33#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz
34#define LOW_CUTOFF_FREQ 0.5    // Low cutoff frequency for bandpass filter (in Hz)
35#define HIGH_CUTOFF_FREQ 40.0  // High cutoff frequency for bandpass filter (in Hz)
36
37/// Function to print the array values for each channel after filtering
38void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
39    // Loop through each channel and print the filtered values
40    for (size_t i = 0; i < n_chans; ++i) {
41        for (size_t j = 0; j < n_time_steps; ++j) {
42            printf("%f ", arr[i * n_time_steps + j]);
43        }
44        printf("\n");
45    }
46}
47
48int main() {
49    // Example dataset 1: Clean signal (increasing values for simplicity)
50    double x1[N_CHANS * N_TIME_STEPS] = {
51		1, 2, 3, 4, 5, // Channel 1
52		6, 7, 8, 9, 10 // Channel 2
53	};
54
55    // Example dataset 2: Noisy signal with both low-frequency and high-frequency components
56    double x2[N_CHANS * N_TIME_STEPS] = {
57        100, -500, 2000, -3000, 1500,   // Channel 1 with low-frequency and high-frequency components
58        50, 1000, -2500, 750, -1000    // Channel 2 with low-frequency and high-frequency components
59    };
60
61    // Apply bandpass filter and print results for the clean signal (Dataset 1)
62    ba_bci_connect_filter_bandpass(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, LOW_CUTOFF_FREQ, HIGH_CUTOFF_FREQ);
63    printf("Bandpass Filtered Data (Example 1 - Clean Signal):\n");
64    print_array(x1, N_CHANS, N_TIME_STEPS);  // Print the filtered data
65
66    // Apply bandpass filter and print results for the noisy signal (Dataset 2)
67    ba_bci_connect_filter_bandpass(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, LOW_CUTOFF_FREQ, HIGH_CUTOFF_FREQ);
68    printf("Bandpass Filtered Data (Example 2 - Noisy Signal):\n");
69    print_array(x2, N_CHANS, N_TIME_STEPS);  // Print the filtered data
70
71    return 0;  // Return 0 to indicate successful execution
72}

High pass filter#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies a highpass filter to time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal with low-frequency fluctuations.
 9//
10// Objective:
11// - Apply a highpass filter to two predefined datasets using `ba_bci_connect_filter_highpass()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with low-frequency components.
14// - Compare the results of applying the highpass filter on both datasets.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with low-frequency fluctuations.
20// - Use `ba_bci_connect_filter_highpass()` to apply the highpass filter to each dataset.
21// - Print the filtered data for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) will likely be minimally affected by the highpass filter, depending on the filter parameters.
25// - The noisy signal (`x2`) will likely have reduced low-frequency components, depending on the cutoff frequency.
26// ===================================================================================
27
28// Define constants for the number of channels, time steps, and filter parameters
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz
32#define CUTOFF_FREQ     0.5    // Cutoff frequency for highpass filter (in Hz)
33
34/// Function to print the array values for each channel after filtering
35void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
36    // Loop through each channel and print the filtered values
37    for (size_t i = 0; i < n_chans; ++i) {
38        for (size_t j = 0; j < n_time_steps; ++j) {
39            printf("%f ", arr[i * n_time_steps + j]);
40        }
41        printf("\n");
42    }
43}
44
45int main() {
46    // Example dataset 1: Clean signal (increasing values for simplicity)
47    double x1[N_CHANS * N_TIME_STEPS] = {
48		1, 2, 3, 4, 5, // Channel 1 with low-frequency fluctuations
49		6, 7, 8, 9, 10 // Channel 2 with low-frequency fluctuations
50	};
51
52    // Example dataset 2: Noisy signal with low-frequency components
53    double x2[N_CHANS * N_TIME_STEPS] = {
54        100, -500, 2000, -3000, 1500,   // Channel 1 with low-frequency fluctuations
55        50, 1000, -2500, 750, -1000    // Channel 2 with low-frequency fluctuations
56    };
57
58    // Apply highpass filter and print results for the clean signal (Dataset 1)
59    ba_bci_connect_filter_highpass(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CUTOFF_FREQ);
60    printf("Highpass Filtered Data (Example 1 - Clean Signal):\n");
61    print_array(x1, N_CHANS, N_TIME_STEPS);  // Print the filtered data
62
63    // Apply highpass filter and print results for the noisy signal (Dataset 2)
64    ba_bci_connect_filter_highpass(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CUTOFF_FREQ);
65    printf("Highpass Filtered Data (Example 2 - Noisy Signal):\n");
66    print_array(x2, N_CHANS, N_TIME_STEPS);  // Print the filtered data
67
68    return 0;  // Return 0 to indicate successful execution
69}

Standard deviation#

 1#include "processor.h"  // Include the header file where ba_bci_connect_std is declared
 2#include <stdio.h>      // Include standard input-output library for printf
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment computes the standard deviation of time-series data across
 7// multiple channels. The data consists of two datasets, each having two channels
 8// and five time steps. The function `ba_bci_connect_std()` is used to calculate
 9// the standard deviation for each channel, allowing us to analyze variability
10// in the data.
11//
12// Objective:
13// - Compute and analyze the standard deviation of time-series data in two datasets.
14//
15// Methodology:
16// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
17// - Use `ba_bci_connect_std()` to compute the standard deviation for each channel.
18// - Print the computed standard deviations for analysis.
19//
20// Expected Outcome:
21// - Higher standard deviation values indicate greater variability in data.
22// - Lower standard deviation values suggest more consistent values over time.
23//
24// ===================================================================================
25
26// Define constants for the number of channels and time steps
27#define N_CHANS      2  // Number of channels (e.g., EEG channels)
28#define N_TIME_STEPS 5  // Number of time steps per channel
29
30// Function to print the computed standard deviation for each channel
31void print_std(const double* std, size_t n_chans)
32{
33	for (size_t i = 0; i < n_chans; ++i)  // Loop through each channel
34	{
35		printf("Channel %zu: Std = %f\n", i, std[i]);  // Print standard deviation for the channel
36	}
37}
38
39int main()
40{
41	// Example dataset 1: Two channels, each with 5 time steps
42	double x1[N_CHANS * N_TIME_STEPS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
43	// Example dataset 2: Different values with another variation
44	double x2[N_CHANS * N_TIME_STEPS] = {0, 2, 4, 6, 8,
45		10, 11, 12, 13, 14};
46
47	// Array to store the computed standard deviation for each channel
48	double std[N_CHANS];
49
50	// Compute and print the standard deviation for the first dataset (x1)
51	ba_bci_connect_std(x1, N_CHANS, N_TIME_STEPS, std);
52	printf("Standard Deviation (Example 1):\n");
53	print_std(std, N_CHANS);
54
55	// Compute and print the standard deviation for the second dataset (x2)
56	ba_bci_connect_std(x2, N_CHANS, N_TIME_STEPS, std);
57	printf("Standard Deviation (Example 2):\n");
58	print_std(std, N_CHANS);
59
60	return 0;  // Return 0 to indicate successful execution
61}

Min Max#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment evaluates the signal quality and calculates the minimum and maximum
 7// values of time-series data from multiple channels. The experiment uses two
 8// predefined datasets: one representing a clean signal and the other
 9// representing a noisy signal.
10//
11// Objective:
12// - Compute and analyze the minimum and maximum values of two predefined datasets
13//   using `ba_bci_connect_minmax()`.
14// - The first dataset (`x1`) contains a clean, predictable signal.
15// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
16// - Compare the min and max values of both the clean and noisy signals.
17//
18// Methodology:
19// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
20// - The first dataset (`x1`) contains a clean, predictable signal.
21// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
22// - Use `ba_bci_connect_minmax()` to evaluate the min and max values for each channel
23//   of the datasets.
24// - Print the computed min and max values for each channel.
25//
26// Expected Outcome:
27// - The clean signal (`x1`) should have consistent min and max values for each channel.
28// - The noisy signal (`x2`) should show larger fluctuations, resulting in different min
29//   and max values compared to the clean signal. The noise will distort the min/max
30//   range, especially in comparison to the clean signal.
31// ===================================================================================
32
33// Define constants for the number of channels and time steps
34#define N_CHANS         2      // Number of channels (e.g., EEG channels)
35#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
36
37// Function to print the minimum and maximum values for each channel
38void print_minmax(const double* x_min, const double* x_max, size_t n_chans) {
39    // Loop through each channel and print its min and max values
40    for (size_t i = 0; i < n_chans; ++i) {
41        printf("Channel %zu: Min = %f, Max = %f\n", i, x_min[i], x_max[i]);
42    }
43}
44
45int main() {
46    // Example dataset 1: Clean signal (increasing values for simplicity)
47    double x1[N_CHANS * N_TIME_STEPS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
48
49    // Example dataset 2: Noisy signal (with noise)
50    double x2[N_CHANS * N_TIME_STEPS] = {
51        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
52        50, 1000, -2500, 750, -1000    // Channel 2 with noise
53    };
54
55    // Arrays to store the minimum and maximum values for each channel
56    double x_min[N_CHANS];
57    double x_max[N_CHANS];
58
59    // Compute and print the min and max values for the clean signal (Dataset 1)
60    ba_bci_connect_minmax(x1, N_CHANS, N_TIME_STEPS, x_min, x_max);  // Calculate min and max values for each channel
61    printf("Min and Max Values (Example 1 - Clean Signal):\n");
62    print_minmax(x_min, x_max, N_CHANS);  // Print the calculated min and max values
63
64    // Compute and print the min and max values for the noisy signal (Dataset 2)
65    ba_bci_connect_minmax(x2, N_CHANS, N_TIME_STEPS, x_min, x_max);  // Calculate min and max values for each channel
66    printf("Min and Max Values (Example 2 - Noisy Signal):\n");
67    print_minmax(x_min, x_max, N_CHANS);  // Print the calculated min and max values
68
69    return 0;  // Return 0 to indicate successful execution
70}

Mean#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment calculates the mean values of time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal.
 9//
10// Objective:
11// - Compute and analyze the mean values of two predefined datasets using `ba_bci_connect_mean()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
14// - Compare the mean values of both the clean and noisy signals.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
20// - Use `ba_bci_connect_mean()` to evaluate the mean values for each channel of the datasets.
21// - Print the computed mean values for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) should have a stable and predictable mean value for each channel.
25// - The noisy signal (`x2`) will likely have a mean value that reflects the noise and large fluctuations.
26// ===================================================================================
27
28// Define constants for the number of channels and time steps
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31
32// Function to print the mean values for each channel
33void print_mean(const double* mean, size_t n_chans) {
34    // Loop through each channel and print its mean value
35    for (size_t i = 0; i < n_chans; ++i) {
36        printf("Channel %zu: Mean = %f\n", i, mean[i]);
37    }
38}
39
40int main() {
41    // Example dataset 1: Clean signal (increasing values for simplicity)
42    double x1[N_CHANS * N_TIME_STEPS] = {
43		1, 2, 3, 4, 5, // Channel 1 with noise
44		6, 7, 8, 9, 10 // Channel 2 with noise
45	};
46
47    // Example dataset 2: Noisy signal (with noise)
48    double x2[N_CHANS * N_TIME_STEPS] = {
49        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
50        50, 1000, -2500, 750, -1000    // Channel 2 with noise
51    };
52
53    // Array to store the mean values for each channel
54    double mean[N_CHANS];
55
56    // Compute and print the mean values for the clean signal (Dataset 1)
57    ba_bci_connect_mean(x1, N_CHANS, N_TIME_STEPS, mean);  // Calculate mean values for each channel
58    printf("Mean Values (Example 1 - Clean Signal):\n");
59    print_mean(mean, N_CHANS);  // Print the calculated mean values
60
61    // Compute and print the mean values for the noisy signal (Dataset 2)
62    ba_bci_connect_mean(x2, N_CHANS, N_TIME_STEPS, mean);  // Calculate mean values for each channel
63    printf("Mean Values (Example 2 - Noisy Signal):\n");
64    print_mean(mean, N_CHANS);  // Print the calculated mean values
65
66    return 0;  // Return 0 to indicate successful execution
67}

Low pass filter#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies a lowpass filter to time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal.
 9//
10// Objective:
11// - Apply a lowpass filter to two predefined datasets using `ba_bci_connect_filter_lowpass()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with fluctuations.
14// - Compare the results of applying the lowpass filter on both datasets.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with fluctuations.
20// - Use `ba_bci_connect_filter_lowpass()` to apply the lowpass filter to each dataset.
21// - Print the filtered data for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) will likely be minimally affected by the lowpass filter, depending on the filter parameters.
25// - The noisy signal (`x2`) will likely have reduced high-frequency noise, depending on the cutoff frequency.
26// ===================================================================================
27
28// Define constants for the number of channels, time steps, and filter parameters
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz
32#define CUTOFF_FREQ     40.0   // Cutoff frequency for lowpass filter (in Hz)
33
34/// Function to print the array values for each channel after filtering
35void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
36    // Loop through each channel and print the filtered values
37    for (size_t i = 0; i < n_chans; ++i) {
38        for (size_t j = 0; j < n_time_steps; ++j) {
39            printf("%f ", arr[i * n_time_steps + j]);
40        }
41        printf("\n");
42    }
43}
44
45int main() {
46    // Example dataset 1: Clean signal (increasing values for simplicity)
47    double x1[N_CHANS * N_TIME_STEPS] = {
48		1, 2, 3, 4, 5, // Channel 1 with noise
49		6, 7, 8, 9, 10 // Channel 2 with noise
50	};
51
52    // Example dataset 2: Noisy signal (with noise)
53    double x2[N_CHANS * N_TIME_STEPS] = {
54        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
55        50, 1000, -2500, 750, -1000    // Channel 2 with noise
56    };
57
58    // Apply lowpass filter and print results for the clean signal (Dataset 1)
59    ba_bci_connect_filter_lowpass(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CUTOFF_FREQ);
60    printf("Lowpass Filtered Data (Example 1 - Clean Signal):\n");
61    print_array(x1, N_CHANS, N_TIME_STEPS);  // Print the filtered data
62
63    // Apply lowpass filter and print results for the noisy signal (Dataset 2)
64    ba_bci_connect_filter_lowpass(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CUTOFF_FREQ);
65    printf("Lowpass Filtered Data (Example 2 - Noisy Signal):\n");
66    print_array(x2, N_CHANS, N_TIME_STEPS);  // Print the filtered data
67
68    return 0;  // Return 0 to indicate successful execution
69}

Signal Quality#

 1#include "processor.h"  // Include the header file for signal quality calculation
 2#include <stdio.h>      // Include standard input-output library for printf
 3#include <stdlib.h>     // Include standard library for random number generation
 4#include <time.h>       // Include time library for random seed initialization
 5
 6// ===================================================================================
 7// Experiment Description:
 8// This experiment evaluates the signal quality of time-series data from multiple channels.
 9// Signal quality assessment is crucial for EEG and biosignal analysis to ensure
10// the reliability of the collected data.
11//
12// Objective:
13// - Compute and analyze signal quality for two different datasets using
14//   `ba_bci_connect_get_signal_quality()`.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and 1000 time steps.
18// - Use a sampling frequency of 250 Hz (common in EEG signal acquisition).
19// - Apply `ba_bci_connect_get_signal_quality()` to evaluate signal quality.
20// - Print the computed quality scores.
21//
22// Expected Outcome:
23// - The function will return quality metrics for each channel, which may vary
24//   depending on the input signal characteristics.
25// - Higher quality values generally indicate more stable and noise-free signals.
26// - The noisy dataset should result in a lower quality score.
27//
28// ===================================================================================
29
30// Define constants for the number of channels, time steps, and sampling frequency
31#define N_CHANS         2      // Number of channels (e.g., EEG electrodes)
32#define N_TIME_STEPS    1000   // Number of time steps per channel (1000 samples)
33#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz (common for EEG)
34
35// Function to print the computed signal quality values for each channel
36void print_quality(const double* quality, size_t n_chans) {
37    for (size_t i = 0; i < n_chans; ++i) {
38        printf("Channel %zu: Quality = %f\n", i, quality[i]);
39    }
40}
41
42// Function to add noise to a dataset
43void add_noise(double* data, size_t n_samples, double noise_factor) {
44    for (size_t i = 0; i < n_samples; ++i) {
45        data[i] += noise_factor * (rand() % 1000 - 500) / 500.0; // Random noise
46    }
47}
48
49// Function to create datasets
50void create_datasets(double* x1, double* x2, size_t n_chans, size_t n_time_steps) {
51    for (size_t i = 0; i < n_chans * n_time_steps; ++i) {
52        x1[i] = i + 1;  // Clean signal with increasing values
53        x2[i] = i + 1;  // Start with clean signal
54    }
55    // Add noise to the second dataset
56    add_noise(x2, n_chans * n_time_steps, 100.0);
57}
58
59int main() {
60    // Initialize random seed for noise generation
61    srand(time(NULL));
62
63    // Allocate memory for datasets
64    double x1[N_CHANS * N_TIME_STEPS];
65    double x2[N_CHANS * N_TIME_STEPS];
66
67    // Create datasets
68    create_datasets(x1, x2, N_CHANS, N_TIME_STEPS);
69
70    // Array to store the computed signal quality values
71    double quality[N_CHANS];
72
73    // Compute and print signal quality for the first dataset (clean signal)
74    printf("Clean Signal (Dataset 1):\n");
75    ba_bci_connect_get_signal_quality(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, quality);
76    printf("Signal Quality (Example 1 - Clean Signal):\n");
77    print_quality(quality, N_CHANS);
78
79    // Compute and print signal quality for the second dataset (noisy signal)
80    printf("Noisy Signal (Dataset 2):\n");
81    ba_bci_connect_get_signal_quality(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, quality);
82    printf("Signal Quality (Example 2 - Noisy Signal):\n");
83    print_quality(quality, N_CHANS);
84
85    return 0;  // Return 0 to indicate successful execution
86}

Notch filter#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies a notch filter to time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal.
 9//
10// Objective:
11// - Apply a notch filter to two predefined datasets using `ba_bci_connect_filter_notch()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
14// - Compare the results of applying the notch filter on both datasets.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
20// - Use `ba_bci_connect_filter_notch()` to apply the notch filter to each dataset.
21// - Print the filtered data for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) will likely be minimally affected by the notch filter, depending on the filter parameters.
25// - The noisy signal (`x2`) may have reduced noise in the frequencies around the center frequency (50 Hz in this case).
26// ===================================================================================
27
28// Define constants for the number of channels, time steps, and filter parameters
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz
32#define CENTER_FREQ     50.0   // Center frequency for notch filter (e.g., powerline noise)
33#define WIDTH_FREQ      2.0    // Width of the notch filter (frequency range)
34
35/// Function to print the array values for each channel after filtering
36void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
37    // Loop through each channel and print the filtered values
38    for (size_t i = 0; i < n_chans; ++i) {
39        for (size_t j = 0; j < n_time_steps; ++j) {
40            printf("%f ", arr[i * n_time_steps + j]);
41        }
42        printf("\n");
43    }
44}
45
46int main() {
47    // Example dataset 1: Clean signal (increasing values for simplicity)
48    double x1[N_CHANS * N_TIME_STEPS] = {
49		1, 2, 3, 4, 5,   // Channel 1 with noise
50		6, 7, 8, 9, 10   // Channel 2 with noise
51	};
52
53    // Example dataset 2: Noisy signal (with noise)
54    double x2[N_CHANS * N_TIME_STEPS] = {
55        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
56        50, 1000, -2500, 750, -1000    // Channel 2 with noise
57    };
58
59    // Apply notch filter and print results for the clean signal (Dataset 1)
60    ba_bci_connect_filter_notch(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CENTER_FREQ, WIDTH_FREQ);
61    printf("Notch Filtered Data (Example 1 - Clean Signal):\n");
62    print_array(x1, N_CHANS, N_TIME_STEPS);  // Print the filtered data
63
64    // Apply notch filter and print results for the noisy signal (Dataset 2)
65    ba_bci_connect_filter_notch(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, CENTER_FREQ, WIDTH_FREQ);
66    printf("Notch Filtered Data (Example 2 - Noisy Signal):\n");
67    print_array(x2, N_CHANS, N_TIME_STEPS);  // Print the filtered data
68
69    return 0;  // Return 0 to indicate successful execution
70}

FFT#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies Fast Fourier Transform (FFT) to time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a sinusoidal signal and the other
 8// representing a linearly decreasing signal. The FFT is used to analyze the frequency components of both signals.
 9//
10// Objective:
11// - Apply FFT to two predefined datasets using `ba_bci_connect_fft()`.
12// - The first dataset (`x1`) represents a sinusoidal signal, and the second dataset (`x2`) represents a linearly decreasing signal.
13// - Compare the frequency domain characteristics of the two datasets based on their magnitudes and phases.
14//
15// Methodology:
16// - Define two datasets (`x1` and `x2`), each with two channels and eight time steps.
17// - Use `ba_bci_connect_fft()` to apply FFT to each dataset and extract their magnitudes and phases.
18// - Print the frequency domain information (magnitude and phase) for each dataset.
19//
20// Expected Outcome:
21// - The sinusoidal signal (`x1`) should have a prominent peak at a particular frequency corresponding to its sinusoidal nature.
22// - The linearly decreasing signal (`x2`) may have a broader frequency spectrum, with peaks spread over multiple frequencies.
23// ===================================================================================
24
25// Define constants for the number of channels, time steps, and FFT parameters
26#define N_CHANS         2      // Number of channels (e.g., EEG channels)
27#define N_TIME_STEPS    8      // Number of time steps (samples) per channel
28#define SAMPLING_FREQ   250.0  // Sampling frequency in Hz
29#define N_FREQS         ((N_TIME_STEPS / 2) + 1) // Number of frequency bins
30
31/// Function to print the FFT results (magnitudes and phases) for each channel
32void print_fft_results(const double* magnitudes, const double* phases, size_t n_chans, size_t n_freqs) {
33    // Loop through each channel and print its frequency analysis results
34    for (size_t i = 0; i < n_chans; ++i) {
35        printf("Channel %zu:\n", i);
36        // Loop through each frequency bin and print the magnitude and phase values
37        for (size_t j = 0; j < n_freqs; ++j) {
38            printf("Frequency %zu: Magnitude = %f, Phase = %f\n", j, magnitudes[i * n_freqs + j], phases[i * n_freqs + j]);
39        }
40    }
41}
42
43int main() {
44    // Example dataset 1: Sinusoidal signal with 8 time steps
45    double x1[N_CHANS * N_TIME_STEPS] = {
46        1, 2, 3, 4, 5, 6, 7, 8,  // Channel 1: Increasing values
47        8, 7, 6, 5, 4, 3, 2, 1   // Channel 2: Decreasing values
48    };
49
50    // Example dataset 2: Linearly decreasing signal with 8 time steps
51    double x2[N_CHANS * N_TIME_STEPS] = {
52        8, 7, 6, 5, 4, 3, 2, 1,   // Channel 1: Decreasing linearly
53        1, 2, 3, 4, 5, 6, 7, 8    // Channel 2: Increasing linearly
54    };
55
56    // Arrays to store magnitudes and phases of the FFT results for each channel and frequency bin
57    double magnitudes[N_CHANS * N_FREQS];
58    double phases[N_CHANS * N_FREQS];
59
60    // Apply FFT to the first dataset (sinusoidal signal)
61    ba_bci_connect_fft(x1, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, magnitudes, phases);
62    printf("FFT Results (Example 1 - Sinusoidal Signal):\n");
63    print_fft_results(magnitudes, phases, N_CHANS, N_FREQS);  // Print the frequency domain results
64
65    // Apply FFT to the second dataset (linearly decreasing signal)
66    ba_bci_connect_fft(x2, N_CHANS, N_TIME_STEPS, SAMPLING_FREQ, magnitudes, phases);
67    printf("FFT Results (Example 2 - Linearly Decreasing Signal):\n");
68    print_fft_results(magnitudes, phases, N_CHANS, N_FREQS);  // Print the frequency domain results
69
70    return 0;  // Return 0 to indicate successful execution
71}

Standardize#

 1#include "processor.h"  // Include the header file for ba_bci_connect_standardize function
 2#include <stdio.h>      // Include standard input-output library for printf
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment standardizes time-series data across multiple channels.
 7// Standardization transforms the data to have zero mean and unit variance,
 8// which is useful for statistical analysis and machine learning applications.
 9//
10// Objective:
11// - Standardize two different datasets using `ba_bci_connect_standardize()`.
12//
13// Methodology:
14// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
15// - Apply `ba_bci_connect_standardize()` to transform the data.
16// - Print the standardized data for analysis.
17//
18// Expected Outcome:
19// - Standardized data should have a mean of 0 and standard deviation of 1.
20// - Different input distributions will yield different transformed values.
21//
22// ===================================================================================
23
24// Define constants for the number of channels and time steps
25#define N_CHANS      2  // Number of channels (e.g., EEG channels)
26#define N_TIME_STEPS 5  // Number of time steps per channel
27
28// Function to print a 2D array stored in a 1D format
29void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
30	for (size_t i = 0; i < n_chans; ++i) {  // Loop through each channel
31		for (size_t j = 0; j < n_time_steps; ++j) {  // Loop through time steps
32			printf("%f ", arr[i * n_time_steps + j]);  // Print value
33		}
34		printf("\n");  // New line for each channel
35	}
36}
37
38int main() {
39	// Example dataset 1: Increasing values
40	double x1[N_CHANS * N_TIME_STEPS] = {
41		1, 2, 3, 4, 5, // Channel 1 with noise
42		6, 7, 8, 9, 10 // Channel 2 with noise
43	};
44	// Modified dataset 2: A more varied pattern with different scaling
45	double x2[N_CHANS * N_TIME_STEPS] = {
46		5, 10, 15, 20, 25, // Channel 1 with noise
47		30, 25, 20, 15, 10 // Channel 2 with noise
48	};
49
50	// Array to store the standardized values
51	double x_standard[N_CHANS * N_TIME_STEPS];
52
53	// Standardize and print results for the first dataset
54	ba_bci_connect_standartize(x1, N_CHANS, N_TIME_STEPS, x_standard);
55	printf("Standardized Data (Example 1):\n");
56	print_array(x_standard, N_CHANS, N_TIME_STEPS);
57
58	// Standardize and print results for the second dataset
59	ba_bci_connect_standartize(x2, N_CHANS, N_TIME_STEPS, x_standard);
60	printf("Standardized Data (Example 2):\n");
61	print_array(x_standard, N_CHANS, N_TIME_STEPS);
62
63	return 0;  // Return 0 to indicate successful execution
64}

Mad#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment calculates the Median Absolute Deviation (MAD) for time-series data
 7// from multiple channels. The experiment uses two predefined datasets: one representing
 8// a clean signal and the other representing a noisy signal.
 9//
10// Objective:
11// - Compute and analyze the MAD values of two predefined datasets using `ba_bci_connect_mad()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
14// - Compare the MAD values of both the clean and noisy signals.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
20// - Use `ba_bci_connect_mad()` to evaluate the MAD values for each channel of the datasets.
21// - Print the computed MAD values for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) should have a stable and lower MAD value for each channel.
25// - The noisy signal (`x2`) will likely have a higher MAD value due to the noise and fluctuations.
26// ===================================================================================
27
28// Define constants for the number of channels and time steps
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31
32// Function to print the MAD values for each channel
33void print_mad(const double* mad, size_t n_chans) {
34    // Loop through each channel and print its MAD value
35    for (size_t i = 0; i < n_chans; ++i) {
36        printf("Channel %zu: MAD = %f\n", i, mad[i]);
37    }
38}
39
40int main() {
41    // Example dataset 1: Clean signal (increasing values for simplicity)
42    double x1[N_CHANS * N_TIME_STEPS] = {
43		1, 2, 3, 4, 5,  // Channel 1 with noise
44		6, 7, 8, 9, 10 // Channel 2 with noise
45	};
46
47    // Example dataset 2: Noisy signal (predefined with noise)
48    double x2[N_CHANS * N_TIME_STEPS] = {
49        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
50        50, 1000, -2500, 750, -1000    // Channel 2 with noise
51    };
52
53    // Array to store the MAD values for each channel
54    double mad[N_CHANS];
55
56    // Compute and print the MAD values for the clean signal (Dataset 1)
57    ba_bci_connect_mad(x1, N_CHANS, N_TIME_STEPS, mad);  // Calculate MAD values for each channel
58    printf("Median Absolute Deviation (Example 1 - Clean Signal):\n");
59    print_mad(mad, N_CHANS);  // Print the calculated MAD values
60
61    // Compute and print the MAD values for the noisy signal (Dataset 2)
62    ba_bci_connect_mad(x2, N_CHANS, N_TIME_STEPS, mad);  // Calculate MAD values for each channel
63    printf("Median Absolute Deviation (Example 2 - Noisy Signal):\n");
64    print_mad(mad, N_CHANS);  // Print the calculated MAD values
65
66    return 0;  // Return 0 to indicate successful execution
67}

Exponential weighted moving average (EWMA)#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment demonstrates the use of Exponentially Weighted Moving Average (EWMA)
 7// to calculate a smoothed version of time-series data from multiple channels.
 8// The experiment applies EWMA to two predefined datasets with different trends.
 9//
10// Objective:
11// - Apply the EWMA method to two datasets using `ba_bci_connect_ewma()`.
12// - The first dataset (`x1`) has increasing values, while the second dataset (`x2`) has decreasing values.
13// - Compare the EWMA values for both datasets and analyze the smoothing effect.
14//
15// Methodology:
16// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
17// - Use `ba_bci_connect_ewma()` to apply EWMA to both datasets.
18// - Print the EWMA values for both datasets.
19//
20// Expected Outcome:
21// - The EWMA values should smooth out the trends in the datasets, with the first dataset showing increasing
22//   values and the second dataset showing decreasing values, but with less variation due to the smoothing effect.
23// ===================================================================================
24
25// Define constants for the number of channels, time steps, and EWMA parameters
26#define N_CHANS         2      // Number of channels (e.g., EEG channels)
27#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
28#define ALPHA           0.1    // Smoothing factor for EWMA
29
30/// Function to print the EWMA values for each channel
31void print_ewma(const double* ewma, size_t n_chans) {
32    for (size_t i = 0; i < n_chans; ++i) {
33        printf("Channel %zu: EWMA = %f\n", i, ewma[i]);
34    }
35}
36
37int main() {
38    // Example dataset 1: Increasing signal
39    double x1[N_CHANS * N_TIME_STEPS] ={
40		1, 2, 3, 4, 5,  // Channel 1: Increasing values
41		6, 7, 8, 9, 10  // Channel 2: Increasing values
42	};
43
44    // Example dataset 2: Decreasing signal
45    double x2[N_CHANS * N_TIME_STEPS] = {10, 9, 8, 7, 6,  // Channel 1: Decreasing values
46                                         5, 4, 3, 2, 1};  // Channel 2: Decreasing values
47
48    // Array to store the EWMA values for each channel
49    double ewma[N_CHANS];
50
51    // Apply EWMA to the first dataset (increasing signal)
52    ba_bci_connect_ewma(x1, N_CHANS, N_TIME_STEPS, ALPHA, ewma);
53    printf("EWMA Values (Example 1 - Increasing Signal):\n");
54    print_ewma(ewma, N_CHANS);  // Print the EWMA values
55
56    // Apply EWMA to the second dataset (decreasing signal)
57    ba_bci_connect_ewma(x2, N_CHANS, N_TIME_STEPS, ALPHA, ewma);
58    printf("EWMA Values (Example 2 - Decreasing Signal):\n");
59    print_ewma(ewma, N_CHANS);  // Print the EWMA values
60
61    return 0;  // Return 0 to indicate successful execution
62}

Median#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment calculates the median values of time-series data from multiple channels.
 7// The experiment uses two predefined datasets: one representing a clean signal and the other
 8// representing a noisy signal.
 9//
10// Objective:
11// - Compute and analyze the median values of two predefined datasets using `ba_bci_connect_median()`.
12// - The first dataset (`x1`) contains a clean, predictable signal.
13// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
14// - Compare the median values of both the clean and noisy signals.
15//
16// Methodology:
17// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
18// - The first dataset (`x1`) contains a clean, predictable signal.
19// - The second dataset (`x2`) contains a noisy signal with large fluctuations.
20// - Use `ba_bci_connect_median()` to evaluate the median values for each channel of the datasets.
21// - Print the computed median values for each channel.
22//
23// Expected Outcome:
24// - The clean signal (`x1`) should have a stable median value for each channel.
25// - The noisy signal (`x2`) should have a median value that reflects the large fluctuations and outliers.
26// ===================================================================================
27
28// Define constants for the number of channels and time steps
29#define N_CHANS         2      // Number of channels (e.g., EEG channels)
30#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
31
32// Function to print the median values for each channel
33void print_median(const double* median, size_t n_chans) {
34    // Loop through each channel and print its median value
35    for (size_t i = 0; i < n_chans; ++i) {
36        printf("Channel %zu: Median = %f\n", i, median[i]);
37    }
38}
39
40int main() {
41    // Example dataset 1: Clean signal (increasing values for simplicity)
42    double x1[N_CHANS * N_TIME_STEPS] = {
43		1, 2, 3, 4, 5, // Channel 1 with noise
44		6, 7, 8, 9, 10 // Channel 2 with noise
45	};
46
47    // Example dataset 2: Noisy signal (with noise)
48    double x2[N_CHANS * N_TIME_STEPS] = {
49        100, -500, 2000, -3000, 1500,   // Channel 1 with noise
50        50, 1000, -2500, 750, -1000    // Channel 2 with noise
51    };
52
53    // Array to store the median values for each channel
54    double median[N_CHANS];
55
56    // Compute and print the median values for the clean signal (Dataset 1)
57    ba_bci_connect_median(x1, N_CHANS, N_TIME_STEPS, median);  // Calculate median values for each channel
58    printf("Median Values (Example 1 - Clean Signal):\n");
59    print_median(median, N_CHANS);  // Print the calculated median values
60
61    // Compute and print the median values for the noisy signal (Dataset 2)
62    ba_bci_connect_median(x2, N_CHANS, N_TIME_STEPS, median);  // Calculate median values for each channel
63    printf("Median Values (Example 2 - Noisy Signal):\n");
64    print_median(median, N_CHANS);  // Print the calculated median values
65
66    return 0;  // Return 0 to indicate successful execution
67}

Demean#

 1#include "processor.h"
 2#include <stdio.h>
 3
 4// ===================================================================================
 5// Experiment Description:
 6// This experiment applies demeaning to EEG data from multiple channels. Demeaning removes
 7// the mean (average) value from each dataset, centering the data around zero, which is
 8// helpful for removing baseline shifts in EEG signals.
 9//
10// Objective:
11// - Apply demeaning to two predefined datasets using `ba_bci_connect_demean()`.
12// - The first dataset (`x1`) represents a linearly increasing signal, and the second dataset (`x2`) represents a linearly decreasing signal.
13// - Compare the demeaned data from both datasets to assess how demeaning removes the mean value from each dataset.
14//
15// Methodology:
16// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
17// - Use `ba_bci_connect_demean()` to apply demeaning to each dataset.
18// - Print the demeaned data for each dataset to analyze the results.
19//
20// Expected Outcome:
21// - The mean value of each dataset should be subtracted, resulting in demeaned data where the mean is centered around zero.
22// ===================================================================================
23
24// Define constants for the number of channels, time steps
25#define N_CHANS         2      // Number of channels (e.g., EEG channels)
26#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
27
28/// Function to print a 2D array (data from multiple channels)
29void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
30    for (size_t i = 0; i < n_chans; ++i) {
31        for (size_t j = 0; j < n_time_steps; ++j) {
32            printf("%f ", arr[i * n_time_steps + j]);
33        }
34        printf("\n");
35    }
36}
37
38int main() {
39    // Example dataset 1: Linearly increasing signal with 5 time steps
40    double x1[N_CHANS * N_TIME_STEPS] = {
41        1, 2, 3, 4, 5,  // Channel 1: Increasing linearly
42        6, 7, 8, 9, 10  // Channel 2: Increasing linearly
43    };
44
45    // Example dataset 2: Linearly decreasing signal with 5 time steps
46    double x2[N_CHANS * N_TIME_STEPS] = {
47        10, 9, 8, 7, 6,  // Channel 1: Decreasing linearly
48        1, 2, 3, 4, 5    // Channel 2: Increasing linearly
49    };
50
51    // Array to store the demeaned data
52    double x_demean[N_CHANS * N_TIME_STEPS];
53
54    // Apply demeaning to the first dataset (increasing signal)
55    ba_bci_connect_demean(x1, N_CHANS, N_TIME_STEPS, x_demean);
56    printf("Demeaned Data (Example 1 - Increasing Signal):\n");
57    print_array(x_demean, N_CHANS, N_TIME_STEPS);  // Print the demeaned data
58
59    // Apply demeaning to the second dataset (decreasing signal)
60    ba_bci_connect_demean(x2, N_CHANS, N_TIME_STEPS, x_demean);
61    printf("Demeaned Data (Example 2 - Decreasing Signal):\n");
62    print_array(x_demean, N_CHANS, N_TIME_STEPS);  // Print the demeaned data
63
64    return 0;  // Return 0 to indicate successful execution
65}

Detrend#

 1#include "processor.h"
 2#include <stdio.h>
 3#include <assert.h>
 4
 5// ===================================================================================
 6// Experiment Description:
 7// This experiment applies detrending to EEG data from multiple channels. The detrending process
 8// removes any linear trend or drift in the data, making the signal more stable for further analysis.
 9//
10// Objective:
11// - Apply detrending to two predefined datasets using `ba_bci_connect_detrend()`.
12// - The first dataset (`x1`) represents a linearly increasing signal, and the second dataset (`x2`) represents a linearly decreasing signal.
13// - Compare the detrended data from both datasets to assess how detrending removes the linear trends.
14//
15// Methodology:
16// - Define two datasets (`x1` and `x2`), each with two channels and five time steps.
17// - Use `ba_bci_connect_detrend()` to apply detrending to each dataset.
18// - Print the detrended data for each dataset to analyze the results.
19//
20// Expected Outcome:
21// - The linear trend in both datasets should be removed, resulting in detrended data where the trend is eliminated.
22// ===================================================================================
23
24// Define constants for the number of channels, time steps
25#define N_CHANS         2      // Number of channels (e.g., EEG channels)
26#define N_TIME_STEPS    5      // Number of time steps (samples) per channel
27
28/// Function to print a 2D array (data from multiple channels)
29void print_array(const double* arr, size_t n_chans, size_t n_time_steps) {
30    for (size_t i = 0; i < n_chans; ++i) {
31        for (size_t j = 0; j < n_time_steps; ++j) {
32            printf("%f ", arr[i * n_time_steps + j]);
33        }
34        printf("\n");
35    }
36}
37
38int main() {
39    // Example dataset 1: Linearly increasing signal with 5 time steps
40    double x1[N_CHANS * N_TIME_STEPS] = {
41        1, 3, 5, 7, 9,  // Channel 1: Increasing linearly with a larger step
42        2, 4, 6, 8, 10  // Channel 2: Increasing linearly with a larger step
43    };
44
45    // Example dataset 2: Linearly decreasing signal with 5 time steps
46    double x2[N_CHANS * N_TIME_STEPS] = {
47        10, 8, 6, 4, 2,  // Channel 1: Decreasing linearly with a larger step
48        9, 7, 5, 3, 1    // Channel 2: Decreasing linearly with a larger step
49    };
50
51    // Array to store the detrended data
52    double x_detrend[N_CHANS * N_TIME_STEPS];
53
54    // Apply detrending to the first dataset (increasing signal)
55    ba_bci_connect_detrend(x1, N_CHANS, N_TIME_STEPS, x_detrend);
56    printf("Detrended Data (Example 1 - Increasing Signal):\n");
57    print_array(x_detrend, N_CHANS, N_TIME_STEPS);  // Print the detrended data
58
59    // Apply detrending to the second dataset (decreasing signal)
60    ba_bci_connect_detrend(x2, N_CHANS, N_TIME_STEPS, x_detrend);
61    printf("Detrended Data (Example 2 - Decreasing Signal):\n");
62    print_array(x_detrend, N_CHANS, N_TIME_STEPS);  // Print the detrended data
63
64    return 0;  // Return 0 to indicate successful execution
65}