LiangLabUMB commited on
Commit
5629399
·
verified ·
1 Parent(s): 3c037f1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -1354,8 +1354,10 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1354
 
1355
  use_min_filter = gr.Checkbox(
1356
  label="Enable minimum size filter",
1357
- value=False,
1358
- info="Remove objects smaller than the threshold below"
 
 
1359
  )
1360
  min_size_slider = gr.Slider(
1361
  minimum=0,
@@ -1363,7 +1365,7 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1363
  value=0,
1364
  step=10,
1365
  label="Minimum Cell Size (pixels)",
1366
- interactive=False,
1367
  )
1368
  min_size_recommendation = gr.Markdown(
1369
  value="*Run segmentation to see recommended minimum*",
@@ -1396,11 +1398,11 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1396
  gr.Markdown("### Stereological Counting")
1397
  use_stereo = gr.Checkbox(
1398
  label="Enable Stereological Counting",
1399
- value=False,
1400
  info="Applied to the segmentation above — no re-segmenting needed"
1401
  )
1402
 
1403
- with gr.Group(visible=False) as stereo_controls:
1404
  gr.Markdown("""
1405
  **Stereological Counting Rules:**
1406
  - Cells touching LEFT or TOP exclusion zones are EXCLUDED
@@ -1416,7 +1418,7 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1416
  left_excl = gr.Slider(
1417
  minimum=0,
1418
  maximum=50,
1419
- value=10,
1420
  step=1,
1421
  label="Left Exclusion Width (%)",
1422
  info="Width of left exclusion zone"
@@ -1425,7 +1427,7 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1425
  top_excl = gr.Slider(
1426
  minimum=0,
1427
  maximum=50,
1428
- value=10,
1429
  step=1,
1430
  label="Top Exclusion Width (%)",
1431
  info="Width of top exclusion zone"
@@ -1471,6 +1473,21 @@ def build_tab(tab_index, masks_state, image_state, result_state):
1471
 
1472
  # ---- Event handlers ------------------------------------------------
1473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1474
  use_stereo.change(
1475
  fn=toggle_stereological_mode,
1476
  inputs=[use_stereo],
 
1354
 
1355
  use_min_filter = gr.Checkbox(
1356
  label="Enable minimum size filter",
1357
+ value=True,
1358
+ info="Remove objects smaller than the threshold below. "
1359
+ "At 0 the app uses its own recommendation "
1360
+ "(25th percentile of detected object sizes)."
1361
  )
1362
  min_size_slider = gr.Slider(
1363
  minimum=0,
 
1365
  value=0,
1366
  step=10,
1367
  label="Minimum Cell Size (pixels)",
1368
+ interactive=True,
1369
  )
1370
  min_size_recommendation = gr.Markdown(
1371
  value="*Run segmentation to see recommended minimum*",
 
1398
  gr.Markdown("### Stereological Counting")
1399
  use_stereo = gr.Checkbox(
1400
  label="Enable Stereological Counting",
1401
+ value=True,
1402
  info="Applied to the segmentation above — no re-segmenting needed"
1403
  )
1404
 
1405
+ with gr.Group(visible=True) as stereo_controls:
1406
  gr.Markdown("""
1407
  **Stereological Counting Rules:**
1408
  - Cells touching LEFT or TOP exclusion zones are EXCLUDED
 
1418
  left_excl = gr.Slider(
1419
  minimum=0,
1420
  maximum=50,
1421
+ value=1,
1422
  step=1,
1423
  label="Left Exclusion Width (%)",
1424
  info="Width of left exclusion zone"
 
1427
  top_excl = gr.Slider(
1428
  minimum=0,
1429
  maximum=50,
1430
+ value=1,
1431
  step=1,
1432
  label="Top Exclusion Width (%)",
1433
  info="Width of top exclusion zone"
 
1473
 
1474
  # ---- Event handlers ------------------------------------------------
1475
 
1476
+ def on_model_change(model_choice):
1477
+ """Hemocytometer counting is only unbiased with the stereological
1478
+ rules applied, so selecting that model turns them on. Left as a
1479
+ normal checkbox rather than locked, so the setting can still be
1480
+ switched off deliberately."""
1481
+ if model_choice == "Hemocytometer Model":
1482
+ return gr.update(value=True), gr.update(visible=True)
1483
+ return gr.update(), gr.update()
1484
+
1485
+ model_dropdown.change(
1486
+ fn=on_model_change,
1487
+ inputs=[model_dropdown],
1488
+ outputs=[use_stereo, stereo_controls]
1489
+ )
1490
+
1491
  use_stereo.change(
1492
  fn=toggle_stereological_mode,
1493
  inputs=[use_stereo],