Home > bioelectromagnetism > avw_hdr_make.m

avw_hdr_make

PURPOSE ^

AVW_HDR_MAKE - Create Analyze format data header (avw.hdr)

SYNOPSIS ^

function [ avw ] = avw_hdr_make

DESCRIPTION ^

 AVW_HDR_MAKE - Create Analyze format data header (avw.hdr)
 
 [ avw ] = avw_hdr_make
 
 avw.hdr - a struct, all fields returned from the header.
           For details, find a good description on the web
           or see the Analyze File Format pdf in the 
           mri_toolbox doc folder or see avw_hdr_read.m
 
 See also, AVW_HDR_READ AVW_HDR_WRITE
           AVW_IMG_READ AVW_IMG_WRITE

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ avw ] = avw_hdr_make
0002 
0003 % AVW_HDR_MAKE - Create Analyze format data header (avw.hdr)
0004 %
0005 % [ avw ] = avw_hdr_make
0006 %
0007 % avw.hdr - a struct, all fields returned from the header.
0008 %           For details, find a good description on the web
0009 %           or see the Analyze File Format pdf in the
0010 %           mri_toolbox doc folder or see avw_hdr_read.m
0011 %
0012 % See also, AVW_HDR_READ AVW_HDR_WRITE
0013 %           AVW_IMG_READ AVW_IMG_WRITE
0014 %
0015 
0016 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
0017 
0018 % Licence:  GNU GPL, no express or implied warranties
0019 % History:  06/2002, Darren.Weber@flinders.edu.au
0020 %           02/2003, Darren.Weber@flinders.edu.au
0021 %                    date/time bug at lines 97-98
0022 %                    identified by Bennett.Landman@ieee.org
0023 %
0024 %                    The Analyze format is copyright
0025 %                    (c) Copyright, 1986-1995
0026 %                    Biomedical Imaging Resource, Mayo Foundation
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 
0029 version = '[$Revision: 1.1 $]';
0030 fprintf('\nAVW_HDR_MAKE [v%s]\n',version(12:16));  tic;
0031 
0032 
0033 % Comments
0034 % The header format is flexible and can be extended for new
0035 % user-defined data types. The essential structures of the header
0036 % are the header_key and the image_dimension.  See avw_hdr_read
0037 % for more detail of the header structure
0038 avw.hdr = make_header;
0039 
0040 t=toc; fprintf('...done (%5.2f sec).\n',t);
0041 
0042 return
0043 
0044 
0045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0047 function [ hdr ] = make_header
0048     
0049     hdr.hk   = header_key;
0050     hdr.dime = image_dimension;
0051     hdr.hist = data_history;
0052     
0053 return
0054 
0055 
0056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0057 function [hk] = header_key
0058     
0059     hk.sizeof_hdr       = int32(348);   % must be 348!
0060     hk.data_type(1:10)  = sprintf('%10s','');
0061     hk.db_name(1:18)    = sprintf('%18s','');
0062     hk.extents          = int32(16384);
0063     hk.session_error    = int16(0);
0064     hk.regular          = sprintf('%1s','r');  % might be uint8
0065     hk.hkey_un0         = uint8(0);
0066     
0067 return
0068 
0069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0070 function [ dime ] = image_dimension
0071     
0072     dime.dim(1:8)       = int16([4 256 256 256 1 0 0 0]);
0073     dime.vox_units(1:4) = sprintf('%4s','mm');
0074     dime.cal_units(1:8) = sprintf('%8s','');
0075     dime.unused1        = int16(0);
0076     dime.datatype       = int16(2);
0077     dime.bitpix         = int16(8);
0078     dime.dim_un0        = int16(0);
0079     dime.pixdim(1:8)    = single([0 1 1 1 1000 0 0 0]);
0080     dime.vox_offset     = single(0);
0081     dime.funused1       = single(0);
0082     dime.funused2       = single(0);
0083     % Set default 8bit intensity scale (from MRIcro), otherwise funused3
0084     dime.roi_scale      = single(1);
0085     dime.cal_max        = single(0);
0086     dime.cal_min        = single(0);
0087     dime.compressed     = int32(0);
0088     dime.verified       = int32(0);
0089     dime.glmax          = int32(255);
0090     dime.glmin          = int32(0);
0091     
0092 return
0093 
0094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0095 function [ hist ] = data_history
0096     
0097     datime = clock;
0098     
0099     hist.descrip(1:80)      = sprintf('%-80s','mri_toolbox @ http://eeg.sf.net/');
0100     hist.aux_file(1:24)     = sprintf('%-24s','');
0101     hist.orient             = uint8(0); % sprintf( '%1s',''); % see notes in avw_hdr_read
0102     hist.originator(1:10)   = sprintf('%-10s','');
0103     hist.generated(1:10)    = sprintf('%-10s','mri_toolbx');
0104     hist.scannum(1:10)      = sprintf('%-10s','');
0105     hist.patient_id(1:10)   = sprintf('%-10s','');
0106     hist.exp_date(1:10)     = sprintf('%02d-%02d-%04d',datime(3),datime(2),datime(1));
0107     hist.exp_time(1:10)     = sprintf('%02d-%02d-%04.1f',datime(4),datime(5),datime(6));
0108     hist.hist_un0(1:3)      = sprintf( '%-3s','');
0109     hist.views              = int32(0);
0110     hist.vols_added         = int32(0);
0111     hist.start_field        = int32(0);
0112     hist.field_skip         = int32(0);
0113     hist.omax               = int32(0);
0114     hist.omin               = int32(0);
0115     hist.smax               = int32(0);
0116     hist.smin               = int32(0);
0117     
0118 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003