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

Fix failing unit-test test_wsireader #7905

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion monai/data/wsi_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ def get_mpp(self, wsi, level: int) -> tuple[float, float]:
unit = wsi.pages[level].tags.get("ResolutionUnit")
if unit is not None:
unit = str(unit.value)[8:]
else:
if unit is None or len(unit) == 0:
warnings.warn("The resolution unit is missing. `micrometer` will be used as default.")
unit = "micrometer"

Expand Down
4 changes: 2 additions & 2 deletions monai/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def __init__(self, input_unit: str, target_unit: str) -> None:
"Both input and target units should be from the same quantity. "
f"Input quantity is {input_base} while target quantity is {target_base}"
)
self._calculate_conversion_factor()
self.conversion_factor = self._calculate_conversion_factor()

def _get_valid_unit_and_base(self, unit):
unit = str(unit).lower()
Expand All @@ -841,7 +841,7 @@ def _calculate_conversion_factor(self):
return 1.0
input_power = self._get_unit_power(self.input_unit)
target_power = self._get_unit_power(self.target_unit)
self.conversion_factor = 10 ** (input_power - target_power)
return 10 ** (input_power - target_power)
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved

def __call__(self, value: int | float) -> Any:
return float(value) * self.conversion_factor
Expand Down
Loading