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

GE_createSPMHeader

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [header, orient, im_offset, adwcount] = GE_createSPMHeader(fname)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%
                      %
 Setup Analyze Header %
                      %
%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%
0002 %                      %
0003 % Setup Analyze Header %
0004 %                      %
0005 %%%%%%%%%%%%%%%%%%%%%%%%
0006 function [header, orient, im_offset, adwcount] = GE_createSPMHeader(fname)
0007 
0008 % Read the info from the file
0009 [su_hdr,ex_hdr,se_hdr,im_hdr,pix_hdr,im_offset] = GE_readHeader(fname);
0010 
0011 % Initial ANALYZE Header Key
0012 header.sizeOfHeader = uint32(348); 
0013 header.dataType(1:10) = char(' ');
0014 header.dbName(1:18) = char(' ');
0015 header.extents = int32(16384);
0016 header.sessionError = int16(0);
0017 header.regular = char('r');
0018 header.hkeyUnused = char(' ');
0019 header.dim(1:8) = double(0);
0020 %Header dim is actually INT16 but need to do arithmetic with it
0021 header.voxUnits(1:4) = char(' ');
0022 header.calUnits(1:8) = char(' ');
0023 header.iUnused1 = int16(0);
0024 header.datatype = int16(0);
0025 header.bitpix = int16(0);
0026 header.dimUnused = int16(0);
0027 header.pixDim(1:8) = double(0);
0028 header.voxOffset = double(0);
0029 header.fUnused1 = double(0);
0030 header.fUnused2 = double(0);
0031 header.fUnused3 = double(0);
0032 header.calMax = double(0);
0033 header.calMin = double(0);
0034 header.compressed = double(0);
0035 header.verified = double(0);
0036 header.glMax = int32(0);
0037 header.glMin = int32(0);
0038 header.description(1:80) = char(' ');
0039 header.auxFile(1:24) = char(' ');
0040 header.orient = int8(0);
0041 header.originator(1:10) = char(' ');
0042 header.generated(1:10) = char(' ');
0043 header.scanNum(1:10) = char(' ');
0044 header.patientID(1:10) = char(' ');
0045 header.expDate(1:10) = char(' ');
0046 header.expTime(1:10) = char(' ');
0047 header.histUN0(1:3) = char(' ');
0048 header.views = int32(0);
0049 header.volsAdded = int32(0);
0050 header.startField = int32(0);
0051 header.fieldSkip = int32(0);
0052 header.oMax = int32(0);
0053 header.oMin = int32(0);
0054 header.sMax = int32(0);
0055 header.sMin = int32(0);
0056 
0057 % Stuff in the file specific stuff
0058 header.datatype = 4;
0059 header.bitpix = 16;
0060 header.orient = 0;
0061 header.glMax = 65535;
0062 header.dim(1) =  4;                % Dimensions (always 4?)
0063 header.dim(2) =  im_hdr.imatrix_X; % X Voxels
0064 header.dim(3) =  im_hdr.imatrix_Y; % Y Voxels
0065 header.dim(4) =  im_hdr.slquant;   % Z Voxels
0066 header.dim(5) =  1;                % Time Points
0067 header.pixDim(2) = im_hdr.pixsize_X;                    % X Voxel Size
0068 header.pixDim(3) = im_hdr.pixsize_Y;                    % Y Voxel Size
0069 header.pixDim(4) = im_hdr.slthick + im_hdr.scanspacing; % Z Voxel Size
0070 
0071 
0072 % Determine the orientation
0073 if (strcmp(char(se_hdr.start_ras),'L'))  & (strcmp(char(se_hdr.end_ras),'R'))
0074      orient = 1;
0075 elseif (strcmp(char(se_hdr.start_ras),'R'))  & (strcmp(char(se_hdr.end_ras),'L'))
0076      orient = -1;
0077 elseif (strcmp(char(se_hdr.start_ras),'I'))  & (strcmp(char(se_hdr.end_ras),'S'))
0078      orient = 2;
0079 elseif (strcmp(char(se_hdr.start_ras),'S'))  & (strcmp(char(se_hdr.end_ras),'I'))
0080      orient = -2;
0081 elseif (strcmp(char(se_hdr.start_ras),'A'))  & (strcmp(char(se_hdr.end_ras),'P'))
0082      orient = 3;
0083 elseif (strcmp(char(se_hdr.start_ras),'P'))  & (strcmp(char(se_hdr.end_ras),'A'))
0084      orient = -3;
0085 else
0086      orient = 0;
0087 end
0088 
0089 % Check if ADW scan
0090 if im_hdr.user9 == 0
0091   adwcount = 1;
0092 else
0093   adwcount = im_hdr.user9;
0094 end
0095 
0096 return
0097 
0098 
0099 
0100 
0101 
0102 
0103 
0104

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