1. Problem: NIfTI’s Core Challenges In Clinical Workflows
NIfTI is the de facto format in neuroimaging research, enabling sharing and algorithm development. However, when used in rigorous clinical workflows, three issues become prominent: inconsistent spatial conventions, heavy metadata loss, and limited compression efficiency.
These issues compound across the lifecycle from acquisition (DICOM) → research (NIfTI) → back to clinical systems (e.g., navigation/archiving), creating obstacles for consistency and traceability.
1.1. Spatial Inconsistency Across Libraries
Reading the same NIfTI file using different libraries can yield inconsistent origin and orientation (RAS+ vs LPS+ practices), leading to downstream registration and analysis risks.
import nibabel as nibimport SimpleITK as sitkimport numpy as npnifti_file ="dicube-testdata/nifti/CT_Philips.nii.gz"nib_image = nib.load(nifti_file)sitk_image = sitk.ReadImage(nifti_file)print(f"Nibabel Origin: {nib_image.affine[:3, 3]} (RAS+ oriented)")print(f"SimpleITK Origin: {sitk_image.GetOrigin()} (LPS+ oriented)")x_nib = nib_image.affine[:3, 0]; x_nib /= np.linalg.norm(x_nib)print(f"Nibabel X Orientation: {x_nib}")print(f"SimpleITK X Orientation: {np.array(sitk_image.GetDirection())[:3]}")y_nib = nib_image.affine[:3, 1]; y_nib /= np.linalg.norm(y_nib)print(f"Nibabel Y Orientation: {y_nib}")print(f"SimpleITK Y Orientation: {np.array(sitk_image.GetDirection())[3:6]}")z_nib = nib_image.affine[:3, 2]; z_nib /= np.linalg.norm(z_nib)print(f"Nibabel Z Orientation: {z_nib}")print(f"SimpleITK Z Orientation: {np.array(sitk_image.GetDirection())[6:9]}")
Nibabel Origin: [ -82.32080078 -134.36405945 -153.72033691] (RAS+ oriented)
SimpleITK Origin: (86.97265625, 229.64453125, 192.01113891601562) (LPS+ oriented)
Nibabel X Orientation: [1. 0. 0.]
SimpleITK X Orientation: [-1. 0. 0.]
Nibabel Y Orientation: [0. 1. 0.]
SimpleITK Y Orientation: [ 0. -1. 0.]
Nibabel Z Orientation: [0. 0. 1.]
SimpleITK Z Orientation: [0. 0. 1.]
They differ on X and Y directions, explaining the common sign flips across libraries.
1.3. Dual Affines: qform vs sform
NIfTI stores two affine transforms: qform (scanner space) and sform (aligned/standard space). Libraries may prefer one over the other, producing varying origins/orientations for the same file.
Converting from DICOM to NIfTI typically drops most clinical metadata (patient, study, device, acquisition parameters). The file becomes detached from its clinical context and is hard to round‑trip safely.
1.5. Limited Compression Efficiency
.nii.gz uses gzip (DEFLATE), a general‑purpose codec not optimized for medical images. Compression ratios are typically 2–4×, leaving room for improvement.
2. DiCube: Designed For Clinical + Research Together
2.1. Unified Coordinate System (LPS+)
DiCube adopts DICOM’s LPS+ consistently. Reading the same DICOM series, DiCube matches SimpleITK’s interpretation.
import osimport pydicomimport dicube, numpy as npimport SimpleITK as sitkdicom_dir ="dicube-testdata/dicom/sample_200"# SimpleITK read DICOM series (LPS+)series_reader = sitk.ImageSeriesReader()series_ids = series_reader.GetGDCMSeriesIDs(dicom_dir)series_files = series_reader.GetGDCMSeriesFileNames(dicom_dir, series_ids[0])series_reader.SetFileNames(series_files)sitk_image_from_dicom = series_reader.Execute()# Keep one original DICOM for later round-trip comparisonsoriginal_dcm = pydicom.dcmread(series_files[0], stop_before_pixels=True)dcb_image = dicube.load_from_dicom_folder(dicom_dir, sort_method=dicube.SortMethod.POSITION_RIGHT_HAND)print("SimpleITK (from DICOM):", np.round(sitk_image_from_dicom.GetOrigin(), 3))print("DiCube (from DICOM):", np.round(dcb_image.space.origin, 3))
Conclusion: NIfTI works well for pure research exchange. For applications that require integrity, traceability, and clinical interoperability, DiCube offers a safer, faster, and more reliable modern alternative.