No worries.
I'm not sure why the compiled binaries from the fsl website dont have the problem but the Ubuntu packaged versions use the external nifticlib library that already uses char* arrays instead of structs for byteswapping...
Chris.
Dr Christopher Adamson, PhD (Melb.), B Software Engineering (Hons., Monash)
Research Officer
Developmental and Functional Brain Imaging, Critical Care and Neurosciences
Murdoch Childrens Research Institute
The Royal Children’s Hospital
Flemington Road Parkville Victoria 3052 Australia
T 9345 4306
M XXXX XXX XXX
E [log in to unmask]
www.mcri.edu.au
-----Original Message-----
From: FSL - FMRIB's Software Library on behalf of Mark Jenkinson
Sent: Wed 2/03/2011 12:19 PM
To: [log in to unmask]
Subject: Re: [FSL] Help with fslstats error
Dear Chris,
Thank you very much for this - I had not heard of it before and it is quite serious.
We will definitely be taking action on this.
Thanks,
Mark
On 2 Mar 2011, at 16:34, Chris Adamson wrote:
> I have been able to reliably reproduce the byteswapping error that I said was caused in nifti1_io.c
>
> I downloaded fsl-4.1.7-sources.tar.gz
>
> extracted it and applied the debian package patches to get it to compile: (none of these apply to the file in question)
>
> Description: Fix bashisms in the code.
> --- a/src/possum/possumX
> +++ b/src/possum/possumX
> @@ -98,7 +98,7 @@
> fi
>
> echo "POSSUMDIR (before)" $POSSUMDIR
> -if [ "${POSSUMDIR}" == "${FSLDEVDIR}" ] ; then
> +if [ "${POSSUMDIR}" = "${FSLDEVDIR}" ] ; then
> echo "POSSUMDIR (during)" $POSSUMDIR
> else
> export POSSUMDIR=$FSLDIR
> --- a/src/possum/possumX_postproc.sh
> +++ b/src/possum/possumX_postproc.sh
> @@ -77,7 +77,7 @@
> #$ -m ae
>
> echo "POSSUMDIR (before)" $POSSUMDIR
> -if [ "${POSSUMDIR}" == "${FSLDEVDIR}" ] ; then
> +if [ "${POSSUMDIR}" = "${FSLDEVDIR}" ] ; then
> echo "POSSUMDIR (during)" $POSSUMDIR
> else
> export POSSUMDIR=$FSLDIR
>
>
> Description: Fix critical syntax error.
> --- a/src/fdt/rotate_bvecs
> +++ b/src/fdt/rotate_bvecs
> @@ -18,7 +18,7 @@
> echo "If you want to force this program to run, please remove the file ${bvecs}_old"
> echo ""
> exit 1
> -done
> +fi
> /bin/cp ${bvecs} ${bvecs}_old
> #/bin/rm -f ${bvecs}
>
> Description: Prevent fslmath from crashing with -tfce option set
> Origin: vendor
> --- a/src/avwutils/fslmaths.cc 2011-01-13 06:09:39.000000000 -0500
> +++ b/src/avwutils/fslmaths.cc 2011-03-02 09:03:00.715017995 -0500
> @@ -940,7 +940,8 @@
>
> for(int t=0;t<inputVolume.tsize();t++) {
> try {
> - tfce(inputVolume[t], height_power, size_power, connectivity, 0, 0);
> + /*tfce(input_volume[t], height_power, size_power, connectivity, 0, 0);*/
> + tfce(inputVolume[t], height_power, size_power, connectivity, 0, inputVolume[t].max()/100.0);
> }
> catch(Exception& e) {
> cerr << "ERROR: TFCE failed, please check your file for valid sizes and voxel values." << e.what() << endl << endl << "Exiting" << endl;
>
> Description: Patch to allow building with recent GCC versions
> --- a/src/fabber/tools.cc
> +++ b/src/fabber/tools.cc
> @@ -68,6 +68,7 @@
>
> #include "tools.h"
> #include "easylog.h"
> +#include <limits>
>
> double DescendingZeroFinder::FindZero() const
> {
> --- a/src/possum/possumfns.h
> +++ b/src/possum/possumfns.h
> @@ -11,9 +11,9 @@
> void voxel4(const double x,const double y,const double z,
> const RowVector& tissue,const Matrix& H,const int nreadp,const int v,
> const double xdim,const double ydim,const double zdim,
> - const double* b0, const double* b0gxx,const double* b0gyy,const double* b0gzz,
> + const double* b0time, const double* b0xtime,const double* b0ytime,const double* b0ztime,
> const double* b0timecourse,const int Nb0,
> - const double b0, const double b0gxx,const double b0gyy,const double b0gzz,
> + const double b0, const double b0x,const double b0y,const double b0z,
> const double* timecourse,const double* activation,const int Nact,
> const string outputname, const double* table_slcprof, const double dslcp, const double dslcp_first, const int Nslc,
> const double den,const double RFtrans, const int opt_test,
>
> Description: Compatibility with the Debian gdchart package code.
> --- a/src/libvis/miscplot.cc
> +++ b/src/libvis/miscplot.cc
> @@ -79,6 +79,7 @@
> #include "gd.h"
> #include "gdc.h"
> #include "gdchart.h"
> + #include "gdcpie.h"
> }
>
> namespace MISCPLOT{
>
> Description: Cosmetics.
> --- a/extras/build
> +++ b/extras/build
> @@ -107,4 +107,4 @@
>
> if [ "X${errorprojs}X" != XX -o "X${errorinstall}X" != XX ] ; then
> exit 1
> -fi
> \ No newline at end of file
> +fi
>
> Description: Cosmetics.
> --- a/extras/build
> +++ b/extras/build
> @@ -107,4 +107,4 @@
>
> if [ "X${errorprojs}X" != XX -o "X${errorinstall}X" != XX ] ; then
> exit 1
> -fi
> \ No newline at end of file
> +fi
> addo@ada4jc:/data/backup/data/programs/debian/patches$ cat tcl_shell_spec
> Description: Specific the TCL interpreter.
> --- a/src/misc_tcl/Runtcl
> +++ b/src/misc_tcl/Runtcl
> @@ -1,5 +1,8 @@
> #!/bin/sh
>
> +# Set TCLTKSHELL \
> +TCLTKSHELL=wish ; export TCLTKSHELL
> +
> # Check for display being set \
> if [ _$DISPLAY = _ ] ; then echo "DISPLAY is not set. Please set your DISPLAY environment variable!" ; exit 1 ; fi
> # Check for FSLDIR being set \
>
> Description: Fix tk problem
> --- generic/tk.h.orig 2008-02-06 16:31:40.000000000 +0100
> +++ generic/tk.h 2008-07-24 08:21:46.000000000 +0200
> @@ -635,17 +635,15 @@
> *
> *---------------------------------------------------------------------------
> */
> -#define VirtualEvent (LASTEvent)
> -#define ActivateNotify (LASTEvent + 1)
> -#define DeactivateNotify (LASTEvent + 2)
> -#define MouseWheelEvent (LASTEvent + 3)
> -#define TK_LASTEVENT (LASTEvent + 4)
> +#define VirtualEvent (MappingNotify + 1)
> +#define ActivateNotify (MappingNotify + 2)
> +#define DeactivateNotify (MappingNotify + 3)
> +#define MouseWheelEvent (MappingNotify + 4)
> +#define TK_LASTEVENT (MappingNotify + 5)
>
> #define MouseWheelMask (1L << 28)
> -
> #define ActivateMask (1L << 29)
> #define VirtualEventMask (1L << 30)
> -#define TK_LASTEVENT (LASTEvent + 4)
>
>
> /*
>
> Then when it compiles it copies the generic configuration to gnu_64-gcc4.4
> I modified the OPTFLAGS line in systemvars.mk file:
> OPTFLAGS = -O3 -fexpensive-optimizations ${ARCHFLAGS}
> ${ARCHFLAGS} is empty
>
> So here are the outputs:
> No optimisations: -O0
> fslhd data/standard/LowerCingulum_1mm.nii.gz
> Byte swapping
> filename data/standard/LowerCingulum_1mm.nii.gz
>
> sizeof_hdr 348
> data_type FLOAT32
> dim0 3
> dim1 182
> dim2 218
> dim3 182
> dim4 1
> dim5 1
> dim6 1
> dim7 1
> vox_units mm
> time_units s
> datatype 16
> nbyper 4
> bitpix 32
> pixdim0 0.0000000000
> pixdim1 1.0000152588
> pixdim2 1.0000000000
> pixdim3 1.0000000000
> pixdim4 1.0000000000
> pixdim5 1.0000000000
> pixdim6 1.0000000000
> pixdim7 1.0000000000
> vox_offset 352
> cal_max 4.0000
> cal_min 0.0000
> scl_slope 1.000000
> scl_inter 0.000000
> phase_dim 0
> freq_dim 0
> slice_dim 0
> slice_name Unknown
> slice_code 0
> slice_start 0
> slice_end 0
> slice_duration 0.000000
> time_offset 0.000000
> intent Unknown
> intent_code 0
> intent_name
> intent_p1 0.000000
> intent_p2 0.000000
> intent_p3 0.000000
> qform_name Unknown
> qform_code 0
> qto_xyz:1 1.000015 0.000000 0.000000 0.000000
> qto_xyz:2 0.000000 1.000000 0.000000 0.000000
> qto_xyz:3 0.000000 0.000000 1.000000 0.000000
> qto_xyz:4 0.000000 0.000000 0.000000 1.000000
> qform_xorient Left-to-Right
> qform_yorient Posterior-to-Anterior
> qform_zorient Inferior-to-Superior
> sform_name Unknown
> sform_code 0
> sto_xyz:1 0.000000 0.000000 0.000000 0.000000
> sto_xyz:2 0.000000 0.000000 0.000000 0.000000
> sto_xyz:3 0.000000 0.000000 0.000000 0.000000
> sto_xyz:4 0.000000 0.000000 0.000000 0.000000
> sform_xorient Unknown
> sform_yorient Unknown
> sform_zorient Unknown
> file_type NIFTI-1+
> file_code 1
> descrip FSL3.2beta
> aux_file Red to yellow?@
>
> Optimisations: -O2
> fslhd data/standard/LowerCingulum_1mm.nii.gz ** ERROR: nifti_convert_nhdr2nim: bad dim[0]
> ** ERROR (nifti_image_read): cannot create nifti image from header 'data/standard/LowerCingulum_1mm.nii.gz'
> ** ERROR: nifti_image_open(data/standard/LowerCingulum_1mm): bad header info
> Error: failed to open file data/standard/LowerCingulum_1mm
> ERROR: Could not open file
>
> Optimisations: -O3 -fexpensive-optimizations
> fslhd data/standard/LowerCingulum_1mm.nii.gz ** ERROR: nifti_convert_nhdr2nim: bad dim[0]
> ** ERROR (nifti_image_read): cannot create nifti image from header 'data/standard/LowerCingulum_1mm.nii.gz'
> ** ERROR: nifti_image_open(data/standard/LowerCingulum_1mm): bad header info
> Error: failed to open file data/standard/LowerCingulum_1mm
> ERROR: Could not open file
>
> to test this I turned on debugging in src/niftiio/nifti1_io.c
>
> line 299: static nifti_global_options g_opts = { 4, 0 };
>
> ** find_file_ext: failed for name 'data/standard/LowerCingulum_1mm'
> -d image_read from 'data/standard/LowerCingulum_1mm', read_data = 0, HAVE_ZLIB = 1
> ** find_file_ext: failed for name 'data/standard/LowerCingulum_1mm'
> ** find_file_ext: failed for name 'data/standard/LowerCingulum_1mm'
> ** find_file_ext: failed for name 'data/standard/LowerCingulum_1mm'
> -d nifti_image_read: found header filename 'data/standard/LowerCingulum_1mm.nii.gz'
> ** bad swapped d0 = 768, unswapped = 768
> ** ERROR: nifti_convert_nhdr2nim: bad dim[0]
> ** ERROR (nifti_image_read): cannot create nifti image from header 'data/standard/LowerCingulum_1mm.nii.gz'
> ** ERROR: nifti_image_open(data/standard/LowerCingulum_1mm): bad header info
> Error: failed to open file data/standard/LowerCingulum_1mm
> ERROR: Could not open file
>
> It just fails to perform the byteswapping i.e. d0 is the same swapped as unswapped. To solve the problem I changed the byteswapping code to use char* arrays rather than structs, as follows:
>
> nifti1_io.c:
>
> 1962 void nifti_swap_2bytes( int n , void *ar ) /* 2 bytes at a time */
> 1963 {
> 1964 /*register int ii ;
> 1965 register twobytes *tb = (twobytes *)ar ;
> 1966 register unsigned char tt ;
> 1967
> 1968 for( ii=0 ; ii < n ; ii++ ){
> 1969 tt = tb[ii].a ; tb[ii].a = tb[ii].b ; tb[ii].b = tt ;
> 1970 }*/
> 1971 int ii;
> 1972 unsigned char tt;
> 1973 unsigned char* uc = (unsigned char*)ar;
> 1974 for(ii = (n - 1) * 2; ii >= 0; ii -= 2){
> 1975 tt = uc[ii]; uc[ii] = uc[ii + 1]; uc[ii + 1] = tt;
> 1976 }
> 1977
> 1978 return ;
> 1979 }
>
> and similar patches for all the other sizes (4, 8, 16)
>
> It is particularly strange because the sizeof operators return the correct values, i.e. sizeof(twobytes) = 2, sizeof(fourbytes) = 4 ... etc
>
> I have been able to do this on
> Intel Xeon E5335 and Intel i7-920 64-bit processors and on the Intel Atom N270 32-bit processor.
>
> My operating system is Ubuntu Maverick 10.10.
>
> g++ --version:
> g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
>
> gcc --version:
> gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
>
> Interestingly I haven't had this problem with the ubuntu package version or the binary versions off the FSL website.
>
> Chris Adamson.
>
> Dr Christopher Adamson, PhD (Melb.), B Software Engineering (Hons., Monash)
> Research Officer
> Developmental and Functional Brain Imaging, Critical Care and Neurosciences
>
> Murdoch Childrens Research Institute
> The Royal Children's Hospital
> Flemington Road Parkville Victoria 3052 Australia
> T 9345 4306
> M XXXX XXX XXX
> E [log in to unmask]
> www.mcri.edu.au
>
>
>
>
> -----Original Message-----
> From: FSL - FMRIB's Software Library on behalf of Chris Adamson
> Sent: Tue 1/03/2011 10:54 PM
> To: [log in to unmask]
> Subject: Re: [FSL] Help with fslstats error
>
> The problem occurred when I ran fslhd ${FSLDIR}/data/standard/LowerCingulum_1mm.nii.gz
> It would crash with the same error as in the other post.
> I will redownload and compile the original source to try and reproduce the error.
>
>
>
> Dr Christopher Adamson, PhD (Melb.), B Software Engineering (Hons., Monash)
> Research Officer
> Developmental and Functional Brain Imaging, Critical Care and Neurosciences
>
> Murdoch Childrens Research Institute
> The Royal Children's Hospital
> Flemington Road Parkville Victoria 3052 Australia
> T 9345 4306
> M XXXX XXX XXX
> E [log in to unmask]
> www.mcri.edu.au
>
>
>
>
> -----Original Message-----
> From: FSL - FMRIB's Software Library on behalf of Mark Jenkinson
> Sent: Tue 1/03/2011 5:22 PM
> To: [log in to unmask]
> Subject: Re: [FSL] Help with fslstats error
>
> Dear Chris,
>
> I'm really surprised to hear this.
> I've never experienced this problem or even heard about it.
> It is really quite concerning.
> Are you sure that this is the case, and if so is it ever something
> you can replicate reliably?
>
> All the best,
> Mark
>
> P.S. Jesse - I would check to see if your images are corrupt
> first. That is the most likely explanation. Try loading them
> into FSLView and see if they view OK.
>
>
>
> On 1 Mar 2011, at 20:28, Chris Adamson wrote:
>
>> Assuming you are on an intel-based machine, check the image to see if the header is in big endian byte order. I have found that the byte swapping routines in nifti1_io.c do not always work when optimisations are turned on.
>>
>> Dr Christopher Adamson, PhD (Melb.), B Software Engineering (Hons., Monash)
>> Research Officer
>> Developmental and Functional Brain Imaging, Critical Care and Neurosciences
>>
>> Murdoch Childrens Research Institute
>> The Royal Children's Hospital
>> Flemington Road Parkville Victoria 3052 Australia
>> T 9345 4306
>> M XXXX XXX XXX
>> E [log in to unmask]
>> www.mcri.edu.au
>>
>>
>>
>>
>> -----Original Message-----
>> From: FSL - FMRIB's Software Library on behalf of Jesse Bledsoe
>> Sent: Tue 1/03/2011 3:12 PM
>> To: [log in to unmask]
>> Subject: [FSL] Help with fslstats error
>>
>> Hi everyone,
>>
>> I am receiving the following error for some data and would appreciate any
>> insights into the error:
>>
>> [bledsoej@circ Grey_White]$ fslstats EF0136_brain_pve_1.nii.gz -m -v
>> ** ERROR (nifti_image_read): short header read 'EF0136_brain_pve_1.nii.gz'
>> ** ERROR: nifti_image_open(EF0136_brain_pve_1): bad header info
>> Error: failed to open file EF0136_brain_pve_1
>> ERROR: Could not open image EF0136_brain_pve_1
>> Image Exception : #22 :: Failed to read volume EF0136_brain_pve_1.nii.gz
>> terminate called after throwing an instance of 'RBD_COMMON::BaseException'
>> Abort (core dumped)
>>
>> Any suggestions are greatly appreciated,
>>
>> Jesse
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the MessageLabs Email Security System.
>> For more information please visit http://www.messagelabs.com/email
>>
>> If you have any question, please contact MCRI IT Helpdesk for further assistance.
>> ______________________________________________________________________
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the MessageLabs Email Security System.
>> For more information please visit http://www.messagelabs.com/email
>> ______________________________________________________________________
>>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
>
> If you have any question, please contact MCRI IT Helpdesk for further assistance.
> ______________________________________________________________________
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
>
> If you have any question, please contact MCRI IT Helpdesk for further assistance.
> ______________________________________________________________________
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
If you have any question, please contact MCRI IT Helpdesk for further assistance.
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
|