Home > functions > common > loadfunc > vb_load_analyze_to_left.m

vb_load_analyze_to_left

PURPOSE ^

load analyze/nifti image to LAS orientation

SYNOPSIS ^

function [B, Vdim, Vsize] = vb_load_analyze_to_left(analyzefile)

DESCRIPTION ^

 load analyze/nifti image to LAS orientation
  [B, Vdim, Vsize] = vb_load_analyze_to_left(analyzefile)
 --- Input
 analyzefile - Analyze/Nifti filename 
               Default Analyze file is left-handed  LAS image
               Default Nifti   file is Right-handed RAS image
 --- Output
 B     : 3D image data  [Xdim, Ydim, Zdim ]
 Vdim  : image size  [Xdim  Ydim  Zdim ] (voxels)
 Vsize : voxel size  [x y z ] (mm)

 written by M. Sato  2008-2-18

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [B, Vdim, Vsize] = vb_load_analyze_to_left(analyzefile)
0002 % load analyze/nifti image to LAS orientation
0003 %  [B, Vdim, Vsize] = vb_load_analyze_to_left(analyzefile)
0004 % --- Input
0005 % analyzefile - Analyze/Nifti filename
0006 %               Default Analyze file is left-handed  LAS image
0007 %               Default Nifti   file is Right-handed RAS image
0008 % --- Output
0009 % B     : 3D image data  [Xdim, Ydim, Zdim ]
0010 % Vdim  : image size  [Xdim  Ydim  Zdim ] (voxels)
0011 % Vsize : voxel size  [x y z ] (mm)
0012 %
0013 % written by M. Sato  2008-2-18
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 % load analyze/nifti image file to RAS orientation
0019 avw = load_nii_ras(analyzefile);
0020 
0021 B = avw.img;
0022 
0023 Vdim  = size(B);
0024 Vsize = avw.hdr.dime.pixdim(2:4);
0025 
0026 % flip x-axis to LAS
0027 B = B(Vdim(1):-1:1, :,:);
0028 
0029 %% written by M. Sato  2005-8-1
0030 %
0031 %if ~isempty( findstr(analyzefile, '.hdr') )
0032 %    analyzefile = analyzefile(1:findstr(analyzefile, '.hdr')-1);
0033 %    analyzefile = [analyzefile '.img'];
0034 %end
0035 %
0036 %% load analyze image file (left-hand)
0037 %try
0038 %  % Faster than avw_img_read, but sometimes make error
0039 %  [B, Vdim, Vsize] = read_image(analyzefile);
0040 %  B = reshape(B,Vdim);
0041 %catch
0042 %  warning(['The "read_image" function output an error. '...
0043 %       'Try "avw_img_read" function']);
0044 %  avw = avw_img_read(analyzefile);
0045 %  B   = avw.img;
0046 %  [Vdim, Vsize] = spm_hread(analyzefile);
0047 %end
0048 %
0049 %return
0050 %
0051 %%&& DEBUG
0052 %B1   = B1(Vdim(1):-1:1, :,:);
0053 %errB = vb_err_array3d(B,B1)
0054 %errD = Vdim  - Vdim1
0055 %errS = Vsize - Vsize1
0056 %%&& DEBUG

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005