This repository contains a specialized Deep Learning pipeline designed to predict Alcohol Use Disorder (AUD) from resting-state EEG recordings. Specifically, this project empirically tests the robustness of neurophysiological differences between individuals with AUD and healthy controls within the alpha-gamma frequency domains. This serves as a computational validation of the neurophysiological biomarkers detailed in the file "predicting AUD from comodulograms".
By restricting a custom multi-modal Convolutional Neural Network (Micro-CNN) to evaluate exclusively the alpha-gamma regions of resting-state phase-amplitude comodulograms, this project isolates generalizable biological signals and evaluates their predictive validity for clinical classification.
- Dataset: Sourced from the Collaborative Study on the Genetics of Alcoholism (COGA) project.
- Electrode Target: Analysis explicitly isolated the frontal midline electrode (Fz) to target the medial prefrontal cortex (mPFC), a region associated with cognitive control and executive function.
- Artifact Mitigation: To prevent electrooculography (EOG) artifacts (e.g., eye blinks) from contaminating the low-frequency delta and theta bands, Independent Component Analysis (ICA) combined with the
ICLabelpackage was applied to the raw continuous EEG recordings. - Epoch Segmentation: Cleaned resting-state sessions were segmented into continuous 30-second epochs. This resulted in a comprehensive dataset containing over 5,309 unique subjects, representing approximately 12,865 distinct clinical visits and over 96,330 distinct 30-second EEG epochs.
- Comodulogram Generation: Cross-frequency Phase-Amplitude Coupling (PAC) was computed for each 30-second epoch and exported as 8-bit grayscale 2D comodulograms.
- Biological Cropping: To test the hypothesis that elevated PAC in alpha-gamma domains serves as a primary biomarker for AUD, images were dynamically cropped to extract specifically the Alpha phase (8–12 Hz) and Gamma amplitude (30–50 Hz) interactions. This reduced the input to a highly dense 66x91 biological matrix, preventing the network from learning background static.
- Data Streaming: All processed matrices and associated tabular metadata (e.g., Subject ID, Age, Sex, AUD diagnosis) were stored within a custom HDF5 database to enable efficient, lazy-loaded multiprocessing in PyTorch.
Standard cross-validation methodologies were insufficient due to extreme demographic imbalances and the presence of shared genetics. A novel Composite Stratified Group 5-Fold strategy was engineered:
- Pre-Onset Identification: 501 highly valuable subjects who genuinely transitioned from a non-AUD state to an active AUD state were flagged (
is_pre_onset_subject). - Composite Stratification: To ensure these subjects were perfectly distributed, the pre-onset flag was combined with AUD status, Sex, and Age Bins to create a single composite label.
- Genetic Isolation (Group): The dataset was strictly grouped by
Family_IDto guarantee that biological family members were never split between training and validation sets. This prevents the network from artificially inflating accuracy by memorizing shared familial genetic brain signatures.
Standard architectures like ResNet-18 severely downsample inputs and caused underfitting on the tightly cropped 66x91 matrices. Therefore, a bespoke multi-modal Micro-Convolutional Neural Network (Micro-CNN) was designed:
- Visual Feature Extraction: The input tensor (1 channel, 66W x 91H) passes through three distinct convolutional blocks (16, 32, and 64 channels). Gentle MaxPool layers systematically reduced the spatial dimensions by a factor of 8 to extract edges, textures, and PAC patterns, preserving the geometric shape of the coupling down to a final 8x11 matrix.
- Flattening and Multi-Modal Fusion: The final matrix was unrolled into a flat 1D array of 5,632 visual features. The subject's specific age was dynamically Z-score normalized (using only the training data statistics for that specific fold to prevent leakage) and concatenated with sex to create a combined feature array of 5,634 features.
- Classification Head: The fused tensor passes through a densely connected classification network to output a final raw logit, highly regularized using heavy Dropout (p = 0.6).
- Loss Function: The network was evaluated using
BCEWithLogitsLossfor binary classification (AUD_this_visit). - Dynamic Class Weighting: To counteract the heavy imbalance of the healthy control majority class, a dynamic positive class weight (
pos_weight) was calculated specific to the training set of each fold and injected into the loss function. - Optimization:
AdamWoptimizer with Early Stopping to capture weights before overfitting occurred.
- Visit-Level Majority Voting: Because clinical diagnoses are derived from full continuous recordings rather than isolated 30-second windows, final clinical performance was calculated using a Majority Visit Vote. Predictions for all epochs corresponding to a single visit were grouped precisely using
Subject_IDandage_this_visitto calculate the model's overall clinical AUROC. - Neurophysiological Validation (Grad-CAM): Gradient-weighted Class Activation Mapping (Grad-CAM) was integrated to visualize the specific frequency intersections driving the network's predictions. Grad-CAM was explicitly hooked into the final convolutional layer of the Micro-CNN to ensure the model utilized valid cortical network integration rather than image artifacts.