Home > rest_20090422 > rest_spm5_files > nic_spm_vol_nifti.m

nic_spm_vol_nifti

PURPOSE ^

Get header information for a NIFTI-1 image.

SYNOPSIS ^

function V = nic_spm_vol_nifti(fname,n)

DESCRIPTION ^

  Get header information for a NIFTI-1 image.
  FORMAT V = spm_vol_nifti(P)
  P - filename.
  n - volume id (a 1x2 array, e.g. [3,1])
  V - a structure containing the image volume information.
____________________________________________________________________________
 Copyright (C) 2005 Wellcome Department of Imaging Neuroscienic_e

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

nic_spm_vol_nifti.m

SOURCE CODE ^

0001 function V = nic_spm_vol_nifti(fname,n)
0002 %  Get header information for a NIFTI-1 image.
0003 %  FORMAT V = spm_vol_nifti(P)
0004 %  P - filename.
0005 %  n - volume id (a 1x2 array, e.g. [3,1])
0006 %  V - a structure containing the image volume information.
0007 %____________________________________________________________________________
0008 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscienic_e
0009 
0010 % John Ashburner
0011 % $Id: spm_vol_nifti.m 112 2005-05-04 18:20:52Z john $
0012 
0013 
0014 if nargin<2,  n = [1 1];      end;
0015 if ischar(n), n = str2num(n); end;
0016 N  = read_nifti(fname);
0017 n  = [n 1 1];
0018 n  = n(1:2);
0019 dm = [N.dat.dim 1 1 1 1];
0020 if any(n>dm(4:5)), V = []; return; end;
0021 
0022 dt = struct(N.dat);
0023 dt = double([dt.dtype dt.be]);
0024 
0025 if isfield(N.extras,'mat') && size(N.extras.mat,3)>=n(1) && sum(sum(N.extras.mat(:,:,n(1))))~=0,
0026     mat = N.extras.mat(:,:,n(1));
0027 else
0028     mat = N.mat;
0029 end;
0030 
0031 off = (n(1)-1+dm(4)*(n(2)-1))*ceil(nic_spm_type(dt(1),'bits')*dm(1)*dm(2)/8)*dm(3) + N.dat.offset;
0032 V   = struct('fname', N.dat.fname,...
0033              'dim',   dm(1:3),...
0034              'dt',    dt,...
0035              'pinfo', [N.dat.scl_slope N.dat.scl_inter off]',...
0036              'mat',   mat,...
0037              'n',     n,...
0038              'descrip', N.descrip,...
0039              'private',N);

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