kaveh commited on
Commit
9f0ec64
·
1 Parent(s): 940be20

added default to substrate

Browse files
Files changed (1) hide show
  1. app.py +10 -33
app.py CHANGED
@@ -277,41 +277,18 @@ with st.sidebar:
277
  if model_type == "single_cell":
278
  try:
279
  with st.container(border=False, key="s2f_grp_conditions"):
280
- st.markdown('<p class="s2f-form-label s2f-form-label--section">Substrate setting (model input)</p>', unsafe_allow_html=True)
281
- conditions_source = st.radio(
282
- "Substrate setting",
283
- ["Reference (6 kPa)", "Preset", "Manual"],
284
- horizontal=True,
 
 
 
 
 
285
  label_visibility="collapsed",
286
- help="The released model is most accurate with the 6 kPa reference setting for all images, "
287
- "including cells on 1 or 10 kPa gels (sensitivity analysis in the paper). Other settings "
288
- "rescale the prediction and are provided for exploration only.",
289
  )
290
- if conditions_source == "Reference (6 kPa)":
291
- substrate_val = REFERENCE_SUBSTRATE
292
- st.caption("Recommended. Used for all results in the paper.")
293
- elif conditions_source == "Preset":
294
- substrate_mode_label = "preset"
295
- substrates = list_substrates()
296
- substrate_val = st.selectbox(
297
- "Preset", substrates,
298
- index=substrates.index(REFERENCE_SUBSTRATE) if REFERENCE_SUBSTRATE in substrates else 0,
299
- help="Presets from config/substrate_settings.json", label_visibility="collapsed",
300
- )
301
- if get_settings_of_category(substrate_val) != get_settings_of_category(REFERENCE_SUBSTRATE):
302
- st.warning("Settings other than the 6 kPa reference reduce accuracy (e.g. the 1 kPa setting "
303
- "makes predictions about 5 times smaller). Use for exploration only.")
304
- else:
305
- substrate_mode_label = "manual"
306
- manual_pixelsize = st.number_input("Pixel-size setting (TFM units, as in training)", min_value=0.1,
307
- max_value=50.0, value=3.0769, step=0.1, format="%.4f",
308
- help="Training used 3.0769 (fibroblasts) to 9.8138.")
309
- manual_young = st.number_input("Young's modulus (Pa)", min_value=100.0, max_value=100000.0,
310
- value=6000.0, step=100.0, format="%.0f")
311
- substrate_config = {"pixelsize": manual_pixelsize, "young": manual_young}
312
- use_manual = True
313
- if (abs(manual_pixelsize - 3.0769) > 1e-3) or manual_young != 6000.0:
314
- st.warning("Settings other than the 6 kPa reference reduce accuracy. Use for exploration only.")
315
  except FileNotFoundError:
316
  st.error("config/substrate_settings.json not found")
317
 
 
277
  if model_type == "single_cell":
278
  try:
279
  with st.container(border=False, key="s2f_grp_conditions"):
280
+ st.markdown('<p class="s2f-form-label s2f-form-label--section">Substrate</p>', unsafe_allow_html=True)
281
+ substrate_mode_label = "preset"
282
+ substrates = list_substrates()
283
+ if REFERENCE_SUBSTRATE in substrates: # the default preset is listed first
284
+ substrates = [REFERENCE_SUBSTRATE] + [s for s in substrates if s != REFERENCE_SUBSTRATE]
285
+ substrate_val = st.selectbox(
286
+ "Substrate", substrates, index=0,
287
+ format_func=lambda s: "Default (6 kPa)" if s == REFERENCE_SUBSTRATE
288
+ else get_settings_of_category(s).get("name", s),
289
+ help="Young's modulus and pixel size of the substrate, given to the model as input channels.",
290
  label_visibility="collapsed",
 
 
 
291
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  except FileNotFoundError:
293
  st.error("config/substrate_settings.json not found")
294