Image 1 of 1: ‘A diagram comparing the array of numbers and image display for a simplified image of an arrow’
Figure 2
Image 1 of 1: ‘A screenshot of a 2D image of human cells undergoing mitosis in Napari’
Figure 3
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
Let’s remove the mitosis image by clicking the remove layer button
at
the top right of the layer list. Then, let’s open a new 3D image: File > Open Sample > napari builtins > Brain (3D)
Figure 4
Image 1 of 1: ‘A screenshot of a head X-ray in Napari’
Figure 5
Image 1 of 1: ‘A diagram comparing 2D and 3D image arrays’
Figure 6
Image 1 of 1: ‘A screenshot of a fluorescence microscopy image of some cells in Napari’
Figure 7
Image 1 of 1: ‘A diagram showing different kinds of channels for a 4x4 image of a cell e.g. red / green / surface height / elasticity’
Figure 8
Image 1 of 1: ‘A screenshot of Napari's layer list, showing two image layers named 'nuclei' and 'membrane'’
Figure 9
Image 1 of 1: ‘A diagram comparing image arrays with three (z, y, x) and four (c, z, y, x) dimensions’
Figure 10
Image 1 of 1: ‘A screenshot of Napari's eye button’
Channels can be easily shown/hidden with the
icons
Figure 11
Image 1 of 1: ‘A screenshot of a 2D time series in Napari’
Figure 12
Image 1 of 2: ‘A screenshot of Napari's play button’
Image 2 of 2: ‘A screenshot of Napari's stop button’
This image is a 2D time series (tyx) of some human cells undergoing
mitosis. The slider at the bottom now moves through time, rather than z
or channels. Try moving the slider from left to right - you should see
some nuclei divide and the total number of nuclei increase. You can also
press the small icon at
the left side of the slider to automatically move along it. The icon
will change into a - pressing
this will stop the movement.
Figure 13
Image 1 of 1: ‘A diagram of a tyx image array’
Figure 14
Image 1 of 1: ‘A screenshot of Napari's roll dimensions button’
What do each of those dimensions represent? (e.g. t, c, z, y, x)
Hint: try using the roll dimensions button
to view different combinations of axes.
Figure 15
Image 1 of 1: ‘A screenshot of Napari's roll dimensions button’
If we press the roll dimensions button
once, we can see an image of various cells and nuclei. Moving the slider
labelled ‘-4’ seems to move up and down in this image (i.e. the z axis),
while moving the slider labelled ‘-1’ changes between highlighting
different features like nuclei and cell edges (i.e. channels).
Therefore, the remaining two axes (-3 and -2) must be y and x. This
means the image’s 4 dimensions are (z, y, x, c)
Figure 16
Image 1 of 1: ‘A screenshot of an H+E slide of skin layers in Napari’
Figure 17
Image 1 of 1: ‘A screenshot of an H+E slide of skin layers in Napari, highlighting the (R,G,B) values’
Figure 18
Image 1 of 1: ‘A screenshot of Napari's eye button’
This shows the red, green and blue channels as separate image layers.
Try inspecting each one individually by clicking the icons to
hide the other layers.
Figure 19
Image 1 of 1: ‘A screenshot of a colorwheel in Napari’
Figure 20
Image 1 of 1: ‘RGB histogram of the Napari Skin sample image’
Figure 21
Image 1 of 1: ‘Diagram of (R, G, B) values next to corresponding colours’
Image 1 of 1: ‘A screenshot of yeast sample data shown in Napari’
Figure 2
Image 1 of 1: ‘Screenshot of metadata printed to Napari's console’
Figure 3
Image 1 of 1: ‘Yeast image shown in Napari with layer 2 twice as big in y and x’
Figure 4
Image 1 of 1: ‘Yeast image shown in Napari with layer 2 twice as big in y’
Figure 5
Image 1 of 1: ‘Yeast image shown in Napari with all layers half size in y/x’
Figure 6
Image 1 of 1: ‘Diagram of a line of 30 pixels - 10 with pixel value 50, then 10 with pixel value 100, then 10 with pixel value 150’
Figure 7
Image 1 of 1: ‘A screenshot of Napari's eye button’
Open all four images in Napari. Zoom in very close to a bright
nucleus, and try showing / hiding different layers with the icon. How
do they differ? How does each compare to timepoint 30 of the original
‘00001_01.ome’ image?
Figure 8
Image 1 of 1: ‘Diagram of an image pyramid with three resolution levels’
Image 1 of 1: ‘Left - the nuclei from Napari's Cells (3D+2Ch) sample image. Right - same image with added gaussian noise’
Figure 2
Image 1 of 1: ‘Diagram of a low signal-to-noise scenario. Left - histogram with no noise. Middle - histogram with added noise (separate histograms). Right - histogram with added noise (combined histogram).’
Figure 3
Image 1 of 1: ‘Diagram of a high signal-to-noise scenario. Left - histogram with no noise. Middle - histogram with added noise (separate histograms). Right - histogram with added noise (combined histogram).’
Figure 4
Image 1 of 1: ‘Diagram highlighting some of the trade-offs of increasing spatial resolution’
Figure 5
Image 1 of 1: ‘A 16x16 image of a grayscale circle’
Figure 6
Image 1 of 1: ‘An 8x8 image of a grayscale circle’
Figure 7
Image 1 of 1: ‘Left - a diagram of two round cells (blue, 10 micrometre wide) overlaid by a perfectly aligned 10 micrometre pixel grid. Right - the equivalent image with a grayscale colormap’
Figure 8
Image 1 of 1: ‘Left - a diagram of two round cells (blue, 10 micrometre wide) overlaid by a misaligned 10 micrometre pixel grid. Right - the equivalent image with a grayscale colormap’
Figure 9
Image 1 of 1: ‘Left - a diagram of two round cells (blue, 10 micrometre wide) overlaid by a 5 micrometre pixel grid. Right - the equivalent image with a grayscale colormap’
Figure 10
Image 1 of 1: ‘Top - a diagram of six round cells (blue, 5 micrometre wide) overlaid by a 10 micrometre pixel grid. Bottom - the equivalent image with a grayscale colormap’
Figure 11
Image 1 of 1: ‘Diagram of four example acquisition image histograms (labelled a-d)’
Image 1 of 1: ‘A screenshot of a fluorescence microscopy image of some cells in Napari’
Figure 2
Image 1 of 2: ‘A screenshot of napari-matplotlib's zoom button’
Image 2 of 2: ‘A screenshot of napari-matplotlib's home button’
If you need a refresher on how to use napari matplotlib,
check out the image display
episode. It may also be useful to zoom into parts of the image
histogram by clicking the
icon at the top of histogram, then clicking and dragging a box around
the region you want to zoom into. You can reset your histogram by
clicking the
icon.
Figure 3
Image 1 of 1: ‘A histogram of the 29th z slice of Napari's cell sample image’
Figure 4
Image 1 of 1: ‘A screenshot of napari-matplotlib's zoom button’
If we look at the brightest part of the image, near z=29, we can see
that there are indeed pixel values over much of this possible range. At
first glance, it may seem like there are no values at the right side of
the histogram, but if we zoom in using the
icon we can clearly see pixels at these higher values.
Figure 5
Image 1 of 1: ‘A histogram of the 29th z slice of Napari's cell sample image - zoomed in to the range from 25000 to 60000’
Figure 6
Image 1 of 1: ‘A screenshot of Napari's console button’
First, let’s take a quick look at a rough semantic segmentation. Open
Napari’s console by pressing the button,
then copy and paste the code below. Don’t worry about the details of
what’s happening in the code - we’ll look at some of these concepts like
gaussian blur and otsu thresholding in later episodes!
Figure 7
Image 1 of 1: ‘A screenshot of a rough semantic segmentation of nuclei in Napari’
Figure 8
Image 1 of 1: ‘A screenshot of Napari's eye button’
You should see an image appear that highlights the nuclei in brown.
Try toggling the ‘semantic_seg’ layer on and off multiple times, by
clicking the icon next
to its name in the layer list. You should see that the brown areas match
the nucleus boundaries reasonably well.
Figure 9
Image 1 of 1: ‘A screenshot of a rough instance segmentation of nuclei in Napari’
Figure 10
Image 1 of 2: ‘A screenshot of Napari's eye button’
Image 2 of 2: ‘A screenshot of Napari's eye button’
You should see an image appear that highlights nuclei in different
colours. Let’s hide the ‘semantic_seg’ layer by clicking the icon next
to its name in Napari’s layer list. Then try toggling the ‘instance_seg’
layer on and off multiple times, by clicking the corresponding icon. You
should see that the coloured areas match most of the nucleus boundaries
reasonably well, although there are some areas that are less well
labelled.
Figure 11
Image 1 of 1: ‘A screenshot of Napari's eye button’
Click the icon next
to ‘semantic_seg’ in the layer list to make it visible.
Figure 12
Image 1 of 1: ‘A screenshot of Napari's eye button’
Click the icon next
to ‘instance_seg’ in the layer list to hide it.
Figure 13
Image 1 of 1: ‘A screenshot highlighting the pixel value of a nuclei segmentation in Napari’
Figure 14
Image 1 of 1: ‘A screenshot of Napari's eye button’
Click the icon next
to ‘instance_seg’ in the layer list to make it visible.
Figure 15
Image 1 of 1: ‘A screenshot of Napari's eye button’
Click the icon next
to ‘semantic_seg’ in the layer list to hide it.
Figure 16
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
Click the
icon to remove these layers.
Figure 17
Image 1 of 1: ‘A screenshot of Napari's labels layer button’
Then click on the
icon (at the top of the layer list) to create a new Labels
layer.
Figure 18
Image 1 of 1: ‘A screenshot of the layer controls for labels layers in Napari’
Figure 19
Image 1 of 3: ‘A screenshot of Napari's paintbrush button’
Image 2 of 3: ‘A screenshot of Napari's pan arrows button’
Image 3 of 3: ‘A screenshot of Napari's erase button’
Let’s start by painting an individual nucleus. Select the paintbrush
by clicking the icon
in the top row of the layer controls. Then click and drag across the
image to label pixels. You can change the size of the brush using the
‘brush size’ slider in the layer controls. To return to normal movement,
you can click the icon
in the top row of the layer controls, or hold down spacebar to activate
it temporarily (this is useful if you want to pan slightly while
painting). To remove painted areas, you can activate the label eraser by
clicking the icon.
Figure 20
Image 1 of 1: ‘A screenshot of a single manually painted nucleus in Napari’
Figure 21
Image 1 of 1: ‘A screenshot of two manually painted nuclei in Napari’
Figure 22
Image 1 of 1: ‘A screenshot of Napari's shuffle button’
When you paint with a new value, you’ll see that Napari automatically
assigns it a new colour. This is because Labels layers use
a
special colormap/LUT for their pixel values. Recall from the image display episode that
colormaps are a way to convert pixel values into corresponding colours
for display. The colormap for Labels layers will assign
random colours to each pixel value, trying to ensure that nearby values
(like 2 vs 3) are given dissimilar colours. This helps to make it easier
to distinguish different labels. You can shuffle the colours used by
clicking the icon in
the top row of the layer controls. Note that the pixel value of 0 will
always be shown as transparent - this is because it is usually used to
represent the background.
Figure 23
Image 1 of 1: ‘A screenshot of Napari's fill button’
What does the icon
do?
Figure 24
Image 1 of 1: ‘A screenshot of Napari's picker button’
What does the icon
do?
Figure 25
Image 1 of 1: ‘A screenshot of Napari's fill button’
icon
Figure 26
Image 1 of 1: ‘A screenshot of Napari's picker button’
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
Make sure you only have ‘nuclei’ in the layer list. Select any
additional layers, then click the
icon to remove them. Also, select the nuclei layer (should be
highlighted in blue), and change its colormap from ‘green’ to ‘gray’ in
the layer controls.
Figure 2
Image 1 of 1: ‘A screenshot of nuclei in Napari using the gray colormap’
Figure 3
Image 1 of 1: ‘A histogram of the 29th z slice of Napari's cell sample image’
Figure 4
Image 1 of 1: ‘Left, nuclei with gray colormap. Right, histogram of the same image. Both with left contrast limit set to 8266.’
Figure 5
Image 1 of 1: ‘Left, nuclei with gray colormap. Right, histogram of the same image. Both with left contrast limit set to 28263.’
Figure 6
Image 1 of 1: ‘A screenshot of Napari's eye button’
You should see a mask appear that highlights the nuclei in brown. If
we set the nuclei contrast limits back to normal (select ‘nuclei’ in the
layer list, then drag the left contrast limits node back to zero), then
toggle on/off the mask or nuclei layers with the icon, you
should see that the brown areas match the nucleus boundaries reasonably
well. They aren’t perfect though! The brown regions have a speckled
appearance where some regions inside nuclei aren’t labelled and some
areas in the background are incorrectly labelled.
Figure 7
Image 1 of 1: ‘Mask of nuclei (brown) overlaid on nuclei image - created with manual thresholding’
Figure 8
Image 1 of 1: ‘Test image containing a rectangle, circle and triangle’
Figure 9
Image 1 of 1: ‘Histogram of the shape image’
Figure 10
Image 1 of 1: ‘Screenshot of plugin installation window for napari-skimage’
Figure 11
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
As before, make sure you only have ‘nuclei’ in the layer list. Select
any additional layers, then click the
icon to remove them. Also, select the nuclei layer (should be
highlighted in blue), and change its colormap from ‘green’ to ‘gray’ in
the layer controls.
Figure 12
Image 1 of 1: ‘Nuclei image with gray colormap’
Figure 13
Image 1 of 1: ‘Screenshot of settings for gaussian blur in Napari’
Figure 14
Image 1 of 1: ‘Nuclei image after gaussian blur with sigma of 1’
Figure 15
Image 1 of 1: ‘Nuclei image after gaussian blur with sigma of 3’
Figure 16
Image 1 of 1: ‘The mouse cursor hovers over a napari image layer named nuclei_gaussian_sigma=1.0.’
Figure 17
Image 1 of 1: ‘Small zoomed-in area of the nucleus image with a pixel highlighted in red. Around this pixel is shown a 3x3 box.’
Figure 18
Image 1 of 1: ‘Left - small area of the nucleus image with a pixel highlighted in red. Around this pixel is shown a 3x3 box. Right - example of a 3x3 kernel’
Figure 19
Image 1 of 1: ‘Plot of a 1D gaussian function comparing three different sigma values’
Figure 20
Image 1 of 1: ‘Plot of a 2D gaussian function comparing three different sigma values’
Figure 21
Image 1 of 1: ‘An example of a 5x5 gaussian kernel’
Figure 22
Image 1 of 1: ‘Diagram of gaussian function with FWHM labelled’
Figure 23
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
First, let’s clean up our layer list. Make sure you only have the
nuclei and nuclei_gaussian_sigma=3.0 layers in
the layer list - select any others and remove them by clicking the
icon. Close all filter settings panels on the right side of Napari
(apart from the gaussian settings) by clicking the tiny X
icon at their top left corner.
Figure 24
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
Let’s return to thresholding our image. Close the gaussian panel by
clicking the tiny X icon at its top left corner. Then
select the ‘blurred_mask’ in the layer list and remove it by clicking
the
icon. Finally, open the napari-matplotlib histogram again
with: Plugins > napari Matplotlib > Histogram
Figure 25
Image 1 of 1: ‘A histogram of the 29th z slice of the nuclei image after a gaussian blur. The left contrast limit is set to 0.134.’
Figure 26
Image 1 of 1: ‘Mask of nuclei (brown) overlaid on nuclei image - created with manual thresholding after gaussian blur’
Figure 27
Image 1 of 1: ‘A screenshot of Napari's delete layer button’
First, let’s clean up our layer list again. Make sure you only have
the ‘nuclei’, ‘mask’, ‘blurred_mask’ and ‘nuclei_gaussian_sigma=3.0’
layers in the layer list - select any others and remove them by clicking
the
icon. Then, if you still have the napari-matplotlib
histogram open, close it by clicking the tiny x icon in the
top left corner.
Figure 28
Image 1 of 1: ‘Mask of nuclei (brown) overlaid on nuclei image - created with Otsu thresholding after gaussian blur’
Figure 29
Image 1 of 2: ‘A screenshot of Napari's shuffle button’
Image 2 of 2: ‘A screenshot of Napari's eye button’
This should produce a mask (in a new layer ending with
‘threshold_otsu’) that is very similar to the one we created with a
manual threshold. To make it easier to compare, we can rename some of
our layers by double clicking on their name in the layer list - for
example, rename ‘mask’ to ‘manual_mask’, ‘blurred_mask’ to
‘manual_blurred_mask’, and ‘…threshold_otsu’ to ‘otsu_blurred_mask’.
Recall that you can change the colour of a mask by clicking the icon in
the top row of the layer controls. By toggling on/off the relevant icons, you
should see that Otsu chooses a slightly different threshold than we did
in our ‘manual_blurred_mask’, labelling slightly smaller regions as
nuclei in the final result.
Figure 30
Image 1 of 1: ‘Test image containing a rectangle, circle and triangle’
Figure 31
Image 1 of 1: ‘A screenshot of Napari's shuffle button’
Recall that you can change the colour of a mask by clicking the icon in
the top row of the layer controls.
Image 1 of 1: ‘A screenshot of a rough semantic segmentation of nuclei in Napari’
Figure 2
Image 1 of 1: ‘A screenshot of an instance segmentation of nuclei with some incorrectly joined instances.’
Figure 3
Image 1 of 1: ‘A screenshot of the napari-skimage Regionprops widget at startup.’
In the napari toolbar, open
Layers > Measure > Regionprops (labels) (skimage).
You should see a dialog like this:
Figure 4
Image 1 of 2: ‘Napari's hide visibility icon’
Image 2 of 2: ‘A screenshot of the numeric value table created by the napari-skimage plugin’
Click Analyze - a table of numeric values should appear
in napari. If it opens in an inconvenient location, you can click and
drag on the header containing the x, and other icons
next to the table window to reposition it.
Figure 5
Image 1 of 1: ‘A screenshot of an instance segmentation of nuclei.’
Figure 6
Image 1 of 1: ‘Napari's 2D/3D toggle’
You may remember from our first
lesson that we can change to 3D view mode by pressing the button. Try it now.
Figure 7
Image 1 of 1: ‘A screenshot of an instance segmentation of nuclei in 3D mode with some incorrectly joined instances.’
You should see the image rendered in 3D, with a clear join between the
upper most light purple nucleus and its neighbour.
Figure 8
Image 1 of 1: ‘A screenshot region-props dialog highlighting the smallest nucleus.’
Figure 9
Image 1 of 1: ‘Semantic segmentation mask eroded with a ball of radius 5.’
Some nuclei that are touching remain partially
connected.
Figure 10
Image 1 of 1: ‘Semantic segmentation mask eroded with a ball of radius 10.’
Erosion with a radius of 10 removes enough pixels to separate
touching nuclei
while still keeping the nuclei you want to analyse.
Figure 11
Image 1 of 1: ‘Semantic segmentation mask eroded with a ball of radius 15.’
Erosion with a radius of 15 is too strong: several nuclei become
over‑eroded
and some disappear completely.
Figure 12
Image 1 of 1: ‘Instance segmentation on the eroded segmentation mask’
Figure 13
Image 1 of 1: ‘Dilated instance segmentation on the eroded segmentation mask’
There are now 19 apparently correctly labelled nuclei that appear to be
the same shape as in the original mask image.
Figure 14
Image 1 of 1: ‘A comparison between the expanded instance segmentation and the original semantic segmentation showing some mismatch between the borders.’
Looking at the above image we can see some small mismatches around the
edges of most of the nuclei. It should be remembered when looking at
this image that it is a single slice though a 3D image, so in some cases
where the differences look large (for example the nucleus at the bottom
right) they may still be only one pixel deep. Will the effect of this on
the accuracy of our results be significant?
Figure 15
Image 1 of 1: ‘The instance segmentation with any nuclei crossing the image boundary removed’