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  2003

SPM 2003

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: SPM2 orient field and flip

From:

Darren Weber <[log in to unmask]>

Reply-To:

Darren Weber <[log in to unmask]>

Date:

Fri, 10 Jan 2003 12:06:02 +1030

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (202 lines)

Dear Joseph, et al,

I'm not sure how SPM2b interacts with the hist.orient field of the Analyze
header, so this contribution may be misguided.

Your comments assume the Analyze header orient field is a binary field with
2 possible values, but it may contain values 0-5 (see below).  These values
do not specifically relate to the 'radiological' (right on left, axial view
from the feet looking up) vs 'neurological' (right on right, axial view from
the head looking down) orientation issue.

According to information from the MAYO clinic, this field contains values
from 0 to 5, which determine how to read the byte order of an *.img file
into a 3D data matrix.  The *.img file is just a series of numbers, so the
header information is crucial for reading these numbers into a 3D matrix (or
4D for a time-series).  The header determines the size of the matrix and the
orient field helps to order the numbers into it.  The notes below guided the
development of the avw* functions available in the mri_toolbox, all source
code available from http://eeg.sourceforge.net.  These functions *attempt*
to work with this field in order to load any Analyze file into the RAS
orientation in a 3D data matrix (RAS = +X right, +Y anterior, +Z superior).
As far as I know, the code is working OK for volume visualization, although
I'm no expert at this and cannot guarantee the code is faultless.  I'm not
sure what the implications are for preprocessing, esp. normalisation and I
have no knowledge of the SPM code for handling Analyze orientation issues.
All I know is that SPM is designed to handle large numbers of volumes, so
memory management is important and it appears that SPM has some wrappers
that effectively manage 'virtual' files and load only the data values as
required (too complex for what I wanted).


% (Conventions gathered from e-mail with [log in to unmask])
%
% 0  transverse (axial) unflipped
%       X direction first,  progressing from patient right to left,
%       Y direction second, progressing from patient posterior to anterior,
%       Z direction third,  progressing from patient inferior to superior.
% 1  coronal unflipped
%       X direction first,  progressing from patient right to left,
%       Z direction second, progressing from patient inferior to superior,
%       Y direction third,  progressing from patient posterior to anterior.
% 2  sagittal unflipped
%       Y direction first,  progressing from patient posterior to anterior,
%       Z direction second, progressing from patient inferior to superior,
%       X direction third,  progressing from patient right to left.
% 3  transverse (axial) flipped
%       X direction first,  progressing from patient right to left,
%       Y direction second, progressing from patient anterior to posterior,
%       Z direction third,  progressing from patient inferior to superior.
% 4  coronal flipped
%       X direction first,  progressing from patient right to left,
%       Z direction second, progressing from patient superior to inferior,
%       Y direction third,  progressing from patient posterior to anterior.
% 5  sagittal flipped
%       Y direction first,  progressing from patient posterior to anterior,
%       Z direction second, progressing from patient superior to inferior,
%       X direction third,  progressing from patient right to left.

We can interpret the above, say 0, by noting that X changes fastest in the
right-left direction, followed by Y in the posterior-anterior direction, and
lastly we have slices in Z from inferior-superior.  So we look at X and Y as
the in-plane dimensions (rows & columns), with X changing fastest.  The
relevant code we get to read such a volume may look like this (from
avw_img_read)...


    % read the whole .img file into matlab (faster)
    fprintf('...reading %s Analyze %s image format.\n',machine,precision);
    fseek(fid,0,'bof');
    tmp = fread(fid,inf,sprintf('%s=>double',precision));
    fclose(fid);

    % Now partition the img data into xyz

% short int dim[ ];      /* Array of the image dimensions */
%
% dim[0]      Number of dimensions in database; usually 4.
% dim[1]      Image X dimension;  number of pixels in an image row.
% dim[2]      Image Y dimension;  number of pixel rows in slice.
% dim[3]      Volume Z dimension; number of slices in a volume.
% dim[4]      Time points; number of volumes in database.
%
    PixelDim = double(avw.hdr.dime.dim(2));
    RowDim   = double(avw.hdr.dime.dim(3));
    SliceDim = double(avw.hdr.dime.dim(4));

    switch double(avw.hdr.hist.orient),

    case 0, % transverse/axial unflipped

        % For the 'transverse unflipped' type, the voxels are stored with
        % Pixels in 'x' axis (varies fastest) - from patient right to left
        % Rows in   'y' axis                  - from patient posterior to
anterior
        % Slices in 'z' axis                  - from patient inferior to
superior

        fprintf('...image orient appears to be axial unflipped\n');

        avw.img = zeros(PixelDim,RowDim,SliceDim);

        n = 1;
        x = 1:PixelDim;
        for z = 1:SliceDim,
            for y = 1:RowDim,
                avw.img(x,y,z) = tmp(n:n+(PixelDim-1));
                n = n + PixelDim;
            end
        end


...more code for the other orientations can be found in the m file for those
who are interested.

Take care, Darren







----- Original Message -----
From: "Joseph Maldjian" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Friday, January 10, 2003 11:03 AM
Subject: SPM2 orient field and flip


Dear SPMers

    Some further clarification on the use of the orient field in the
analyze header and the defaults.analyze.flip parameter in spm_defaults.m
would be greatly appreciated.

If the defaults.analyze.flip paramer in spm_defaults.m is set to 1, then
SPM2 flips the images during display regardless of the value in the
orient field in the analyze header.

My understanding is that the orient field describes the orientation of
the image, where 1 (meaning flipped) refers to neurologic convention,
and 0 refers to radiologic convention.
Does the defaults.analyze.flip parameter in the spm_defaults.m file
refer to the viewing convention for a particular laboratory (ie, "our
lab always view our data in Talairach space and therefore neurologic
convention"), or does it refer to the orientation of the data at the
beginning of an analysis (prior to spatial normalization, ie, "our data
always starts in radiologic convention")?

If defaults.analyze.flip refers to the orientation of the initial data,
then what is the purpose of the orient field in the header, since the
defaults.analyze.flip parameter overrides this information and always
flips the images during display if set to 1 (defaults.analyze.flip)?
If defaults.analyze.flip refers to the viewing convention for a
particular laboratory, then why does SPM2 ignore the value of the orient
field in the analyze header during display?

It seems that if the default.analyze.flip parameter is set to 1, and the
orient field in the analyze header is set to 1, SPM2 should not flip
these images as they are already "flipped".
As it is now, we may run into problems when reprocessing SPM99 data,
using SPM2 data sets outside of SPM2, or when using non-SPM2 templates.

    If previously normalized SPM99 data (snr.img files) is processed
through SPM2 (the data is already flipped in neurologic convention, but
has an orient field of 0 ) the default.analyze.flip parameter needs to
be set to 0 in order to display the images properly (in neurologic
convention).
If new data is processed through SPM2 that starts in radiologic
convention,  the default.analyze.flip parameter needs to be set to 1.
However, the output data, will have a value of 0 in the orient field
(and they will be right-left flipped relative to SPM99 data when viewed
outside of SPM2).  This results in the unfortunate circumstance of
requiring separate hard-coded values for the defaults.analyze.flip
parameter within a lab (especially problematic with multiple users and a
single common distribution).  If we wish to view/manipulate this data
outside of SPM2, there will be no intrinsic method of determining right
and left between the SPM99 data sets and the SPM2 data sets.  In this
regard, the orient field would be of value for the SPM2 data sets ( 1
meaning it is in neurologic convention), as long as it does not get
ignored within SPM2 because of the defaults.analyze.flip parameter.
    As another example, if we wish to use our own normalized template
(already in neurologic convention), what should the
defaults.analyze.flip parameter be set to?  Setting it to 1 would be
appropriate for the input radiologic convention data, however wouldn't
this also result in the template image being flipped (since the orient
field is apparently being ignored)?

thank you



--------------------
Best Regards,

Joseph Maldjian, MD
Associate Professor of Radiology and Biomedical Engineering
Director Functional MRI
Wake Forest University School of Medicine
[log in to unmask]
phone:  336 716-2815

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

May 2024
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