a b/README.md
1
# wsic
2
3
[![Gitmoji](https://img.shields.io/badge/gitmoji-%20%F0%9F%98%9C%20%F0%9F%98%8D-FFDD67.svg)](https://gitmoji.dev)
4
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5
[![image](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
7
[![Python application](https://github.com/John-P/wsic/actions/workflows/python-app.yml/badge.svg?branch=dev)](https://github.com/John-P/wsic/actions/workflows/python-app.yml)
8
[![Documentation
9
Status](https://readthedocs.org/projects/pip/badge/?version=stable)](https://wsic.readthedocs.io/en/latest/)
10
11
[![image](https://img.shields.io/pypi/v/wsic)](https://pypi.org/project/wsic/)
12
[![image](https://codecov.io/gh/John-P/wsic/branch/main/graph/badge.svg?token=ICCWDKJG5J)](https://codecov.io/gh/John-P/wsic)
13
[![image](https://deepsource.io/gh/John-P/wsic.svg/?label=active+issues&show_trend=true&token=D-sO1mhzQv1n9FPl0RFaAfGt)](https://deepsource.io/gh/John-P/wsic/?ref=repository-badge)
14
15
Whole Slide Image (WSI) conversion for brightfield histology images.
16
17
Provides a command line interface (CLI) for easy convertion between
18
formats:
19
20
```
21
Usage: wsic convert [OPTIONS]
22
23
  Convert a WSI.
24
25
Options:
26
  -i, --in-path PATH              Path to WSI to read from.
27
  -o, --out-path PATH             The path to output to.
28
  -t, --tile-size <INTEGER INTEGER>...
29
                                  The size of the tiles to write.
30
  -rt, --read-tile-size <INTEGER INTEGER>...
31
                                  The size of the tiles to read.
32
  -w, --workers INTEGER           The number of workers to use.
33
  -c, --compression [blosc|deflate|jpeg xl|jpeg-ls|jpeg|jpeg2000|lzw|png|webp|zstd]
34
                                  The compression to use.
35
  -cl, --compression-level INTEGER
36
                                  The compression level to use.
37
  -d, --downsample INTEGER        The downsample factor to use.
38
  -mpp, --microns-per-pixel <FLOAT FLOAT>...
39
                                  The microns per pixel to use.
40
  -ome, --ome / --no-ome          Save with OME-TIFF metadata (OME-TIFF and
41
                                  NGFF).
42
  --overwrite / --no-overwrite    Whether to overwrite the output file.
43
  -to, --timeout FLOAT            Timeout in seconds for reading a tile.
44
  -W, --writer [auto|jp2|svs|tiff|zarr]
45
                                  The writer to use. Overrides writer detected
46
                                  by output file extension.
47
  -s, --store [dir|ndir|zip|sqlite]
48
                                  The store to use (zarr/NGFF only). Defaults
49
                                  to ndir (nested directory).
50
  -h, --help                      Show this message and exit.
51
```
52
53
![A demonstration of converting a JP2 file to a pyramid
54
TIFF.](https://github.com/John-P/wsic/raw/main/docs/_static/wsic_convert_demo.gif)
55
56
# Getting Started
57
58
For basic usage see the documentation page ["How do
59
I...?"](https://wsic.readthedocs.io/en/latest/how_do_i.html).
60
61
# Features
62
63
- Reading and writing several container formats.
64
- Support for a wide range of compression codecs.
65
- Custom tile size
66
- Lossless repackaging / transcoding (to zarr/NGFF or TIFF) from:
67
  - SVS (JPEG compressed)
68
  - OME-TIFF (single image, JPEG and JPEG2000 (J2K) compressed)
69
  - Generic Tiled TIFF (JPEG, JPEG2000, and WebP compressed)
70
  - DICOM WSI (JPEG and JPEG2000 (J2K) compressed)
71
72
## Read Container Formats
73
74
- [OpenSlide](https://openslide.org/) Formats:
75
  - Aperio SVS (.svs)
76
  - Hamamatsu (.vms, .vmu, .ndpi)
77
  - Leica (.scn)
78
  - Mirax MRXS (.mrxs)
79
  - Sakura (.svslide)
80
  - Trestle (.tif)
81
  - Ventana (.bif, .tif)
82
  - Generic tiled TIFF (.tif; DEFLATE, JPEG, and Webp
83
    compressed)
84
- Other Tiled TIFFs
85
  ([tifffile](https://github.com/cgohlke/tifffile) supported
86
  formats)
87
  - Tiled with various codecs: e.g. JPEG XL, JPEG 2000, WebP, and zstd.
88
  - RGB/brightfield [OME-TIFF](https://docs.openmicroscopy.org/ome-model/5.6.3/ome-tiff/).
89
- [JP2](https://jpeg.org/jpeg2000/) (via
90
  [glymur](https://glymur.readthedocs.io/en/latest/) and
91
  [OpenJPEG](https://www.openjpeg.org/))
92
  - Including Omnyx JP2 files.
93
- [Zarr](https://zarr.readthedocs.io/en/stable/)
94
  - Single array.
95
  - Group of (multiresolution) arrays.
96
  - [NGFF v0.4](https://ngff.openmicroscopy.org/0.4/index.html).
97
- [DICOM WSI](https://dicom.nema.org/dicom/dicomwsi/) (via
98
  [wsidicom](https://github.com/imi-bigpicture/wsidicom))
99
  - [DICOM VL Whole Slide Image IODs](https://dicom.innolitics.com/ciods/vl-whole-slide-microscopy-image).
100
101
## Write Container Formats
102
103
- TIFF
104
  - Generic Tiled / Pyramid TIFF
105
  - OME-TIFF
106
  - SVS
107
- JP2
108
- Zarr (NGFF v0.4)
109
- DICOM (.dcm)
110
111
# Notes & FAQs
112
113
Python on [Windows handles multiprocessing
114
differenly](https://docs.python.org/2/library/multiprocessing.html#windows)
115
to POSIX/UNIX-like systems. I suggest using the [Windows Subsystem for
116
Linux](https://learn.microsoft.com/en-us/windows/wsl/about) on Windows
117
to ensure that wsic functions correctly and efficiently.
118
119
# Other Tools
120
121
There are many other great tools in this space. Below are some other
122
tools for converting WSIs.
123
124
1. **[bfconvert](https://www.openmicroscopy.org/bio-formats/downloads/)**
125
   Part of the Bio-Formats command line tools. Uses bioformats to convert
126
   from many formats to OME-TIFF.
127
1. **[biofromats2raw](https://github.com/glencoesoftware/bioformats2raw)**
128
   Convert from Bio-Formats formats to zarr.
129
1. **[isyntax2raw](https://github.com/glencoesoftware/isyntax2raw)** Convert from Philips' iSyntax format to a zarr using Philips' SDK.
130
1. **[wsidicomiser](https://github.com/sectra-medical/wsidicomizer)** Convert OpenSlide images to WSI DICOM.
131
132
# Credits
133
134
This package was created with
135
[Cookiecutter](https://github.com/audreyr/cookiecutter) and the
136
[audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage)
137
project template.