wsi-dicom
wsi-dicom converts whole-slide imaging files that wsi-rs can open into
DICOM VL Whole Slide Microscopy instances. It provides a Rust API, a CLI, and an
optional native GUI.
j2k supplies JPEG, JPEG 2000, and HTJ2K codec primitives. wsi-rs
opens vendor WSI formats such as SVS and NDPI. wsi-dicom owns DICOM export,
metadata validation, transfer-syntax routing, reports, and writer errors.
Install
Install the CLI:
Use the Rust API:
[]
= "0.7.0"
GPU support is opt-in:
[]
= { = "0.7.0", = ["metal"] } # macOS
# or
= { = "0.7.0", = ["cuda"] } # CUDA-capable Linux/Windows
Feature flags:
| Feature | Effect |
|---|---|
default |
CPU-only DICOM export. |
cuda |
Enables CUDA JPEG 2000 encode acceleration when available. wsi-rs CUDA tile decode and direct JPEG-to-HTJ2K CUDA transcode are not exposed by wsi-dicom 0.7.0. |
metal |
Enables Metal JPEG 2000 encode acceleration on macOS, Metal codestream validation decode, and wsi-rs Metal tile decode plumbing. |
For local maximum CPU throughput:
RUSTFLAGS="-C target-cpu=native"
The optional GUI lives in apps/wsi-dicom-gui:
Quickstart
Always provide metadata JSON/FHIR input or explicitly select research placeholder metadata.
Use --metadata metadata.json for real metadata. --metadata and
--research-placeholder are mutually exclusive. Existing generated .dcm
paths are refused by default; pass --overwrite only when replacement is
intentional. Each conversion is staged and committed as one generation, so an
ordinary failure does not leave a partial set of final .dcm files.
Generated DICOM UIDs are fresh for each conversion. Reproducible pipelines may
opt into full source-content/configuration identity with
--uid-policy deterministic; this hashes the complete source and is therefore
more expensive on large slides.
The default conversion preset is lossless-review, which emits HTJ2K Lossless
RPCL. For explicit JPEG Baseline output:
Useful operational commands:
HTJ2K pixel decode validation auto-detects grk_decompress when it is on
PATH. You can also provide an explicit absolute decoder command:
Missing external tools are reported as skipped unless --strict is set.
Directory validation is bounded by file count, depth, timeout, and child output
capture limits; symlink traversal is refused.
Rust API
Use the builder API for normal exports:
use ;
let report = from_slide
.to_directory
.with_research_placeholder_metadata
.tile_size
.jpeg_quality
.icc_profile_policy
.run?;
Use request types when an integration needs full control:
use ;
let mut options = lossless_review;
options.transfer_syntax = Htj2k;
options.jpeg_direct_htj2k_profile = Lossy97Balanced;
options.icc_profile_policy = FallbackSrgb;
let request = new?;
let report = export_dicom?;
For composed tile samples:
use ;
let pixels = vec!;
let samples = new?;
let frame = encode_dicom_j2k_frame?;
Behavior Notes
- ICC handling is explicit. Missing source profiles default to synthesized sRGB;
use
--icc strict,--icc fallback-display-p3, or--icc omit-if-missingwhen a different policy is required. - JPEG Baseline output preserves compatible native JPEG frames. HTJ2K lossless output rejects nonconformant color JPEG direct routes and falls back through decoded RGB/RCT.
- JPEG 2000 passthrough preserves eligible native source codestreams.
- Route profile and coverage JSON reports expose available frame counts, sampled frame percentages, route counters, pixel profiles, and GPU counters.
- Output names encode scene, series, level, Z, channel, and time coordinates; consumers must use report paths rather than assuming the pre-0.7 name shape.
- Passing validators is release evidence, not formal DICOM certification.
Development
Core checks:
Pre-1.0 release gates:
Before a 1.0 release candidate, run these gates against published
dependencies and a representative real-slide corpus covering advertised routes,
metadata modes, ICC policies, validator checks, and any GPU route being
advertised.
Use the GDC benchmark harness only when publishing speed evidence:
Run the same command on the Metal and CUDA hosts with host-specific release
binaries and --system-label values. Merge result directories with
--merge-results, then publish failures, unsupported slides, transfer syntax,
frame geometry, tool versions, host details, and machine-readable results with
any performance claim.
Stability
wsi-dicom is pre-1.0. The builder API is the preferred integration surface.
Lower-level request, report, validation, and profiling types are public, but
callers should prefer constructors and defaults over struct literals where
provided.
License
Dual-licensed under either MIT or Apache-2.0, at your option.