pnlbwh / pnlpipe

A Python-based framework for processing anatomical (T1, T2) and diffusion weighted images
Other
12 stars 8 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 364: invalid start byte #12

Closed tashrifbillah closed 5 years ago

tashrifbillah commented 6 years ago

Can you try running the following in my computer? (my computer because I have done a few local fixes to at least come to this point of execution).

(base) [tb571@pnl-z840-2 pnlpipe]$ pnlscripts/axisAlign.py -i ../1001/1001-t1w.nrrd -o test.nrrd --force

[[ 0.  1.  0.]
 [ 0.  0. -1.]
 [-1.  0.  0.]]
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
* Changing to working dir /tmp/tmp82nhqkrf
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
[[ 0.  1.  0.]
 [ 0.  0. -1.]
 [-1.  0.  0.]]
* unu save -f nrrd -e gzip -i "/home/tb571/Downloads/1001/1001-t1w.nrrd" -o "test.nrrd"

  File "pnlscripts/axisAlign.py", line 183, in <module>
    main()
  File "pnlscripts/axisAlign.py", line 177, in main
    axis_align_3d(image_in, outfile=args.outfile)
  File "pnlscripts/axisAlign.py", line 144, in axis_align_3d
    replace_line_in_file(image_new, 'space directions:', newline)
  File "pnlscripts/axisAlign.py", line 52, in replace_line_in_file
    for line in fileinput.FileInput(afile, inplace=1):
  File "/home/tb571/miniconda3/lib/python3.6/fileinput.py", line 250, in __next__
    line = self._readline()
  File "/home/tb571/miniconda3/lib/python3.6/fileinput.py", line 364, in _readline
    return self._readline()
  File "/home/tb571/miniconda3/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 364: invalid start byte

I Googled a bit, but looks like I didn't find any solution so far. My guess is fileinput library is outdated to handle python 3. So, I would be interested to replace this library with a more compatible one. But, since we are talking about NIFTI pipeline, do we really want to do this fix for NRRD?

tashrifbillah commented 5 years ago

We have moved to pynrrd to do this job.