Skip to content

Commit

Permalink
Merge branch 'dicom-update' of https://github.com/TissueImageAnalytic…
Browse files Browse the repository at this point in the history
…s/tiatoolbox into faster-patch-dataset
  • Loading branch information
measty committed Mar 31, 2023
2 parents fa9f85c + 45956d5 commit 0635e0d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.pytest.ini_options]
collect_ignore = ["setup.py", "benchmark/"]

[tool.black]
exclude = '''
/(
Expand Down Expand Up @@ -34,3 +37,17 @@
]
ignore_errors = true
omit = ['tests/*', 'tiatoolbox/__main__.py', '*/utils/env_detection.py']

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 88
filter_files = "True"
skip = [".gitignore", "benchmarks/*"]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.distutils.bdist_wheel]
universal = true
16 changes: 0 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ replace = version: {new_version} # TIAToolbox version
search = TOOLBOX_VER: {current_version}
replace = TOOLBOX_VER: {new_version}

[bdist_wheel]
universal = 1

[flake8]
exclude = docs, *__init__*, setup.py
max-line-length = 88
Expand All @@ -30,16 +27,3 @@ spellcheck-targets = comments
dictionaries = en_US,python,technical
max-cognitive-complexity = 14
max-expression-complexity = 7

[aliases]
test = pytest

[tool:pytest]
collect_ignore = ['setup.py', 'benchmark/']

[isort]
profile = black
multi_line_output = 3
skip_gitignore = True
line_length = 88
filter_files = True
12 changes: 8 additions & 4 deletions tests/test_wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ def test_ngff_omero_below_min_version(tmp_path):
wsireader.WSIReader.open(sample_copy)


def test_ngff_omero_above_max_version(tmp_path):
def test_ngff_omero_above_max_version(tmp_path, caplog):
"""Test for FileNotSupported when omero version is above maximum."""
sample = _fetch_remote_sample("ngff-1")
# Create a copy of the sample
Expand All @@ -2130,8 +2130,10 @@ def test_ngff_omero_above_max_version(tmp_path):
zattrs["omero"]["version"] = "10.0"
with open(sample_copy / ".zattrs", "w") as fh:
json.dump(zattrs, fh, indent=2)
with pytest.raises(FileNotSupported):
# Check that the warning is logged
with caplog.at_level(logging.WARNING):
wsireader.WSIReader.open(sample_copy)
assert "maximum supported version" in caplog.text


def test_ngff_multiscales_below_min_version(tmp_path):
Expand All @@ -2150,7 +2152,7 @@ def test_ngff_multiscales_below_min_version(tmp_path):
wsireader.WSIReader.open(sample_copy)


def test_ngff_multiscales_above_max_version(tmp_path):
def test_ngff_multiscales_above_max_version(tmp_path, caplog):
"""Test for FileNotSupported when multiscales version is above maximum."""
sample = _fetch_remote_sample("ngff-1")
# Create a copy of the sample
Expand All @@ -2162,8 +2164,10 @@ def test_ngff_multiscales_above_max_version(tmp_path):
zattrs["multiscales"][0]["version"] = "10.0"
with open(sample_copy / ".zattrs", "w") as fh:
json.dump(zattrs, fh, indent=2)
with pytest.raises(FileNotSupported):
# Check that the warning is logged
with caplog.at_level(logging.WARNING):
wsireader.WSIReader.open(sample_copy)
assert "maximum supported version" in caplog.text


def test_ngff_non_numeric_version(tmp_path, monkeypatch):
Expand Down
6 changes: 3 additions & 3 deletions tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def is_ngff(
max_version,
multiscales_versions,
)
return False
return True

if len(multiscales_versions) > 1:
logger.warning(
Expand All @@ -189,7 +189,7 @@ def is_ngff(
max_version,
multiscales_versions,
)
return False
return True

return is_zarr(path)

Expand Down Expand Up @@ -3881,7 +3881,7 @@ def _info(self) -> WSIMeta:
)
for level in self.wsi.levels
]
dataset = self.wsi.base_level.datasets[0]
dataset = self.wsi.levels.base_level.datasets[0]
# Get pixel spacing in mm from DICOM file and convert to um/px (mpp)
mm_per_pixel = dataset.pixel_spacing
mpp = (mm_per_pixel.width * 1e3, mm_per_pixel.height * 1e3)
Expand Down

0 comments on commit 0635e0d

Please sign in to comment.