Home > fmri > utils > GE2SPM > GE_reorientHeader.m

GE_reorientHeader

PURPOSE ^

SYNOPSIS ^

function [outHeader] = GE_reorientHeader(inHeader, orient)

DESCRIPTION ^

 outHeader = GE_reorientHeader(inHeader, orient)

 Fixes the analyze header file based on the acquistion

 Souheil Inati
 Dartmouth College
 May 2000
 souheil.inati@dartmouth.edu

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [outHeader] = GE_reorientHeader(inHeader, orient)
0002 %
0003 % outHeader = GE_reorientHeader(inHeader, orient)
0004 %
0005 % Fixes the analyze header file based on the acquistion
0006 %
0007 % Souheil Inati
0008 % Dartmouth College
0009 % May 2000
0010 % souheil.inati@dartmouth.edu
0011 %
0012 
0013 % Initialize the output Header
0014 outHeader = inHeader;
0015 
0016 % Get the dimensions
0017 nX = inHeader.dim(2);
0018 nY = inHeader.dim(3);
0019 nZ = inHeader.dim(4);
0020 pX = inHeader.pixDim(2); % X Voxel Size
0021 pY = inHeader.pixDim(3); % Y Voxel Size
0022 pZ = inHeader.pixDim(4); % Z Voxel Size
0023 
0024 % Reshape and flip around to match what SPM expects
0025 % ie axial in radiological convention
0026 % Orientation is 1=axial, 2=sagittal, 3=coronal
0027 % with opposite sign if backwards slice order
0028 switch orient
0029 case  0 % Undefined Orientation
0030    fprintf('Orientation is undefined.  Check your images!');
0031 
0032 case {1, -1} % Sagittal
0033    outHeader.dim(2) = nZ;
0034    outHeader.dim(3) = nX;
0035    outHeader.dim(4) = nY;
0036    outHeader.pixDim(2) = pZ;
0037    outHeader.pixDim(3) = pX;
0038    outHeader.pixDim(4) = pY;
0039 
0040 case {2, -12}  % Axial
0041    outHeader.dim(2) = nX;
0042    outHeader.dim(3) = nY;
0043    outHeader.dim(4) = nZ;
0044    outHeader.pixDim(2) = pX;
0045    outHeader.pixDim(3) = pY;
0046    outHeader.pixDim(4) = pZ;
0047 
0048 case {3, -3} % Coronal
0049    outHeader.dim(2) = nX;
0050    outHeader.dim(3) = nZ;
0051    outHeader.dim(4) = nY;
0052    outHeader.pixDim(2) = pX;
0053    outHeader.pixDim(3) = pZ;
0054    outHeader.pixDim(4) = pY;
0055 
0056 end
0057 
0058 % Set the origin to the center of the volume
0059 outHeader.originator = [floor(outHeader.dim(2)/2) floor(outHeader.dim(3)/2) floor(outHeader.dim(4)/2) 0 0];
0060 
0061 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003