[Neuroimaging] Fwd: [Freesurfer] negative header after preproc-sess

Christopher Markiewicz effigies at bu.edu
Thu Jul 27 10:20:03 EDT 2017


Looks like the FreeSurfer hack needs to be expanded to more cases. Could
you go ahead and open an issue on https://github.com/nipy/nibabel/issues?

On Thu, Jul 27, 2017 at 9:41 AM, Bai Haohao <jarblank1200 at gmail.com> wrote:

> Dear nibabel experts,
>
> I forward this email to nibabel mailing list because I think it is related
> to nibabel, even this problem is caused by nifti standard and freesurfer.
>
> I am using nibabel to load data after freesurfer "*preproc-sess -suface
> self" *and I get negative dim(-1 1 1, see origin email for detail), which
> makes nibabel.get_data() failed, but freesurfer first level analysis can be
> done successfully, in my view it means freesurfer can get data from this
> bad header.
>
> I find a way to solve it is by using "mri_convert *.nii.gz *.mgz", then
> nibabel could get data from *.mgz. But I think if nibabel could support
> getting data from negative header file would be more helpful.
>
> Just some undevelopped thoughts, I hope I express it clearly.
>
> Best,
>
> Bai Haohao
>
>
>
> ---------- Forwarded message ----------
> From: Douglas Greve <greve at nmr.mgh.harvard.edu>
> Date: Thu, Jul 6, 2017 at 7:07 AM
> Subject: Re: [Freesurfer] negative header after preproc-sess
> To: freesurfer at nmr.mgh.harvard.edu
>
>
> When the nifti standard was adopted, they used a short int to represent
> the dimensions. Unfortunately, this only allows for a maximum dimension of
> 32k, which is not big enough for surfaces. So I hacked the FS nifti format
> to put a -1 as the first dim at which point the FS code will go to another
> place in the header to get the spatial dimensions. It is possible to
> reshape the spatial dimensions as long as the largest prime factor is less
> than 32k (see mri_surf2surf with --reshape option). Other than that, you
> might ask the nibabel people to program the same hack.
>
> On 6/25/17 6:48 AM, Bai Haohao wrote:
>
> Hello Freesurfer experts,
>
> I am running my data with preproc-sess to project my func data to
> individual anatomy file, and the command shows as below:
>
> preproc-sess -sf ${Sesslist} -fsd "bold" -surface self lhrh -fwhm 0
> -per-run -force
>
>
> And the subjectname point to the subject dir that created after recon-all.
>
> After the running completed, I try to load data from
> fmcpr.sm0.self.lh.nii.gz with nibabel, and I get this error info:
>
> >>> f.get_data()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/pymodules/python2.7/nibabel/spatialimages.py", line 341,
> in get_data
>     return np.asanyarray(self._data)
>   File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line
> 512, in asanyarray
>     return array(a, dtype, copy=False, order=order, subok=True)
>   File "/usr/lib/pymodules/python2.7/nibabel/arrayproxy.py", line 55, in
> __array__
>     self._data = self._read_data()
>   File "/usr/lib/pymodules/python2.7/nibabel/arrayproxy.py", line 60, in
> _read_data
>     data = self.header.data_from_fileobj(fileobj)
>   File "/usr/lib/pymodules/python2.7/nibabel/analyze.py", line 486, in
> data_from_fileobj
>     data = self.raw_data_from_fileobj(fileobj)
>   File "/usr/lib/pymodules/python2.7/nibabel/analyze.py", line 458, in
> raw_data_from_fileobj
>     return array_from_file(shape, dtype, fileobj, offset)
>   File "/usr/lib/pymodules/python2.7/nibabel/volumeutils.py", line 493,
> in array_from_file
>     raise IOError(msg)
> IOError: Expected -1804 bytes, got 264809160 bytes from file
> "fmcpr.vol2surf.lh.nii.gz"
>  - could the file be damaged?
>
>
> Then I check the file header by nibabel, and I get this:
>
>
> >>> print(f.get_header())
> <class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
> sizeof_hdr      : 348
> data_type       :
> db_name         :
> extents         : 0
> session_error   : 0
> regular         :
> dim_info        : 0
> dim             : [  4  -1   1   1 451   1   1   1]
> intent_p1       : 0.0
> intent_p2       : 0.0
> intent_p3       : 0.0
> intent_code     : none
> datatype        : float32
> bitpix          : 32
> slice_start     : 0
> pixdim          : [-1.          1.          1.          1.
>  2.00000072  1.          1.
>   1.        ]
> vox_offset      : 352.0
> scl_slope       : 0.0
> scl_inter       : 0.0
> 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           : 146790
> descrip         : FreeSurfer May 13 2013
> aux_file        :
> qform_code      : scanner
> sform_code      : scanner
> quatern_b       : -0.0115927606821
> quatern_c       : -0.996071338654
> quatern_d       : -0.0864994972944
> qoffset_x       : 73344.5546875
> qoffset_y       : -1492.14978027
> qoffset_z       : -2311.28955078
> srow_x          : [ -9.99280393e-01   2.56918129e-02   2.79041883e-02
> 7.33445547e+04]
> srow_y          : [  2.04970520e-02   9.84766901e-01  -1.72667429e-01
>  -1.49214978e+03]
> srow_z          : [  3.19152586e-02   1.71971247e-01   9.84584868e-01
>  -2.31128955e+03]
> intent_name     :
> magic           : n+1
>
>
>
>
> Note that the dim has value -1, but when I use -surface fsaverage, the dim
> is correct(show as below):
>
> dim             : [    4 27307     1     6   451     1     1     1]
>
>
> And I read the source code, the difference between self and fsaverage is
> appeared when running rawfunc2surf-sess, and log files are attached.
>
> I have tried many commands to load data from fmcpr.sm0.self.lh.nii.gz,
> such as fslview, freeview, mri_convert, mri_surf2surf, ...
>
> and only tksurfer could read this file by -timecourse
> fmcpr.sm0.self.lh.nii.gz.
>
> I want to figure out how could I fix it, and any suggestion would be
> helpful.
>
> Thanks in advance,
>
> Bai Haohao
>
>
> Version info:
> System: ubuntu-16.04.1-server-amd64
> Freesurfer: freesurfer-Linux-centos4_x86_64-stable-pub-v5.3.0-HCP
> nibabel: python-nibabel  1.2.2-1
>
>
>
> _______________________________________________
> Freesurfer mailing listFreesurfer at nmr.mgh.harvard.eduhttps://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
>
>
>
> _______________________________________________
> Freesurfer mailing list
> Freesurfer at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20170727/e746a8ce/attachment.html>


More information about the Neuroimaging mailing list