MELAGE: An open-source Python toolkit for medical imaging (3D MRI & 3D ultrasound, 3D CT, etc.).
Project description
๐ง ๐ฉป MELAGE: Medical Imaging Software
Machine learning & analysis for next-generation neuroimaging and medical imaging research
Table of Contents
- Features
- Plugins & Dynamic Extensions
- Installation
- Usage
- Dependencies
- Manual (collapsible)
- License
- Citation & Acknowledgements
- Releases
MELAGE is an open-source neuroimaging software designed for analysis, segmentation, and visualization of multimodal datasets.
It combines classical medical image processing with state-of-the-art deep learning support, making it useful for both researchers and practitioners.
๐ New in v2.x: Real-Time Video Segmentation MELAGE now supports full medical video loading and processing. Apply segmentation algorithms to video streams (e.g., Ultrasound loops) with the same speed and accuracy as static images. Analyze, segment, and save results frame-by-frame in real-time.
๐ฅ Key Features
- โก Real-Time Video Processing: Seamlessly load medical videos (e.g., Ultrasound, Cine-MRI) and perform segmentation with the same high speed and accuracy as static images.
- ๐ผ๏ธ Multi-Modality Support: Comprehensive support for MRI, CT, X-Ray, and Ultrasound data in standard formats (DICOM, NIfTI, AVI, MP4).
- ๐ง Deep Learning Integration: Built-in support for PyTorch models, allowing you to deploy state-of-the-art AI for automated segmentation and classification.
- ๐ ๏ธ Advanced Preprocessing: Powerful tools for denoising, filtering, resampling, and harmonizing image data before analysis.
- ๐จ Interactive Visualization: 2D and 3D rendering capabilities for exploring anatomical structures and segmentation results in detail.
- ๐ Dynamic Plugin System: easily extend functionality by dropping Python scripts into the plugins/ folderโMELAGE automatically generates the GUI for you.
- ๐พ Flexible Export: Save your results, including video segmentation masks, into standard research-ready formats.
๐งฉ Plugins & Dynamic Extensions
MELAGE now features a powerful Dynamic Plugin System that allows you to integrate custom Deep Learning models or image processing algorithms without modifying the core source code.
How it works:
- Create: Write your algorithm or model wrapper as a Python class inheriting from the MELAGE Plugin base class.
- Drop-in: Place your script in the
plugins/directory. - Auto-Load: MELAGE automatically detects, loads, and generates a GUI widget for your tool upon launch.
This modular architecture supports:
- Deep Learning inference: Drag-and-drop integration for
.pthor.onnxmodels. - Custom Analysis: Add proprietary segmentation or quantification logic.
- Workflow Automation: Create macros for repetitive tasks.
๐ How to Add a Plugin
- Folder Structure: Organize your plugin in its own directory under the
plugins/folder. MELAGE recursively scans these folders to find valid plugins.plugins/ โโโ warpseg/ โ โโโ __init__.py โ โโโ WarpSeg.py <-- Contains the Plugin Class โ โโโ WarpSeg_schema.py <-- Contains the Plugin Scheme for GUI โโโ my_new_tool/ โโโ ...
๐ Installation
๐ง LINUX:
๐ STEP 0: INSTALL CONDA (PREREQUISITE)
If you don't have Conda, install Miniconda (lightweight version).
- Download installer
wget [https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh)
- Run installer (Type 'yes' to license and init)
bash Miniconda3-latest-Linux-x86_64.sh - Refresh shell
source ~/.bashrc
๐ ๏ธ STEP 1: CREATE ENVIRONMENT (RECOMMENDED)
# Create env (Python 3.10 is most stable with PyQt5)
conda create -n melage-gui python=3.10 -c conda-forge -y
# Activate the environment
conda activate melage-gui
# Install PyQt5 (includes Qt frameworks)
conda install -c conda-forge pyqt=5 -y
# Install melage inside the environment
pip install melage
# Verify which melage is being used (should point to this env)
which melage
# Run
melage
๐ฆ STEP 2: INSTALL MELAGE (STANDALONE)
If skipping Conda (Not recommended for GUI apps):
From PyPI:
pip install melage
๐ STEP 3: CREATE ONE-CLICK LAUNCHERS
Create a script file to automatically activate the environment and run the app.
- Create a file named 'launch_melage.sh' with the following content:
(Note: Adjust the 'source' path if your conda is installed elsewhere)
#!/bin/bash # Initialize Conda (Adjust path based on 'conda info --base') source ~/miniconda3/etc/profile.d/conda.sh conda activate melage-gui melage
- Make it executable:
chmod +x launch_melage.sh
- Run it:
./launch_melage.sh
- (Optional) Create a Desktop Shortcut file named 'Melage.desktop':
(Create this file in ~/.local/share/applications/ for Start Menu access
OR on your ~/Desktop/ for a desktop icon).
[Desktop Entry] Version=1.0 Type=Application Name=Melage Comment=Melage GUI # IMPORTANT: Use absolute paths below (e.g., /home/user/...) Exec=/home/user/path/to/launch_melage.sh Icon=/home/user/path/to/your_icon.png Terminal=false Categories=Utility;
- (Optional) If put on Desktop, right-click file -> "Allow Launching".
๐ macOS:
๐ STEP 0: INSTALL CONDA (PREREQUISITE)
-
Download installer (Intel)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
... OR ...
Download installer (Apple M1/M2 Silicon)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
-
Run installer
bash Miniconda3-latest-MacOSX-x86_64.sh # or bash Miniconda3-latest-MacOSX-arm64.sh
-
Refresh shell
source ~/.zshrc
๐ ๏ธ STEP 1: CREATE ENVIRONMENT (RECOMMENDED)
# Create env (Python 3.10 is most stable with PyQt5)
conda create -n melage-gui python=3.10 -c conda-forge -y
# Activate the environment
conda activate melage-gui
# Install PyQt5 (includes Qt frameworks)
conda install -c conda-forge pyqt=5 -y
# Install melage inside the environment
pip install melage
# Verify which melage is being used (should point to this env)
which melage
# Run
melage
๐ฆ STEP 2: INSTALL MELAGE (STANDALONE)
If skipping Conda (Not recommended for GUI apps):
From PyPI:
pip install melage
๐ STEP 3: CREATE ONE-CLICK LAUNCHERS
Create a script file to automatically activate the environment and run the app.
- Create a file named 'launch_melage.sh' with the following content:
(Note: Adjust the 'source' path if your conda is installed elsewhere)
#!/bin/bash # Initialize Conda (Adjust path based on 'conda info --base') source ~/miniconda3/etc/profile.d/conda.sh conda activate melage-gui melage
- Make it executable:
chmod +x launch_melage.sh
- Run it:
./launch_melage.sh
Alternatively
- Open "Automator" (Cmd + Space -> Type Automator).
- Select "Application" -> Click "Choose".
- Search for "Run Shell Script" and double-click it.
- Paste the code below (Update the path using 'conda info --base'!):
source /Users/yourname/miniconda3/etc/profile.d/conda.sh
conda activate melage-gui
melage
- Press Cmd+S to save. Name it "Melage" and save to Applications.
--- HOW TO CHANGE THE APP ICON ---
- Copy your logo image (Open image -> Cmd + C).
- Right-click your new "Melage.app" -> "Get Info".
- Click the small icon in the top-left corner of the Info window.
- Paste (Cmd + V).
๐ฅ๏ธ WINDOWS:
๐ STEP 0: INSTALL CONDA (PREREQUISITE)
- Download .exe from https://docs.conda.io/en/latest/miniconda.html
- Run installer.
- Open "Anaconda Prompt" from Start Menu for the steps below.
๐ ๏ธ STEP 1: CREATE ENVIRONMENT (RECOMMENDED)
# Create env
conda create -n melage-gui python=3.10 -c conda-forge -y
# Activate
conda activate melage-gui
# Install PyQt5
conda install -c conda-forge pyqt=5 -y
# Install antspyx (Optioanl) to avoid pip install melage failed for any reason)
conda install -c conda-forge antspyx
# Install melage
pip install melage
# Run
melage
๐ฆ STEP 2: INSTALL MELAGE (STANDALONE)
If skipping Conda (Not recommended for GUI apps):
From PyPI:
pip install melage
๐ STEP 3: CREATE ONE-CLICK LAUNCHERS
- Create a file named 'launch_melage.bat' with the following content:
call conda activate melage-gui melage pause
- Double-click 'launch_melage.bat' to run the app.
- (Optional) Right-click the .bat file -> "Send to" -> "Desktop (create shortcut)" to give it a custom icon.
๐ฅ๏ธโจ Usage
After installation and activating your virtual environment, you can launch MELAGE directly from the terminal:
conda activate melage-gui
melage
MELAGE graphical user interface in action.
๐ฆ Dependencies
MELAGE relies on the following core libraries:
- NumPy, SciPy โ numerical computing & scientific operations
- scikit-image, Pillow, OpenCV โ image processing & visualization
- scikit-learn, numba, einops โ machine learning & acceleration
- nibabel, pydicom, pynrrd, SimpleITK โ medical imaging formats (NIfTI, DICOM, NRRD)
- PyQt5, QtPy, qtwidgets โ GUI support
- matplotlib, vtk, PyOpenGL โ visualization & rendering
- shapely, trimesh, rdp โ geometry & 3D mesh processing
- pyfftw โ fast Fourier transforms
- cryptography โ security utilities
- dominate โ HTML generation
Optional Extras
- Deep Learning:
torch>=1.12(pip install melage[dl])
๐ Manual
๐ Main Page
The Main Page is the first window that appears after launching MELAGE.
๐ From here, you can:
- โ Create a new project
- ๐ Load a previously saved project (default format:
.bn)
The MELAGE Main Window
๐ ๏ธ Toolbars
1๏ธโฃ Project Toolbar
Located at the top-left of the main window, the Project Toolbar provides quick access to essential project actions:
- ๐ Create New Project โ Start a new project and open a new image file.
- ๐ Load Project โ Open a previously saved project with all applied changes (so you donโt lose your progress).
- ๐พ Save Project โ Save the current project. This will overwrite the existing file if one is already open.
๐ These options are also available through the File menu:
File โ New ProjectFile โ Load ProjectFile โ Save
Project toolbar: (from left to right) Create New Project, Load Project, Save
2๏ธโฃ Image Toolbar
To the right of the Project Toolbar, youโll find the Image Toolbar, which allows you to load up to two images simultaneously:
- ๐ผ Open First Image โ Default button for loading First image (often referred to as the top image).
- ๐งฒ Open Second Image โ Default button for loading Second image.
Image toolbar: Left โ No project loaded. Right โ Project loaded.
3๏ธโฃ Tools Toolbar
At the top-left of MELAGE, youโll find the Tools Toolbar, which contains seven buttons grouped into three sections:
- โ๏ธ Build Lines โ Draw multiple lines in the same slice and create a segmentation by connecting their endpoints (explained in detail later).
- ๐ฏ Point Selection โ Mark and locate selected points within a slice.
- ๐ Zoom In โ Zoom into all windows (3/6 view) simultaneously.
- ๐ Zoom Out โ Zoom out of all windows simultaneously.
- ๐ Measurement โ Ruler tool to measure distances and lengths.
- ๐ Linking โ Synchronize sagittal, coronal, and axial slices. This makes it easy to locate the same point across all views.
- ๐ง 3D Toggle โ Show or hide 3D widgets in the view.
Tools toolbar with essential navigation and annotation functions
4๏ธโฃ Panning Toolbar
Just below the Project Toolbar, youโll find the Panning Toolbar with two options:
- ๐ฑ Arrow โ Standard selection arrow.
- โ Panning โ Drag to move around within a slice (useful after zooming).
Panning toolbar for navigating slices
5๏ธโฃ Segmentation Toolbar
On the right side of the Panning Toolbar, youโll find the Segmentation Toolbar. From left to right:
- ๐ฉน Eraser โ Remove segmentation from the image.
- ๐ฉนโ Eraser X Times โ Erase the same region across multiple following slices.
- ๐ Pen โ Freehand segmentation with arbitrary closed shapes.
- ๐ Contour โ Draw a contour to segment everything inside it.
- ๐โ Contour X Times โ Apply contour segmentation across multiple slices.
- โญ Circle โ Segment a region using a circle with an adjustable radius.
- ๐จ Activated Color โ Displays the currently active segmentation color.
- ๐ท Color Name โ Shows the name of the active segmentation color.
Segmentation toolbar for drawing and editing regions
6๏ธโฃ Exit Toolbar
Finally, at the far right, youโll find the Exit Toolbar, which includes:
- ๐งฉ Logo โ Displays the MELAGE / MELAGE+ logo.
- โ Exit โ Closes the application.
Exit toolbar with logo and close button
Widgets
๐จ Color widget
|
|
|
Choose, activate, and search label colors (LUTs) for different structures. You can switch styles, import your own, and customize labels. |
You can freely change stylesโor add your own.
Currently default styles come from these human brain atlases:
- ๐ผ Albert Neonatal brain atlas
- ๐ผ M-CRIB 2.0 neonatal brain atlas
- ๐ง Adult brain (generic)
There are also two tissue-based styles and one simple scheme.
You can import a new style via Import.
Label names are editable, and you can create a new label by clicking a color in the Segmentation Toolbar.
Add a color
Pick a new color here. Then youโll see a second window:
Add index and name
Set the index and name for the new color.
If the index already exists, the new color will replace the previous one.
๐งฐ Image enhancement widget
|
|
|
Enhance images with:
- ๐ Brightness & contrast
- ๐งฑ Band-pass & Hamming filters
- ๐งญ Sobel edge operator
- ๐ Rotation by anatomical planes (sagittal, axial, coronal) or combinations
Thereโs also a โsagittal โ coronalโ swap for datasets that need plane reorientation (handy for certain top/bottom image workflows).
๐ Table widget
Table widget
This table includes:
- ๐ Description โ additional notes
- ๐ผ Image type โ top (first image) or bottom (second image)
- ๐ Measure 1 โ surface or length (ruler)
- ๐ Measure 2 โ perimeter or angle (ruler)
- ๐งพ Slice โ slice number
- ๐ช Window name โ sagittal, coronal, or axial
- ๐ฏ CenterXY โ center position
- ๐ FileName โ file name
Table widget (context menu)
Right-click options:
- โ Add โ insert a new row
- โ๏ธ Edit โ edit the current cell
- ๐ค Export โ save table as CSV
- ๐ Remove โ delete the current row
๐ผ๏ธ Batch Images widget
Images widget
Manage a set of images (e.g., different modalities or sessions) and their corresponding segmentations.
- Toggle the eye icon to show/hide an image.
- A segmentation file requires its image to be loaded first.
Images widget (context menu)
Right-click options:
- ๐ฅ Import
- Images โ import one or more images
- Segmentation โ import a segmentation associated with a loaded image
- ๐ Remove Selected โ remove the highlighted item
- ๐งน Clear All โ clear all non-active images
When importing, youโll see:
Import dialog
Choose the image/segmentation type from the dialog.
Use Preview to inspect an image before opening it. ๐
๐ Segmentation intensity widget
Segmentation intensity
Adjust the visual intensity of the segmentation overlay.
- 0 โ hide segmentation
- Higher values โ stronger overlay
๐๏ธ Marker size widget
Marker size
Controls (top โ bottom):
- โญ Circle radius for region selection
- โ๏ธ Pen thickness for contour drawing
Tabs
MELAGE includes three tabs:
Tabs overview
1) ๐ค Mutual view
- Process two images at once.
- Each image shows three planes in the order: coronal, sagittal, axial.
- The number above each plane is the slice index.
- Side letters indicate orientation: S (sagittal), A (axial), C (coronal).
- You can segment and process either image directly in this view.
- The top panel shows the first (top) image; the bottom panel shows the second (bottom) image.
- If one image is closed, the tab displays the three planes of the remaining image:
2) ๐งฉ Top image (first image) workspace
Designed to focus on one plane at larger size while tracking the instant 3D view of the segmentation.
- ๐ Horizontal slider: scroll through slices
- ๐ Plane selection: choose sagittal, axial, or coronal
- ๐ Show seg: toggle segmentation overlay
- ๐ง 3D visualization: real-time 3D feedback
3) ๐งฉ Bottom image (second image) workspace
Same layout and controls, dedicated to the second (bottom) image.
- ๐ Horizontal slider: scroll through slices
- ๐ Plane selection: sagittal, axial, or coronal
- ๐ Show seg: toggle segmentation overlay
- ๐ง 3D visualization: real-time 3D feedback
๐ง 3D Visualization
Right-click on the 3D region to access various options:
๐ GoTo
- Activating GoTo lets you jump to the corresponding location in the image.
- The approximate mouse position in 3D space appears at the bottom-right of the window.
- The selected point will also appear in the closest sagittal, coronal, or axial plane.
๐งฉ Segmentation
- Toggle segmentation overlay within the 3D view.
- โ ๏ธ Tip: If it doesnโt activate immediately, switch to another tab and return.
๐งฉ Transparent 3D Overlay
MELAGE allows users to seamlessly overlay segmentation masks on top of anatomical images within the 3D visualization module. This feature enables clear comparison between raw data and segmented structures, while maintaining anatomical context.
- Transparency Control: Adjust the opacity of the segmentation layer for balanced visualization.
- Interactive Toggle: Enable or disable overlays dynamically without reloading the view.
- Integrated Navigation: Selected points remain synchronized across sagittal, coronal, and axial planes.
- โ ๏ธ Tip: If the overlay does not activate immediately, switch to another tab and return.
Transparent 3D overlay.
Transparent 3D overlay of segmentation mask and anatomical image in MELAGE.
๐จ BG color
- Change the background color of the 3D visualization.
- Choose between different themes to improve contrast.
๐๏ธ Painting
โ๏ธ Draw
- Cut parts of the 3D image interactively by drawing.
๐ Image render
- Render the 3D image using different color maps.
- The Segmentation Intensity widget can enhance visualization.
|
|
|
|
|
|
|
|
๐งญ Axis
- Display axes alongside the 3D visualization for orientation.
๐บ๏ธ Grid
- Show a reference grid within the 3D window.
๐ ๏ธ Tools
โ๏ธ Segmentation options with contour
Right-click on a segmented contour to access these options:
- ๐ฏ Center โ show center of the region
- ๐ Surface area โ compute region surface
- ๐ Perimeter โ measure perimeter length
- ๐ค Send to table โ export all measurements to the table widget
- โ Add to interpolation โ add the current slice to slice-to-slice interpolation
- โถ๏ธ Apply interpolation โ apply interpolation using current and previous slices
๐ Interpolation between slices
To interpolate across slices:
- โ Activate the colors you want to interpolate
- ๐ผ Select a segmented region in one plane (sagittal, axial, or coronal)
- โ Add more regions from other slices (as many as needed)
- ๐ฑ Right-click โ Apply interpolation
- โณ Wait for interpolation results
๐ Ruler
The ruler measures distances between two points in an image.
Right-click on a ruler gives access to:
- ๐ฏ Center position
- ๐ Length
- ๐ Line angle
- ๐ Remove โ delete the current ruler
- ๐ค Send to table โ export ruler data
๐ You can add unlimited rulers.
๐งฐ Tools menu
Options available under the Tools menu:
- โฉ๏ธ Undo โ revert up to 10 segmentations
- โช๏ธ Redo โ redo up to 10 actions
- ๐งช Preprocessing โ N4 Bias Field Correction, Image Masking, BET, DeepBET, Thresholding, Masking Ops, Change CS
- โน๏ธ Basic Info โ Histogram, Resize, Image Info
๐งฎ N4 Bias Field Correction
Uses SimpleITK. Parameters include:
- Otsu thresholding for mask creation
- Fitting level
- Shrinking factor
- Max iterations
- Image selection (top = first image, bottom = second image)
After running, you can restore the Original image if needed.
๐ญ Image Masking
Keep or remove image parts using segmentation masks:
- Image selection (top or bottom)
- Action: Keep / Remove
- Mask color
- Apply button
Reset by using mask color 9876_Combined.
๐ง Brain Extraction Tool (BET)
Implements Smith 2002.
Parameters:
- Advanced mode
- Iterations
- Adaptive thresholding
- Fractional threshold
- Search distance
- Radius of curvature
๐ค Deep Learning Brain Extraction
DL-based brain extraction with configurable options:
- Advanced mode (editable)
- Image selection
- Model selection
- CUDA acceleration (optional)
- Threshold (-4 to 4)
- Network weights path
- Apply button
๐ก Tip: Adjust threshold without rerunning the model.
โ๏ธ Image Thresholding
Multi-Otsu based thresholding:
- Image selection
- Number of classes
- Apply
โโ Masking Operations
Combine masks using summation or subtraction:
- Masking color(s)
- Operation
- Image selection
- Apply
๐งญ Change CS (Coordinate System)
- Image selection
- From (current system)
- To (desired system)
- Apply
๐ Basic Info
Tools for inspecting and resizing images.
- ๐ Histogram โ view image histogram
- ๐ Resize โ isotropic resize
- โน๏ธ Image info โ metadata with search
๐ File Menu
Options include:
- ๐ New project โ start fresh
- ๐ Load project โ open saved project
- ๐พ Save โ overwrite project
- ๐พ Save as โ save under new name
- ๐ฅ Import โ import segmentation
- ๐ค Export โ save modified image/segmentation with suffix
- ๐ธ Screenshot โ capture a plane or whole scene
- โ Close top image โ close first (top) image
- โ Close bottom image โ close second (bottom) image
- โ๏ธ Settings โ change application defaults
- ๐ช Exit โ close app (confirmation window will ask to save project)
๐ License
For licensing inquiries, please contact:
Protection & Registration
MELAGE is registered in the Electronic Register of Intellectual Property as software, under file FCAD-22002, by the Technology Transfer Office of the Andalusian Public Health System (OTT-SSPA).
- Identifier: 2211222681375
- View registration details on SafeCreative
This legal protection ensures intellectual property rights are formally secured.
๐ Citation & Acknowledgements
If you use MELAGE in your research, please cite the following work:
Jafrasteh, B., Lubiรกn-Lรณpez, S. P., & Benavente-Fernรกndez, I. (2023).
MELAGE: A purely Python-based Neuroimaging Software (Neonatal).
arXiv preprint arXiv:2309.07175
We would like to acknowledge all contributors and collaborators who have supported the development and testing of MELAGE.
๐ Releases
Stable releases and updates of MELAGE are available on the GitHub Releases page.
- ๐ข Stable releases: Fully tested, recommended for production and research use.
- ๐งช Pre-releases / beta versions: For testing new features and providing feedback.
Stay updated by watching the repository for new release notifications.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file melage-2.1.2.tar.gz.
File metadata
- Download URL: melage-2.1.2.tar.gz
- Upload date:
- Size: 63.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a52b0b22d471a980bfa97ee664171a05c3e0b83566a63cd4b419021e01db320
|
|
| MD5 |
17e30e847283d25da71da9414d32e0b3
|
|
| BLAKE2b-256 |
5e838ba8a87eb433b85ed0807f1868c33a91b4ecbd66323bd524e37a832ba163
|
File details
Details for the file melage-2.1.2-py3-none-any.whl.
File metadata
- Download URL: melage-2.1.2-py3-none-any.whl
- Upload date:
- Size: 53.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aae643c9e2ba9336b535885fdda6935fdd72a3c0904b2216e0b9349a4dc0f0a
|
|
| MD5 |
7ac9636a053da2696897be410bb932a7
|
|
| BLAKE2b-256 |
774498acbb7aff506f2a94974848da3dcaa6c318574929a11efdb9d8f97d6d6c
|