Home > fmri > fsl > read_avw.m

read_avw

PURPOSE ^

[img, dims,scales,bpp,endian] = READ_AVW(fname)

SYNOPSIS ^

function [img,dims,scales,bpp,endian] = read_avw(fname)

DESCRIPTION ^

 [img, dims,scales,bpp,endian] = READ_AVW(fname)

  Read in an Analyze or nifti file into either a 3D or 4D
  array (depending on the header information)
  fname is the filename (must be inside single quotes)
  Note: automatically detects - unsigned char, short, long, float
         double and complex formats
  Extracts the 4 dimensions (dims), 
  4 scales (scales) and bytes per pixel (bpp) for voxels 
  contained in the Analyze or nifti header file (fname)
  Also returns endian = 'l' for little-endian or 'b' for big-endian

  See also: SAVE_AVW

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [img,dims,scales,bpp,endian] = read_avw(fname)
0002 % [img, dims,scales,bpp,endian] = READ_AVW(fname)
0003 %
0004 %  Read in an Analyze or nifti file into either a 3D or 4D
0005 %  array (depending on the header information)
0006 %  fname is the filename (must be inside single quotes)
0007 %  Note: automatically detects - unsigned char, short, long, float
0008 %         double and complex formats
0009 %  Extracts the 4 dimensions (dims),
0010 %  4 scales (scales) and bytes per pixel (bpp) for voxels
0011 %  contained in the Analyze or nifti header file (fname)
0012 %  Also returns endian = 'l' for little-endian or 'b' for big-endian
0013 %
0014 %  See also: SAVE_AVW
0015 
0016 % remove extension if it exists
0017 if ( (length(findstr(fname,'.hdr'))>0) | ...
0018         (length(findstr(fname,'.img')>0)) | ...
0019         (length(findstr(fname,'.nii')>0)) ),
0020   fname=fname(1:(length(fname)-4));
0021 end
0022 if ( (length(findstr(fname,'.hdr.gz')>0)) | ...
0023         (length(findstr(fname,'.img.gz')>0)) | ...
0024         (length(findstr(fname,'.nii.gz')>0)) ),
0025   fname=fname(1:(length(fname)-7));
0026 end
0027 
0028 %% convert to uncompressed nifti pair (using FSL)
0029 tmpname = tempname;
0030 tmp=sprintf('! $FSLDIR/etc/matlab/convertTOniftipair %s %s \n',fname,tmpname);
0031 eval(tmp);
0032 
0033   [dims,scales,bpp,endian,datatype]= read_avw_hdr(tmpname);
0034   if (datatype==32),
0035     % complex type
0036     img=read_avw_complex(tmpname);
0037   else
0038     img=read_avw_img(tmpname);
0039   end
0040   
0041 tmp=sprintf('! /bin/rm %s.hdr %s.img \n',tmpname,tmpname);
0042 eval(tmp);
0043

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003