Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: a widget for setting Reader settings #63

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions napari_aicsimageio/_settings_widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import napari
from magicgui import magic_factory

import napari_aicsimageio.core


@magic_factory(
delimiter={"label": "Delimiter in scene labels:"},
in_mem_size={"label": "Threshold for out-of-memory loading (GB)"},
frac_mem_size={
"label": "Threshold for out-of-memory loading (<small>% free memory</small>):"
},
call_button="Apply Reader Settings and Close Widget",
psobolewskiPhD marked this conversation as resolved.
Show resolved Hide resolved
info_label=dict(
widget_type="Label",
label="<h4>For each napari session, to use the settings:<br>press the Apply button!</h4>",
),
persist=True,
)
def set_settings(
info_label: str,
napari_viewer: napari.Viewer,
delimiter: str = napari_aicsimageio.core.SCENE_LABEL_DELIMITER,
in_mem_size: float = napari_aicsimageio.core.IN_MEM_THRESHOLD_SIZE_BYTES / 1e9,
frac_mem_size: int = int(napari_aicsimageio.core.IN_MEM_THRESHOLD_PERCENT * 100),
) -> None:

napari_aicsimageio.core.SCENE_LABEL_DELIMITER = delimiter
napari_aicsimageio.core.IN_MEM_THRESHOLD_SIZE_BYTES = in_mem_size * 1e9
napari_aicsimageio.core.IN_MEM_THRESHOLD_PERCENT = frac_mem_size / 100

viewer = napari_viewer
viewer.window.remove_dock_widget(set_settings.native)
7 changes: 7 additions & 0 deletions napari_aicsimageio/napari.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ contributions:
- id: napari-aicsimageio.get_reader
title: Get AICSImageIO Reader
python_name: napari_aicsimageio.core:get_reader
- id: napari-aicsimageio.settings_widget
title: Open AICSImageIO Reader Settings
python_name: napari_aicsimageio._settings_widget:set_settings
psobolewskiPhD marked this conversation as resolved.
Show resolved Hide resolved

widgets:
- command: napari-aicsimageio.settings_widget
display_name: AICSImageIO Reader Settings
readers:
- command: napari-aicsimageio.get_reader
filename_patterns: [
Expand Down