Home > fmri > utils > old > GE2SPM.orig > GE_reorientHeader.m

GE_reorientHeader

PURPOSE ^

Initialize the output Header

SYNOPSIS ^

function [outHeader] = GE_reorientHeader(inHeader, orient)

DESCRIPTION ^

 Initialize the output Header

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Sat 25-May-2019 04:00:51 by m2html © 2003