Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update incorrect argument and deprecated function for tifffile.TiffWriter #433

Merged
merged 7 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/requirements-claratrain.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
openslide-python==1.1.2
tifffile==2020.9.3
tifffile>=2022.7.28
itk==5.1.2
dask[array,delayed,distributed]==2021.2.0
dask-cuda==0.17.0
zarr==2.6.1
fsspec==0.8.5
numpy # 1.17.3 already exists in the image
opencv-contrib-python==4.5.1.48
imagecodecs==2020.5.30
imagecodecs>=2021.6.8
4 changes: 2 additions & 2 deletions docker/requirements-jupyter-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
openslide-python==1.1.2
tifffile==2020.9.3
tifffile>=2022.7.28
itk==5.1.2
dask[array,delayed,distributed]==2021.2.0
dask-cuda==0.17.0
zarr==2.6.1
fsspec==0.8.5
numpy==1.19.5
opencv-contrib-python==4.5.1.48
imagecodecs==2020.5.30
imagecodecs>=2021.6.8
cupy-cuda110==8.4.0
jupyterlab==3.0.7
dask_labextension==5.0.0
Expand Down
4 changes: 2 additions & 2 deletions docker/requirements-jupyter.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
openslide-python==1.1.2
tifffile==2020.9.3
tifffile>=2022.7.28
itk==5.1.2
dask[array,delayed,distributed]==2021.2.0
dask-cuda==0.17.0
zarr==2.6.1
fsspec==0.8.5
numpy==1.19.5
opencv-contrib-python==4.5.1.48
imagecodecs==2020.5.30
imagecodecs>=2021.6.8
cupy-cuda110==8.4.0
jupyterlab==3.0.7
dask_labextension==5.0.0
Expand Down
1 change: 1 addition & 0 deletions python/cucim/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GPUtil>=1.4.0
imagecodecs>=2021.6.8
openslide-python>=1.1.2
opencv-python>=4.6
psutil>=5.8.0
pytest>=6.2.4
pytest-cov>=2.12.1
Expand Down
4 changes: 2 additions & 2 deletions python/cucim/src/cucim/clara/converter/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def svs2tif(input_file, output_folder, tile_size, overlap,
else:
subfiletype = SUBFILETYPE_NONE

tif.save(
tif.write(
src_arr,
software="Glencoe/Faas pyramid",
metadata={"axes": "YXC"},
Expand All @@ -174,7 +174,7 @@ def svs2tif(input_file, output_folder, tile_size, overlap,
y_resolution // 2 ** level,
resolution_unit,
),
compress=("jpeg", 95), # requires imagecodecs
compression=("jpeg", 95), # requires imagecodecs
subfiletype=subfiletype,
)
logger.info("Done.")
Expand Down
43 changes: 43 additions & 0 deletions python/cucim/tests/unit/clara/converter/test_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Copyright (c) 2022, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
from pathlib import Path


def test_image_converter_stripe_4096x4096_256_jpeg(
tmp_path,
testimg_tiff_stripe_4096x4096_256_jpeg):
import tifffile

from cucim.clara.converter import tiff

tile_size = 128
overlap = 0
num_workers = os.cpu_count()
file_name = "test_image_converter_stripe_4096x4096_256_jpeg-output.tif"
output_path = tmp_path / file_name
tiff.svs2tif(testimg_tiff_stripe_4096x4096_256_jpeg, Path(tmp_path),
tile_size, overlap, num_workers, file_name)
assert os.path.exists(output_path)

with tifffile.TiffFile(output_path) as tif:
assert len(tif.pages) == 6
assert tif.pages[0].shape == (4096, 4096, 3)
assert tif.pages[0].tile == (128, 128)
assert tif.pages[0].compression == tifffile.COMPRESSION.JPEG
assert tif.pages[5].shape == (128, 128, 3)
assert tif.pages[5].tile == (128, 128)
assert tif.pages[5].compression == tifffile.COMPRESSION.JPEG