Simple script to create an empty volume by taking the metadata from an example image.


In [1]:
medpy_create_empty_volume_by_example.py resources/flair.nii.gz output/empty.nii.gz

Let's compare the metadata.


In [2]:
medpy_info.py resources/flair.nii.gz


Informations obtained from image header:
header type=<class 'nibabel.nifti1.Nifti1Image'>
voxel spacing=(1.0, 1.0)
offset=(-0.0, -0.0)

Informations obtained from image array:
datatype=float32,dimensions=2,shape=(181, 217)
first and last element: 0.0 / 0.0

In [3]:
medpy_info.py output/empty.nii.gz


Informations obtained from image header:
header type=<class 'nibabel.nifti1.Nifti1Image'>
voxel spacing=(1.0, 1.0)
offset=(-0.0, -0.0)

Informations obtained from image array:
datatype=float32,dimensions=2,shape=(181, 217)
first and last element: 0.0 / 0.0

But they do differ in every (non-zero) voxel.


In [4]:
medpy_diff.py resources/flair.nii.gz output/empty.nii.gz


Voxel differ: 16453 of 39277 total voxels
Max difference: 51866.8203125

In [ ]: