Skip to content

GaijinOtohp/bsp-using-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License

Biological Signal Processing using AI

This is a friendly desktop application project in C# for signal processing, and customized for Electrocardiogram (ECG) signal features extraction and classification.

Content

Features of the application

. Signals comparator (cross-correlation, minimum distance, dynamic time wrapping).
. Filtering tools (Butterworth, Chebychev I, Chebychev II, DC removal, Normalization, Discrete Wavelet Transform, etc.).
. Signal spectrum analyzer.
. Signal peaks analyzer (up peaks, down peaks, stable state, tangent deviation states).
. Customized Machine learning algorithms (Deep Neural Networks, Naive Bayes, K-nearest neighbor) for ECG waves detection.
. A customized tool for data generation (features selection).
. Data analysis (raw visualization, Principal Component Analysis).

Prerequisites

For implementing the Tensorflow.NET framework, this application is dependent on .NET 6.0 SDK and Visdual Studio 2022 17.0 or later.

Application Overview

BSP using AI - main form

Main form

The main form gives access to navigate to "Signal comparator", "Signals collector", "AI tools", and "Signal details/modify" forms. The "Choose File" button opens a file dialog for choosing the signal. The application allows for plotting multiple signals on the same window. Two types of signal files are accepted (".mat", and ".txt") as given in bsp-using-ai/Sample signals/. A window will pop up after selecting the signal for inserting the corresponding sampling rate and quantization step to the chosen signal.

BSP using AI - choose signal

Details/Modify Form

It contains multiple filtering tools and shows its effect on the signal in addition to the spectrum analysis that corresponds to the signal. The section below the horizontal line belongs to our customized data generation for the ECG signals classification (click the blue button named "Set features labels" to start generating data, and after finishing click "Save" in the main form). All the created machine-learning models will be listed in the combo box next to the "Predict" button. Select the desired model and click "Predict" for annotating the signal automatically using the selected model (any changes should be discarded by clicking the red button named "Discard" before starting the prediction).

BSP using AI - signal details form

The figure below shows an example of applying a band pass filter using two separate filters (a high pass and a low pass).

BSP using AI - signal details form - concatenate filters

The order of the filters matters as illustrated in the two figures below:

BSP using AI - signal details form - filters order matters 1

BSP using AI - signal details form - filters order matters 2

Left-clicking on the filter pops up a menu for deleting the selected filter:

BSP using AI - signal details form - delete filter

Signal fusion Form

Signal fusion divides the signal into periods of frequency with the highest magnitude and provides multiple operations to perform across the separated periods. The period range is adjustable manually if any auto miss-calculation occurs. The periods can be centralized and stretched concerning the R peak, or even translated with an offset.

BSP using AI - signal fusion form - choose period

The operations apply across all periods. The addition operation takes the samples of all the periods and divides them by the number of periods. It's like creating the mean of the periods.

BSP using AI - signal fusion form - addition operation

The multiplication operation is the same as the addition operation but instead of adding the samples, it multiplies the samples.

BSP using AI - signal fusion form - multiplication operation

The cross-correlation operation applies the cross-correlation across all the periods.

BSP using AI - signal fusion form - cross-correlation operation

The orthogonalization operation applies the Gram–Schmidt orthogonalization between the periods and outputs the result of orthogonal periods named "Psi".

BSP using AI - signal fusion form - orthogonalization operation

The fuse button next to orthogonalization takes the Psies and performs an addition operation across them.

BSP using AI - signal fusion form - fused orthogonalization operation

Signal comparator Form

It accepts two signals for comparison. Ticking the checkboxes named "Select first signal" and "Select second signal" allows for the reception of the signals for comparison. Almost every plot in the application has the option of sending its signal for comparison. Clicking on the plot the first left click pops up the default menu of "ScottPlot", then left-clicking on the plot for the second time popsup the menu for sending the signal for comparison as shown in the figure below:

BSP using AI - signals comparator form - receive signal

Three options for comparison are available. The first one is cross-correlation:

BSP using AI - signals comparator form - cross-correlation

The second option is named "Minimum distance". It translates the second signal with the offset of the highest coefficient in cross-correlation, and takes the absolute subtraction of the two signals as "Minimum distance":

BSP using AI - signals comparator form - minimum distance

The third option of comparison is Dynamic Time Wrapping:

BSP using AI - signals comparator form - dynamic time wrapping

Signal collector Form

It is an option for gathering different signals close together for better manual visual analysis.

BSP using AI - signals collector form

AI tools Form

This part is customized only for ECG signals features classification (peaks annotation) using three types of machine learning models (Neural Networks, K-Nearest Neighbors, and Naive Bayes). It also contains data analysis tools (raw data visualization, and Principal Component Analysis) that can be used for other purposes. For creating a new model, the user will have to choose the model type and the problem to solve from the two combo boxes in the top-left corner, then click "Create new model". The button "Dataset explorer" opens the form for listing the previously generated saved data. The button "Fit" opens the form for choosing the training data for the model.

BSP using AI - ai tools form

Model details Form

It displays the training data and validation information of the model. It also allows for changing the decision thresholds of the classification models. Any changes applied to the decision thresholds can be saved by clicking the "Save changes" button. Clicking on any of the seven sub-models opens the form of data analysis of the selected sub-model.

BSP using AI - model details form

Data analysis Form

The raw data visualization differs from coloring the data points in the scatter-plot linearly for models solving regression problems to associating each class with a unique color for models solving classification problems as shown in the two figures below respectively.

BSP using AI - data visualization form - raw data analysis for regression problem

BSP using AI - data visualization form - raw data analysis for classification problem

The Principal Component Analysis tab displays the Eigenvalues of the training dataset in a histogram. Clicking on any bar in the histogram displays the coefficients of the corresponding Eigenvector.

BSP using AI - data visualization form - pca eigenvector

License

MIT

About

Desktop application in C# for signal processing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages