Skip to content

Commit ae80569

Browse files
authored
Merge pull request #13 from janelia-cellmap/refactor
♻️ update readme, variable renaming
2 parents 8bd7d68 + 704e7a6 commit ae80569

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# zarrify
22

3-
Convert TIFF, MRC, and N5 files to OME-Zarr format.
3+
Convert TIFF/TIFF Stacks, MRC, and N5 files to Zarr (v2) format with ome-ngff (0.4) metadata.
44

55
## Install
66

@@ -10,18 +10,26 @@ pip install zarrify
1010

1111
## Usage
1212

13+
### Local processing
1314
```bash
14-
zarrify --src input.tiff --dest output.zarr --cluster local
15+
zarrify --src input.tiff --dest output.zarr --cluster local --workers 20
16+
```
17+
18+
### LSF cluster processing
19+
```bash
20+
bsub -n 1 -J to_zarr 'zarrify --src input.tiff --dest output.zarr --cluster lsf --workers 20'
1521
```
1622

1723
## Python API
1824

25+
Integrating conversion to zarr into python script
26+
1927
```python
2028
import zarrify
2129
from zarrify.utils.dask_utils import initialize_dask_client
2230

23-
client = initialize_dask_client("local")
24-
zarrify.to_zarr("input.tiff", "output.zarr", client)
31+
client = initialize_dask_client("local") # or "lsf"
32+
zarrify.to_zarr("input.mrc", "output.zarr", client, workers=20)
2533
```
2634

2735
## Supported formats

src/zarrify/to_zarr.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def init_dataset(src :str,
5555
def to_zarr(src : str,
5656
dest: str,
5757
client : Client,
58-
num_workers : int = 20,
58+
workers : int = 20,
5959
zarr_chunks : list[int] = [128]*3,
6060
axes : list[str] = ['z', 'y', 'x'],
6161
scale : list[float] = [1.0,]*3,
@@ -67,7 +67,7 @@ def to_zarr(src : str,
6767
src (str): input data location.
6868
dest (str): output zarr group location.
6969
client (Client): dask client instance.
70-
num_workers (int, optional): Number of dask workers. Defaults to 20.
70+
workers (int, optional): Number of dask workers. Defaults to 20.
7171
zarr_chunks (list[int], optional): _description_. Defaults to [128,]*3.
7272
axes (list[str], optional): axis order. Defaults to ['z', 'y', 'x'].
7373
scale (list[float], optional): voxel size (in physical units). Defaults to [1.0,]*3.
@@ -78,7 +78,7 @@ def to_zarr(src : str,
7878
dataset = init_dataset(src, axes, scale, translation, units)
7979

8080
# write in parallel to zarr using dask
81-
client.cluster.scale(num_workers)
81+
client.cluster.scale(workers)
8282
dataset.write_to_zarr(dest, client, zarr_chunks)
8383
client.cluster.scale(0)
8484
# populate zarr metadata
@@ -94,7 +94,7 @@ def to_zarr(src : str,
9494
)
9595
@click.option("--dest", "-d", type=click.STRING, help="Output .zarr file path.")
9696
@click.option(
97-
"--num_workers", "-w", default=100, type=click.INT, help="Number of dask workers"
97+
"--workers", "-w", default=100, type=click.INT, help="Number of dask workers"
9898
)
9999
@click.option(
100100
"--cluster",
@@ -143,7 +143,7 @@ def to_zarr(src : str,
143143
type=str,
144144
help="Metadata unit names. Order matters. \n Example: -t nanometer nanometer nanometer",
145145
)
146-
def cli(src, dest, num_workers, cluster, zarr_chunks, axes, translation, scale, units):
146+
def cli(src, dest, workers, cluster, zarr_chunks, axes, translation, scale, units):
147147

148148
# create a dask client to submit tasks
149149
client = initialize_dask_client(cluster)
@@ -152,7 +152,7 @@ def cli(src, dest, num_workers, cluster, zarr_chunks, axes, translation, scale,
152152
to_zarr(src,
153153
dest,
154154
client,
155-
num_workers,
155+
workers,
156156
zarr_chunks,
157157
axes,
158158
scale,

0 commit comments

Comments
 (0)