This functions applies FSL Eddy Current Correction to the Diffusion weighted data(4D image) [Usage] dmri_4D_image_correct(niftigz_file); [Input] niftigz_file : Diffusion weighted data(4D image). (.nii.gz) [Output] none [Output files] Diffusion weighted data(4D image) after applying Eddy Current Correction. The output filename is original + _ecc [See also] https://users.fmrib.ox.ac.uk/~behrens/fdt_docs/fdt_eddy.html Eddy currents in the gradient coils induce (approximate) stretches and shears in the diffusion weighted images. These distortions are different for different gradient directions. Eddy Current Correction corrects for these distortions, and for simple head motion, using affine registration to a reference volume. [Example] dmri_4D_image_correct('/home/cbi/org/DTI_data.nii.gz'); creates /home/cbi/org/DTI_data_m.nii.gz /home/cbi/org/DTI_data_m.bvec /home/cbi/org/DTI_data_m.bval Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function dmri_4D_image_correct(niftigz_file) 0002 % This functions applies FSL Eddy Current Correction to the 0003 % Diffusion weighted data(4D image) 0004 % [Usage] 0005 % dmri_4D_image_correct(niftigz_file); 0006 % 0007 % [Input] 0008 % niftigz_file : Diffusion weighted data(4D image). 0009 % (.nii.gz) 0010 % [Output] 0011 % none 0012 % 0013 % [Output files] 0014 % Diffusion weighted data(4D image) after applying Eddy Current Correction. 0015 % The output filename is original + _ecc 0016 % 0017 % [See also] 0018 % https://users.fmrib.ox.ac.uk/~behrens/fdt_docs/fdt_eddy.html 0019 % Eddy currents in the gradient coils induce (approximate) stretches 0020 % and shears in the diffusion weighted images. These distortions are 0021 % different for different gradient directions. Eddy Current Correction 0022 % corrects for these distortions, and for simple head motion, using 0023 % affine registration to a reference volume. 0024 % 0025 % [Example] 0026 % dmri_4D_image_correct('/home/cbi/org/DTI_data.nii.gz'); 0027 % creates /home/cbi/org/DTI_data_m.nii.gz 0028 % /home/cbi/org/DTI_data_m.bvec 0029 % /home/cbi/org/DTI_data_m.bval 0030 % 0031 % Copyright (C) 2011, ATR All Rights Reserved. 0032 % License : New BSD License(see VBMEG_LICENSE.txt) 0033 0034 % 0035 % --- Previous check 0036 % 0037 if ~exist('niftigz_file', 'var') 0038 error('Please check arguments.'); 0039 end 0040 if exist(niftigz_file, 'file') ~= 2 0041 error('Input file not found.'); 0042 end 0043 0044 % 0045 % --- Main Procedure 0046 % 0047 disp('Applying Eddy current correction...'); 0048 start = tic; 0049 [p, f, e] = fileparts(niftigz_file(1:end-7)); % -7 => .nii.gz 0050 bvec_file = [p, '/', f, '.bvec']; 0051 bval_file = [p, '/', f, '.bval']; 0052 0053 c_niftigz_file = [p, '/', f, '_m.nii.gz']; 0054 c_bvec_file = [p, '/', f, '_m.bvec']; 0055 c_bval_file = [p, '/', f, '_m.bval']; 0056 0057 command = ['eddy_correct ' niftigz_file, ' ' c_niftigz_file, ' 0']; 0058 [status, cmdout] = dmri_system(command, '-echo'); 0059 if status ~= 0 0060 error('Please check input arguments'); 0061 end 0062 0063 % bvec correction and new bvec file is saved as FSL readable format. 0064 disp('Applying bvec correction..'); 0065 ecclog = [p, '/', f, '_m.ecclog']; 0066 corrected_bvec_file = ecc_bvecs(ecclog, bvec_file); 0067 mv_cmd = ['mv ' corrected_bvec_file, ' ', c_bvec_file]; 0068 system(mv_cmd); 0069 0070 % just copy and rename bval file 0071 cp_cmd = ['cp ' bval_file, ' ', c_bval_file]; 0072 system(cp_cmd); 0073 disp('Finished.'); 0074 toc(start);