Home > fmri > utils > GE2SPM > GE_reorientImage.m

GE_reorientImage

PURPOSE ^

SYNOPSIS ^

function [outVol] = GE_reorientImage(inVol, orient)

DESCRIPTION ^

GE_reorientImage

 function [outVol] = GE_reorientImage(inVol, orient)
 reorients the inVol 3D volume to be SPM compatible
 based on the orient flag

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

 09/26/03 PJ Changed default handling to assume axial inf. to superior

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [outVol] = GE_reorientImage(inVol, orient)
0002 %
0003 %GE_reorientImage
0004 %
0005 % function [outVol] = GE_reorientImage(inVol, orient)
0006 % reorients the inVol 3D volume to be SPM compatible
0007 % based on the orient flag
0008 %
0009 % Souheil J. Inati
0010 % Dartmouth College
0011 % May 2000
0012 % souheil.inati@dartmouth.edu
0013 %
0014 % 09/26/03 PJ Changed default handling to assume axial inf. to superior
0015 
0016 [nX nY nZ] = size(inVol);
0017 
0018 % Reshape and flip around to match what SPM expects
0019 % ie axial in radiological convention
0020 % Orientation is 1=axial, 2=sagittal, 3=coronal
0021 % with opposite sign if backwards slice order
0022 %
0023 % This has been tested with Ax,Sag,Cor with slices going
0024 % both ways.  Also for Oblique axial.
0025 % Don't count on double obliques or anything really fancy
0026 %
0027 
0028 
0029 switch orient
0030   case  0 % Undefined Orientation
0031     fprintf('Warning: Orientation is undefined.  Check your images!\n');
0032     outVol = inVol;
0033     outVol(:,1:nY,:) = outVol(:,nY:-1:1,:);
0034 
0035   case  1 % Sagittal (L to R)
0036     outVol = permute(inVol,[3 1 2]);
0037     outVol(1:nZ,:,:) = outVol(nZ:-1:1,:,:);
0038     outVol(:,1:nX,:) = outVol(:,nX:-1:1,:);
0039     outVol(:,:,1:nY) = outVol(:,:,nY:-1:1);
0040 
0041   case -1 % Sagittal (R to L)
0042     outVol = permute(inVol,[3 1 2]);
0043     outVol(:,1:nX,:) = outVol(:,nX:-1:1,:);
0044     outVol(:,:,1:nY) = outVol(:,:,nY:-1:1);
0045 
0046   case  2  % Axial (I to S)
0047     outVol = inVol;
0048     outVol(:,1:nY,:) = outVol(:,nY:-1:1,:);
0049 
0050   case -2  % Axial (S to I)
0051     outVol = inVol;
0052     outVol(:,1:nY,:) = outVol(:,nY:-1:1,:);
0053     outVol(:,:,1:nZ) = outVol(:,:,nZ:-1:1);
0054 
0055   case  3 % Coronal (A to P)
0056     outVol = permute(inVol,[1 3 2]);
0057     outVol(:,:,1:nY) = outVol(:,:,nY:-1:1);
0058     outVol(:,1:nZ,:) = outVol(:,nZ:-1:1,:);
0059 
0060   case -3 % Coronal (P to A)
0061     outVol = permute(inVol,[1 3 2]);
0062     outVol(:,:,1:nY) = outVol(:,:,nY:-1:1);
0063 
0064 end
0065 
0066 return

Generated on Mon 11-Nov-2019 04:00:39 by m2html © 2003