Skip to content

Commit fb60446

Browse files
committed
markdown source builds
Auto-generated via `{sandpaper}` Source : 70164e5 Branch : main Author : Kimberly Meechan <24316371+K-Meech@users.noreply.github.com> Time : 2026-06-08 11:52:18 +0000 Message : Merge pull request #125 from HealthBioscienceIDEAS/km/axis-labels Updates for negative axis labels
1 parent 621e5ef commit fb60446

6 files changed

Lines changed: 42 additions & 15 deletions

File tree

fig/brain-napari.png

11.4 KB
Loading

fig/cells-napari.png

-595 Bytes
Loading

fig/cells-time-napari.png

1.51 KB
Loading

fig/plate1-czi-napari.png

-17.8 KB
Loading

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"episodes/imaging-software.md" "cd1002354eaf1d92c83ca9b235443593" "site/built/imaging-software.md" "2025-06-25"
88
"episodes/what-is-an-image.md" "77453b0c3031890f96104617bcd46a49" "site/built/what-is-an-image.md" "2025-11-04"
99
"episodes/image-display.md" "0d8150fdf6516bc2abb026debedfa3dd" "site/built/image-display.md" "2025-11-04"
10-
"episodes/multi-dimensional-images.md" "e723d61ca973be7d6e8ea118fa4679a5" "site/built/multi-dimensional-images.md" "2025-10-29"
10+
"episodes/multi-dimensional-images.md" "36d8d27a775bf837aaa3cf77791779fa" "site/built/multi-dimensional-images.md" "2026-06-08"
1111
"episodes/filetypes-and-metadata.md" "da960d27ce829282421cd9d27c223821" "site/built/filetypes-and-metadata.md" "2025-10-29"
1212
"episodes/designing-a-light-microscopy-experiment.md" "9a236fbc9a48f560a786077ea9662c9c" "site/built/designing-a-light-microscopy-experiment.md" "2025-11-04"
1313
"episodes/choosing-acquisition-settings.md" "1bf362eeea03fe66d4e170d9803dc649" "site/built/choosing-acquisition-settings.md" "2024-08-16"

multi-dimensional-images.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,33 @@ array:
112112
![](fig/2d-3d-arrays.png){alt="A diagram comparing 2D and
113113
3D image arrays" width='80%'}
114114

115-
In Napari (and Python in general), dimensions are referred to by their index
116-
e.g. here dimension 0 is the z axis, dimension 1 is the y axis and dimension 2
117-
is the x axis. We can check this in Napari by looking at the number at the very
118-
left of the slider. Here it's labelled '0', showing that it controls movement
119-
along dimension 0 (i.e. the z axis).
115+
In Napari (and Python in general), dimensions are referred to by their 'index',
116+
which is an integer assigned to each position. The first dimension has an index
117+
of 0, the second an index of 1 and so on...
118+
119+
For our 3D image:
120+
121+
- **Shape**: (10, 256, 256)
122+
- **Axis**: (z, y, x)
123+
- **Index**: (0, 1, 2)
124+
125+
We can also use negative numbers for the index, in which case it counts
126+
backwards from the last dimension:
127+
128+
- **Shape**: (10, 256, 256)
129+
- **Axis**: (z, y, x)
130+
- **Index**: (-3, -2, -1)
131+
132+
Napari uses a negative index in most places e.g. if you look at the number at
133+
the very left of the slider, it is labelled '-3'. This shows it controls
134+
movement along dimension -3 (i.e. the z axis).
120135

121136
:::::::::::::::::::::::::::::::::::::: callout
122137

123138
## Axis labels
124139

125140
By default, sliders will be labelled by the index of the dimension they move
126-
along e.g. 0, 1, 2... Note that it is possible to re-name these though! For
141+
along e.g. -1, -2, -3... Note that it is possible to re-name these though! For
127142
example, if you click on the number at the left of the slider, you can freely
128143
type in a new value. This can be useful to label sliders with informative names
129144
like 'z', or 'time'.
@@ -233,8 +248,13 @@ See the diagram below for a visualisation of how these 3D and 4D arrays compare:
233248
(z, y, x) and four (c, z, y, x) dimensions" width='80%'}
234249

235250
As we've seen before, the labels on the left hand side of each slider in Napari
236-
matches the index of the dimension it moves along. The top slider (labelled 1)
237-
moves along the z axis, while the bottom slider (labelled 0) switches channels.
251+
matches the index of the dimension it moves along. The top slider (labelled -3)
252+
moves along the z axis, while the bottom slider (labelled -4) switches channels.
253+
Remember a negative index counts backwards from the last dimension, so for this image:
254+
255+
- **Shape**: (2, 60, 256, 256)
256+
- **Axis**: (c, z, y, x)
257+
- **Index**: (-4, -3, -2, -1)
238258

239259
We can separate the channels again by right clicking on the 'membrane' image
240260
layer and selecting:
@@ -254,12 +274,18 @@ something like:
254274

255275
```
256276
from skimage import data
257-
viewer.add_image(data.cells3d(), channel_axis=1)
277+
viewer.add_image(data.cells3d(), channel_axis=-3)
258278
```
259279
This adds the cells 3D image (which is stored as zcyx), and specifies that
260-
dimension 1 is the channel axis. This allows Napari to split the channels
280+
dimension -3 is the channel axis. This allows Napari to split the channels
261281
automatically into different layers.
262282

283+
Note: we could use a positive index here and get the same result:
284+
```
285+
from skimage import data
286+
viewer.add_image(data.cells3d(), channel_axis=1)
287+
```
288+
263289
Often when loading your own images into Napari e.g. with the
264290
BioIO plugin (as we will see in the
265291
[filetypes and metadata episode](filetypes-and-metadata.md)), the channel
@@ -452,14 +478,15 @@ image.shape
452478
If we press the roll dimensions button ![](
453479
https://raw.githubusercontent.com/napari/napari/main/src/napari/resources/icons/roll.svg
454480
){alt="A screenshot of Napari's roll dimensions button" height='25px'} once, we
455-
can see an image of various cells and nuclei. Moving the slider labelled '0'
481+
can see an image of various cells and nuclei. Moving the slider labelled '-4'
456482
seems to move up and down in this image (i.e. the z axis), while moving the
457-
slider labelled '3' changes between highlighting different features like nuclei
458-
and cell edges (i.e. channels). Therefore, the remaining two axes (1 and 2) must
483+
slider labelled '-1' changes between highlighting different features like nuclei
484+
and cell edges (i.e. channels). Therefore, the remaining two axes (-3 and -2) must
459485
be y and x. This means the image's 4 dimensions are (z, y, x, c)
460486

461487
### 3
462-
The channel axis is 3 (remember that the numbering always starts form 0!)
488+
The channel axis is -1 (remember that -1 is the last dimension). We could also
489+
use an equivalent positive index of 3.
463490

464491
### 4
465492
There are 3 channels which we can see from the `.shape` output, or from the

0 commit comments

Comments
 (0)