Home > bioelectromagnetism > avw_hdr_check_datatype.m

avw_hdr_check_datatype

PURPOSE ^

avw_hdr_check_datatype - read Analyze format data header (*.hdr)

SYNOPSIS ^

function [ avw ] = avw_hdr_check_datatype(avw,verbose)

DESCRIPTION ^

 avw_hdr_check_datatype - read Analyze format data header (*.hdr)

 avw = avw_hdr_check_datatype(avw,verbose)

 attempts to set the datatype based on the bits per pixel, although
 this really needs to be done the other way around.  The following
 table indicates the values recognised for 
 avw.hdr.dime.datatype and avw.hdr.dime.bitpix

 short int datatype      /* Datatype for this image set */ 
 /*Acceptable values for datatype are*/ 
 #define DT_NONE             0
 #define DT_UNKNOWN          0    /*Unknown data type*/ 
 #define DT_BINARY           1    /*Binary             ( 1 bit per voxel)*/ 
 #define DT_UNSIGNED_CHAR    2    /*Unsigned character ( 8 bits per voxel)*/ 
 #define DT_SIGNED_SHORT     4    /*Signed short       (16 bits per voxel)*/ 
 #define DT_SIGNED_INT       8    /*Signed integer     (32 bits per voxel)*/ 
 #define DT_FLOAT           16    /*Floating point     (32 bits per voxel)*/ 
 #define DT_COMPLEX         32    /*Complex (64 bits per voxel; 2 floating point numbers)/* 
 #define DT_DOUBLE          64    /*Double precision   (64 bits per voxel)*/ 
 #define DT_RGB            128    /*A Red-Green-Blue datatype*/
 #define DT_ALL            255    /*Undocumented*/
 
 short int bitpix;    /* Number of bits per pixel; 1, 8, 16, 32, or 64. */ 
 
 verbose - the default is to output processing information to the command
           window.  If verbose = 0, this will not happen.

 See also avw_hdr_write, avw_hdr_make, avw_view_hdr, avw_view

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ avw ] = avw_hdr_check_datatype(avw,verbose)
0002 
0003 % avw_hdr_check_datatype - read Analyze format data header (*.hdr)
0004 %
0005 % avw = avw_hdr_check_datatype(avw,verbose)
0006 %
0007 % attempts to set the datatype based on the bits per pixel, although
0008 % this really needs to be done the other way around.  The following
0009 % table indicates the values recognised for
0010 % avw.hdr.dime.datatype and avw.hdr.dime.bitpix
0011 %
0012 % short int datatype      /* Datatype for this image set */
0013 % /*Acceptable values for datatype are*/
0014 % #define DT_NONE             0
0015 % #define DT_UNKNOWN          0    /*Unknown data type*/
0016 % #define DT_BINARY           1    /*Binary             ( 1 bit per voxel)*/
0017 % #define DT_UNSIGNED_CHAR    2    /*Unsigned character ( 8 bits per voxel)*/
0018 % #define DT_SIGNED_SHORT     4    /*Signed short       (16 bits per voxel)*/
0019 % #define DT_SIGNED_INT       8    /*Signed integer     (32 bits per voxel)*/
0020 % #define DT_FLOAT           16    /*Floating point     (32 bits per voxel)*/
0021 % #define DT_COMPLEX         32    /*Complex (64 bits per voxel; 2 floating point numbers)/*
0022 % #define DT_DOUBLE          64    /*Double precision   (64 bits per voxel)*/
0023 % #define DT_RGB            128    /*A Red-Green-Blue datatype*/
0024 % #define DT_ALL            255    /*Undocumented*/
0025 %
0026 % short int bitpix;    /* Number of bits per pixel; 1, 8, 16, 32, or 64. */
0027 %
0028 % verbose - the default is to output processing information to the command
0029 %           window.  If verbose = 0, this will not happen.
0030 %
0031 % See also avw_hdr_write, avw_hdr_make, avw_view_hdr, avw_view
0032 %
0033 
0034 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
0035 
0036 % Licence:  GNU GPL, no express or implied warranties
0037 % History:  05/2002, Darren.Weber@flinders.edu.au
0038 %                    The Analyze format and c code below is copyright
0039 %                    (c) Copyright, 1986-1995
0040 %                    Biomedical Imaging Resource, Mayo Foundation
0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0042 
0043 if ~exist('verbose','var'), verbose = 1; end
0044 
0045 if verbose,
0046     version = '[$Revision: 1.1 $]';
0047     fprintf('\nAVW_HDR_CHECK_DATATYPE [v%s]\n',version(12:16));  tic;
0048 end
0049 
0050 if ~exist('avw','var'),
0051     error('...no input avw');
0052 end
0053 
0054 
0055 switch avw.hdr.dime.bitpix,
0056   
0057   case 0,
0058     error('avw.hdr.dime.bitpix = 0, unknown datatype');
0059     
0060   case 1,
0061     avw.hdr.dime.datatype = 1;
0062     
0063   case 8,
0064     avw.hdr.dime.datatype = 2;
0065     
0066   case 16,
0067     avw.hdr.dime.datatype = 4;
0068     
0069   case 32,
0070     warning('bitpix = 32, assuming datatype is float (rather than signed int)');
0071     avw.hdr.dime.datatype = 16;
0072     
0073   case 64,
0074     warning('bitpix = 64, assuming datatype is double (rather than complex)');
0075     avw.hdr.dime.datatype = 64;
0076     
0077   case 128,
0078     avw.hdr.dime.datatype = 128;
0079     
0080   otherwise
0081     error('unknown bitpix and datatype');
0082     
0083 end
0084 
0085 if verbose,
0086     t = toc; fprintf('...done ( %6.2f sec)\n\n',t);
0087 end
0088 
0089 return

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