Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,6 @@ st.markdown("""
|
|
| 16 |
<style>
|
| 17 |
/* CSS แก้ปัญหาการสั่นของหน้าจอ */
|
| 18 |
.stApp { transition: none !important; }
|
| 19 |
-
/* กำหนดความสูงตายตัวให้กับ container กราฟ */
|
| 20 |
-
.fixed-height-chart { min-height: 500px; display: flex; align-items: center; justify-content: center; }
|
| 21 |
html, body, [class*="st-"] {
|
| 22 |
font-size: 18px;
|
| 23 |
}
|
|
@@ -113,7 +111,7 @@ def draw_kspace_diagram():
|
|
| 113 |
|
| 114 |
# ตัวอักษรบอกทิศทาง +kx, -kx, +ky, -ky (อยู่นอกกรอบ)
|
| 115 |
ax.text(1.1, 0, '+kx', fontsize=20, fontweight='bold', va='center')
|
| 116 |
-
ax.text(-1.
|
| 117 |
ax.text(0, 1.1, '+ky', fontsize=20, fontweight='bold', ha='center')
|
| 118 |
ax.text(0, -1.1, '-ky', fontsize=20, fontweight='bold', ha='center', va='top')
|
| 119 |
|
|
@@ -177,8 +175,11 @@ def draw_filtered_kspace(filtered_k):
|
|
| 177 |
|
| 178 |
def draw_mri(mri_result):
|
| 179 |
fig, ax = plt.subplots(figsize=(4, 4))
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
| 182 |
ax.axis('off')
|
| 183 |
return get_image_from_plot(fig)
|
| 184 |
|
|
@@ -329,10 +330,12 @@ with col_main:
|
|
| 329 |
col_anim1, col_anim2 = st.columns([1, 1])
|
| 330 |
with col_anim1:
|
| 331 |
img1_ph = st.empty()
|
| 332 |
-
|
|
|
|
| 333 |
with col_anim2:
|
| 334 |
img2_ph = st.empty()
|
| 335 |
-
|
|
|
|
| 336 |
|
| 337 |
st.markdown("""
|
| 338 |
---
|
|
|
|
| 16 |
<style>
|
| 17 |
/* CSS แก้ปัญหาการสั่นของหน้าจอ */
|
| 18 |
.stApp { transition: none !important; }
|
|
|
|
|
|
|
| 19 |
html, body, [class*="st-"] {
|
| 20 |
font-size: 18px;
|
| 21 |
}
|
|
|
|
| 111 |
|
| 112 |
# ตัวอักษรบอกทิศทาง +kx, -kx, +ky, -ky (อยู่นอกกรอบ)
|
| 113 |
ax.text(1.1, 0, '+kx', fontsize=20, fontweight='bold', va='center')
|
| 114 |
+
ax.text(-1.2, 0, '-kx', fontsize=20, fontweight='bold', va='center', ha='right')
|
| 115 |
ax.text(0, 1.1, '+ky', fontsize=20, fontweight='bold', ha='center')
|
| 116 |
ax.text(0, -1.1, '-ky', fontsize=20, fontweight='bold', ha='center', va='top')
|
| 117 |
|
|
|
|
| 175 |
|
| 176 |
def draw_mri(mri_result):
|
| 177 |
fig, ax = plt.subplots(figsize=(4, 4))
|
| 178 |
+
if np.max(mri_result) > 0:
|
| 179 |
+
vmax = np.percentile(mri_result, 99.5) # ตัด noise สว่างจ้าออก เพื่อให้เนื้อสมองสว่างขึ้น
|
| 180 |
+
else:
|
| 181 |
+
vmax = 1
|
| 182 |
+
ax.imshow(np.flipud(mri_result), cmap='gray', vmin=0, vmax=vmax)
|
| 183 |
ax.axis('off')
|
| 184 |
return get_image_from_plot(fig)
|
| 185 |
|
|
|
|
| 330 |
col_anim1, col_anim2 = st.columns([1, 1])
|
| 331 |
with col_anim1:
|
| 332 |
img1_ph = st.empty()
|
| 333 |
+
# นำ use_container_width=True ออกเพื่อล็อกขนาดภาพไม่ให้สั่น
|
| 334 |
+
img1_ph.image(draw_pulse_sequence(st.session_state.fill_step, total_anim_steps))
|
| 335 |
with col_anim2:
|
| 336 |
img2_ph = st.empty()
|
| 337 |
+
# นำ use_container_width=True ออกเพื่อล็อกขนาดภาพไม่ให้สั่น
|
| 338 |
+
img2_ph.image(draw_kspace_filling(st.session_state.fill_step, total_anim_steps))
|
| 339 |
|
| 340 |
st.markdown("""
|
| 341 |
---
|