MODEL
Epilepsy, a common chronic neurological disorder, is characterized by abnormal synchronous discharges of neurons in the brain, leading to transient brain dysfunction. Its onset is random, sudden and unstable. According to global epidemiological research, over 50 million people worldwide are affected by epilepsy each year, with millions of patients in China alone. The incidence rate among children and adolescents is significantly higher than that among adults, accounting for approximately 30% of the total number of patients. This large patient group not only faces direct physiological risks - each seizure may cause muscle strains, fractures and other injuries, and long-term repeated discharges can lead to irreversible damage to nerve cells - but also bears heavy psychological pressure. About 60% of patients suffer from anxiety, low self-esteem, depression and other emotional disorders, and in severe cases, they may even face the risk of sudden death due to status epilepticus. Therefore, it urgently requires attention from the society and breakthroughs in medical technology. In clinical diagnosis practice, electroencephalogram (EEG) signal analysis is the core method for diagnosing epilepsy, but its results are highly dependent on the experience of physicians: on the one hand, the consistency of identification of abnormal discharges such as "spikes" and "sharp waves" by physicians of different seniorities can vary by 15% to 20% (novice physicians are prone to miss weak abnormal signals); on the other hand, individual physiological differences among patients (such as brain development stage, underlying diseases) may lead to "pseudo-abnormalities" in EEG signals, further reducing diagnostic accuracy. Therefore, developing precise and objective methods for diagnosing epilepsy and predicting seizures has become an important research direction in clinical neuroscience. In recent years, time series prediction techniques based on machine learning and deep learning have shown significant advantages in EEG signal analysis - convolutional neural networks (CNN) are good at extracting local signal features, while recurrent neural networks (RNN) can effectively handle the dynamic correlations of time series data, providing technical support for the construction of an automated diagnosis system. This study aims to integrate the above technologies to develop an intelligent system that can monitor patients' brain electrical activities in real time, automatically identify epileptic seizures, and output time-domain and frequency-domain feature data, providing objective basis for clinical intervention.
Currently, the most commonly used EEG data acquisition device in clinical practice is the non-invasive scalp electroencephalograph. Its advantages lie in the fact that it does not require surgical intervention, has high patient tolerance, and is suitable for long-term continuous monitoring. This device records the electrical activity signals of brain neurons by attaching electrodes at specific positions on the scalp and generates standardized EDF (European Data Format) files. These files not only contain multi-channel EEG data (each channel corresponds to a scalp electrode, synchronously monitoring the activity of different brain regions), but also include basic patient information (ID, age, gender) and recording parameters (start and end time of collection, total duration, sampling rate, etc.), providing complete metadata for subsequent analysis. The original EDF files used in this study contain 23 acquisition channels. After data preprocessing (removing channels with poor contact or excessive noise), 21 valid channels were retained, covering key brain regions such as the frontal lobe (Fp1/Fp2), central region (C3/C4), parietal lobe (P3/P4), and occipital lobe (O1/O2), capable of comprehensively capturing the characteristics of whole-brain electrical activity (Figure 1 shows the channel positioning diagram). The data sources is publicly available epilepsy EEG datasets ( the OpenNeuro scalp EEG dataset for epilepsy). The final dataset used for modeling contains 52 dual-channel localization operation EDF files, with a sampling rate set at 2000Hz - this sampling frequency can accurately capture millisecond-level abnormal discharge signals (such as spikes lasting 20-70ms), avoiding signal distortion due to insufficient sampling, and providing high-quality raw data for subsequent feature extraction and model training.



The electroencephalogram (EEG) signals of epilepsy patients and healthy individuals have fundamental differences in electrical activity characteristics: The EEG waves of healthy people show stable rhythms, and different brain regions exhibit orderly and symmetrical activity patterns, for example, the occipital lobe mainly shows alpha waves (8-13Hz) in the waking state and beta waves (13-30Hz) in the sleeping state, reflecting the coordinated activity of the neuronal network; while epilepsy patients may also show "epileptiform discharges" even during the interictal period (when there are no clinical seizure symptoms), which is the core biological marker for epilepsy diagnosis. Common types of epileptiform discharges include:
• Spike wave:A brief burst signal lasting 20-70ms, resulting from rapid abnormal synchronous discharge of neurons, and appears as sharp positive or negative peaks on the EEG waveform;
• Sharp wave:Lasting 70-200ms, with a slightly wider amplitude than spikes, and showing a "fast rise and slow fall" feature, indicating abnormally elevated neuronal excitability;
• Spike and slow wave complex: Alternating between spikes and slow waves (0.5-3Hz), commonly seen in epilepsy subtypes such as absence seizures, and is a typical abnormal signal during the seizure period.
When an epileptic seizure occurs, the abnormal manifestations of the EEG signal become more significant, such as continuous spikes, rhythmic slow waves, etc., and are often accompanied by clinical symptoms such as limb convulsions and loss of consciousness. At this time, the amplitude and frequency fluctuations of the EEG signal are much greater than in the normal state.
Feature Engineering DesignTo enhance the model's ability to identify abnormal signals, based on the events.tsv file provided by the author (which records channel names, event start and end times, time-frequency domain feature values, and epileptic discharge labels (0 = normal, 1 = abnormal)), we further constructed a multi-dimensional feature set. The additional features include:
• L1 norm: measures the sum of the absolute values of the amplitude of the electroencephalogram (EEG) signal, reflecting the overall intensity of the signal. The L1 norm of epileptic discharges is typically significantly higher than that of normal signals.
• Shannon entropy: quantifies the uncertainty and complexity of the signal. The Shannon entropy of normal EEG signals is more stable, while the entropy of abnormal signals fluctuates more due to irregular discharges.
• Sample entropy: describes the regularity of the signal. Normal EEG signals have higher sample entropy (stable rhythm), while abnormal signals have lower sample entropy due to disordered discharge patterns.
• Permutation entropy: assesses the complexity based on the temporal sequence arrangement pattern of the signal. Permutation entropy significantly decreases during epileptic seizures and can serve as a key indicator for seizure prediction.
• Combined features: the product of L1 norm and sample entropy, the product of L1 norm and permutation entropy, and the product of L1 norm and Shannon entropy (denoted as FS1), aiming to simultaneously capture the intensity and complexity features of the signal and enhance feature discrimination.
The above-mentioned features were ultimately integrated into a feature matrix and saved in the file eeg_features_removed_segments_sorted.tsv, containing a total of 50,267 samples. The data has been sorted in ascending order by channel labels and subject IDs to ensure consistency and repeatability in subsequent modeling (Table 1 shows a partial example of the feature matrix).
Table 1 Example of Feature Matrix (Partial Samples)
TWe integrated the basic features from columns 6 to 14 in the events.tsv file (including Events_RMS, Window_RMS, EventPeak2Peak, SNR, Amplpp, PowerTrough, Ftrough, PowmaxFR, and fmax_FR) with the aforementioned entropy-like features and applied them to both machine learning and deep learning models. Through iterative optimization, the diagnostic accuracy was improved.
Random Forest (RF) ModelThe random forest algorithm was first used for baseline verification. The dataset selected was the preprocessed data of the first 7 subjects (with outliers removed and Z-score standardized). The model parameters were set as follows: 100 decision trees, a maximum depth of 15, and a minimum sample split of 2. The feature importance analysis results showed that Amplpp (signal peak-to-peak amplitude), EventPeak2Peak (event peak-to-peak), and fmax_FR (power corresponding to the maximum frequency) were the key features influencing the model's prediction. Among them, Amplpp had the highest importance ratio (about 35%) - this is because the peak-to-peak amplitude of epileptic discharges (such as spike peak-to-peak can reach 100-300 μV) is much higher than that of normal brain waves (20-50 μV), and the amplitude difference becomes the core basis for distinguishing abnormal from normal signals; EventPeak2Peak was the second (about 28%), reflecting the fluctuation range of the signal during the event.
The confusion matrix of the random forest model indicated that the model had a relatively high accuracy in identifying normal signals (Non-Seizure), but the recall rate for epileptic signals (Seizure) was insufficient, suggesting that a single machine learning model is difficult to fully capture the temporal dynamic characteristics of EEG signals.


To enhance the ability to capture temporal features, we constructed a 13-layer CNN model, which includes: 2 convolutional layers (Conv1D, with 32 and 64 filters respectively, kernel size 3), 2 batch normalization layers (BN), 3 ReLU activation function layers (to enhance non-linear expression), 2 fully connected layers (with 128 and 64 neurons respectively), 1 dropout layer (dropout rate 0.3 to prevent overfitting), and 1 Softmax output layer (binary classification: epilepsy / normal). The model uses the Adam optimizer, with an initial learning rate of 1e-4, 60 training epochs, and 11,300 iterations. The training results show that the final accuracy (ACC) of the model is 76.10%, which is lower than the expected target. From the confusion matrix of the validation set, it can be seen that the model has a relatively high misjudgment rate for epilepsy signals; the learning curve (Figure 8) shows that the training set loss continuously decreases, but the validation set loss starts to rise after 30 epochs, indicating the existence of overfitting - this is mainly due to the limited sample size of the EEG signals (50,267 samples) and the strong dependence of the CNN model on local features, making it difficult to fully utilize the temporal correlation information.



To integrate the local feature extraction capability of CNN and the temporal modeling ability of LSTM, the research team further constructed a CNN-LSTM hybrid model (Figure 10), with the following structural design:
• Convolutional module: 2 convolutional blocks (Conv1D→BN→ReLU→MaxPooling1D), the first block captures local signal features (such as the sharp peaks of spikes), and the second block extracts global high-order features (such as the periodicity of spike and slow wave complexes);
• Flatten layer: Converts the two-dimensional feature maps output by the convolutional module into one-dimensional vectors to prepare for the input of the LSTM layer;
• LSTM layer: Sets 64 hidden units to learn the long-term dependencies of EEG signals and selectively retain key temporal information (such as the abnormal discharge trend before an episode);
• Activation and regularization: The ReLU activation function enhances nonlinear expression, and the Dropout layer (dropout rate 0.3) suppresses overfitting;
• Output layer: The Softmax function outputs the probability of binary classification (epilepsy / normal).
The model training parameters are consistent with those of CNN, and the final AUC (area under the receiver operating characteristic curve) is 0.8465, significantly better than the single CNN model, proving the importance of temporal correlation information for epilepsy diagnosis. However, this model still has the problems of high training complexity and slow inference speed, making it difficult to meet the requirements of real-time clinical monitoring.


To balance accuracy and practicality, the research team conducted lightweight optimization on the CNN model: simplifying the network structure (reducing the number of convolutional and fully connected layers) while retaining the core feature extraction capability. The specific structure is as follows:
1. Input layer: Receives the standardized EEG signal feature vector (dimension matching the number of features);
2. First convolutional block: Conv1D (32 filters, kernel size 3) → BN1 → ReLU1 (extracts basic local features);
3. Second convolutional block: Conv1D (16 filters, kernel size 3) → BN2 → ReLU2 (extracts high-order local features);
4. Fully connected module: flatten layer (converts two-dimensional features to one-dimensional) → fc1 (64 neurons, ReLU3 activation) → Dropout (0.3) → fc2 (32 neurons);
5. Output layer: Softmax function outputs the prediction probability of epilepsy/normal. The optimized model adopts a learning rate scheduling strategy (initial learning rate 6.25e-05, linearly decaying with the number of iterations), increasing the training rounds to 100, with 11,500 iterations, and simultaneously introduces an early stopping mechanism (patience=10) - terminating training when the validation set loss does not decrease for 10 consecutive rounds, effectively suppressing overfitting. The final training results show: The model accuracy has increased to 80.88%, the training time is 15 minutes and 14 seconds (in a single GPU environment), and the learning curve shows that the training set and validation set losses tend to be consistent, with significantly improved generalization performance, becoming the final output model of this study.
We attempted to implement deep learning using a CNN model comprising thirteen layers, including convolutional layers, batch normalization layers, three activation function layers (ReLU), two fully connected layers, a Dropout layer, and a Softmax and output layer. After 60 epochs and 11,300 iterations, the model achieved an accuracy (ACC) of 76.10%, which fell short of expectations. To address this, we introduced Long Short-Term Memory Networks (LSTM) and conducted parameter adjustments to the CNN architecture.
In the first two iterations, the accuracy of the training set increased rapidly, accompanied by a decline in the accuracy of the test set. This indicates that during these two iterations, the improvement in the training set accuracy was achieved at the cost of the test set accuracy. This could be attributed to the differences in the distribution of the two datasets. After the third iteration, as the number of iterations increased, the accuracies of both the training set and the test set showed an upward trend. This implies that at this stage, the model effectively captured the characteristic features of epileptic abnormal electroencephalograms (EEGs). Moreover, the model continuously adjusted the learning rate and the weights of relevant feature parameters. The accuracy of the model gradually converged and became more stable. Eventually, after 10 iterations, the accuracy leveled off at approximately 76%. During the first four iterations, the model exhibited significant underfitting/overfitting issues. However, after 10 iterations, the difference in accuracy between the training set and the test set was relatively small. This suggests that the model had overcome the overfitting/underfitting problems and continuously enhanced its generalization ability.

To enhance accuracy and better serve output tasks characterized by time-frequency signals, we implemented a CNN-LSTM architecture. This model consists of two convolutional blocks (conv→bn→ReLU→pool), where the first block captures local features while the second extracts global, higher-order features. The flattened layer converts multi-feature information from CNN into one-dimensional vectors. The LSTM layer then learns long-range dependencies to selectively retain or forget information, producing hidden states. An activation layer (ReLU) enhances complex capability expression, while a Dropout layer applies regularization to prevent overfitting. Finally, a Softmax activation function outputs epileptic/non-epileptic results. The model achieved an AUC of 0.8465, meeting our expectations effectively.
However, due to the severe overfitting in the previous model, we conducted further optimization of the CNN architecture. We simplified some steps at the cost of reduced feature representation capability and limited computational efficiency improvement. The final model structure is: input data → Convolution for feature extraction (conv1→BN1→ReLU1) → Convolution for higher-order features (conv2→BN2→ReLU2) → Fully connected layer integrating features (fc1→ReLU3→Dropout→fc2) → Softmax output probability → Predicting epileptic/non-epileptic outcomes. After 100 epochs with 11,500 iterations, the model achieved an accuracy rate (ACC) of 80.88%, significantly improving generalization performance. This optimized model serves as our final output.


Our research team has developed a complete workflow for epilepsy diagnosis, covering all aspects from data preprocessing (cleaning, filling in missing values, and removing outliers), handling class imbalance (using the SMOTE algorithm to balance positive and negative samples), feature engineering (basic features + entropy-based features + combined features), model construction (random forest → CNN → CNN-LSTM → optimized CNN), and iterative optimization. Based on the initial code for identifying epileptic events, the introduction of entropy-based features and machine learning techniques has significantly improved the ability to distinguish true positives (epileptic signals) from false positives (normal signals misjudged as abnormal). Additionally, the model uses a one-dimensional convolutional neural network, which can be adapted to the scenario of electroencephalogram (EEG) activity monitoring during drug intervention for bipolar disorder patients, providing a technical reference for signal analysis across different disease scenarios.
Research Significance and Cognitive EnhancementThrough this research, our team has deepened their understanding of the characteristics of the epilepsy seizure detection and prediction system:
1.Identifying the impact of class imbalance: By comparing the model performance before and after balancing, it was found that the ratio of positive to negative samples (initially about 1:5) significantly affects machine learning models - imbalanced data leads to model bias towards the majority class (normal signals), reducing the recall rate of epilepsy signals, while the SMOTE algorithm can increase the recall rate by 12% to 15%;
2.Analyzing the patterns of epilepsy signals: Through feature importance analysis, it was determined that amplitude features such as Amplpp and EventPeak2Peak are core indicators for epilepsy diagnosis, while entropy features can supplement information on signal complexity. The combination of the two can enhance the comprehensiveness of diagnosis;
3.Introducing confidence output: The model can output the confidence level (0-1) of each prediction result, helping researchers assess the reliability of individual predictions - results with a confidence level below 0.7 need to be further evaluated in combination with clinical symptoms to enhance diagnostic safety.
Data Authenticity and PortabilityThis research model is entirely constructed based on real measurement data: the feature and label data mainly come from publicly available epilepsy EEG datasets OpenNeuro. All data have undergone strict quality control (signal-to-noise ratio ≥ 20dB) to ensure the reliability and clinical applicability of the model.
Furthermore, the technical framework of this research has high portability: the research documentation meticulously records the key steps of each stage (such as data preprocessing parameters, model hyperparameters) and operation guidelines. Its workflow can serve as a demonstration tutorial for the cross-application of biomedicine and machine learning; at the same time, this technical framework is applicable to most signal-based biomedical classification problems (such as ECG arrhythmia diagnosis, EEG analysis of sleep apnea, EMG signal-based movement intention recognition, etc.), providing a technical template for cross-disciplinary research.
OutlooksAlthough the current model has achieved an accuracy rate of 80.88%, there is still room for improvement. In the future, adaptive filtering technology can be integrated to optimize the preprocessing process, reducing the impact of motion artifacts and power frequency interference on EEG signals. Additionally, the sample size should be expanded, especially for rare epilepsy subtypes, to further enhance the model's generalization ability. Moreover, the integration of the model with clinical devices can be explored to develop portable EEG monitoring terminals, enabling real-time early warning of epileptic seizures and providing more timely intervention support for patients. In summary, this study has constructed a high-accuracy and highly portable epilepsy diagnosis model through systematic technological innovation and iterative optimization, providing an objective and efficient technical tool for clinical epilepsy diagnosis and offering practical references for the cross-application of biomedical signals and machine learning.
Our team's project comprehensively covers the entire workflow from data cleaning, missing value handling, and class imbalance mitigation to feature engineering, model construction, and optimization. Building upon our initial code-based identification of epileptic events in patients, we further incorporated features such as information entropy and applied machine learning to refine the output features, thereby improving the accuracy in distinguishing true positives from false positives. The model leverages advanced technologies including one-dimensional convolutional neural networks for monitoring brain activity patterns in patients undergoing continuous medication intervention for bipolar disorder. Through systematic iterative optimization, the model achieved an accuracy rate of 80.88%.
The model has enabled the research team to gain a deeper understanding of the characteristics of epileptic seizure detection and prediction systems. By analyzing performance across different preprocessing steps, the team identified how class imbalance impacts machine learning models and enhanced their comprehension of epileptic signal patterns. Additionally, the model's confidence output function helps researchers assess the reliability of individual predictions. The model is entirely based on real measurement data. The development of these characteristic and label data primarily comes from publicly available epilepsy EEG datasets or experimental data collected by the team through biosensors. The model is rigorously built upon experimental measurement data.
The workflow of this project serves as a model tutorial for the application of biology and machine learning, with high portability. The documentation details all key steps and parameters, and its technical framework applies to most signal-based biomedical classification problems.
All the contents above demonstrate our pursuit of the best model.
Download Addressβ-hydroxybutyric acid (BHB) is the core functional molecule in ketogenic diet for epilepsy treatment. The ketogenic diet restricts carbohydrate intake, promoting fat metabolism in the body to produce BHB and other ketone bodies. These ketone bodies can cross the blood-brain barrier to exert neuroprotective effects and inhibit epileptic seizures. In clinical treatment, after BHB is absorbed through the gastrointestinal tract and enters the bloodstream, there are significant individual differences in its diffusion (such as transport to brain tissue) and metabolism (such as oxidation and decomposition in the liver). If a fixed dose is administered, it may lead to insufficient blood ketone concentration (poor therapeutic effect) or excessive accumulation (risk of ketoacidosis) in some patients.
By constructing a pharmacokinetic model to predict the metabolic curve of BHB, the initial synthesis amount can be optimized based on the patient's physiological characteristics (such as gender and weight), achieving individualized dosing. Currently, the mainstream drug metabolism models include one-compartment, two-compartment, and multi-compartment models. However, these models are mainly based on empirical fitting and do not incorporate the physiological structure of the human body (such as different absorption regions in the gastrointestinal tract and the liver as a metabolic organ). For example, the one-compartment model assumes that the drug is uniformly distributed in the body, which does not align with the actual process of BHB's segmented absorption in the gastrointestinal tract and specific metabolism in the liver, limiting its clinical applicability. In contrast, the physiologically based pharmacokinetic (PBPK) model is based on the physiological structure and function of the human body (such as absorption sites in the gastrointestinal tract, blood distribution volume, and liver clearance capacity) for modeling, which is more consistent with the real metabolic pathway of BHB in the body and can more accurately quantify the impact of individual differences on pharmacokinetics. Therefore, it has become the core model framework of this study.
Parameter | Explanation | Calculation |
---|---|---|
\( f_{\text{slowsite}} \) | Slow rate absorption point fraction | \( \beta_{f_{\text{slowsite}}} \cdot \left( \frac{\text{Dose}}{31184} \right) \frac{1}{1 + e^{-f_{\text{slowsite}}}} \) |
\( V \) | Apparent volume of distribution | \( \beta_{V} \cdot \beta_{\text{coefficient\_SEX\_}V} \) |
\( CL \) | Clearance | \( \beta_{CL} \cdot \left( \frac{LBW}{70} \right)^{\beta_{\text{coefficient\_LBW\_}CL}} \) |
\( k_{a\ \text{fastsite}} \) | Rapid absorption site rate constant (\( h^{-1} \)) | 3.28 for formulation 1 2.36 for formulation 2 |
\( k_{a\ \text{slowsite}} \) | Slow absorption site rate constant (\( h^{-1} \)) | 0.54 |
\( LBW \) | Fat-free body weight | |
\( ALAG_{\text{slowsite}} \) | Slow absorption site lag time (h) | |
\( V_{\text{max}} \) | Maximum metabolic rate (mg/h) | 4520 |
\( K_m \) | Mie constant (mg/L) | 52.7 |
\( BSL \) | Baseline input parameters (mg/L) | 7.23 |
\( SLP \) | Sigmoid slope parameter | -0.051 |
\( INT \) | Sigmoid intercept parameter | -15.5 |
\( F \) | Bioavailability | \( \begin{aligned} &\beta_{F\_\text{formulation}} + {} \\ &\beta_{\text{coefficient\_Dose\_}F} \cdot \left( \frac{\text{Dose}}{31184} \right) \cdot {} \\ &\frac{1}{1 + e^{-F}} \end{aligned} \) |
\( \text{Dose} \) | BHB dose | |
\( \beta_{F\_\text{formulation}} \) | Pharmaceutical formulation covariate effect parameter | 1 (formulation.1) 0.37 (formulation.2) |
\( \beta_{\text{coefficient\_Dose\_}F} \) | Parameter of auxiliary effect of drug absorption | -0.18 |
\( \beta_{\text{coefficient\_LBW\_}CL} \) | Weight effect parameter | 2.09 |
\( \beta_{\text{coefficient\_SEX\_}V} \) | Gender effect parameters | 1 (male) 0.77 (female) |
\( R_{\text{in}} \) | Endogenous BHB production rate (mg/h) | \( \text{BSL} \cdot CL \) |
\( k_{\text{out}} \) | Metabolic rate constant (\( h^{-1} \)) | \( \frac{CL}{V} \) |
\( A_1 \) | Rapid absorption site BHB drug content(mg) | |
\( A_2 \) | Slowly absorption site BHB drug content (mg) | |
\( A_3 \) | Blood exogenous BHB content (mg) | |
\( A_4 \) | Blood endogenous BHB content (mg) | |
\( C_1 \) | Rapid absorption site BHB drug concentration(mmol/L) | |
\( C_2 \) | Slowly absorption site BHB drug concentration (mmol/L) | |
\( C_3 \) | Blood exogenous BHB concentration (mmol/L) | |
\( C_4 \) | Blood endogenous BHB concentration (mmol/L) |
The population pharmacokinetic behavior of BHB exhibits complex nonlinear characteristics, with its absorption and elimination processes regulated by multiple factors:
1.Absorption process: Experimental verification indicates that the intestinal absorption of BHB follows a "biphasic kinetic model" - after oral administration, a portion is rapidly absorbed at the fast site at a high rate, while another portion is absorbed at the slow site at a lower rate, and the absorption efficiency is influenced by the formulation type and dosage.
2.Elimination process: Two elimination mechanisms exist simultaneously: First-order kinetic elimination: The clearance rate CL is fixed at 10.9 L/h (the elimination rate is proportional to the concentration when the drug concentration is low); Capacity-limited elimination: Regulated by the maximum metabolic rate Vmax (4520 mg/h) and the Michaelis constant Km (52.7 mg/L) (when the drug concentration is high, the elimination rate approaches Vmax and no longer increases with the concentration).
3.Individual difference influencing factors: Formulation design (e.g., formulation 1 has a higher absorption efficiency than formulation 2), body weight (affecting CL through LBW), and gender (affecting V through βcoefficient_SEX_V}) significantly alter the total absorption and in vivo distribution range of BHB, and are covariates that need to be considered in individualized dosing. In addition, the total BHB concentration in the blood is composed of "exogenous administration (A3/C3)" and "endogenous synthesis (A4/C4)", and the total concentration is regulated by a feedback inhibition mechanism to adjust the endogenous generation rate Rin- when the total concentration is too high, Rindecreases to reduce endogenous BHB synthesis and prevent excessive accumulation of blood ketones.
This model consists of 4 core modules, each corresponding to different disposition stages of the drug in the body:
Intestinal Absorption Module: It is divided into a fast absorption site (fastsite) and a slow absorption site (slowsite). After administration, the drug first enters the intestine and is distributed to the two sites based on the type and dose of the formulation (the distribution ratio is determined by fslowsite). Then, it is absorbed into the blood at rates of ka fastsite and ka slowsite respectively. Exogenous Blood Module: The BHB absorbed into the blood forms an exogenous BHB pool (A3/C3), which is metabolized and cleared at a rate of CL.
Endogenous Blood Module: The human body generates endogenous BHB (A4/C4) through its own metabolism at a rate of Rin, and it is cleared at a rate determined by kout. Feedback Regulation Module: The total BHB concentration in the blood (C3+C4) serves as a feedback signal to regulate the generation of endogenous BHB, maintaining a stable BHB level in the body.

The model describes the dynamic changes of BHB content (A1~A4) in each part over time through the following differential equations, where the initial conditions (values at t = 0) are marked:
1.Rapid absorption site BHB drug content(mg) A1:The drug is absorbed into the bloodstream only from this site and there are no other input pathways.
\(\frac{dA_1}{dt} = -k_{\text{ofastive}} \cdot F \cdot A_1\)
The initial conditions: \( A_1(0) = (1 - f_{\text{slowsite}}) \cdot \text{Dose} \) (The portion of the administered dose that is distributed to the rapidly absorbed site)
2.Slowly absorption site BHB drug content (mg) \( A_2 \): There is an absorption lag time. After the lag ends, the drug begins to be absorbed.
\( \frac{dA_2}{dt} = -k_{a\ \text{slowsite}} \cdot F \cdot A_2 (t > ALAG_{\text{slowsite}}) \)
\( \frac{dA_2}{dt} = 0 (t < ALAG_{\text{slowsite}}) \)
The initial conditions: \( A_2(0) = f_{\text{slowsite}} \cdot \text{Dose} \) (The portion of the administered dose that is distributed to the slow absorption site)
3.Blood exogenous BHB content (mg) \( A_3 \): The drug is input from two absorption sites and is cleared through \( CL \).
\( \frac{dA_3}{dt} = k_{a\ \text{fastsite}} \cdot F \cdot A_1 + k_{a\ \text{slowsite}} \cdot F \cdot A_2 - \frac{CL \cdot A_3}{V} \)
The initial conditions: \( A_3(0) = 0 \) (There was no exogenous BHB in the blood before administration); \( C_3 = \frac{A_3}{V} \) (The conversion relationship between concentration and content)
4.Blood endogenous BHB content (mg) \( A_4 \): Generated by \( R_{\text{in}} \) and cleared through \( k_{\text{out}} \).
\( \frac{dA_4}{dt} = R_{\text{in}} - k_{\text{out}} \cdot A_4 \)
The initial conditions: \( A_4(0) = BSL \cdot V \) (The basal content of endogenous BHB before drug administration)
Steady-state simplified equation
When the model is in a steady state (where the endogenous BHB generation rate equals the clearance rate and there is no feedback inhibition effect), the differential equation for endogenous BHB can be simplified to:
\( \frac{dA_4}{dt} = R_{\text{in}} - k_{\text{out}} \cdot A_4 = 0 \)
At this point, \( R_{\text{in}} = k_{\text{out}} \cdot A_4 \), the production and clearance of endogenous BHB reach equilibrium.
Figure 15 evaluates the prediction accuracy of the model through four subplots.
The upper left subgraph (observed values vs. group predicted values): The scattered points are closely clustered around the diagonal line, indicating that the model's predicted values for the "average BHB concentration of the group" are highly consistent with the actual observed values, with no obvious systematic bias.
The upper right subgraph (observed values vs. individual predicted values): The scattered points are also close to the diagonal line, suggesting that the model can adapt to the physiological differences among different individuals (such as weight and gender), and has good prediction accuracy for the BHB concentration of individual patients.
The lower left subgraph (conditional weighted residuals vs. group predicted values): The residuals (observed values - predicted values) are uniformly distributed around 0, with no obvious trend (such as no rule of "the higher the predicted value, the larger the residual"), indicating that the model has no systematic error.
The lower right subgraph (conditional weighted residuals vs. time): The residuals do not show a fixed pattern over time, and there is no situation where the residuals are significantly higher or lower in a certain time period, suggesting that the model has strong stability in predicting BHB concentrations at different time points.

The concentration trends of BHB in different sites (C1~C4) over time have the following core features:
• Concentration at rapid absorption sites (C1): It rapidly rises to a peak within 1 to 2 hours after administration, then drops quickly due to rapid drug absorption, approaching 0 after 8 to 10 hours, demonstrating the characteristic of "rapid absorption".
• Concentration at slow absorption sites (C2): It rises slowly after administration (with a lag of 2 to 3 hours), with the peak occurring later than C1 (4 to 6 hours), and the decline rate is slow. It still maintains a certain concentration after 15 to 20 hours, reflecting the continuous contribution of "slow absorption" to blood drug concentration.
• Exogenous BHB concentration in blood (C3): It shows a "biphasic rise" trend - it rises rapidly in the early stage due to the rapid absorption at C1, and then maintains a plateau due to the slow absorption at C2. Subsequently, it gradually decreases due to clearance, approaching 0 after 25 hours.
• Endogenous BHB concentration in blood (C4): It remains at a relatively stable level throughout (2 to 3 mmol/L), and is less affected by the feedback regulation of exogenous BHB, ensuring a basic supply of BHB in the body and avoiding excessive inhibition of endogenous synthesis due to exogenous administration.

This model can simulate the metabolic process of BHB in the body relatively well, but there are still the following areas for improvement:
• Individual differences: Currently, only weight, gender, and formulation type are included as covariates, without considering age (such as metabolic differences between children and adults), liver and kidney function (which affect BHB metabolism), and the impact of seizure frequency on BHB metabolism. It is necessary to further increase the sample size to incorporate these factors.
• Feedback inhibition mechanism: The model only qualitatively describes "total concentration regulation", without establishing a quantitative feedback regulation formula (such as the specific function relationship between total concentration and BHB metabolism). More clinical data is needed to derive this.
• Parameter completeness: The calculation methods for some parameters (such as BHB production rate, BHB clearance rate) are not clearly defined. It is necessary to supplement these with human physiological formulas or experimental data to enhance the practicality of the model.
Download Address