IVIMfitSlicer is a comprehensive 3D Slicer extension designed for the robust analysis of Intravoxel Incoherent Motion (IVIM) Diffusion-Weighted Imaging (DWI) data.
It integrates the power of the ivimfit Python library directly into the clinical workflow of 3D Slicer, offering both voxel-wise parametric mapping and ROI-averaged statistical modeling with advanced visualization capabilities.
Research Grade: Designed for high-precision fitting using multiple algorithms, including Segmented, Free, Tri-exponential, and Bayesian models.
- Mono-Exponential (ADC): Standard Apparent Diffusion Coefficient calculation.
-
Bi-Exponential (IVIM):
-
Segmented Fit: Robust two-step estimation (High-b first, then Low-b) to separate diffusion (
$D$ ) from perfusion ($f, D^*$ ). Default threshold: $b=200$. - Free Fit: Non-linear least squares fitting for all parameters simultaneously.
-
Segmented Fit: Robust two-step estimation (High-b first, then Low-b) to separate diffusion (
-
Tri-Exponential: Advanced compartmental analysis for separating fast, intermediate, and slow diffusion components (
$f_{fast}, f_{interm}, f_{slow}$ ). - Bayesian Inference: (Optional) MCMC-based parameter estimation for high-precision ROI statistics.
- Simultaneous Output: Generates both 3D parametric maps and numerical ROI statistics in a single run.
-
Smart Visualization:
- Auto-Layout: Automatically switches Slicer layout to "Four-Up Quantitative" to show maps and fitting plots side-by-side.
-
Interactive Plotting: Plots the Raw Signal vs. Fitted Curve with
$R^2$ values and calculated parameters directly in the Slicer interface. -
Auto-Scaling: Automatically scales diffusion maps (
$\times 10^6$ ) and fractions ($\times 100$ ) to ensure optimal visibility and contrast.
- Sequence & MultiVolume Support: Seamlessly handles 4D datasets, including Sequence Nodes and MultiVolume nodes.
- Standard Clinical Preset: Includes a dedicated "Load 10-Point Preset" button to instantly apply standard b-values (
0, 50, 100, 150, 200, 300, 400, 500, 700, 900) for rapid analysis setup.
- Open 3D Slicer.
- Go to the Extensions Manager.
- Search for
IVIMfitSlicerand install.
- Clone or download this repository.
- Open 3D Slicer.
- Go to Developer Tools -> Extension Wizard.
- Click Select Extension and navigate to the
IVIMfitSlicerfolder. - Ensure the module is checked and accept the restart if prompted.
Optional: Only required for the "Bayesian " algorithm.
The **Bayesian ** mode performs extensive Markov Chain Monte Carlo (MCMC) sampling (10,000 draws, 3 chains) to provide highly accurate parameter estimations and Gelman-Rubin (R-hat) convergence statistics.
The Computational Bottleneck:
Computing massive MCMC chains in pure Python can take hours or even a full day. To achieve high performance, the underlying PyMC/PyTensor engine attempts to compile the mathematical models into C++ code. However, 3D Slicer's embedded Python environment is stripped down to save space and lacks the necessary C++ headers (include) and linking libraries (libs).
The Solution (C++ Acceleration): If you want to run the Quality mode in minutes rather than days, you must manually link a standard Python environment to your 3D Slicer installation to enable C++ compilation. If you skip this setup, the module will fallback to pure Python (expect extremely long computation times).
- A C++ Compiler (e.g.,
g++via MSYS2/MinGW) added to your system PATH. - A standard local Python installation that matches Slicer's Python version (e.g., Python 3.9 or 3.12).
- Locate Slicer's Python Directory:
Navigate to your Slicer installation path, typically:
C:\Users\<YourUsername>\AppData\Local\slicer.org\3D Slicer <Version>\lib\Python - Fix the Linking Libraries (
libs):- Inside Slicer's Python folder, create a new empty folder named
libs. - Go to your system's standard Python installation folder (e.g.,
C:\Users\<YourUsername>\AppData\Local\Programs\Python\Python312\libs). - Copy the library file (e.g.,
python3.liband/orpython312.lib) and paste it into the newlibsfolder inside Slicer.
- Inside Slicer's Python folder, create a new empty folder named
- Fix the Headers (
include):- Go to your system's standard Python folder and copy the entire
includefolder (which containsPython.h). - Paste it directly into Slicer's Python directory (next to the
libsfolder you just created).
- Go to your system's standard Python folder and copy the entire
- Restart 3D Slicer as Administrative Mode:
Run the Bayesian mode. The system will now detect
g++and the header files, compiling the model in seconds and unlocking maximum hardware performance.
Unlike Windows, Linux systems dynamically link shared objects (.so), so the process is simpler.
1. Install Compiler & Headers:
Open your terminal and run:
sudo apt-get update
sudo apt-get install build-essential python3.9-dev (Change 3.9 to match Slicer's Python version)
2. Link the Headers:
- Navigate to Slicer's Python directory:
~/Slicer-5.x.x-linux-amd64/lib/Python - Create a folder named
include. - Copy your system's python headers (usually in
/usr/include/python3.x) into this folder. (Alternatively:ln -s /usr/include/python3.x ~/Slicer-path/lib/Python/include)
macOS uses Apple's Clang compiler instead of standard GCC.
1. Install C++ Compiler:
Open Terminal and run:
xcode-select --install
2. Link the Headers:
- Right-click
Slicer.app-> Show Package Contents. - Navigate to:
Contents/lib/Python - Create an
includefolder. - Copy the
includefolder from your standard Python installation (usually in/Library/Frameworks/Python.framework/Versions/3.x/include/) into Slicer's newly createdincludefolder.
Strategic Design Choice regarding Parametric Mapping: Computing Markov Chain Monte Carlo (MCMC) simulations on a voxel-by-voxel basis for 3D parametric mapping is computationally prohibitive (potentially taking days for a single volume).
To maximize workflow efficiency without sacrificing statistical rigor, IVIMfitSlicer employs a hybrid approach:
- 3D Parametric Maps are generated rapidly using the robust Segmented algorithm for Bayesian selections, providing immediate visual feedback and spatial distribution context.
- ROI-Averaged Statistics, which are critical for scientific conclusions, are computed using the selected Bayesian Inference model to provide the highest parameter precision and R-hat convergence values.
Import your DWI dataset (DICOM, NRRD, or Sequence) into 3D Slicer.
- Go to the Segment Editor module.
- Create a segmentation mask covering the tissue of interest (e.g., Tumor, Liver, Kidney).
- Note: Analysis is strictly ROI-based to ensure computational efficiency and high SNR.
- Switch to the IVIMfitSlicer module (under Diffusion category).
- Input Image: Select your DWI sequence.
- ROI Mask: Select the segmentation you created.
- B-Values: Enter b-values manually or click "Load 10-Point Preset" for quick configuration.
- Algorithm: Choose your desired model (e.g.,
Bi-Exponential (Segmented)).
- Click "Run Analysis & Plot".
- The module will:
- Extract data from the ROI.
- Perform voxel-wise fitting (generating maps).
- Perform ROI-averaged fitting (generating statistics).
- You can change view layout and obsreve fitting curve with PlotCharts.
- You can change shown map by selecting in "Data" section.
Step 1: Configuration (Main Window)
Setting up inputs, ROI mask, and selecting the preset with Bi-Exponential Segmented model.
Step 2: Analysis Results (Maps & Plots)
Generated Diffusion (D) Map and the ROI fitting curve with calculated parameters .
IVIM Bi-Exponential Model:
-
$D$ : True diffusion coefficient (Slow component). -
$D^*$ : Pseudo-diffusion coefficient (Fast/Perfusion component). -
$f$ : Perfusion fraction.
Tri-Exponential Model: $$\frac{S(b)}{S_0} = f_{fast} \cdot e^{-b D^{fast}} + f{interm} \cdot e^{-b D^{interm}} + f{slow} \cdot e^{-b D}$$ Useful for tissues with three distinct diffusion compartments.
This extension automatically manages the following Python dependencies:
ivimfit(Core calculation engine)numpy,scipypydicom
You can find Sample Data on Slicer's Sample Data Module
Author: Atakan Isik (Baskent University)
License: MIT License.
If you use this software in your research, please cite the associated repository or publication10.36948/ijfmr.2025.v07i05.56036.
Developed for the Slicer Community.