Skip to content

"Unexpected end of ZLIB input stream"

Out of the box, this library does not appear to save the nifti format correctly.

Repro:

var test Nifti1Image
test.LoadImage("test_data/MNI152.nii.gz", true)
test.Save("save.nii")                     //save nifti image and compress it

Expected: save.nii should be viewable in imagej and be the same dataset as MNI152.nii.gz

Result:

  • image throws the exception: java.io.EOFException: Unexpected end of ZLIB input stream;
  • save.nii dataset only contains 75 slices while the original has 91.

Seems like something is getting truncated somewhere that's chopping off the final slices.