Create fractional anisotropy image using dtifit command(fsl) [Usage] dmri_FA_image_create(niftigz_file, bval_file, bvec_file, brain_mask_file, output_dir, output_name); [Input] niftigz_file : gzipped Nifti file(.nii.gz) 4D series of data volumes. bval_file : A text file containing a list of b values applied during each volume acquisition. The order of entries in this file must match the order of volumes in the input data and entries in the gradient directions text file. bvec_file : A text file containing a list of gradient directions applied during diffusion weighted volumes. The order of entries in this file must match the order of volumes in the input data series. brain_mask_file : gzipped Nifti file(.nii.gz) BET binary brain mask. A single binarised volume in diffusion space containing ones inside the brain and zeroes outside the brain. output_dir : output directory. output_name : output filename. output_dir/output_name.nii.gz will be created. [See also] http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/fdt/fdt_dtifit.html [Output] none Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function dmri_FA_image_create(niftigz_file, ... 0002 bval_file, bvec_file, ... 0003 brain_mask_file, ... 0004 output_dir, ... 0005 output_name) 0006 % Create fractional anisotropy image using dtifit command(fsl) 0007 % [Usage] 0008 % dmri_FA_image_create(niftigz_file, 0009 % bval_file, bvec_file, 0010 % brain_mask_file, 0011 % output_dir, 0012 % output_name); 0013 % [Input] 0014 % niftigz_file : gzipped Nifti file(.nii.gz) 0015 % 4D series of data volumes. 0016 % bval_file : A text file containing a list of b values applied 0017 % during each volume acquisition. The order of entries 0018 % in this file must match the order of volumes in 0019 % the input data and entries in the gradient 0020 % directions text file. 0021 % bvec_file : A text file containing a list of gradient directions 0022 % applied during diffusion weighted volumes. The order 0023 % of entries in this file must match the order of volumes 0024 % in the input data series. 0025 % brain_mask_file : gzipped Nifti file(.nii.gz) 0026 % BET binary brain mask. 0027 % A single binarised volume in diffusion space 0028 % containing ones inside the brain and zeroes 0029 % outside the brain. 0030 % output_dir : output directory. 0031 % output_name : output filename. 0032 % output_dir/output_name.nii.gz will be created. 0033 % 0034 % [See also] 0035 % http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/fdt/fdt_dtifit.html 0036 % 0037 % [Output] 0038 % none 0039 % 0040 % 0041 % Copyright (C) 2011, ATR All Rights Reserved. 0042 % License : New BSD License(see VBMEG_LICENSE.txt) 0043 0044 % 0045 % --- Previous check 0046 % 0047 if nargin ~= 6 0048 error('Please check input argument.'); 0049 end 0050 if exist(niftigz_file, 'file') ~= 2 0051 error('Specified diffusion weighted data file not found.'); 0052 end 0053 if exist(bval_file, 'file') ~= 2 0054 error('Specified bval_file not found.'); 0055 end 0056 if exist(bvec_file, 'file') ~= 2 0057 error('Specified bvec_file not found.'); 0058 end 0059 if exist(brain_mask_file, 'file') ~= 2 0060 error('Specified brain_mask file(.nii.gz) not found.'); 0061 end 0062 if ~ischar(output_dir) 0063 error('output_dir should be specified by character string.'); 0064 end 0065 if ~ischar(output_name) 0066 error('output_name should be specified by character string.'); 0067 end 0068 if exist(output_dir, 'dir') ~= 7 0069 mkdir(output_dir); 0070 end 0071 0072 % 0073 % --- Main Procedure 0074 % 0075 disp('Creating fractional anisotropy image.'); 0076 start = tic; 0077 base_name = [output_dir, '/', output_name]; 0078 command = ['dtifit -k ', niftigz_file, ... 0079 ' -m ' , brain_mask_file, ... 0080 ' -r ' , bvec_file, ... 0081 ' -b ' , bval_file, ... 0082 ' -o ' , base_name]; 0083 0084 [status, cmdout] = dmri_system(command, '-echo'); 0085 if status ~= 0 0086 error('Please check input arguments.'); 0087 end 0088 0089 % Remove unnecesary files. 0090 delete([base_name, '_L*.nii.gz']); 0091 delete([base_name, '_M*.nii.gz']); 0092 delete([base_name, '_S*.nii.gz']); 0093 delete([base_name, '_V*.nii.gz']); 0094 0095 % Rename 0096 command = ['mv ' base_name, '_FA.nii.gz', ' ', base_name, '.nii.gz']; 0097 [status, comret] = system(command, '-echo'); 0098 0099 toc(start);