Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
---
|
4 |
+
|
5 |
+
# VascularAge Model
|
6 |
+
|
7 |
+
## Background
|
8 |
+
|
9 |
+
With the growing availability of wearable devices, photoplethysmography (PPG) has become a promising non-invasive tool for monitoring cardiovascular health. This model estimates vascular age (AI-vascular age) from PPG signals, providing insights into an individual's cardiovascular health and risk.
|
10 |
+
|
11 |
+
## Use Case
|
12 |
+
|
13 |
+
The `VascularAge` model is designed to help assess cardiovascular health by estimating vascular age. It can be used for:
|
14 |
+
|
15 |
+
- **Risk Stratification**: Identify individuals at higher risk for cardiovascular events.
|
16 |
+
- **Health Monitoring**: Track cardiovascular health over time for personalized intervention.
|
17 |
+
|
18 |
+
This model provides a non-invasive approach for scalable, real-time cardiovascular health assessment using PPG signals from wearable devices.
|
19 |
+
|
20 |
+
## Usage (Pytorch)
|
21 |
+
|
22 |
+
```python
|
23 |
+
import json
|
24 |
+
import torch
|
25 |
+
import numpy as np
|
26 |
+
from net1d import Net1D
|
27 |
+
|
28 |
+
# Function to normalize PPG data (Z-score along the last dimension)
|
29 |
+
def normalize_ppg(parsed_ppg: np.ndarray) -> np.ndarray:
|
30 |
+
mean_ppg = parsed_ppg.mean(axis=-1, keepdims=True) # Compute mean along the last dimension
|
31 |
+
std_ppg = parsed_ppg.std(axis=-1, keepdims=True) # Compute standard deviation along the last dimension
|
32 |
+
normalized_ppg = (parsed_ppg - mean_ppg) / (std_ppg + 1e-8) # Z-score normalization
|
33 |
+
return normalized_ppg
|
34 |
+
|
35 |
+
# Load the configuration file
|
36 |
+
with open('./config.json') as f:
|
37 |
+
cfg = json.load(f)
|
38 |
+
|
39 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
40 |
+
|
41 |
+
# Initialize the model
|
42 |
+
model = Net1D(**cfg).to(device)
|
43 |
+
|
44 |
+
# Load model weights
|
45 |
+
model.load_state_dict(torch.load('./model.pth', map_location=device))
|
46 |
+
|
47 |
+
# Prepare raw PPG data (example) and normalize it
|
48 |
+
raw_ppg_data = np.random.randn(1, 1, 100) # Example PPG data (batch size of 1, 1 channel, 100 time steps)
|
49 |
+
normalized_ppg_data = normalize_ppg(raw_ppg_data) # Normalize the PPG data
|
50 |
+
|
51 |
+
# Convert normalized PPG data to tensor
|
52 |
+
ppg_data_tensor = torch.tensor(normalized_ppg_data, dtype=torch.float32).to(device)
|
53 |
+
|
54 |
+
# Perform inference
|
55 |
+
model.eval()
|
56 |
+
with torch.no_grad():
|
57 |
+
vascular_age = model(ppg_data_tensor)
|
58 |
+
|
59 |
+
print(f"Estimated Vascular Age: {vascular_age.item()}")
|