A comprehensive toolkit for graph-based image analysis, multicut optimization, and n-dimensional image processing. NIFTY provides efficient C++ implementations with Python bindings for complex image segmentation and analysis tasks.
Simple installation from PyPI (Recommended):
pip install niftyFor development or latest features:
git clone --recursive https://github.com/DerThorsten/nifty.git
cd nifty
pip install -e .import nifty
import numpy as np
# Create a simple graph
graph = nifty.graph.UndirectedGraph(5)
graph.insertEdge(0, 1)
graph.insertEdge(1, 2)
graph.insertEdge(2, 3)
graph.insertEdge(3, 4)
print(f"Graph has {graph.numberOfNodes()} nodes and {graph.numberOfEdges()} edges")
# Check available features
print(f"NIFTY version: {nifty.__version__}")
nifty.print_version_info()NIFTY has migrated from CMake to setuptools! This brings several benefits:
- Simple installation: Just
pip install nifty - PyPI distribution: Standard Python package management
- Automatic dependency handling: No manual configuration needed
- Better error messages: Clear guidance when dependencies are missing
xtensor-python Migration: As part of this migration, NIFTY now uses a custom xtensor-python source from https://github.com/maxstidbits/xtensor-python that includes the completed setuptools/pip migration. This ensures full compatibility with the new build system and provides a seamless installation experience.
| Before (CMake) | After (Setuptools) |
|---|---|
| Complex multi-step build | Single pip install command |
| Manual dependency setup | Automatic dependency detection |
| Platform-specific instructions | Cross-platform compatibility |
| Build configuration required | Runtime feature detection |
# Basic installation with core features
pip install nifty# Install with HDF5 support
pip install nifty[hdf5]
# Install with solver support (GLPK)
pip install nifty[solvers]
# Install with Z5 support
pip install nifty[z5]
# Install all optional dependencies
pip install nifty[hdf5,solvers,z5]
# Development installation
pip install nifty[dev]Core Dependencies (automatically installed):
- Python β₯ 3.8
- NumPy β₯ 1.19.0
- scikit-image
System Dependencies (must be installed separately):
- xtensor β₯ 0.26.0 (C++ tensor library)
- xtensor-python β₯ 0.28.0 (Python bindings for xtensor - now installed via pip from custom source)
- Boost β₯ 1.63.0 (C++ libraries)
- C++17 compatible compiler
Note: xtensor-python is now installed from a custom GitHub source that includes the completed setuptools/pip migration. This ensures compatibility with the new build system.
Optional Dependencies:
- HDF5: For HDF5 file format support
- GLPK: Open-source linear programming solver
- Z5: Chunked array storage format
- OpenMP: Parallel processing support
# Install system dependencies
sudo apt-get update
sudo apt-get install -y \
build-essential \
python3-dev \
libboost-all-dev \
libxtensor-dev \
libhdf5-dev \
libglpk-dev
# Install xtensor-python from custom GitHub source
pip install git+https://github.com/maxstidbits/xtensor-python.git
# Install NIFTY
pip install nifty[hdf5,solvers]# Install system dependencies
brew install boost xtensor hdf5 glpk
# Install xtensor-python from custom GitHub source
pip install git+https://github.com/maxstidbits/xtensor-python.git
# Install NIFTY
pip install nifty[hdf5,solvers]# Using conda (recommended for Windows)
conda install -c conda-forge boost xtensor hdf5 glpk
# Install xtensor-python from custom GitHub source
pip install git+https://github.com/maxstidbits/xtensor-python.git
# Install NIFTY
pip install nifty[hdf5,solvers]# Create conda environment with dependencies
conda create -n nifty-env -c conda-forge python=3.11 boost xtensor
conda activate nifty-env
# Install xtensor-python from custom GitHub source
pip install git+https://github.com/maxstidbits/xtensor-python.git
# Install NIFTY
pip install niftyNIFTY automatically detects available features at runtime:
import nifty
# Check what features are available
info = nifty.get_version_info()
print("Available features:")
for feature, available in info['features'].items():
status = "β" if available else "β"
print(f" {status} {feature.lower().replace('with_', '')}")
# Check specific features
if hasattr(nifty, 'hdf5'):
print("HDF5 support is available")
else:
print("HDF5 support is not available")Error: fatal error: xtensor/xarray.hpp: No such file or directory
Solution:
# Install xtensor via system package manager
# Ubuntu/Debian
sudo apt-get install libxtensor-dev
# macOS
brew install xtensor
# Conda
conda install -c conda-forge xtensor
# Install xtensor-python from custom GitHub source
pip install git+https://github.com/maxstidbits/xtensor-python.gitError: fatal error: boost/graph/adjacency_list.hpp: No such file
Solution:
# Ubuntu/Debian
sudo apt-get install libboost-all-dev
# macOS
brew install boost
# Conda
conda install -c conda-forge boostError: Microsoft Visual C++ 14.0 is required (Windows)
Solution: Install Visual Studio Build Tools or use conda:
conda install -c conda-forge compilersError: ImportError: cannot import name '_nifty'
Solution: Check that C++ extensions were built correctly:
import nifty
print(nifty.__file__) # Should show installed location
nifty.print_version_info() # Check build statusEnable verbose output for troubleshooting:
export NIFTY_DEBUG=1
pip install nifty -vIf you encounter issues:
- Check system dependencies: Ensure xtensor, xtensor-python, and Boost are installed
- Verify Python version: NIFTY requires Python β₯ 3.8
- Check compiler: Ensure C++17 support is available
- Review error messages: Look for specific missing dependencies
- Use conda: Consider using conda for dependency management on Windows
- Installation Guide: Detailed installation instructions
- Migration Guide: Migrating from CMake to setuptools
- Contributing Guide: Development setup and guidelines
- API Documentation: Complete API reference
We welcome contributions! See CONTRIBUTING.md for development setup and guidelines.
# Clone with submodules
git clone --recursive https://github.com/DerThorsten/nifty.git
cd nifty
# Install in development mode
pip install -e .[dev]
# Run tests
python -m pytest src/python/test/NIFTY is released under the MIT License. See LICENSE for details.
- xtensor: Modern C++ tensor library
- pybind11: Python bindings for C++
- Boost: C++ libraries
- Contributors: All the developers who have contributed to NIFTY
- Stable: Core functionality is stable and well-tested
- Active Development: Regular updates and improvements
- Community Driven: Open to contributions and feedback
Need help? Open an issue on GitHub or check our documentation.