|
a |
|
b/docs/how_do_i.rst |
|
|
1 |
How do I...? |
|
|
2 |
============ |
|
|
3 |
|
|
|
4 |
...convert a whole slide image? |
|
|
5 |
------------------------------- |
|
|
6 |
|
|
|
7 |
The CLI included with WSIC has the `convert` command for converting WSIs:: |
|
|
8 |
|
|
|
9 |
wsic convert -i <input> -o <output> |
|
|
10 |
|
|
|
11 |
The output format is determined from the output file extension according |
|
|
12 |
to the following table: |
|
|
13 |
|
|
|
14 |
========= =========== |
|
|
15 |
Extension Format |
|
|
16 |
========= =========== |
|
|
17 |
.tiff Tiled TIFF |
|
|
18 |
.svs Aperio SVS |
|
|
19 |
.zarr Zarr/NGFF |
|
|
20 |
.jp2 JPEG2000 |
|
|
21 |
.dcm DICOM |
|
|
22 |
========= =========== |
|
|
23 |
|
|
|
24 |
You can also use the WSIC API to do this programmatically. For example: |
|
|
25 |
|
|
|
26 |
>>> import wsic |
|
|
27 |
>>> reader = wsic.readers.OpenSlideReader("in_file.svs") |
|
|
28 |
>>> writer = wsic.writers.ZarrWriter( |
|
|
29 |
"out_file.zarr", |
|
|
30 |
pyramid_levels=[2, 4, 8], |
|
|
31 |
compression="jpeg", |
|
|
32 |
compression_level=90, |
|
|
33 |
) |
|
|
34 |
>>> writer.copy_from_reader(reader) |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
...change the tile size? |
|
|
38 |
------------------------ |
|
|
39 |
|
|
|
40 |
The tile size can be specified with the `--tile-size` or `-t` option. |
|
|
41 |
The default tile size is 256x256.:: |
|
|
42 |
|
|
|
43 |
wsic convert -i <input> -o <output> --tile-size 512 512 |
|
|
44 |
|
|
|
45 |
|
|
|
46 |
...use a different compression codec? |
|
|
47 |
------------------------------------- |
|
|
48 |
|
|
|
49 |
There are many compression codecs available for use with WSIC. The |
|
|
50 |
compression codec can be specified with the `--compression` or `-c` |
|
|
51 |
option, and the 'level' of compression can be specified with the |
|
|
52 |
`--compression-level` or `-cl` option. |
|
|
53 |
|
|
|
54 |
wsic convert -i <input> -o <output> -c jpeg -cl 90 |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
Codecs Supported By File Format |
|
|
58 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
|
59 |
|
|
|
60 |
====== ================================================================ |
|
|
61 |
Format Codecs |
|
|
62 |
====== ================================================================ |
|
|
63 |
TIFF JPEG, JPEG-LS, JPEG XL, JPEG2000, DEFLATE, WebP, LZW, Zstd |
|
|
64 |
Zarr Blosc, JPEG, JPEG-LS, JPEG2000, DEFLATE, WebP, PNG, LZW, Zstd |
|
|
65 |
SVS JPEG |
|
|
66 |
DICOM JPEG, JPEG2000 |
|
|
67 |
JP2 JPEG2000 |
|
|
68 |
====== ================================================================ |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
Interpretation of Level Option |
|
|
72 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
|
73 |
|
|
|
74 |
========= =========================== |
|
|
75 |
Codec Level |
|
|
76 |
========= =========================== |
|
|
77 |
JPEG 'Quality' (0-100) |
|
|
78 |
JPEG XL 'Effort' / Speed |
|
|
79 |
JPEG-LS Maximum Absolute Error (MAE) |
|
|
80 |
JPEG 2000 PSNR (db) |
|
|
81 |
PNG 'Effort' / Speed |
|
|
82 |
Zstd 'Effort' / Speed |
|
|
83 |
========= =========================== |
|
|
84 |
|
|
|
85 |
|
|
|
86 |
...add pyramid/resolution levels? |
|
|
87 |
--------------------------------- |
|
|
88 |
|
|
|
89 |
Downsampled copies of the image stored in the WSI, known as |
|
|
90 |
pyramid/resolution levels, can be specified with the `--dowmsample` or |
|
|
91 |
`-d` option. For most formats these levels must be in ascending order. |
|
|
92 |
It is also common that they must be powers of two. Each `-d`` option |
|
|
93 |
will append a resolution level to the file in the order they are |
|
|
94 |
given.:: |
|
|
95 |
|
|
|
96 |
wsic convert -i <input> -o <output> -d 2 -d 4 -d 8 |
|
|
97 |
|
|
|
98 |
|
|
|
99 |
...speed up conversion? |
|
|
100 |
----------------------- |
|
|
101 |
|
|
|
102 |
There are a few different ways to speed up conversion: increasing the |
|
|
103 |
read tile size, increasing the number of workers, or using repackaing / |
|
|
104 |
transcoding instead of conversion by copying decoded pixel data. |
|
|
105 |
|
|
|
106 |
|
|
|
107 |
Read Tile Size |
|
|
108 |
^^^^^^^^^^^^^^ |
|
|
109 |
|
|
|
110 |
One way to speed up conversion is to increase the size of the area read |
|
|
111 |
at each step of the conversion. This can be done from the CLI with the |
|
|
112 |
`--read-size` or `-rt` option. The default read size is to use the tile |
|
|
113 |
size of the input file or 4096x4096, whichever is lower.:: |
|
|
114 |
|
|
|
115 |
wsic convert -i <input> -o <output> --read-size 512 512 |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
Note that you may also need to increase the tile read timeout for large |
|
|
119 |
tile read sizes using the `--timeout` or `-to` option. There is a |
|
|
120 |
default timeout of 10 seconds to prevent the CLI tool from haning |
|
|
121 |
indefinately. Setting this to a negative value will lead to an unbounded |
|
|
122 |
read time allowed.:: |
|
|
123 |
|
|
|
124 |
wsic convert -i <input> -o <output> --read-size 512 512 -to 30 |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
Number of Workers |
|
|
128 |
^^^^^^^^^^^^^^^^^ |
|
|
129 |
|
|
|
130 |
Reading data from the input image is performed with a number of worker |
|
|
131 |
sub-processes. The number of workers can be set from the CLI with the |
|
|
132 |
`--workers` or `-w` option. The default number of workers is to use the |
|
|
133 |
number of (virtual) CPUs available.:: |
|
|
134 |
|
|
|
135 |
wsic convert -i <input> -o <output> --workers 4 |
|
|
136 |
|
|
|
137 |
|
|
|
138 |
Repackaging |
|
|
139 |
^^^^^^^^^^^^ |
|
|
140 |
|
|
|
141 |
Repackaging is a much faster way to convert the WSI from one format to |
|
|
142 |
another. However, it is more restrictive. Only certain formats can be |
|
|
143 |
repacked, and the compression codec must be preserved. This is because |
|
|
144 |
repackaing is takeing the already encoded tile data and rearranging |
|
|
145 |
those encoded tiles.:: |
|
|
146 |
|
|
|
147 |
wsic transcode -i <input> -o <output> --repackage |
|
|
148 |
|
|
|
149 |
This is currently supported with a source image in TIFF, Zarr, and DICOM |
|
|
150 |
format and with an output format of TIFF or Zarr (NGFF). |
|
|
151 |
|
|
|
152 |
|
|
|
153 |
...write an OME-TIFF |
|
|
154 |
-------------------- |
|
|
155 |
|
|
|
156 |
To write out a TIFF with OME XML metadata in the description tag, use |
|
|
157 |
the `--ome` flag with an `.ome.tiff` output path.:: |
|
|
158 |
|
|
|
159 |
wsic convert -i <input> -o <output.ome.tiff> --ome |
|
|
160 |
|
|
|
161 |
|
|
|
162 |
...write an NGFF Zarr |
|
|
163 |
--------------------- |
|
|
164 |
|
|
|
165 |
To write a Zarr which follows the NGFF spec (v0.4), use the `--ome` flag |
|
|
166 |
with a `.zarr`` output file path.:: |
|
|
167 |
|
|
|
168 |
wsic convert -i <input> -o <output.zarr> --ome |