Skip to content

Commit

Permalink
Philis tiff metadata (#75)
Browse files Browse the repository at this point in the history
* Fix pixel spacing for philips tiff
  • Loading branch information
erikogabrielsson authored Nov 30, 2023
1 parent e23c29b commit f7517b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] -

## [0.10.4] - 2023-11-30

### Fixed

- Order of pixel spacing for philips tiff files.

## [0.10.3] - 2023-09-01

### Fixed
Expand Down Expand Up @@ -161,7 +167,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release of opentile.

[Unreleased]: https://github.com/imi-bigpicture/opentile/compare/v0.10.3..HEAD
[Unreleased]: https://github.com/imi-bigpicture/opentile/compare/v0.10.4..HEAD
[0.10.4]: https://github.com/imi-bigpicture/opentile/compare/v0.10.3..v0.10.4
[0.10.3]: https://github.com/imi-bigpicture/opentile/compare/v0.10.2..v0.10.3
[0.10.2]: https://github.com/imi-bigpicture/opentile/compare/v0.10.1..v0.10.2
[0.10.1]: https://github.com/imi-bigpicture/opentile/compare/v0.10.0..v0.10.1
Expand Down
2 changes: 1 addition & 1 deletion opentile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
from opentile.opentile import OpenTile
from opentile.metadata import Metadata

__version__ = "0.10.3"
__version__ = "0.10.4"
17 changes: 8 additions & 9 deletions opentile/formats/philips/philips_tiff_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ def __init__(self, tiff_file: TiffFile):

metadata = ElementTree.fromstring(tiff_file.philips_metadata)
self._tags: Dict[str, Optional[str]] = {tag: None for tag in self.TAGS}
for element in metadata.iter():
if element.tag == "Attribute" and element.text is not None:
name = element.attrib["Name"]
if name in self._tags and self._tags[name] is None:
self._tags[name] = element.text
for element in metadata.iter("Attribute"):
if element.text is None:
continue
name = element.attrib["Name"]
if name in self._tags and self._tags[name] is None:
self._tags[name] = element.text

@property
def scanner_manufacturer(self) -> Optional[str]:
return self._tags["DICOM_MANUFACTURER"]

@cached_property
def scanner_software_versions(self) -> Optional[List[str]]:
print(self._tags["DICOM_SOFTWARE_VERSIONS"])
if self._tags["DICOM_SOFTWARE_VERSIONS"] is None:
return None
return self._split_and_cast_text(self._tags["DICOM_SOFTWARE_VERSIONS"], str)
Expand All @@ -88,9 +88,8 @@ def aquisition_datetime(self) -> Optional[datetime]:
def pixel_spacing(self) -> Optional[Tuple[float, float]]:
if self._tags["DICOM_PIXEL_SPACING"] is None:
return None
return tuple(
self._split_and_cast_text(self._tags["DICOM_PIXEL_SPACING"], float)[0:2]
)
values = self._split_and_cast_text(self._tags["DICOM_PIXEL_SPACING"], float)
return values[1], values[0]

@cached_property
def properties(self) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "opentile"
version = "0.10.3"
version = "0.10.4"
description = "Read tiles from wsi-TIFF files"
authors = ["Erik O Gabrielsson <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit f7517b1

Please sign in to comment.