NA-MIC Project WeeksOHIF Viewer is a widely used web-based medical image viewer built on Cornerstone3D. Segmentation is central to many clinical and research workflows, yet reliability and robustness in OHIF/Cornerstone still lag behind user expectations — with recurring errors and edge cases in everyday use (OHIF/Viewers#5453).
During Project Week 45, I would like to focus on improving the stability and user experience of segmentation in OHIF/Cornerstone. I am looking forward to collaborating with others interested in segmentation, digital pathology, and web-based imaging viewers.
This project targets three complementary areas:
Several related gaps remain in the broader stack: the WSI microscopy viewer (wsi-microscopy-viewer) does not yet support segmentation display, overlapping segmentations are not always handled reliably, and contour ↔ labelmap conversion is not yet exposed end-to-end in OHIF. This project aims to advance solutions within Cornerstone3D and OHIF toward a more dependable segmentation experience across radiology and pathology use cases.
For DICOM persistence, standards context, and recommended interchange with research formats (NIfTI), see Background and References.
wsi-microscopy-viewer vs. SLIM and document pipeline gaps.cornerstonejs/cornerstone3D and OHIF/Viewers for work continuing beyond the week.(To be filled in during and after the event)
| Resource | Notes |
|---|---|
| OHIF Viewer | Web viewer |
| Cornerstone3D | Rendering engine |
| Cornerstone3D PR #2170 | Contour ↔ labelmap conversion |
| SLIM Viewer | Microscopy segmentation reference |
| OHIF WSI Microscopy Viewer | WSI viewer (limited segmentation support) |
| Item | Relevance |
|---|---|
| #5453 | Segmentation reliability |
| #5849 | Labelmap interpolation (editing; affects exported SEG) |
| #4875 | DICOM label-map support |
| PR #5806 | SEG load/save via per-frame imageLoader; shared dcmjs writer |
| #2833 | Interoperability between highdicom-authored SEGs and OHIF |
Reference material for persistence, standards, tooling, and conversion with NIfTI. Intended as background for the DICOM persistence objective and approach step 6.
| Goal | Recommended approach | Typical stack |
|---|---|---|
| Clinical / PACS / multi-site sharing | DICOM Segmentation (SOP Class 1.2.840.10008.5.1.4.1.1.66.4) via DICOMweb alongside source images |
OHIF cornerstone-dicom-seg, @cornerstonejs/adapters, dcmjs; offline creation with highdicom or dcmqi |
| In-viewer editing in OHIF | Cornerstone3D labelmap or contour during interaction; export to DICOM SEG on save from referenced volume metadata | @cornerstonejs/adapters, dcmjs (PR #5806: shared dicomWriter.ts, preserved transfer syntax) |
| Research / ML pipelines | NIfTI, NRRD, or Slicer .seg.nrrd internally; DICOM at archive boundaries |
SimpleITK, NiBabel, Slicer; highdicom or pydicom-seg for DICOM export |
| Many non-overlapping segments (100+) | Label-map encodings when available; classic BINARY SEG remains valid but often large/slow | highdicom LABELMAP prototypes; DCMTK/dcmqi; OHIF #5806 (labelmap RLE where supported) |
OHIF loading (PR #5806): Replaces whole-object ArrayBuffer fetch with per-frame imageLoader decoding (Cornerstone3D fix/use-imageLoader-for-seg). Improves load/save for labelmap and compressed bitmap SEGs. Parser type (labelmap vs bitmap) follows SOP Class / pixel layout. Caveat: multi-frame SEGs on non–WADO-RS schemes (dicomfile:, wadouri:) may decode only one frame without error if /frames/N URLs are missing.
Three related tracks:
Segmentation IOD (existing) — Part 3 §C.8.20. Types include BINARY and FRACTIONAL. Multiple segments historically meant separate binary frame sets (supports overlap; inefficient for many non-overlapping labels). See PW38 DICOM SEG notes.
Supplement 243 — Label Map Segmentation (Final Text, DICOM 2024d) — Dedicated IOD: pixel values encode segment membership in one array (no overlap per instance). NEMA Sup 243 · overview. Prototypes: highdicom (PW39); DCMTK/dcmqi/Slicer (PW40).
LABELMAP Segmentation Type (classic SEG object) — Community encodings on the existing Segmentation IOD (RLE/JPEG-LS/JP2K). Example (TotalSegmentator, PW39): ~385 MB binary vs ~1.9–6.7 MB compressed labelmap.
OHIF: #4875 tracks first-class label-map support. Until broadly available, assume classic DICOM SEG for production interchange; experiment with label-map objects alongside #5806.
| DICOM SEG | NIfTI / NRRD / seg.nrrd | |
|---|---|---|
| Strengths | Standard SOP Class; segment metadata; FoR / referenced series; DICOMweb / PACS | Fast I/O; ML ecosystem; simple dense arrays |
| Weaknesses | Size/speed for many-segment binary SEG; viewer variance | Weak clinical metadata; no study linkage without sidecars |
Hub-and-spoke pattern: NIfTI or in-memory labelmaps inside analysis; DICOM SEG at the boundary for VNA/PACS, OHIF, or Slicer.
Mostly lossless for voxels if geometry and labels are preserved:
Image Orientation Patient, spacing, and Image Position Patient from the referenced series (or per-frame functional groups). NIfTI sform/qform must match the DICOM patient frame.highdicom / pydicom-seg (Python); dcmqi / Quantitative Reporting (Slicer); dcmjs / adapters (OHIF).NIfTI does not carry DICOM identity or segment ontology. Required inputs:
| Input | If missing |
|---|---|
| Referenced series (Study/Series/SOP UIDs, Frame of Reference UID) | Must be chosen explicitly — cannot derive from NIfTI alone |
| Spatial alignment with reference grid | Resample NIfTI to reference geometry or document transform |
| Per-segment metadata (number, label, category codes) | Sidecar JSON/CSV or defaults |
| Segmentation Type | BINARY, LABELMAP, or Sup 243 object per overlap/tooling support |
| Overlap policy | Overlapping labels in one array need separate binary segments or another representation |
Suggested pipeline: load reference DICOM → resample labelmap → encode with highdicom or dcmqi → validate in OHIF via DICOMweb. Web-only: dcmjs adapters from Cornerstone labelmaps when viewport metadata includes the reference study.
┌─────────────────────────────────────────┐
│ Application layer │
│ OHIF │ 3D Slicer │ ML scripts │
└────┬──────────┬──────────────┬──────────┘
│ │ │
┌─────────────┼──────────┼──────────────┼─────────────┐
▼ ▼ ▼ ▼ ▼
dcmjs + cornerstone- dcmqi + highdicom pydicom-seg
adapters dicom-seg Quant. (+ pydicom) (+ SimpleITK)
│ Reporting │
└─────────────┬──────────────┘
▼
pydicom (Python) │ dicomParser (JS, legacy)
▼
DCMTK / GDCM (C++) — dcmseg, DIMSE
| Package | Language | Role |
|---|---|---|
| pydicom | Python | Low-level DICOM I/O |
| highdicom | Python | SEG/SR/PR builders; label-map prototypes |
| pydicom-seg | Python | Fast multiclass SEG → SimpleITK |
| dcmjs | JavaScript | Browser SEG (de)serialization |
| @cornerstonejs/adapters | TypeScript | Labelmap/contour ↔ DICOM SEG |
| DCMTK / dcmseg | C++ | Reference encoding |
| dcmqi | C++ / CLI | ITK/NIfTI ↔ DICOM SEG (Slicer) |
Validate round-trips (highdicom → OHIF → dcmjs → Slicer) when changing write options (transfer syntax, fragmentMultiframe, labelmap vs bitmap).