Skip to main content

Terminal-based medical image viewer for DICOM, NRRD, and Nifti formats with high-quality graphics rendering

Project description

PyDCMView

Terminal-based medical image viewer for DICOM, NRRD, and Nifti formats with high-quality graphics rendering.

Installation

pip install pydcmview

Usage

pydcmview <path_to_image_file_or_dicom_directory>

When using over remote SSH, I've only gotten advanced graphics rendering to work with kitty with the following remote SSH command

kitty +kitten ssh <typical_ssh_arguments_here>

e.g., kitty +kitten ssh -p 6000 my_server_address

With other remote SSH connections, it falls back to Unicode block rendering. Adjust the terminal font zoom to increase/decrease rendering resolution. Each character block represents 2 pixels.

Features

  • Format Support: DICOM, NRRD, and Nifti formats
  • High-Quality Rendering: Uses textual-image with Sixel and Kitty graphics protocols for superior image quality
  • 2D Slice Viewing: Navigate through N-dimensional images slice by slice
  • Interactive Dimension Selection: Overlay-based dimension selection with axis assignment and flipping
  • WASD Scrolling: Pan across images with 5% step size, zoom-aware navigation
  • Zoom Controls: Zoom in/out functionality with scroll position preservation (0.01x to 20.0x)
  • Crosshair Mode: Interactive crosshair with adjustable opacity and pixel intensity display
  • Window/Level Adjustment: Percentage-based contrast and brightness control (1% and 5% increments)
  • Colormap Selection: Multiple colormap options for enhanced visualization
  • Smart Navigation: Arrow keys and vim motion keys supported throughout
  • Comprehensive Status Bar: Real-time display of image info, coordinates, and available commands

Key Bindings

Normal Mode

  • q: Quit application
  • ↑/↓ or j/k: Navigate through slices
  • w/a/s/d: Scroll image (up/left/down/right) - 5% of image size per step
  • t: Toggle dimension selection overlay
  • c: Enter colormap selection
  • h: Enter crosshair mode
  • Shift+W: Enter window/level mode
  • [/]: Zoom out/in (preserves scroll position)

Dimension Selection Overlay

  • ↑/↓ or j/k: Navigate dimensions
  • x: Assign dimension to X-axis (swaps if already assigned to Y)
  • y: Assign dimension to Y-axis (swaps if already assigned to X)
  • f: Toggle flip for selected dimension (marked with *)
  • Enter: Confirm and apply changes
  • Esc: Cancel and return to normal mode

Crosshair Mode

  • ↑/↓/←/→ or h/j/k/l: Move crosshair position
  • Shift+↑/↓ or J/K: Adjust crosshair opacity
  • Esc: Exit crosshair mode

Window/Level Mode

  • ↑/↓ or j/k: Adjust window width (1% of intensity range)
  • ←/→ or h/l: Adjust window center/level (1% of intensity range)
  • Shift+↑/↓ or J/K: Adjust window width (5% of intensity range)
  • Shift+←/→ or H/L: Adjust window center/level (5% of intensity range)
  • Esc: Exit window/level mode

Technical Details

Rendering Engine

  • Primary: textual-image library with Terminal Graphics Protocol support
  • Fallback: Unicode block characters for broader terminal compatibility
  • Graphics Protocols: Sixel (xterm, mintty) and Kitty graphics for high-resolution display

Navigation and Zoom

  • WASD Scrolling: 5% of image dimensions per step, scaled with zoom level
  • Zoom Preservation: Scroll position maintained during zoom operations with bounds checking
  • Zoom Range: 0.01x to 20.0x with nearest-neighbor interpolation for medical accuracy
  • Smart Constraints: Automatic scroll boundary enforcement to prevent out-of-bounds navigation

Dimension Management

  • Dynamic axis assignment for N-dimensional data
  • Independent dimension flipping with visual indicators
  • Automatic slice axis calculation for 3D+ datasets

Requirements

  • Python 3.8+
  • textual>=0.70.0
  • textual-image>=0.3.0 (replaces rich-pixels for better graphics)
  • SimpleITK>=2.3.0
  • numpy>=1.21.0
  • pydicom>=2.3.0
  • Pillow>=8.0.0

Recent Updates

Graphics Engine Upgrade

  • Migrated from rich-pixels to textual-image for superior rendering quality
  • Added support for Sixel and Kitty terminal graphics protocols
  • Maintained backward compatibility with Unicode block rendering

Enhanced Navigation

  • WASD Scrolling: Added image panning with percentage-based movement (5% of image size)
  • Zoom Position Preservation: Zoom operations now maintain current view position with bounds checking
  • Improved Window/Level: Percentage-based adjustments (1% and 5%) relative to image intensity range
  • Colormap Integration: Multiple colormap options for enhanced medical image visualization
  • Extended Zoom Range: Increased zoom capability from 5.0x to 20.0x maximum

UI/UX Improvements

  • Real-time status bar updates with zoom level and opacity display
  • Context-sensitive key binding hints
  • Smooth overlay transitions with semi-transparent backgrounds
  • Improved dimension swapping logic for intuitive axis assignment

Terminal Compatibility

Best Experience:

  • Kitty terminal (full graphics protocol support)
  • iTerm2 (with graphics support)
  • xterm with Sixel support

Good Experience:

  • Most modern terminals (Unicode block fallback)
  • Windows Terminal
  • GNOME Terminal
  • Terminal.app (macOS)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydcmview-0.1.6.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydcmview-0.1.6-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pydcmview-0.1.6.tar.gz.

File metadata

  • Download URL: pydcmview-0.1.6.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pydcmview-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7b339d070b6d02a9b5aba0c12083db6838782430460a83c76cf16a880046d52f
MD5 4df1b0d2f3dbdd0611303af27bfa5a6c
BLAKE2b-256 666df567292f99f1f9abda8a8f66ac4e7244fb0902b7f85fd5539bc21d0d7b3c

See more details on using hashes here.

File details

Details for the file pydcmview-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pydcmview-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pydcmview-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3fa8ff32f45657fedf146193beb6869904b8e17ad556a265ebf61183c1b34a0e
MD5 e53ef263c985df3ac3dbbd55a8466272
BLAKE2b-256 71030d9bd613b458fa3e96af41073c2de808ba33ae19c045bd1ee7c47197637d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page