Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +67 -29
src/app.py
CHANGED
|
@@ -307,7 +307,7 @@ with tab1:
|
|
| 307 |
index=0,
|
| 308 |
key="enc_scheme",
|
| 309 |
help=(
|
| 310 |
-
"**6-bit LNS** β Custom
|
| 311 |
"**Base64 (6-bit)** β Standard Base64 encoding of UTF-8 bytes. 6 bits/symbol.\n\n"
|
| 312 |
"**ASCII (7-bit)** β Standard 7-bit ASCII. 7 bits/char.\n\n"
|
| 313 |
"**UTF-8 (8-bit)** β Full UTF-8 byte encoding. 8 bits/byte. Supports all Unicode."
|
|
@@ -1063,13 +1063,13 @@ with tab3:
|
|
| 1063 |
|
| 1064 |
transform_option = st.selectbox(
|
| 1065 |
"Value transformation:",
|
| 1066 |
-
["Raw (linear)", "
|
| 1067 |
index=0,
|
| 1068 |
key="transform_select",
|
| 1069 |
help=(
|
| 1070 |
"**Raw** - No transformation.\n\n"
|
| 1071 |
-
"**
|
| 1072 |
-
"**
|
| 1073 |
)
|
| 1074 |
)
|
| 1075 |
|
|
@@ -1086,14 +1086,14 @@ with tab3:
|
|
| 1086 |
# result[col] = result[col] - med
|
| 1087 |
# return result
|
| 1088 |
|
| 1089 |
-
if transform_option == "
|
| 1090 |
transformed = np.log1p(pos_data)
|
| 1091 |
-
value_label = "Editing Value (
|
| 1092 |
-
transform_tag = "
|
| 1093 |
-
elif transform_option == "
|
| 1094 |
transformed = np.log1p(np.log1p(pos_data))
|
| 1095 |
-
value_label = "Editing Value (
|
| 1096 |
-
transform_tag = "
|
| 1097 |
# elif transform_option == "log1p β pos. norm.":
|
| 1098 |
# transformed = robust_pos_normalize_log1p(pos_data)
|
| 1099 |
# value_label = "Editing Value (log1p β pos. norm.)"
|
|
@@ -1108,33 +1108,71 @@ with tab3:
|
|
| 1108 |
lambda x: int(re.search(r"(\d+)", str(x)).group(1)) if re.search(r"(\d+)", str(x)) else 0
|
| 1109 |
)
|
| 1110 |
|
|
|
|
| 1111 |
st.markdown("#### π Histogram - All Values")
|
| 1112 |
|
| 1113 |
n_bins = st.number_input("Number of bins:", min_value=10, max_value=300, value=80, step=10, key="hist_bins")
|
| 1114 |
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
ax2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1119 |
ax2.set_title(f"Raw Values Distribution ({transform_tag})")
|
| 1120 |
-
|
| 1121 |
-
|
| 1122 |
-
|
| 1123 |
-
|
| 1124 |
-
|
| 1125 |
-
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
|
| 1131 |
-
ax2.
|
| 1132 |
-
|
| 1133 |
-
ax2.
|
| 1134 |
-
|
|
|
|
|
|
|
| 1135 |
fig2.tight_layout()
|
| 1136 |
st.pyplot(fig2)
|
| 1137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1138 |
st.markdown("#### 2οΈβ£ Density Scatter Plot")
|
| 1139 |
st.caption("Each dot = one measurement (sample Γ position). Color = local point density.")
|
| 1140 |
|
|
|
|
| 307 |
index=0,
|
| 308 |
key="enc_scheme",
|
| 309 |
help=(
|
| 310 |
+
"**6-bit LNS** β Custom 57-character table (A-Z, 0-9, punctuation). 6 bits/char.\n\n"
|
| 311 |
"**Base64 (6-bit)** β Standard Base64 encoding of UTF-8 bytes. 6 bits/symbol.\n\n"
|
| 312 |
"**ASCII (7-bit)** β Standard 7-bit ASCII. 7 bits/char.\n\n"
|
| 313 |
"**UTF-8 (8-bit)** β Full UTF-8 byte encoding. 8 bits/byte. Supports all Unicode."
|
|
|
|
| 1063 |
|
| 1064 |
transform_option = st.selectbox(
|
| 1065 |
"Value transformation:",
|
| 1066 |
+
["Raw (linear)", "ln(1+x)", "ln(ln(1+x))"],
|
| 1067 |
index=0,
|
| 1068 |
key="transform_select",
|
| 1069 |
help=(
|
| 1070 |
"**Raw** - No transformation.\n\n"
|
| 1071 |
+
"**ln(1+x)** - `ln(1 + x)`. Compresses high values, spreads low range.\n\n"
|
| 1072 |
+
"**ln(ln(1+x))** - Double ln. Even stronger compression.\n\n"
|
| 1073 |
)
|
| 1074 |
)
|
| 1075 |
|
|
|
|
| 1086 |
# result[col] = result[col] - med
|
| 1087 |
# return result
|
| 1088 |
|
| 1089 |
+
if transform_option == "ln(1+x)":
|
| 1090 |
transformed = np.log1p(pos_data)
|
| 1091 |
+
value_label = "Editing Value (ln(1+x))"
|
| 1092 |
+
transform_tag = "ln(1+x)"
|
| 1093 |
+
elif transform_option == "ln(ln(1+x))":
|
| 1094 |
transformed = np.log1p(np.log1p(pos_data))
|
| 1095 |
+
value_label = "Editing Value (ln(ln(1+x)))"
|
| 1096 |
+
transform_tag = "ln(ln(1+x))"
|
| 1097 |
# elif transform_option == "log1p β pos. norm.":
|
| 1098 |
# transformed = robust_pos_normalize_log1p(pos_data)
|
| 1099 |
# value_label = "Editing Value (log1p β pos. norm.)"
|
|
|
|
| 1108 |
lambda x: int(re.search(r"(\d+)", str(x)).group(1)) if re.search(r"(\d+)", str(x)) else 0
|
| 1109 |
)
|
| 1110 |
|
| 1111 |
+
|
| 1112 |
st.markdown("#### π Histogram - All Values")
|
| 1113 |
|
| 1114 |
n_bins = st.number_input("Number of bins:", min_value=10, max_value=300, value=80, step=10, key="hist_bins")
|
| 1115 |
|
| 1116 |
+
matplotlib.rcParams["font.family"] = "Arial"
|
| 1117 |
+
matplotlib.rcParams["font.sans-serif"] = ["Arial", "DejaVu Sans", "Liberation Sans", "sans-serif"]
|
| 1118 |
+
|
| 1119 |
+
fig2, ax2 = plt.subplots(figsize=(7, 5))
|
| 1120 |
+
all_vals = melted["Value"].values
|
| 1121 |
+
ax2.hist(all_vals, bins=n_bins, color="#808080", alpha=0.8, label="All")
|
| 1122 |
+
ax2.set_xlim(left=0.0)
|
| 1123 |
+
ax2.xaxis.set_major_locator(MultipleLocator(0.5))
|
| 1124 |
+
ax2.xaxis.set_minor_locator(MultipleLocator(0.1))
|
| 1125 |
+
ax2.tick_params(axis="x", which="major", length=6)
|
| 1126 |
+
ax2.tick_params(axis="x", which="minor", length=3)
|
| 1127 |
+
ax2.legend(fontsize=8)
|
| 1128 |
ax2.set_title(f"Raw Values Distribution ({transform_tag})")
|
| 1129 |
+
ax2.set_xlabel(value_label)
|
| 1130 |
+
ax2.set_ylabel("Counts")
|
| 1131 |
+
|
| 1132 |
+
# Apply axis styling
|
| 1133 |
+
for attr in [ax2.xaxis.label, ax2.yaxis.label, ax2.title]:
|
| 1134 |
+
attr.set_fontsize(12)
|
| 1135 |
+
attr.set_fontweight("bold")
|
| 1136 |
+
attr.set_fontfamily("Arial")
|
| 1137 |
+
for spine in ax2.spines.values():
|
| 1138 |
+
spine.set_linewidth(1.5)
|
| 1139 |
+
ax2.tick_params(axis="both", which="both", width=1.2, labelsize=10)
|
| 1140 |
+
ax2.spines['top'].set_visible(False)
|
| 1141 |
+
ax2.spines['right'].set_visible(False)
|
| 1142 |
+
for ticklab in ax2.get_xticklabels() + ax2.get_yticklabels():
|
| 1143 |
+
ticklab.set_fontfamily("Arial")
|
| 1144 |
+
ticklab.set_fontweight("normal")
|
| 1145 |
+
|
| 1146 |
fig2.tight_layout()
|
| 1147 |
st.pyplot(fig2)
|
| 1148 |
|
| 1149 |
+
# st.markdown("#### π Histogram - All Values")
|
| 1150 |
+
|
| 1151 |
+
# n_bins = st.number_input("Number of bins:", min_value=10, max_value=300, value=80, step=10, key="hist_bins")
|
| 1152 |
+
|
| 1153 |
+
# fig2, ax2 = plt.subplots(figsize=(10, 4))
|
| 1154 |
+
# ax2.hist(melted["Value"].values, bins=n_bins, color="#4F46E5", edgecolor="white", linewidth=0.3)
|
| 1155 |
+
# ax2.set_xlabel(value_label)
|
| 1156 |
+
# ax2.set_ylabel("Count")
|
| 1157 |
+
# ax2.set_title(f"Raw Values Distribution ({transform_tag})")
|
| 1158 |
+
# val_min = melted["Value"].min()
|
| 1159 |
+
# val_max = melted["Value"].max()
|
| 1160 |
+
# val_range = val_max - val_min
|
| 1161 |
+
# if val_range <= 2:
|
| 1162 |
+
# tick_step = 0.1
|
| 1163 |
+
# elif val_range <= 6:
|
| 1164 |
+
# tick_step = 0.2
|
| 1165 |
+
# elif val_range <= 20:
|
| 1166 |
+
# tick_step = 1
|
| 1167 |
+
# else:
|
| 1168 |
+
# tick_step = 5
|
| 1169 |
+
# ax2.set_xticks(np.arange(np.floor(val_min / tick_step) * tick_step,
|
| 1170 |
+
# val_max + tick_step, tick_step))
|
| 1171 |
+
# ax2.tick_params(axis='x', labelsize=8, rotation=45)
|
| 1172 |
+
# ax2.grid(axis='y', alpha=0.3)
|
| 1173 |
+
# fig2.tight_layout()
|
| 1174 |
+
st.pyplot(fig2)
|
| 1175 |
+
|
| 1176 |
st.markdown("#### 2οΈβ£ Density Scatter Plot")
|
| 1177 |
st.caption("Each dot = one measurement (sample Γ position). Color = local point density.")
|
| 1178 |
|