Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
|
6 |
+
# Function to simulate WBC activity over time
|
7 |
+
def simulate_wbc_activity(days):
|
8 |
+
# Creating a simple simulation for WBC activity
|
9 |
+
# This can be replaced with more complex logic based on real data
|
10 |
+
neutrophils = np.random.normal(20, 5, days).clip(0, 50)
|
11 |
+
lymphocytes = np.random.normal(15, 4, days).clip(0, 40)
|
12 |
+
monocytes = np.random.normal(10, 3, days).clip(0, 30)
|
13 |
+
eosinophils = np.random.normal(5, 2, days).clip(0, 20)
|
14 |
+
return pd.DataFrame({
|
15 |
+
"Day": range(1, days + 1),
|
16 |
+
"Neutrophils": neutrophils,
|
17 |
+
"Lymphocytes": lymphocytes,
|
18 |
+
"Monocytes": monocytes,
|
19 |
+
"Eosinophils": eosinophils
|
20 |
+
})
|
21 |
+
|
22 |
+
# Streamlit UI
|
23 |
+
st.title("WBC Simulation in Post-Surgery Hematoma and Infection")
|
24 |
+
|
25 |
+
st.markdown("""
|
26 |
+
## Understanding White Blood Cells (WBC)
|
27 |
+
In the event of a hematoma and infection post-surgery, different types of WBCs play crucial roles.
|
28 |
+
- **Neutrophils 🧦**: First responders to infection sites.
|
29 |
+
- **Lymphocytes 🧡**: Provide long-term immunity.
|
30 |
+
- **Monocytes 🧜**: Transform into macrophages to engulf pathogens.
|
31 |
+
- **Eosinophils 🧝**: Combat multicellular parasites and allergic reactions.
|
32 |
+
""")
|
33 |
+
|
34 |
+
# User input for simulation days
|
35 |
+
days = st.slider("Select number of days for the simulation", 1, 30, 7)
|
36 |
+
|
37 |
+
# Simulating WBC activity
|
38 |
+
wbc_data = simulate_wbc_activity(days)
|
39 |
+
|
40 |
+
# Plotting the WBC activity
|
41 |
+
st.line_chart(wbc_data.set_index("Day"))
|
42 |
+
|
43 |
+
st.markdown("""
|
44 |
+
## Simulation Insights
|
45 |
+
The graph above simulates the activity of different WBC types over time post-surgery.
|
46 |
+
- **Peak in Neutrophils**: Indicates the body's immediate response to infection.
|
47 |
+
- **Lymphocytes Trend**: Shows the development of immunity over time.
|
48 |
+
- **Monocytes and Eosinophils**: Fluctuate based on the severity of the infection and allergic reactions.
|
49 |
+
""")
|
50 |
+
|
51 |
+
st.markdown("""
|
52 |
+
### Note
|
53 |
+
This is a simplified simulation intended for educational purposes and does not represent actual medical data.
|
54 |
+
""")
|