JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for SPM Archives


SPM Archives

SPM Archives


SPM@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  January 2008

SPM January 2008

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Reorienting nii images problem with the latest Update 1048

From:

d gitelman <[log in to unmask]>

Reply-To:

d gitelman <[log in to unmask]>

Date:

Wed, 2 Jan 2008 09:55:13 -0600

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (199 lines) , write_hdr_raw.m (77 lines)

Hi

I can confirm that this is a bug in the write_hdr_raw.m file located in the
folder @nifti/private in the spm5 directory. The problem only arises when
spm tries to write to a file's header without writing out a whole new image
file (i.e., in the case of reorienting files). Unfortunately it trashes the
image data in the process so you will have to recreate the files.

The spm_authors are aware of the bug and will hopefully post an official fix
soon.

Until then I suggest reverting to the previous version of write_header_raw.m
which I have attached to this email. Save the file as write_hdr_raw.m and
put it in the directory noted above. (Make sure to backup the file you are
replacing). This fix is only necessary if you have updated spm in the last
week or so.

Darren

 
----------
Darren Gitelman, MD
Department of Neurology
Northwestern University
voice:  (312) 908-8614
fax:    (312) 908-5073
page:   (312) 695-1849
email: [log in to unmask]
---------- 

> -----Original Message-----
> From: SPM (Statistical Parametric Mapping) 
> [mailto:[log in to unmask]] On Behalf Of Torben Ellegaard Lund
> Sent: Wednesday, January 02, 2008 9:30 AM
> To: [log in to unmask]
> Subject: Re: [SPM] Reorienting nii images problem with the 
> latest Update 1048
> 
> Dear All
> 
> I can reproduce the error Kiyotaka reports. One of my 
> structural images changed from 19,3MB to 4KB after applying 
> and saving a rotation of .25 radians around the x-axis. This 
> error was reproduced running
> SPM5 using matlab 7.4.0.287 (R2007a) on MacBook Pro running  
> OS X version 10.5.1
> 
> 
> Best
> Torben
> 
> 
> Torben Ellegaard Lund
> Assistant Professor, PhD
> The Danish National Research Foundation's Center for 
> Functionally Integrative Neuroscience (CFIN) Aarhus 
> University Aarhus University Hospital Building 30 
> Noerrebrogade 8000 Aarhus C Denmark
> Phone: +4589494380
> Fax: +4589494400
> http://www.cfin.au.dk
> [log in to unmask]
> 
> 
>   These were the error messages i got:
> 
>   >> --------------------------
> Running "Display Image"
> Image "/Users/torbenl/Desktop/sRune-0002-00001-000001-01.nii" 
> can not be resampled
> 
> and after clicking in the image:
> 
>  >> Image 
> "/Users/torbenl/Desktop/sRune-0002-00001-000001-01.nii" can 
> not be resampled ??? Cant open image file.
> 
> Error in ==> spm_image at 106
>               
> set
> (st
> .in
> ,'String
> ',sprintf('%g',spm_sample_vol(st.vols{1},pos(1),pos(2),pos(3),
> st.hld)));
> 
> Error in ==> spm_orthviews at 258
> 	eval(st.callback);
> 
> ??? Error using ==> if
> strcmp
> (get(gcf,'SelectionType'),'normal'),spm_orthviews('Reposition');elseif
> strcmp
> (get
> (gcf
> ,'SelectionType
> '),'extend
> '),spm_orthviews('reposition');spm_orthviews('context_menu','t
> s',1);end;
> Cant open image file.
> 
> ??? Error while evaluating axes ButtonDownFcn
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On 02/01/2008, at 15.41, Volkmar Glauche wrote:
> 
> > Dear Kiyotaka Nemoto,
> >
> > I can't confirm this with the latest SPM5 version here. If 
> it is not 
> > SPM, the failure you observe could be due to file system 
> problems (out 
> > of disk space, permissions, file locking by another application).
> >
> > Volkmar
> >
> > On Wed, 2008-01-02 at 22:54 +0900, Kiyotaka Nemoto wrote:
> >> Dear SPM developers,
> >>
> >> I came across with a problem when I try to reorient .nii 
> images via 
> >> display button with the latest Update 1048. I think this may be a 
> >> bug, so I report the problem.
> >>
> >> Below is what I did.
> >>
> >> 1) Dicom files were converted to an Nifti image with 
> Jolinda Smmith's 
> >> MRIConvert. Files are stored as a single nii file.
> >>
> >> 2) An nii image was displayed with "Display" function. 
> SPM5 displays 
> >> the image without any problems.
> >>
> >> 3) I set AC-PC manually and push "Reorient images...", reorienting 
> >> the image.
> >>
> >> 4) Then I get into trouble. The graphics window went white 
> only with 
> >> a frame and an error message in Matlab says, "Image cannot be 
> >> resampled..." "file too small"
> >>
> >> 5) I checked the file size and saw that now the nii file I 
> tried to 
> >> reorient is only 348 bytes, which is the same as usual .hdr files.
> >> That is, nii file with a header and an image (over 20Mbytes) was 
> >> replaced with a mere header information and image itself 
> was lost...
> >> So, this must have something to do with handling header 
> information 
> >> of nii format.
> >>
> >> I checked the following to make sure that this is a problem of 
> >> handling nii format and this doesn't happen with previous versions;
> >>
> >> A) I prepared Analyze format images (.hdr and .img files) and went 
> >> through the same procedure I described above. This time everything 
> >> works fine.
> >>
> >> B) I re-installed SPM5 in a different directory, and applied Update
> >> 958 (the last update). This also worked fine. Nii files 
> were handled 
> >> correctly.
> >>
> >> Below is my computer environment, (though I think it is not so 
> >> important since Update958 works fine with this environment...)
> >>
> >> CPU: Athlon64 3800+
> >> OS: openSUSE 10.3 64bit
> >> Matlab: R2007b 7.5.0.338 (64bit)
> >> gcc: 4.2.1
> >>
> >>
> >> Any advice or proposal would be appreciated.
> >>
> >> Best regards and wish you a happy new year!
> >>
> >> Kiyotaka
> >>
> >>
> > --
> > Volkmar Glauche
> >
> > Freiburg Brain Imaging
> > http://fbi.uniklinik-freiburg.de/
> > Phone +49(0)761 270-5331
> > Fax   +49(0)761 270-5416
> 



function ok = write_hdr_raw(fname,hdr,be) % Write a NIFTI-1 .hdr file. % FORMAT ok = write_hdr_raw(fname,hdr,be) % fname - filename of image % hdr - a structure containing hdr info % be - whether big-endian or not % ok - status (1=good, 0=bad) % _______________________________________________________________________ % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience % % $Id: write_hdr_raw.m 1029 2007-12-19 18:30:38Z john $ [pth,nam,ext] = fileparts(fname); if isfield(hdr,'magic')     org = niftistruc;     switch deblank(hdr.magic)     case {'ni1'}         hname = fullfile(pth,[nam '.hdr']);     case {'n+1'}         hname = fullfile(pth,[nam '.nii']);     otherwise         error('Bad header.');     end; else     org = mayostruc;     hname = fullfile(pth,[nam '.hdr']); end; if nargin >=3     if be, mach = 'ieee-be';     else mach = 'ieee-le';     end; else mach = 'native'; end; ok = true; fp = fopen(hname,'r+',mach); if fp==-1     fp = fopen(hname,'w+',mach);     if fp==-1         ok = false;         return;     end; end; for i=1:length(org)     if isfield(hdr,org(i).label),         dat = hdr.(org(i).label);         if length(dat) ~= org(i).len,             if length(dat)< org(i).len,                 dat = [dat(:) ; zeros(org(i).len-length(dat),1)];             else                 dat = dat(1:org(i).len);             end;         end;     else         dat = org(i).def;     end;     % fprintf('%s=\n',org(i).label)     % disp(dat)     len = fwrite(fp,dat,org(i).dtype.prec);     if len ~= org(i).len,         ok = false;     end; end; fclose(fp); if ~ok,      fprintf('There was a problem writing to the header of\n');      fprintf('"%s"\n', fname); end; return;

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager