EOFError: Compressed file ended before the end-of-stream marker was reached - T1 preprocessing using nipype

Hello nipype experts,

I run into some errors while using nipype for T1 preprocessing. I reoriented the image with the function Reorient2Std of FSL (nipype.interfaces.fsl.utils import Reorient2Std), but when running the next node with its output the image appears to be corrupted. This is the output of the .pklz file:

File: /home/reyerolo/PycharmProjects/nipype/scripts/anat/crash-20190926-174129-reyerolo-inu_4.a0-0c532b48-4c8b-4d91-80bc-79cb4a9776a0.pklz
Node: anat_preproc.inu_4
Working directory: /home/reyerolo/PycharmProjects/nipype/analysis_2/T1/anat_preproc/_subject_id_E14/inu_4

Node inputs:

args =
bias_image =
bspline_fitting_distance =
bspline_order =
convergence_threshold =
copy_header = True
dimension = 3
environ = {‘NSLOTS’: ‘1’}
input_image = [’/home/reyerolo/PycharmProjects/nipype/analysis_2/T1/anat_preproc/_subject_id_E14/reorient/mapflow/_reorient0/T1_reoriented.nii.gz’]
mask_image =
n_iterations =
num_threads = 1
output_image =
save_bias = True
shrink_factor =
weight_image =

Traceback:
Traceback (most recent call last):
File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/plugins/linear.py”, line 48, in run
node.run(updatehash=updatehash)
File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 472, in run
result = self._run_interface(execute=True)
File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1259, in _run_interface
self.config[‘execution’][‘stop_on_first_crash’])))
File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1181, in _collate_results
(self.name, ‘\n’.join(msg)))
Exception: Subnodes of node: inu_4 failed:
Subnode 0 failed
Error: Traceback (most recent call last):

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py”, line 99, in nodelist_runner
result = node.run(updatehash=updatehash)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 472, in run
result = self._run_interface(execute=True)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 563, in _run_interface
return self._run_command(execute)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 643, in _run_command
result = self._interface.run(cwd=outdir)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 375, in run
runtime = self._run_interface(runtime)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/interfaces/ants/segmentation.py”, line 441, in _run_interface
self._copy_header(self._gen_filename(‘output_image’))

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nipype/interfaces/ants/segmentation.py”, line 452, in _copy_header
new_img = out_img.class(out_img.get_data(), in_img.affine,

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nibabel/dataobj_images.py”, line 202, in get_data
data = np.asanyarray(self._dataobj)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/numpy/core/numeric.py”, line 553, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nibabel/arrayproxy.py”, line 356, in array
raw_data = self.get_unscaled()

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nibabel/arrayproxy.py”, line 351, in get_unscaled
mmap=self._mmap)

File “/home/reyerolo/anaconda3/lib/python3.7/site-packages/nibabel/volumeutils.py”, line 524, in array_from_file
n_read = infile.readinto(data_bytes)

File “/home/reyerolo/anaconda3/lib/python3.7/gzip.py”, line 276, in read
return self._buffer.read(size)

File “/home/reyerolo/anaconda3/lib/python3.7/_compression.py”, line 68, in readinto
data = self.read(len(byte_view))

File “/home/reyerolo/anaconda3/lib/python3.7/gzip.py”, line 482, in read
raise EOFError("Compressed file ended before the "

EOFError: Compressed file ended before the end-of-stream marker was reached

This node is for using ants segmentation package N4BiasFieldCorrection. I have used this pipeline a while ago and encountered any errors, but the nifty images I get now seem to be corrupted and I don’t know what is happening.

Any help is very much appreciated!

this looks like a nibabel issue. i believe this could be from either an actually corrupted file or the way gzip is being used.

i fixed a version of this while writing a compressed file in nipype here, but that is unrelated to this issue.