Comprehensive toolkit for NIfTI medical imaging datasets. Extract 2D slices from 3D volumes, validate data integrity (geometry, orientations, NaN), register and resample, compute statistics, generate visualizations, and build detection/segmentation pipelines—all with zero external ML dependencies.
Extract 2D slices (all views) and build datasets for ML. Preprocess with skull stripping, registration, resampling, MIP. Transform intensity (normalize, window, rescale) and geometry (resample, crop). Analyze (compare, statistics, splits). Visualize (overlays, montages). Validate data integrity (geometry, orientations, NaN, image↔mask coherence) via Python API or CLI (niqc). Run quick edits from the shell — rotate, flip, crop, rescale, DICOM↔NIfTI — via the nii CLI. No ML dependencies.
Everyday NIfTI edits without opening Python, mirroring the package API (each command also works on a whole folder):
nii rotate scan.nii.gz out/ --k 1 --axes 0 1 # lossless 90° rotation
nii flip scans/ out/ --axis 0 # mirror a whole folder
nii crop-content scan.nii.gz out/ --margin 2 # crop to the foreground box
nii rescale scan.nii.gz out/ --out-min 0 --out-max 255
nii to-dicom scan.nii.gz out/ # NIfTI → DICOM series
nii from-dicom dicom/case_01/ out/ # DICOM series → NIfTIGeometric ops update the affine in step with the data, so a flip or rotation never corrupts orientation. See the docs for the full reference.
Now, this code is available with PyPI here. The package can be installed with:
pip install nidatasetand can be imported as:
import nidataset as nidFull documentation: https://giuliorusso.github.io/Ni-Dataset/
Complete example project: CT-manager (slice extraction, registration, QC validation, preprocessing pipeline)
nibabel>=5.0.0
numpy>=1.24
opencv-python>=4.7
pandas>=1.5
Pillow>=9.4
scipy>=1.10
SimpleITK>=2.2
scikit-image>=0.19
tqdm>=4.64Install the requirements with:
pip install -r requirements.txt👨💻 Ciro Russo, PhD
MIT License

