Home > vbmeg > functions > tool_box > dmri_processor > functions > util > ecc_bvecs.m

ecc_bvecs

PURPOSE ^

ecc_bvecs(ecclog,bvecsfile)

SYNOPSIS ^

function corrected_bvec_file = ecc_bvecs(ecclog,bvecsfile)

DESCRIPTION ^

 ecc_bvecs(ecclog,bvecsfile)

 S.Jbabdi 03/2009
 M.Fukushima 2012/06/10
 R.Hayashi   2013/11/20 corrected file is put to tempname.

 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 corrected_bvec_file = ecc_bvecs(ecclog,bvecsfile)
0002 % ecc_bvecs(ecclog,bvecsfile)
0003 %
0004 % S.Jbabdi 03/2009
0005 % M.Fukushima 2012/06/10
0006 % R.Hayashi   2013/11/20 corrected file is put to tempname.
0007 %
0008 % Copyright (C) 2011, ATR All Rights Reserved.
0009 % License : New BSD License(see VBMEG_LICENSE.txt)
0010 
0011 % read bvecs file
0012 bvecs = load(bvecsfile);
0013 if(size(bvecs,2)==3 && size(bvecs,1)>3)
0014     bvecs = bvecs';
0015 end
0016 ecclog_tmp_file = tempname;
0017 
0018 % read ecc-log file
0019 [stat,ret] = unix(['cat ' ecclog ' | grep Final -A 4 | sed s/"Final result:"//g | sed s/--//g > ' ecclog_tmp_file]);
0020 if stat ~= 0
0021     error(['error occured', ret]);
0022 end
0023 mat = load(ecclog_tmp_file);
0024 
0025 % rotate bvecs
0026 rotbvecs = zeros(size(bvecs));
0027 for i = 1:size(bvecs,2)
0028     M = mat((i-1)*4+1:i*4,:);
0029     M = M(1:3,1:3);
0030     
0031     % extract rotation matrix
0032     [u,s,v] = svd(M*M');
0033     R = inv(u*sqrt(s)*v')*M;
0034     
0035     rotbvecs(:,i) = R*bvecs(:,i);
0036 end
0037 
0038 % save([bvecsfile '_rot'],'rotbvecs','-ascii','-double');
0039 corrected_bvec_file = tempname;
0040 saveascii(rotbvecs,corrected_bvec_file,14);
0041 
0042

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005