Home > rest_20090422 > rest_spm5_files > @read_nifti > private > getdict.m

getdict

PURPOSE ^

Dictionary of NIFTI stuff

SYNOPSIS ^

function d = getdict

DESCRIPTION ^

 Dictionary of NIFTI stuff
 _______________________________________________________________________
 Copyright (C) 2005 Wellcome Department of Imaging Neuroscience

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

getdict.m

SOURCE CODE ^

0001 function d = getdict
0002 % Dictionary of NIFTI stuff
0003 % _______________________________________________________________________
0004 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience
0005 
0006 %
0007 % $Id: getdict.m 253 2005-10-13 15:31:34Z guillaume $
0008 
0009 
0010 persistent dict;
0011 if ~isempty(dict),
0012     d = dict;
0013     return;
0014 end;
0015 
0016 % Datatype
0017 t = true;
0018 f = false;
0019 table = {...
0020     0   ,'UNKNOWN'   ,'uint8'   ,@uint8  ,1,1  ,t,t,f
0021     1   ,'BINARY'    ,'uint1'   ,@logical,1,1/8,t,t,f
0022     256 ,'INT8'      ,'int8'    ,@int8   ,1,1  ,t,f,t
0023     2   ,'UINT8'     ,'uint8'   ,@uint8  ,1,1  ,t,t,t
0024     4   ,'INT16'     ,'int16'   ,@int16  ,1,2  ,t,f,t
0025     512 ,'UINT16'    ,'uint16'  ,@uint16 ,1,2  ,t,t,t
0026     8   ,'INT32'     ,'int32'   ,@int32  ,1,4  ,t,f,t
0027     768 ,'UINT32'    ,'uint32'  ,@uint32 ,1,4  ,t,t,t
0028     1024,'INT64'     ,'int64'   ,@int64  ,1,8  ,t,f,f
0029     1280,'UINT64'    ,'uint64'  ,@uint64 ,1,8  ,t,t,f
0030     16  ,'FLOAT32'   ,'float32' ,@single ,1,4  ,f,f,t
0031     64  ,'FLOAT64'   ,'double'  ,@double ,1,8  ,f,f,t
0032     1536,'FLOAT128'  ,'float128',@crash  ,1,16 ,f,f,f
0033     32  ,'COMPLEX64' ,'float32' ,@single ,2,4  ,f,f,f
0034     1792,'COMPLEX128','double'  ,@double ,2,8  ,f,f,f
0035     2048,'COMPLEX256','float128',@crash  ,2,16 ,f,f,f
0036     128 ,'RGB24'     ,'uint8'   ,@uint8  ,3,1  ,t,t,f};
0037 
0038 dtype = struct(...
0039     'code'     ,table(:,1),...
0040     'label'    ,table(:,2),...
0041     'prec'     ,table(:,3),...
0042     'conv'     ,table(:,4),...
0043     'nelem'    ,table(:,5),...
0044     'size'     ,table(:,6),...
0045     'isint'    ,table(:,7),...
0046     'unsigned' ,table(:,8),...
0047     'min',-Inf,'max',Inf',...
0048     'supported',table(:,9));
0049 for i=1:length(dtype),
0050     if dtype(i).isint
0051         if dtype(i).unsigned
0052             dtype(i).min =  0;
0053             dtype(i).max =  2^(8*dtype(i).size)-1;
0054         else
0055             dtype(i).min = -2^(8*dtype(i).size-1);
0056             dtype(i).max =  2^(8*dtype(i).size-1)-1;
0057         end;
0058     end;
0059 end;
0060 % Intent
0061 table = {...
0062     0   ,'NONE'         ,'None',{}
0063     2   ,'CORREL'       ,'Correlation statistic',{'DOF'}
0064     3   ,'TTEST'        ,'T-statistic',{'DOF'}
0065     4   ,'FTEST'        ,'F-statistic',{'numerator DOF','denominator DOF'}
0066     5   ,'ZSCORE'       ,'Z-score',{}
0067     6   ,'CHISQ'        ,'Chi-squared distribution',{'DOF'}
0068     7   ,'BETA'         ,'Beta distribution',{'a','b'}
0069     8   ,'BINOM'        ,'Binomial distribution',...
0070         {'number of trials','probability per trial'}
0071     9   ,'GAMMA'        ,'Gamma distribution',{'shape','scale'}
0072     10  ,'POISSON'      ,'Poisson distribution',{'mean'}
0073     11  ,'NORMAL'       ,'Normal distribution',{'mean','standard deviation'}
0074     12  ,'FTEST_NONC'   ,'F-statistic noncentral',...
0075         {'numerator DOF','denominator DOF','numerator noncentrality parameter'}
0076     13  ,'CHISQ_NONC'   ,'Chi-squared noncentral',{'DOF','noncentrality parameter'}
0077     14  ,'LOGISTIC'     ,'Logistic distribution',{'location','scale'}
0078     15  ,'LAPLACE'      ,'Laplace distribution',{'location','scale'}
0079     16  ,'UNIFORM'      ,'Uniform distribition',{'lower end','upper end'}
0080     17  ,'TTEST_NONC'   ,'T-statistic noncentral',{'DOF','noncentrality parameter'}
0081     18  ,'WEIBULL'      ,'Weibull distribution',{'location','scale','power'}
0082     19  ,'CHI'          ,'Chi distribution',{'DOF'}
0083     20  ,'INVGAUSS'     ,'Inverse Gaussian distribution',{'mu','lambda'}
0084     21  ,'EXTVAL'       ,'Extreme Value distribution',{'location','scale'}
0085     22  ,'PVAL'         ,'P-value',{}
0086     23  ,'LOGPVAL'      ,'Log P-value',{}
0087     24  ,'LOG10PVAL'    ,'Log_10 P-value',{}
0088     1001,'ESTIMATE'     ,'Estimate',{}
0089     1002,'LABEL'        ,'Label index',{}
0090     1003,'NEURONAMES'   ,'NeuroNames index',{}
0091     1004,'MATRIX'       ,'General matrix',{'M','N'}
0092     1005,'MATRIX_SYM'   ,'Symmetric matrix',{}
0093     1006,'DISPLACEMENT' ,'Displacement vector',{}
0094     1007,'VECTOR'       ,'Vector',{}
0095     1008,'POINTS'       ,'Pointset',{}
0096     1009,'TRIANGLE'     ,'Triangle',{}
0097     1010,'QUATERNION'   ,'Quaternion',{}
0098     1011,'DIMLESS'      ,'Dimensionless',{}
0099 };
0100 intent = struct('code',table(:,1),'label',table(:,2),...
0101     'fullname',table(:,3),'param',table(:,4));
0102 
0103 % Units
0104 table = {...
0105      0,   1,'UNKNOWN'
0106      1,1000,'m'
0107      2,   1,'mm'
0108      3,1e-3,'um'
0109      8,   1,'s'
0110     16,1e-3,'ms'
0111     24,1e-6,'us'
0112     32,   1,'Hz'
0113     40,   1,'ppm'
0114     48,   1,'rads'};
0115 units = struct('code',table(:,1),'label',table(:,3),'rescale',table(:,2));
0116 
0117 % Reference space
0118 % code  = {0,1,2,3,4};
0119 table = {...
0120     0,'UNKNOWN'
0121     1,'Scanner Anat'
0122     2,'Aligned Anat'
0123     3,'Talairach'
0124     4,'MNI_152'};
0125 anat  = struct('code',table(:,1),'label',table(:,2));
0126 
0127 % Slice Ordering
0128 table = {...
0129     0,'UNKNOWN'
0130     1,'sequential_increasing'
0131     2,'sequential_decreasing'
0132     3,'alternating_increasing'
0133     4,'alternating_decreasing'};
0134 sliceorder = struct('code',table(:,1),'label',table(:,2));
0135 
0136 % Q/S Form Interpretation
0137 table = {...
0138     0,'UNKNOWN'
0139     1,'Scanner'
0140     2,'Aligned'
0141     3,'Talairach'
0142     4,'MNI152'};
0143 xform = struct('code',table(:,1),'label',table(:,2));
0144 
0145 dict = struct('dtype',dtype,'intent',intent,'units',units,...
0146     'space',anat,'sliceorder',sliceorder,'xform',xform);
0147 
0148 d = dict;
0149 return;
0150 
0151 function varargout = crash(varargin)
0152 error('There is a NIFTI-1 data format problem (an invalid datatype).');
0153

Generated on Wed 29-Apr-2009 01:06:38 by m2html © 2005