Activating layer


how to activate a layer from code? change the current selected layer to the one that I want.

thanks, HM

You would need to do something like:

import napari
from skimage import data

viewer = napari.Viewer()
# we see the camera layer selected

# To change which layers are selected
viewer.layers[-1].selected = False  # deselect the camera layer
viewer.layers[0].selected = True  # select the astronaut layer

great got it. many thanks.
I will select by layer name because I have few layers.

viewer.layers['Image'].selected = True 

it is not easy for a matlab programer to understand function/class input/output in python

We’ll hopefully be making some improvements here in the next couple of releases, that make this easier. For anyone interested, a potential new selection model is in review here