Description
Depression Detection Using Advanced Graphical Deep Learning-Part1 (Signal Processing)
Introduction
Major depressive disorder (MDD), a common psychiatric illness, frequently presents with symptoms like anxiety, irritability, and insomnia. Self-harm behaviors, including suicide, have been linked to moderate to severe depression. Presently, the clinical diagnosis of depression mostly depends on specialist physician interviews and several psychiatric rating measures such as the Patient Health Questionnaire-9 items (PHQ-9), Beck Depression Inventory (BDI), and Hamilton Depression Scale (HAMD).
Electroencephalography (EEG) is widely utilized in clinical settings for disease diagnosis because of its high temporal resolution, non-invasiveness, and inexpensive data-gathering costs. Research in psychological and cognitive sciences has demonstrated that EEG signals can provide insights into a wide range of psychological and cognitive functions. Prior research has utilized approaches such as dimensionality reduction or extraction of frequency band signals as features followed by the application of machine learning algorithms as classifiers to carry out certain tasks. However, the efficacy of these methods is highly dependent on the precision of the chosen features, and there is no connection between the classifier and the pre-existing features.
EEG signals, which exhibit significant levels of unpredictability and nonlinearity, provide challenges for conventional approaches in efficiently extracting information. Currently, deep learning technology has demonstrated exceptional performance in image recognition, natural language processing, and other domains by utilizing its strong ability to fit nonlinear data and its advantages in end-to-end learning. Previous works tend to apply deep learning techniques on EEG information for several applications such as emotional recognition, movement imagery, and disease identification. Many research studies have attempted to obtain prominent biomarkers by analyzing signals obtained from EEG for the intent of diagnosing depression.
The utilized deep learning techniques can be roughly classified into two categories: CNN-based (Convolutional Neural Network) and GNN-based (Graph Neural Network). CNN-based algorithms treat EEG signals as images and use different kinds of filters known as convolutional kernels to learn about them. However, these algorithms do not allow enough consideration for the dependency between the channels. On the other hand, methods based on GNN transform the EEG signals into data graphs. They use pre-calculated adjacency matrices to display the relations between sundry channels. These approaches treat multiple channels’ relationships with a spatial structure at a given time to facilitate features extraction linked in the different channels. However, pre-calculated techniques work only for fixed adjacency matrices, and they cannot reflect the changes in the specific brain networks and dynamic changes in the connections. People become sad and small-world networks get changed during the rapid eye movement sleep.
Challenges
The current GNN-based algorithms continue to encounter the following obstacles:
- Differences in the brain networks among individuals and the neural systems of the human brain are quite intricate. Existing techniques are inadequate in precisely constructing detailed brain network topological structures, especially when it comes to mimicking the dynamic changes of the brain network.
- The current research has not incorporated the temporal dependency information of brain networks.
Data Description
The resting-state depression EEG dataset was obtained from the University of New Mexico. The subjects sampled were from a class contending with the Beck Depression Inventory (BDI) administered to an introductory psychology class at Arizona State University. All subjects volunteered their informed consent after getting the Institutional Review Board approval from Arizona State University. It included 122 participants, of which 46 can be classified as depressed according to the BDI or have signs of depression. The subjects’ BDI ratings were also unchanged in the testing and experimental evaluation phase. The information collected during the experiment included the participant’s age, sex, the Beck Depression Inventory Score, Spielberger Trait Anxiety Inventory Score, and the scores of both the cognitive and affective subscales. The EEG data was obtained using 66 Ag/AgCl electrodes. The bandpass filtering was configured to range from 0.5Hz to 100Hz and the sampling rate was set at 500Hz. The impedance was maintained below 10kΩ. We chose 63 participants for our trial consisting of 33 individuals diagnosed with depression and 30 individuals who are in good condition. The dataset can be found at OpenNeuro.
Data Pre-processing
Importing Libraries
sys: For system-specific arguments and functions, simplifying the issue of file paths.numpy: For arithmetic operations and array operations.pandas: For working with participants’ data and electrode locations in tabular format.mne: For analysis of EEG data among other functionalities as it supports raw data reading and adjustments.os: For directory and file operations, potentially used in iteration of data files.scipy.ioandscipy.signal: Required for loading and processing signals.functools.partial: Reduces the verbosity of repetitious function parameters by enabling partial construction of the function.matplotlib: For plotting, including creating heat maps and signal plots.h5py: For processing and storing array data in the HDF5 format.pickle: For serializing and deserializing Python objects, useful for storing and loading previously pre-processed data structures.
These libraries address the preprocessing of EEG data starting from signal extraction, filtering, augmentation of the data, and data storing.
Figure 1: Importing Libraries
Signal Extraction
The SignalExtraction class contains methods for pre-processing EEG data along with other data included with the signal. CDSs fulfill several significant functions associated with the processing of several kinds of important data. The fn_signal_extraction_openneuro and fn_signal_extraction_predict_d006 functions convert the EEG data from the MATLAB (*.mat) files into NumPy variables concerning the signal tolerance with respect to the file arrangement as well as selected channels. Ultimately, in the fn_label_extraction_openneuro function, there is a special DataFrame which parses the BDI scores and labels with the help of the number of the participant. A read_mat_iterator and a read_mne_iterator methods construct the common recorders for MATLAB and MNE files by folders. They use scipy.io.loadmat, mne.Signals. The loaded raw EEG signals are processed using load() while the signals’ metadata and BDI labels of the subjects are obtained through the read.csv() function from the pd package. Regarding the second part of input data, the following methods are used to extract the participant information and the electrode coordinates from the metadata files, namely participants.tsv and electrodes.tsv. In the process of data acquisition and analysis in psychiatry and EEG, fault handling during the processing is based on the try-except blocks, resulting in rich experience gained in the usage of the described system.
Figure 2: Pre-Processing for Signal Extraction
Signal Processing
The SignalProcessing class is responsible for the raw EEG data and metadata processing. To remove the undesired frequency components from the stream, it provides bandpass and notch filtration techniques. Thus, the method called resample reduces the computing effort as the signal is brought down to a lower frequency, and therefore, a considerable amount of information is not lost. Data augmentation transforms signal data into higher-order tensors for analysis. The tensor_generator method segments signals into time slices then arranges the data into tensors for further analysis. Given that we want to achieve uniform analysis, distance matrices are computed from the electrode coordinate data by the AdjMatrix method and then normalized. The to_bdi_label technique converts the obtained BDI scores into categorical labels, which are useful for categorization. Last but not least, the to_h5 method effectively stores and re-imports pre-processed data I/O: subject ID, signal arrays, labels, and frequencies with HDF5 format. The former methods help in the preparation of the EEG data for either machine learning modeling or for statistical analysis of mental health facets.
Figure 3: Pre-Processing for Signal
Data Preparation for Model Training
The TrainingData class is responsible for making training data ready for the training of machine learning models; it transforms pre-processed EEG signals into training data tuples. The signal_to_trainingData method unpacks each signal tuple; this tuple contains the subject ID, processed signal slices, emitted adjacency distance matrix, BDI score, and BDI label. It walks through each slice of the signal, pairing it with the adjacency matrix and the BDI label, and making a tuple of it. This makes certain that each signal slice corresponds with its right metadata to make it easier to use methods of supervised learning. signal_to_trainingData is utilized for traversing the signal tuples by trainingData_iterator in a list. Altogether these methods help prepare EEG data to enhance the training process.
Figure 4: Pre-Processing Data for Model Training
Data Visualizations
BDI Plot
It takes a dataset X, gets BDI labels along with adjacency matrices and signal slices of the data, and only after that explores and describes the distribution of the BDI labels. The respective elements of the tuples in X, notably the BDI labels, are the parameters considered in creating the distribution plot.
Figure 5: Plot for Distribution of BDI Labels
Bandpass Filtering
The plots show the impact of bandpass filtering to a synthetic signal. The original signal refers to the raw data obtained from the instrument under test, while the filtered signal refers to the desired band signal of 1 Hz to 50 Hz, leaving out all the high-frequency noise and other unwanted high-frequency signals which are not relevant to the analysis.
Figure 6: Bandpass Filtering for Original and Filtered Signal
Notch Filter
The time domain graph shows the timeline of the original signal waveform and the notched signal waveform. Applying the notch filter for the 50 Hz removes the peak of the signal almost completely, thus cleaning the signal from the 50 Hz interference. The other Notch filter frequency response graph depicts the magnitude response of the notch filter. It learns how the filter works by reducing the specified frequencies. As for 50 Hz, one can see on the plot that this filter effectively reduces this specific frequency as other frequencies seem nearly unchanged.
Figure 7: Notch Filter with respect to amplitude and Frequency
Signal Plot
These plots demonstrate the method of downsampling a signal that has a higher sampling frequency (500 Hz) to that of a lower sampling frequency (100 Hz). The signal depicted in the top subplot represents the actual high resolution, while that in the bottom subplot represents low resolution with fewer data points. It is useful to grasp how the signal will appear subsequently and how the important characteristics will continue to be present even though the number of samples is less after resampling. These are handy in signal processing when one has to keep or transmit data and at the same time not have to worry about seriously distorting the signal.
Figure 8: Signal Plot for Original and Resampled Signal
Figure 9: Detailed Signal Plot
Adjacency Matrix (Heatmap)
The adjacency distance matrices are presented in the form of heat maps, which are quite helpful in visualizing the spatial relations and distances in the graph constituted by the nodes. These heatmaps incorporate the distances to scale where darker shades of the color represent smaller distances or perhaps strong associations, while the lighter shades represent larger distances or weak associations.
Figure 10: Adjacency Matrix
References
[1] Luo, G., An, P., Li, Y., Hong, R., Chen, S., Rao, H., & Chen, W. (2023). Exploring adaptive graph topologies and temporal graph networks for eeg-based depression detection. IEEE Transactions on Neural Systems and Rehabilitation Engineering. [2] Hernández-Del-Toro, T., Reyes-García, C. A., & Villasenor-Pineda, L. (2021). Toward asynchronous EEG-based BCI: Detecting imagined words segments in continuous EEG signals. Biomedical Signal Processing and Control, 65, 102351. [3] Khadidos, A. O., Alyoubi, K. H., Mahato, S., Khadidos, A. O., & Mohanty, S. N. (2023). Computer aided detection of major depressive disorder (mdd) using electroencephalogram signals. IEEE Access. [4] Khadidos, A. O., Alyoubi, K. H., Mahato, S., Khadidos, A. O., & Mohanty, S. N. (2023). Machine Learning and Electroencephalogram Signal based Diagnosis of Dipression. Neuroscience Letters, 809, 137313. [5] Sharma, G., Parashar, A., & Joshi, A. M. (2021). DepHNN: a novel hybrid neural network for electroencephalogram (EEG)-based screening of depression. Biomedical signal processing and control, 66, 102393.
Other Related Product Links
[Python Code for Depression Detection Using Advanced Graphical Deep Learning – Part 2 (Adjacency Matrix Generation)] (https://scholarscolab.com/product/eeg-sensors-relational-analysis-and-adjacency-matrix-generation/)
{Python Code for Depression Detection Using Advanced Graphical Deep Learning – Part 4 (Graph Topology)} (https://scholarscolab.com/product/graph-topology%e2%80%90based-depression-detection/)
abhishek gupta
ScholarsColab.com is an innovative and first of its kind platform created by Vidhilekha Soft Solutions Pvt Ltd, a Startup recognized by the Department For Promotion Of Industry And Internal Trade, Ministry of Commerce and Industry, Government of India recognised innovative research startup.





ryan.viracka-0243 (verified owner) –
eficiente
ryan.viracka-0243 (verified owner) –
eficiente
alex.chacon (verified owner) –
excelent
alex.chacon (verified owner) –
excelent
alex.chacon (verified owner) –
excelent
alex.chacon (verified owner) –
excelent
alex.chacon (verified owner) –
excelent
alex.chacon (verified owner) –
excelent
durga sai sriram.suggu (verified owner) –
good one
abdul.fofanah (verified owner) –
This is good start to development of research