Spaces:
Running on Zero
Running on Zero
| """CT Hounsfield-unit window/level presets and conversion helpers.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| class WLPreset: | |
| name: str | |
| width: float | |
| level: float | |
| def to_min_max(self) -> tuple[float, float]: | |
| return self.level - self.width / 2.0, self.level + self.width / 2.0 | |
| CT_PRESETS: dict[str, WLPreset] = { | |
| "soft_tissue": WLPreset("Soft Tissue", 350, 50), | |
| "lung": WLPreset("Lung", 1500, -600), | |
| "bone": WLPreset("Bone", 1800, 400), | |
| "brain": WLPreset("Brain", 80, 40), | |
| } | |
| CT_PRESET_LABELS = [p.name for p in CT_PRESETS.values()] | |