ProfRick commited on
Commit
4097314
Β·
verified Β·
1 Parent(s): 370127a

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +20 -0
  2. README.md +27 -0
  3. app.py +132 -0
  4. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a small Python base image
2
+ FROM python:3.11-slim
3
+
4
+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 PORT=7860
5
+
6
+ WORKDIR /app
7
+
8
+ # System deps (optional): build-base for matplotlib backends if needed
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ libglib2.0-0 libsm6 libxext6 libxrender1 \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ COPY requirements.txt /app/requirements.txt
14
+ RUN pip install --upgrade pip && pip install -r requirements.txt
15
+
16
+ COPY app.py /app/app.py
17
+
18
+ EXPOSE 7860
19
+
20
+ CMD streamlit run app.py --server.port $PORT --server.address 0.0.0.0
README.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Signal to Secretion
3
+ emoji: 🧠
4
+ colorFrom: indigo
5
+ colorTo: indigo
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ ---
10
+
11
+ # Signal to Secretion (Streamlit β€’ Docker Space)
12
+
13
+ Interactive physiology mini-app:
14
+
15
+ 1. Choose a scenario.
16
+ 2. Build the **dominant autonomic pathway** (transmitter β†’ receptor β†’ PSP).
17
+ 3. Select **hormone type / circulation / receptor** for common hormones.
18
+ 4. Explore a **flow & pressure gradient simulator** for delivery.
19
+
20
+ ## How this Space runs
21
+ This is a **Docker** Space with Streamlit. The container starts:
22
+
23
+ ```bash
24
+ streamlit run app.py --server.port $PORT --server.address 0.0.0.0
25
+ ```
26
+
27
+ No additional configuration is required.
app.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import streamlit as st
4
+
5
+ st.set_page_config(page_title="Signal to Secretion", page_icon="🧠", layout="wide")
6
+
7
+ # -------------------
8
+ # Data: scenarios (dominant only; effectors have no parentheses)
9
+ # -------------------
10
+ SCENARIOS = {
11
+ "Predator threat (fight-or-flight)": {
12
+ "dominant": "Sympathetic",
13
+ "steps_labels": ("Pre-ganglionic", "Post-ganglionic"),
14
+ "effector": "Heart",
15
+ "function": "↑ Heart rate and contractility β†’ ↑ Cardiac output",
16
+ },
17
+ "Post-meal digestion (rest-and-digest)": {
18
+ "dominant": "Parasympathetic",
19
+ "steps_labels": ("Pre-ganglionic", "Post-ganglionic"),
20
+ "effector": "GI tract smooth muscle & glands",
21
+ "function": "↑ Motility and secretions β†’ enhanced digestion/absorption",
22
+ },
23
+ "Cold exposure (thermoregulatory response)": {
24
+ "dominant": "Sympathetic",
25
+ "steps_labels": ("Pre-ganglionic", "Post-ganglionic"),
26
+ "effector": "Cutaneous arterioles",
27
+ "function": "Vasoconstriction β†’ conserve core heat",
28
+ },
29
+ "Hypotension (baroreflex β€” pressure drop)": {
30
+ "dominant": "Sympathetic",
31
+ "steps_labels": ("Pre-ganglionic", "Post-ganglionic"),
32
+ "effector": "Arterioles and Heart",
33
+ "function": "↑ Total peripheral resistance (Β± ↑ HR) β†’ restore arterial pressure",
34
+ },
35
+ "Guided breathing / meditation (vagal tone)": {
36
+ "dominant": "Parasympathetic",
37
+ "steps_labels": ("Pre-ganglionic", "Post-ganglionic"),
38
+ "effector": "Heart",
39
+ "function": "↓ SA node rate and AV conduction β†’ ↓HR, ↑HRV",
40
+ },
41
+ }
42
+
43
+ # Allowed options (per your constraints)
44
+ TX_OPTIONS = ["β€” select β€”", "Acetylcholine (ACh)", "Norepinephrine/Epinephrine"]
45
+ RC_OPTIONS = ["β€” select β€”", "Cholinergic (nicotinic)", "Cholinergic (muscarinic)", "Adrenergic"]
46
+ PSP_OPTIONS = ["β€” select β€”", "EPSP", "IPSP"]
47
+
48
+ HORMONES = ["Insulin", "Epinephrine", "Cortisol", "Aldosterone", "T3/T4"]
49
+ HORMONE_CLASS = ["β€” select β€”", "amino acid/peptide", "steroid"]
50
+ HORMONE_CIRC = ["β€” select β€”", "Free", "Bound to Transport Protein"]
51
+ HORMONE_RECEPTOR = ["β€” select β€”", "membrane bound receptor", "intracellular receptor"]
52
+
53
+ # Sidebar
54
+ with st.sidebar:
55
+ st.header("1) Choose a Scenario")
56
+ scenario = st.selectbox("Scenario", list(SCENARIOS.keys()), index=0)
57
+ st.caption("Use the main panel to build the pathway and explore gradients.")
58
+
59
+ st.title("Signal to Secretion: From Hypothalamus to Effector")
60
+
61
+ # Section 2
62
+ st.subheader("2) Neural Pathway (Dominant Branch Only)")
63
+ st.write("Complete the transmitter β†’ receptor β†’ PSP for each step. Then review the effector and function card.")
64
+
65
+ st.markdown("**Step** | **Transmitter** | **Receptor** | **PSP**")
66
+ st.markdown("---")
67
+
68
+ chosen = {}
69
+ for idx, step_label in enumerate(SCENARIOS[scenario]["steps_labels"]):
70
+ c1, c2, c3, c4 = st.columns([1.3, 2.2, 2.4, 1.2])
71
+ with c1:
72
+ st.write(step_label)
73
+ with c2:
74
+ tx = st.selectbox(f"Transmitter_{idx}", TX_OPTIONS, key=f"tx_{scenario}_{idx}")
75
+ with c3:
76
+ rc = st.selectbox(f"Receptor_{idx}", RC_OPTIONS, key=f"rc_{scenario}_{idx}")
77
+ with c4:
78
+ psp = st.selectbox(f"PSP_{idx}", PSP_OPTIONS, key=f"psp_{scenario}_{idx}")
79
+ chosen[step_label] = {"tx": tx, "rc": rc, "psp": psp}
80
+
81
+ st.info(f"**Effector:** {SCENARIOS[scenario]['effector']}\n\n**Function:** {SCENARIOS[scenario]['function']}")
82
+
83
+ st.markdown("---")
84
+
85
+ # Section 3
86
+ st.subheader("3) Hormone Structure β€’ Transport β€’ Receptors")
87
+ st.write("For each hormone, choose its type, circulation mode, and receptor location/type.")
88
+
89
+ header_cols = st.columns([1.2, 1.6, 1.8, 1.8])
90
+ header_cols[0].markdown("**Hormone**")
91
+ header_cols[1].markdown("**Type**")
92
+ header_cols[2].markdown("**Circulation**")
93
+ header_cols[3].markdown("**Receptor**")
94
+
95
+ for i, h in enumerate(HORMONES):
96
+ c1, c2, c3, c4 = st.columns([1.2, 1.6, 1.8, 1.8])
97
+ with c1:
98
+ st.write(h)
99
+ with c2:
100
+ st.selectbox(f"Type_{i}", HORMONE_CLASS, key=f"type_{h}")
101
+ with c3:
102
+ st.selectbox(f"Circulation_{i}", HORMONE_CIRC, key=f"circ_{h}")
103
+ with c4:
104
+ st.selectbox(f"Receptor_{i}", HORMONE_RECEPTOR, key=f"rec_{h}")
105
+
106
+ st.markdown("---")
107
+
108
+ # Section 4
109
+ st.subheader("4) Flow Down Gradients (Delivery Simulator)")
110
+ st.write("Adjust concentration and pressure to visualize delivery dynamics. Higher concentration and higher pressure speed delivery to tissues.")
111
+
112
+ colA, colB = st.columns(2)
113
+ with colA:
114
+ dC = st.slider("Ξ”[Hormone] (target - blood)", min_value=0.0, max_value=1.0, value=0.4, step=0.02)
115
+ with colB:
116
+ P = st.slider("Circulatory pressure (relative)", min_value=0.1, max_value=2.0, value=1.0, step=0.05)
117
+
118
+ G = max(dC, 1e-3)
119
+ rate = P * G
120
+ t = np.linspace(0, 10, 250)
121
+ k = 0.35 * rate + 0.05
122
+ delivered = 1 - np.exp(-k * t)
123
+
124
+ fig, ax = plt.subplots()
125
+ ax.plot(t, delivered, label="Fraction delivered to tissue")
126
+ ax.set_xlabel("Time")
127
+ ax.set_ylabel("Delivered (0–1)")
128
+ ax.set_title("Hormone Delivery vs. Gradients")
129
+ ax.legend(loc="best")
130
+ st.pyplot(fig, clear_figure=True)
131
+
132
+ st.caption("Delivery rises faster with larger Ξ”[Hormone] and higher circulatory pressure.")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit==1.38.0
2
+ numpy==1.26.4
3
+ matplotlib==3.8.4