I fell while skiing and damanged my knee. Infuriated by the experience of reading my MRI results, I quickly built a DicomViewer with the help of Cursor and Grok. You can read about the experienec on Novice.Media. The app is not perfect, just like the rest of us. I hope that the next tech person that needs to see their MRI would be to use it, maybe fix bugs or contribute their features. Reach out on X if you would like to talk about it.
Below is a README.md file that encapsulates all the instructions, explanations, and usage details for the DICOM (Digital Imaging and Communications in Medicine) viewer script . This file includes everything someone would need to set up, run, and use the viewer for their own DICOM files, along with troubleshooting tips and potential next steps.
A powerful, local DICOM viewer written in Go that allows you to visualize DICOM files, including multi-frame sequences. The viewer supports zoom, pan, contrast adjustment, frame navigation, and series selection. Built for anyone with a computer who wants to load some DICOM files and view them, without the need to dowload any professional software, or to register for an account. The tool is lightweight and fast. No frills, yet.
- Quick Start
- Features
- Prerequisites
- Installation
- Usage
- Contributing
- License
- Code of Conduct
- Security
- Acknowledgments
The easiest way to get started is using our automated setup script. The script handles all dependencies, building, and launching the viewer.
You only need:
- A Unix-like system (macOS, Linux)
- Basic terminal access
- DICOM files to view
- (Theoretically it will work on Windows too, but I don't have one, haven't tried)
-
Get the code:
# Either clone the repository git clone https://github.com/kirillzubovsky/dicom-viewer.git cd dicom-viewer # Or download as ZIP from GitHub and extract it
-
Make the script executable:
chmod +x start.sh
-
Run the script with your DICOM directory:
./start.sh /path/to/dicom_files
Here I am assuming that just like me you were handed a CD with a DICOM recotry on, which you can copy on your machine. If that's not the case, you can read through the 'DICOM Directory Structure' section and see how to adjust the code for your needs.
The start.sh script is something I've been creating for all my projects. It just makes it easier to pick up a file on any machine and have it running without going through too many debug cycles. This particular script automatically:
- Checks your system requirements
- Installs Go if not present (using your system's package manager)
- Installs all necessary dependencies
- Sets up the project structure
- Validates your DICOM files
- Builds and launches the viewer
The script uses color-coded messages to keep you informed:
- Blue [INFO]: Normal progress information
- Green [SUCCESS]: Completed steps
- Yellow [WARNING]: Non-critical issues
- Red [ERROR]: Critical issues that need attention
The automated setup works on:
- macOS (using Homebrew)
- Ubuntu/Debian (using apt)
- Fedora (using dnf)
- Arch Linux (using pacman)
For other systems, follow the manual installation below.
If you encounter issues:
-
Path Issues:
# Try using absolute path ./start.sh $(pwd)/dicom_files
-
Permission Issues:
# Make sure script is executable chmod +x start.sh # For system packages sudo ./start.sh /path/to/dicom_files
-
Build Issues:
# Clean and retry rm -rf dicom_viewer/ ./start.sh /path/to/dicom_files
- DICOM File Parsing: Reads DICOM files and extracts metadata and pixel data
- Multi-Frame Support: Handles multi-frame DICOM files with frame-by-frame navigation
- Series Grouping: Groups images by series using DICOMDIR or directory structure
- Advanced Image Controls:
- Zoom: Zoom in/out with maintained aspect ratio
- Pan: Click and drag to pan around zoomed images
- Contrast Adjustment: Fine-tune image contrast with a wide-range slider
- Frame Navigation: Step through frames or use auto-play functionality
- Metadata Display: Shows comprehensive metadata including:
- Patient information
- Study details
- Image dimensions
- Anatomical orientation
- Series description
- Export Functionality: Export series to PNG format with:
- Current contrast settings preserved
- Complete metadata in text format
- Sequential frame numbering
- Cross-Platform: Works on Windows, macOS, and Linux
- Go: Version 1.16 or later
- Required Libraries:
- For Windows: GCC compiler (via MinGW or MSYS2)
- For Ubuntu/Debian:
sudo apt-get install gcc libgl1-mesa-dev xorg-dev - For macOS: Xcode Command Line Tools (
xcode-select --install)
- DICOM Files: A set of DICOM files organized in a standard directory structure
If you prefer to install manually or the automated script doesn't work for your system, follow these steps:
- Download Go from golang.org/dl/
- Follow the installation instructions for your operating system
- Verify installation:
go version
- Install MSYS2 from msys2.org
- Open MSYS2 terminal and run:
pacman -S mingw-w64-x86_64-gcc
- Add MinGW-w64 bin directory to your PATH
xcode-select --installsudo apt-get update
sudo apt-get install gcc libgl1-mesa-dev xorg-dev-
Create a project directory:
mkdir dicom_viewer cd dicom_viewer -
Initialize Go module:
go mod init dicom_viewer
-
Create
dicom_viewer.goand copy the source code into it -
Install dependencies:
go get github.com/suyashkumar/dicom go get fyne.io/fyne/v2
-
Basic usage:
go run dicom_viewer.go /path/to/dicom_files
-
Building an executable:
go build dicom_viewer.go
Then run:
- Windows:
dicom_viewer.exe path\to\dicom_files - macOS/Linux:
./dicom_viewer /path/to/dicom_files
- Windows:
The viewer expects one of these directory structures:
- With DICOMDIR:
dicom_files/ └── DICOM/ └── PAxxxxxx/ └── STxxxxxx/ └── SExxxxxx/ ├── IMxxxxxx └── ...
- Series Selection: Use dropdown at top to switch between series
- Frame Navigation:
- "Prev Frame"/"Next Frame" buttons
- "Play" button for automatic frame cycling
- Frame counter shows current position
- Zoom:
- "Zoom In": Increase image size
- "Zoom Out": Decrease image size
- "Reset Zoom": Return to original size
- Click and drag to pan when zoomed in
- Contrast:
- Slider adjusts image contrast
- Range: -255 to +255
- Current contrast value displayed
- Click "Export Series" button
- Select destination folder
- Creates:
- Directory named
series_SExxxxxx - PNG files for each frame with current contrast
metadata.txtwith series information
- Directory named
-
Window System Error (Linux):
sudo apt-get install libgl1-mesa-dev xorg-dev
-
Compilation Error (Windows):
- Ensure MinGW-w64 is properly installed
- Check PATH includes MinGW-w64 bin directory
-
No Series Found:
- Check directory structure
- Verify file permissions
- Ensure files are valid DICOM format
-
Performance Issues:
- Large series may load slowly
- Consider reducing frame rate in auto-play
- Close other memory-intensive applications
- "No valid DICOM series found": Check directory structure and file formats
- "Failed to parse DICOM file": File may be corrupted or in unsupported format
- "No frames found in pixel data": DICOM file may not contain image data
This project is provided under the MIT License. You are free to use, modify, and distribute it.
- Built with github.com/suyashkumar/dicom for DICOM parsing
- Uses fyne.io/fyne/v2 for cross-platform GUI
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Go coding standards and conventions
- Add tests for new features
- Update documentation as needed
- Keep pull requests focused and atomic
- Write meaningful commit messages
Please report security issues to me privately. Ideally though, just make a pull request and fix them. This is a hobby.
This viewer:
- Processes DICOM files locally only
- Does not transmit any data
- Does not store or cache patient information
Don't be a jerk.
This project is licensed under the MIT License - see the LICENSE file for details.
- github.com/suyashkumar/dicom - MIT License
- fyne.io/fyne/v2 - BSD 3-Clause License
Planned features and improvements:
- Fix remaining bugs with zoom/pan and window resizing
- Stich 2D images into a 3D visualization
- Put a 3D model of a human body next to the MRI images, and allow humans to visualize their images in context of their body. It would make it easier to understand orientation of an object.
- You choose..
- ¯_(ツ)_/¯
If you use this software in your research, please cite it as:
@software{dicom_viewer_go,
author = {Kirill Zubovsky},
title = {DICOM Viewer in Go},
year = {2025},
url = {https://github.com/kirillzubovsky/dicom-viewer}
}