Pre initialize plugins value at running napari viewer
kmilo9999 opened this issue · 3 comments
Hello,
I was wondering if it's possible to open Napari in Python with the CellSeg3D plugin already loaded. If so, can some of the values in the inference tab be pre-initialized?
Hello @kmilo9999,
Yes that is possible, and fairly easy actually, you just need to manually set the values for the UI elements.
For inference you can find the UI code here ; from there you can manually set the values for what you need, and add the preset widget to the viewer.
You can do so using code like this :
import napari
from napari_cellseg3d.code_plugins.plugin_model_inference import Inferer
### Create viewer & widget
viewer = napari.Viewer()
widget = Inferer(viewer)
### Set the options you'd like
widget.model_choice.setCurrentIndex(1)
widget.use_window_choice.setChecked(True)
widget.use_instance_choice.setChecked(True)
### Add the widget to the viewer and run napari
viewer.window.add_dock_widget(widget, area='right')
napari.run()
Note that using this you can also programmatically add your layer, set the save path and start the inference. So you can fully script the plugin this way :)
Let me know if you have any question about the code or if anything goes wrong and I can try to help.
Thanks and best regards,
Cyril
This is great! Thank you so much!
Glad to help ! I will go ahead and close this, but please feel free to reopen if you need any help.
Best,
Cyril