|
--- |
|
license: mit |
|
language: |
|
- en |
|
--- |
|
# VascularAge Model |
|
|
|
## Background |
|
|
|
Photoplethysmography (PPG) has emerged as a non-invasive method for monitoring cardiovascular health. This model estimates vascular age (AI-vascular age) from PPG signals, offering insights into an individual's cardiovascular health and associated risks. |
|
|
|
The model was developed and evaluated using data from the UK Biobank (UKBB) cohort, where PPG signals were collected in a standardized format. For more details, please refer to our [research article](https://arxiv.org/abs/2502.12990). |
|
|
|
## Use Case |
|
|
|
The `VascularAge` model is designed to estimate vascular age, which can be used for: |
|
|
|
- **Risk Stratification**: Identifying individuals at higher risk for cardiovascular events. |
|
- **Health Monitoring**: Tracking cardiovascular health over time to support personalized interventions. |
|
|
|
This model provides a non-invasive, scalable approach for real-time cardiovascular health assessment using PPG signals. It is specifically trained to process PPG data from the UKBB dataset, ensuring its effectiveness in research and clinical settings that use similar data. |
|
|
|
## Data Format |
|
|
|
To ensure compatibility, PPG signals should be preprocessed and formatted in the same way as in the UKBB dataset. The expected format for input PPG signals is a 3D array with the shape `(batch_size, num_channels, num_samples)`. |
|
|
|
## Usage (Pytorch) |
|
|
|
```python |
|
import json |
|
import torch |
|
import numpy as np |
|
from net1d import Net1D |
|
|
|
# Function to normalize PPG data (Z-score along the last dimension) |
|
def normalize_ppg(parsed_ppg: np.ndarray) -> np.ndarray: |
|
mean_ppg = parsed_ppg.mean(axis=-1, keepdims=True) # Compute mean along the last dimension |
|
std_ppg = parsed_ppg.std(axis=-1, keepdims=True) # Compute standard deviation along the last dimension |
|
normalized_ppg = (parsed_ppg - mean_ppg) / (std_ppg + 1e-8) # Z-score normalization |
|
return normalized_ppg |
|
|
|
# Load the configuration file |
|
with open('./config.json') as f: |
|
cfg = json.load(f) |
|
|
|
device = 'cuda' if torch.cuda.is_available() else 'cpu' |
|
|
|
# Initialize the model |
|
model = Net1D(**cfg).to(device) |
|
|
|
# Load model weights |
|
model.load_state_dict(torch.load('./model.pth', map_location=device)) |
|
|
|
# Prepare raw PPG data (example) and normalize it |
|
raw_ppg_data = np.random.randn(1, 1, 100) # Example PPG data (batch size of 1, 1 channel, 100 time steps) |
|
normalized_ppg_data = normalize_ppg(raw_ppg_data) # Normalize the PPG data |
|
|
|
# Convert normalized PPG data to tensor |
|
ppg_data_tensor = torch.tensor(normalized_ppg_data, dtype=torch.float32).to(device) |
|
|
|
# Perform inference |
|
model.eval() |
|
with torch.no_grad(): |
|
vascular_age = model(ppg_data_tensor) |
|
|
|
print(f"Estimated Vascular Age: {vascular_age.item()}") |