Skip to content

Commit 4da9c79

Browse files
Update tooltips
1 parent a0cb807 commit 4da9c79

File tree

3 files changed

+98
-76
lines changed

3 files changed

+98
-76
lines changed

micro_sam/sam_annotator/_tooltips.py

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,52 @@
33

44
tooltips = {
55
"embedding": {
6-
"custom_weights": "Select a path for custom weights.",
6+
"custom_weights": "Select custom model weights. For example for a model you have finetuned",
77
"device": "Select the computational device to use for processing.",
8-
"embeddings_save_path": "Path to save the computed image embeddings.",
9-
"halo": """Enter values to activate halo. Only x value for quadratic halo and both for custom.
10-
Only active when tiling is active.""",
11-
"image": "Select an image to segment objects.",
12-
"model": "Select a model to use for segmentation tasks.",
13-
"prefer_decoder": "Choose if to use segmentation decoder.",
14-
"run_button": "Compute embeddings or load embeddings if embeddings file path is specified.",
15-
"settings": "",
16-
"tiling": "Enter values to activate tiling. Only x-value for quadratic tiling or both values for custom tiling.",
17-
# ... other tooltips for embedding widgets ...
8+
"embeddings_save_path": "Select path to save or load the computed image embeddings.",
9+
"halo": "Enter overlap values for computing tiled embeddings. Enter only x-value for quadratic size.\n Only active when tiling is used.",
10+
"image": "Select the napari image layer.",
11+
"model": "Select the segment anything model.",
12+
"prefer_decoder": "Choose if the segmentation decoder is used for automatic segmentation. Only if it is available for the selected model..",
13+
"run_button": "Compute embeddings or load embeddings if embedding_save_path is specified.",
14+
"tiling": "Enter tile size for computing tiled embeddings. Enter only x-value for quadratic size or both for non-quadratic.",
1815
},
1916
"segmentnd": {
20-
"box_extension": "box_extension",
21-
"custom_weights": "Path to the file containing pre-trained weights for the segmentation model.",
22-
"iou_threshold": "iou_threshold",
23-
"motion_smoothing": "motion_smoothing",
24-
"projection_dropdown": "projection dropdown",
25-
"settings": "",
26-
# ... other tooltips for segmentation widgets ...
17+
"box_extension": "Enter factor by which box size is increased when projecting to adjacent slices. Larger factors help if object sizes change between slices.",
18+
"iou_threshold": "Enter the minimal overlap between objects in adjacent slices to continue segmentation.",
19+
"motion_smoothing": "Enter the motion smoothing factor. It is used to follow objects which have a directed movement, higher values help for objects that are moving fast.",
20+
"projection_dropdown": "Choose the projection mode. It determines which prompts are derived from the masks projected to adjacent frames to rerun SAM.",
2721
},
2822
"autosegment": {
29-
"apply_to_volume": "apply_to_volume",
30-
"boundary_distance_thresh": "boundary_distance_thresh",
31-
"box_nms_thresh": "box_nms_thresh",
32-
"center_distance_thresh": "center_distance_thresh",
33-
"gap_closing": "gap_closing",
34-
"min_extent": "min_extent",
35-
"min_object_size": "min_object_size",
36-
"pred_iou_thresh": "pred_iou_thresh",
23+
# General settings.
24+
"apply_to_volume": "Choose if automatic segmentation is run for the full volume or only the current slice.",
25+
"gap_closing": "Enter value for closing gaps across slices for volumetric segmentation. Higher values will reduce artifacts due to missing slices in objects but may lead to wrongly merging objects.",
26+
"min_extent": "Enter the minimal number of slices for objects in volumetric segmentation. To filter out small segmentation artifacts.",
27+
"min_object_size": "Enter the minimal object size in pixels. This refers to the size per slice for volumetric segmentation.",
3728
"run_button": "Run automatic segmentation.",
38-
"stability_score_thresh": "stability_score_thresh",
39-
"with_background": "with_background",
40-
# ... tooltips for autosegment widgets ...
41-
},
42-
"segment": {
43-
"run_button": "run_button",
29+
"with_background": "Choose if your image has a large background area.",
30+
# Settings for AIS.
31+
"boundary_distance_thresh": "Enter the boundary distance threshold.",
32+
"center_distance_thresh": "Enter the center distance threshold.",
33+
# Settings for AMG.
34+
"box_nms_thresh": "Enter the non-maximum suppression threshold.",
35+
"pred_iou_thresh": "Enter the threshold for filtering objects based on the predicted IOU.",
36+
"stability_score_thresh": "Enter the threshold for filtering objects based on the stability score.",
4437
},
4538
"prompt_menu": {
46-
"labels": "Choose positive prompts to inlcude regions or negative ones to exclude regions.",
39+
"labels": "Choose positive prompts to inlcude regions or negative ones to exclude regions. Toggle between the settings by pressing [t].",
4740
},
4841
"annotator_tracking": {
49-
"track_id": "track_id",
50-
"track_state": "track_state",
42+
"track_id": "Select the id of the track you are currently annotating.",
43+
"track_state": "Select the state of the current annotation. Choose 'division' if the object is dviding in the current frame.",
44+
},
45+
"image_series_annotator": {
46+
"folder": "Select the folder with the images to annotate.",
47+
"output_folder": "Select the folder for saving the segmentation results.",
48+
"pattern": "Select a pattern for selecting files. E.g. '*.tif' to only select tif files. By default all files in the input folder are selected.",
49+
"is_volumetric": "Choose if the data you annotate is volumetric.",
5150
},
51+
# TODO update these once we have finalized the names in the widget.
5252
"training": {
5353
"checkpoint": "checkpoint",
5454
"device": "device",
@@ -62,23 +62,21 @@
6262
"raw_path": "raw_path",
6363
"raw_path_val": "raw_path_val",
6464
"segmentation_decoder": "segmentation_decoder",
65-
"setting": "setting"
66-
}
65+
},
6766
}
6867

6968

70-
def get_tooltip(widget_type, name):
71-
"""
72-
Retrieves the tooltip for a given parameter name within a specific widget type.
69+
def get_tooltip(widget_type: str, name: str) -> str:
70+
"""Retrieves the tooltip for a given parameter name within a specific widget type.
7371
7472
Args:
75-
widget_type (str): The type of widget (e.g., "embedding", "segmentation").
76-
name (str): The name of the parameter to get the tooltip for.
73+
widget_type: The type of widget (e.g., "embedding", "segmentation").
74+
name: The name of the parameter to get the tooltip for.
7775
7876
Returns:
79-
str: The tooltip string, or None if not found.
77+
The tooltip string, or None if not found.
8078
"""
8179
if widget_type in tooltips:
8280
return tooltips[widget_type].get(name)
8381
else:
84-
return None # Handle cases where the widget type is not found
82+
return None # Handle cases where the widget type is not found

micro_sam/sam_annotator/_widgets.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,19 @@ def clear(viewer: "napari.viewer.Viewer") -> None:
305305
"""Widget for clearing the current annotations.
306306
307307
Args:
308-
viewer (napari.viewer.Viewer): _description_
308+
viewer: The napari viewer.
309309
"""
310310
vutil.clear_annotations(viewer)
311311

312312

313313
@magic_factory(call_button="Clear Annotations [Shift + C]")
314314
def clear_volume(viewer: "napari.viewer.Viewer", all_slices: bool = True) -> None:
315-
"""Widget for clearing the current annotations in 3D."""
315+
"""Widget for clearing the current annotations in 3D.
316+
317+
Args:
318+
viewer: The napari viewer.
319+
all_slices: Choose whether to clear the annotations for all or only the current slice.
320+
"""
316321
if all_slices:
317322
vutil.clear_annotations(viewer)
318323
else:
@@ -322,7 +327,12 @@ def clear_volume(viewer: "napari.viewer.Viewer", all_slices: bool = True) -> Non
322327

323328
@magic_factory(call_button="Clear Annotations [Shift + C]")
324329
def clear_track(viewer: "napari.viewer.Viewer", all_frames: bool = True) -> None:
325-
"""Widget for clearing all tracking annotations and state."""
330+
"""Widget for clearing all tracking annotations and state.
331+
332+
Args:
333+
viewer: The napari viewer.
334+
all_frames: Choose whether to clear the annotations for all or only the current frame.
335+
"""
326336
if all_frames:
327337
_reset_tracking_state(viewer)
328338
vutil.clear_annotations(viewer)
@@ -468,9 +478,11 @@ def commit(
468478
"""Widget for committing the segmented objects from automatic or interactive segmentation.
469479
470480
Args:
471-
viewer (napari.viewer.Viewer): _description_
472-
layer (str, optional): _description_. Defaults to "current_object".
473-
commit_path (Optional[Path], optional): _description_. Defaults to None.
481+
viewer: The napari viewer.
482+
layer: Select the layer to commit. Can be either 'current_object' to commit interacitve segmentation results.
483+
Or 'auto_segmentation' to commit automatic segmentation results.
484+
commit_path: Select a file path where the committed results and prompts will be saved.
485+
This feature is still experimental.
474486
"""
475487
_, seg, mask, bb = _commit_impl(viewer, layer)
476488

@@ -497,12 +509,14 @@ def commit_track(
497509
layer: str = "current_object",
498510
commit_path: Optional[Path] = None,
499511
) -> None:
500-
"""Widget for committing the segmented objects from interactive tracking.
512+
"""Widget for committing the objects from interactive tracking.
501513
502514
Args:
503-
viewer (napari.viewer.Viewer): _description_
504-
layer (str, optional): _description_. Defaults to "current_object".
505-
commit_path (Optional[Path], optional): _description_. Defaults to None.
515+
viewer: The napari viewer.
516+
layer: Select the layer to commit. Can be either 'current_object' to commit interacitve segmentation results.
517+
Or 'auto_segmentation' to commit automatic segmentation results.
518+
commit_path: Select a file path where the committed results and prompts will be saved.
519+
This feature is still experimental.
506520
"""
507521
# Commit the segmentation layer.
508522
id_offset, seg, mask, bb = _commit_impl(viewer, layer)
@@ -560,7 +574,7 @@ def settings_widget(
560574
"""Widget to update global micro_sam settings.
561575
562576
Args:
563-
cache_directory (Optional[Path], optional): _description_. Defaults to util.get_cache_directory().
577+
cache_directory: Select the path for the micro_sam cache directory. `$HOME/.cache/micro_sam`.
564578
"""
565579
os.environ["MICROSAM_CACHEDIR"] = str(cache_directory)
566580
print(f"micro-sam cache directory set to: {cache_directory}")
@@ -662,15 +676,11 @@ def _validate_prompts(viewer: "napari.viewer.Viewer") -> bool:
662676

663677
@magic_factory(call_button="Segment Object [S]")
664678
def segment(viewer: "napari.viewer.Viewer", batched: bool = False) -> None:
665-
"""_summary_
679+
"""Segment object(s) for the current prompts.
666680
667681
Args:
668-
viewer (napari.viewer.Viewer): _description_
669-
batched (bool, optional): _description_. Defaults to False.
670-
call_button: run code
671-
672-
Returns:
673-
_type_: _description_
682+
viewer: The napari viewer.
683+
batched: Choose if you want to segment multiple objects with point prompts.
674684
"""
675685
if _validate_embeddings(viewer):
676686
return None
@@ -701,6 +711,11 @@ def segment(viewer: "napari.viewer.Viewer", batched: bool = False) -> None:
701711

702712
@magic_factory(call_button="Segment Slice [S]")
703713
def segment_slice(viewer: "napari.viewer.Viewer") -> None:
714+
"""Segment object for to the current prompts.
715+
716+
Args:
717+
viewer: The napari viewer.
718+
"""
704719
if _validate_embeddings(viewer):
705720
return None
706721
if _validate_prompts(viewer):
@@ -735,13 +750,10 @@ def segment_slice(viewer: "napari.viewer.Viewer") -> None:
735750

736751
@magic_factory(call_button="Segment Frame [S]")
737752
def segment_frame(viewer: "napari.viewer.Viewer") -> None:
738-
"""_summary_
753+
"""Segment object for the current prompts.
739754
740755
Args:
741-
viewer (napari.viewer.Viewer): _description_
742-
743-
Returns:
744-
_type_: _description_
756+
viewer: The napari viewer.
745757
"""
746758
if _validate_embeddings(viewer):
747759
return None

micro_sam/sam_annotator/image_series_annotator.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .annotator_3d import Annotator3d
2121
from ._state import AnnotatorState
2222
from .util import _sync_embedding_widget
23+
from ._tooltips import get_tooltip
2324

2425

2526
def _precompute(
@@ -291,14 +292,16 @@ def _create_options(self):
291292
self.folder = None
292293
_, layout = self._add_path_param(
293294
"folder", self.folder, "directory",
294-
title="Input Folder", placeholder="Folder with images ..."
295+
title="Input Folder", placeholder="Folder with images ...",
296+
tooltip=get_tooltip("image_series_annotator", "folder")
295297
)
296298
self.layout().addLayout(layout)
297299

298300
self.output_folder = None
299301
_, layout = self._add_path_param(
300302
"output_folder", self.output_folder, "directory",
301-
title="Output Folder", placeholder="Folder to save the results ..."
303+
title="Output Folder", placeholder="Folder to save the results ...",
304+
tooltip=get_tooltip("image_series_annotator", "output_folder")
302305
)
303306
self.layout().addLayout(layout)
304307

@@ -307,6 +310,7 @@ def _create_options(self):
307310
model_options = [model for model in model_options if not model.endswith("decoder")]
308311
_, layout = self._add_choice_param(
309312
"model_type", self.model_type, model_options, title="Model:",
313+
tooltip=get_tooltip("embedding", "model")
310314
)
311315
self.layout().addLayout(layout)
312316

@@ -316,39 +320,47 @@ def _create_settings(self):
316320

317321
self.pattern = "*"
318322
_, layout = self._add_string_param(
319-
"", self.pattern,
323+
"", self.pattern, tooltip=get_tooltip("image_series_annotator", "pattern")
320324
)
321325
setting_values.layout().addLayout(layout)
322326

323327
self.is_volumetric = False
324-
setting_values.layout().addWidget(self._add_boolean_param("is_volumetric", self.is_volumetric))
328+
setting_values.layout().addWidget(self._add_boolean_param(
329+
"is_volumetric", self.is_volumetric, tooltip=get_tooltip("image_series_annotator", "is_volumetric")
330+
))
325331

326332
self.device = "auto"
327333
device_options = ["auto"] + util._available_devices()
328-
self.device_dropdown, layout = self._add_choice_param("device", self.device, device_options)
334+
self.device_dropdown, layout = self._add_choice_param(
335+
"device", self.device, device_options, tooltip=get_tooltip("embedding", "device")
336+
)
329337
setting_values.layout().addLayout(layout)
330338

331339
self.embeddings_save_path = None
332340
_, layout = self._add_path_param(
333-
"embeddings_save_path", self.embeddings_save_path, "directory", title="embeddings save path:"
341+
"embeddings_save_path", self.embeddings_save_path, "directory", title="embeddings save path:",
342+
tooltip=get_tooltip("embedding", "embeddings_save_path")
334343
)
335344
setting_values.layout().addLayout(layout)
336345

337346
self.custom_weights = None # select_file
338347
_, layout = self._add_path_param(
339-
"custom_weights", self.custom_weights, "file", title="custom weights path:"
348+
"custom_weights", self.custom_weights, "file", title="custom weights path:",
349+
tooltip=get_tooltip("embedding", "custom_weights")
340350
)
341351
setting_values.layout().addLayout(layout)
342352

343353
self.tile_x, self.tile_y = 0, 0
344354
self.tile_x_param, self.tile_y_param, layout = self._add_shape_param(
345-
("tile_x", "tile_y"), (self.tile_x, self.tile_y), min_val=0, max_val=2048, step=16
355+
("tile_x", "tile_y"), (self.tile_x, self.tile_y), min_val=0, max_val=2048, step=16,
356+
tooltip=get_tooltip("embedding", "tiling")
346357
)
347358
setting_values.layout().addLayout(layout)
348359

349360
self.halo_x, self.halo_y = 0, 0
350361
self.halo_x_param, self.halo_y_param, layout = self._add_shape_param(
351-
("halo_x", "halo_y"), (self.halo_x, self.halo_y), min_val=0, max_val=512
362+
("halo_x", "halo_y"), (self.halo_x, self.halo_y), min_val=0, max_val=512,
363+
tooltip=get_tooltip("embedding", "halo")
352364
)
353365
setting_values.layout().addLayout(layout)
354366

0 commit comments

Comments
 (0)