-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🐛 Fix Writing MPP To NGFF v0.4 Zarr (#37) * 🐛 Change CoordinateTransform Order To YXC (#41) * 🐛 Fix Reading TIFF Resolution Tag * 🐛 Minor Bug Fixes (#40) * 🐛 Ensure cv2 Arg Is an int Tuple * ✨ Add TIFF Writer For CLI Based On Ext * 🐛 Add Missing **kwargs * 🚸 Change TIFFWriter OME Default To False * ✏️ Typo Fix transcribed -> transcoded * ♻️ Move CLI Tests To Seperate Module * 🐛 Fix Typo in Class For Transcoding From DICOM * ✅ Add CLI Tests * 🔧 Add release Branch To Workflows * 🔖 Bump version: 0.5.1 → 0.6.1 * 🔧 Set Tag To False In bump2version Config * ♻️ Rename Module To Avoid Shadowing * 📝 Update History * 📝 Reverse History Ordering
- Loading branch information
Showing
13 changed files
with
310 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,60 @@ | ||
# History | ||
|
||
## 0.1.0 (2022-02-22) | ||
## 0.6.1 (2022-10-21) | ||
|
||
- First release on PyPI. | ||
- Select Writer class based on file extension from CLI. | ||
- Bug fixes: | ||
- Fix writing MPP to NGFF v0.4. | ||
- Change coordinate transformation ordering. | ||
- Fix reading TIFF resolution tag. Previously only the numerator of | ||
the resolution fraction was being read. | ||
- Other minor bug fixes. | ||
|
||
## 0.6.0 (2022-10-03) | ||
|
||
- Add ability to write resolution metadata to JP2. Thanks to | ||
@quintusdias for helping get this implemented in glymur. | ||
- Remove QOI codec code as this is not included in imagecodes. Thanks to | ||
Christoph Gohlke for adding this. | ||
- Add a "How do I?" documentation page. | ||
|
||
## 0.5.1 (2022-06-27) | ||
|
||
- Bug fixes: | ||
- Fix parsing of OpenSlide MPP to float. | ||
|
||
## 0.5.0 (2022-06-25) | ||
|
||
- Add ability to transcode/repackage to a TIFF file (from DICOM or SVS). | ||
- Refactor `ZarrReaderWriter` to seperate `ZarrWriter` and `ZarrReader`. | ||
- Bug fixes: | ||
- Fix thumbnaiul generation for zarr. | ||
- Fix NGFF metadata `CoordinateTransformation` field default factor. | ||
|
||
## 0.4.0 (2022-06-20) | ||
|
||
- Add ability to write JPEG compressed SVS files. | ||
- Add support for thumbnail generation and a CLI command. | ||
- Swap from strings to enums for codecs and color spaces. | ||
|
||
## 0.3.0 (2022-05-13) | ||
|
||
- Remove unused CLI debug option. | ||
- Add generation of OME-NGFF metadata (JSON .zattrs file). | ||
- Add timeout when copying tiles to prevent indefinite hanging. | ||
- Improve joining/termination of child processes at shutdown. | ||
- Use the TIFF resolution tag if present. | ||
- Add `get_tile` method to all `Reader` classes. | ||
- Update supported Python versions to 3.8, 3.9, 3.10. | ||
- Bug fixes: | ||
- Fix and issue with concatenation of pyramid downsamples. | ||
- Add a custom Queue class for multiprocessing on macOS. | ||
- Fix handling of `pyramid_downsamples` argument when `None`. | ||
|
||
## 0.2.0 (2022-03-22) | ||
|
||
- Add Support To Read DICOM WSI and transform to zarr. | ||
|
||
## 0.1.0 (2022-02-22) | ||
|
||
- First release on PyPI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import sys | ||
import warnings | ||
from pathlib import Path | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from wsic import cli | ||
|
||
|
||
def test_convert_timeout(samples_path, tmp_path): | ||
"""Check that CLI convert raises IOError when reading times out.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "XYC.jp2") | ||
out_path = str(Path(td) / "XYC.tiff") | ||
warnings.simplefilter("ignore") | ||
with pytest.raises(IOError, match="timed out"): | ||
runner.invoke( | ||
cli.convert, | ||
["-i", in_path, "-o", out_path, "--timeout", "0"], | ||
catch_exceptions=False, | ||
) | ||
|
||
|
||
def test_thumbnail(samples_path, tmp_path): | ||
"""Check that CLI thumbnail works.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = samples_path / "XYC.jp2" | ||
out_path = Path(td) / "XYC.jpeg" | ||
runner.invoke( | ||
cli.thumbnail, | ||
["-i", str(in_path), "-o", str(out_path), "-s", "512", "512"], | ||
catch_exceptions=False, | ||
) | ||
assert out_path.exists() | ||
assert out_path.is_file() | ||
assert out_path.stat().st_size > 0 | ||
|
||
|
||
def test_thumbnail_downsample(samples_path, tmp_path): | ||
"""Check that CLI thumbnail works with downsample option.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = samples_path / "XYC.jp2" | ||
out_path = Path(td) / "XYC.jpeg" | ||
result = runner.invoke( | ||
cli.thumbnail, | ||
["-i", str(in_path), "-o", str(out_path), "-d", "16"], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
assert out_path.exists() | ||
assert out_path.is_file() | ||
assert out_path.stat().st_size > 0 | ||
|
||
|
||
def test_thumbnail_no_cv2(samples_path, tmp_path, monkeypatch): | ||
"""Check that CLI thumbnail works without OpenCV (cv2).""" | ||
monkeypatch.setitem(sys.modules, "cv2", None) | ||
with pytest.raises(ImportError): | ||
import cv2 # noqa # skipcq | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = samples_path / "XYC.jp2" | ||
out_path = Path(td) / "XYC.jpeg" | ||
runner.invoke( | ||
cli.thumbnail, | ||
["-i", str(in_path), "-o", str(out_path), "-s", "512", "512"], | ||
catch_exceptions=False, | ||
) | ||
assert out_path.exists() | ||
assert out_path.is_file() | ||
assert out_path.stat().st_size > 0 | ||
|
||
|
||
def test_help(): | ||
"""Test the help output.""" | ||
runner = CliRunner() | ||
help_result = runner.invoke(cli.main, ["--help"]) | ||
assert help_result.exit_code == 0 | ||
assert "Console script for wsic." in help_result.output | ||
|
||
|
||
def test_transcode_svs_to_zarr(samples_path, tmp_path): | ||
"""Test the CLI for transcoding SVS to zarr.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "CMU-1-Small-Region.svs") | ||
out_path = str(Path(td) / "CMU-1-Small-Region.zarr") | ||
result = runner.invoke( | ||
cli.transcode, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_transcode_svs_to_tiff(samples_path, tmp_path): | ||
"""Test the CLI for transcoding SVS to (tiled) TIFF.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "CMU-1-Small-Region.svs") | ||
out_path = str(Path(td) / "CMU-1-Small-Region.tiff") | ||
result = runner.invoke( | ||
cli.transcode, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_transcode_dicom_to_tiff(samples_path, tmp_path): | ||
"""Test the CLI for transcoding DICOM to (tiled) TIFF.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "CMU-1-Small-Region") | ||
out_path = str(Path(td) / "CMU-1-Small-Region.tiff") | ||
result = runner.invoke( | ||
cli.transcode, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_convert_jp2_to_tiff(samples_path, tmp_path): | ||
"""Test the CLI for converting JP2 to tiled TIFF.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "XYC.jp2") | ||
out_path = str(Path(td) / "XYC.tiff") | ||
result = runner.invoke( | ||
cli.convert, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_convert_jp2_to_zarr(samples_path, tmp_path): | ||
"""Test the CLI for converting JP2 to zarr.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = str(samples_path / "XYC.jp2") | ||
out_path = str(Path(td) / "XYC.zarr") | ||
result = runner.invoke( | ||
cli.convert, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_transcode_bad_input_file_ext(samples_path, tmp_path): | ||
"""Test the CLI for transcoding with a bad input file extension.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
# in_path must exists but not be a valid input | ||
in_path = str(samples_path / "XYC.jp2") | ||
out_path = str(Path(td) / "XYC.tiff") | ||
result = runner.invoke( | ||
cli.transcode, | ||
["-i", in_path, "-o", out_path], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 2 | ||
|
||
|
||
def test_transcode_bad_output_file_ext(samples_path, tmp_path): | ||
"""Check that CLI raises click.BadParameter when output file extension is bad.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(temp_dir=tmp_path) as td: | ||
in_path = samples_path / "XYC-half-mpp.tiff" | ||
out_path = Path(td) / "XYC.foo" | ||
result = runner.invoke( | ||
cli.transcode, | ||
["-i", str(in_path), "-o", str(out_path)], | ||
catch_exceptions=False, | ||
) | ||
assert result.exit_code == 2 |
Oops, something went wrong.