# scikit-image
import skimage
vol=skimage.io.imread( 't.mhd' )
# Simple ITK
import SimpleITK as sitk
vol =sitk.ReadImage('t.mhd')
OjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0
Offset = 0.0 0.0 0.0
CenterOfRotation = 0.0 0.0 0.0
AnatomicalOrientation = RAS
ElementSpacing = 1.49479 1.49479 2.3125
DimSize = 668 668 980
ElementType = MET_SHORT
ElementDataFile = data.raw
import nibabel as nib
hd = nib.load( path_to_single_nii )
k = 'pixdim'
print( 'Pixel spacing', hd.header[k] )
load_nii( path_to_single_nii )
<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
sizeof_hdr : 348
data_type : b''
db_name : b''
extents : 0
session_error : 0
regular : b'r'
dim_info : 0
dim : [ 3 512 512 42 1 1 1 1]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : int16
bitpix : 16
slice_start : 0
pixdim : [-1. 0.782 0.782 8. 0. 0. 0. 0. ]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 10
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip : b'Time=134609.000'
aux_file : b''
qform_code : scanner
sform_code : scanner
quatern_b : 0.0
quatern_c : 1.0
quatern_d : 0.0
qoffset_x : 201.757
qoffset_y : -199.79768
qoffset_z : -1296.7
srow_x : [ -0.782 -0. 0. 201.757]
srow_y : [ 0. 0.782 0. -199.79768]
srow_z : [ 0. 0. 8. -1296.7]
intent_name : b''
magic : b'n+1'