You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify volumetric array axis order is WHD (X,Y,Z), not HWD (#8337)
MONAI's NIfTI/ITK readers return ndarrays whose axis 0 is columns/Width
(X), axis 1 is rows/Height (Y), and axis 2 is Depth/slices (Z) — see
`ITKReader._get_array_data` in `monai/data/image_reader.py` which
applies `.T` to the ITK-native (Z,Y,X) array to produce (X,Y,Z), and
nibabel which already serves (X,Y,Z). Several docstrings and one error
message described this layout as `HWD` / `CHWD` / `NCHWD`, which swaps
the spatial meanings of H and W and is misleading to users writing
custom loaders or comparing array shapes against DICOM/NIfTI metadata.
Update the user-facing docstrings to use `WHD` / `CWHD` / `NCWHD` and
add a brief note on each describing the per-axis meaning so the
convention is unambiguous when read in isolation:
- monai/data/image_writer.py: `H, HW, HWD` → `W, WH, WHD` in the
`resample_if_needed` docstring (the canonical NIfTI-semantics
description in the writer hierarchy).
- monai/visualize/utils.py: `matshow3d` volume shape doc.
- monai/visualize/img2tensorboard.py: docstrings + the
`AssertionError` message in `_image3_animated_gif`. The TensorBoard
API arguments `dataformats="HW"/"CHW"/"NCHWT"` and the user-visible
GIF tag suffix `f"{tag}_HWD"` are intentionally left unchanged —
those are TensorBoard-side conventions / public log keys.
- monai/handlers/tensorboard_handlers.py: `frame_dim` docstring on
`TensorBoardImageHandler`.
- monai/apps/vista3d/inferer.py: `point_based_window_inferer` input
shape doc.
This change is documentation-only; no runtime behavior is affected.
Out of scope for this commit (tracked separately):
- `monai/apps/deepedit/transforms.py` uses the `CHWD` label in 15
places that are tightly coupled to click-coordinate construction
(`[g[0], g[-2], g[-1], sid]`). Renaming the label without verifying
the click semantics would create a doc/code mismatch and may mask a
real coordinate-order bug; this needs a separate code-level review.
- `monai/apps/deepgrow/transforms.py` uses `CDHW` (depth-first), which
is a different convention question from the H/W swap addressed here.
- Tensor-axis docstrings in losses/metrics/inferers (NCHW, NCHWD,
BCDHW, BC[HWD], etc.) follow the established PyTorch placeholder
convention and are dimension-agnostic; not touched.
- Detection box-mode enums (`XYZWHD`, `CCCWHD`) and anchor flatten
counts (`HWA`, `HWDA`) define H/W/D explicitly within their own
subsystems and are internally consistent; not touched.
Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
0 commit comments