nv-generate / utils /windowing.py
zephyrie's picture
Initial commit: NV-Generate Gradio showcase
ab1db83
raw
history blame contribute delete
630 Bytes
"""CT Hounsfield-unit window/level presets and conversion helpers."""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
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()]