Home > vbmeg > functions > tool_box > dmri_processor > functions > dmri_response_estimation_prepare.m

dmri_response_estimation_prepare

PURPOSE ^

Preprocess FA image and get brain area for response function estimation.

SYNOPSIS ^

function dmri_response_estimation_prepare(fa_niftigz_file, output_niftigz_file)

DESCRIPTION ^

 Preprocess FA image and get brain area for response function estimation.

 [Usage]
    dmri_response_estimation_prepare(fa_niftigz_file, output_niftigz_file);

 [Input]
        fa_niftigz_file : Fractional Anisotropy Image (.nii.gz)
    output_niftigz_file : Preprocessed and extracted brain area(.nii.gz)

 [Output]
    none

 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 dmri_response_estimation_prepare(fa_niftigz_file, output_niftigz_file)
0002 % Preprocess FA image and get brain area for response function estimation.
0003 %
0004 % [Usage]
0005 %    dmri_response_estimation_prepare(fa_niftigz_file, output_niftigz_file);
0006 %
0007 % [Input]
0008 %        fa_niftigz_file : Fractional Anisotropy Image (.nii.gz)
0009 %    output_niftigz_file : Preprocessed and extracted brain area(.nii.gz)
0010 %
0011 % [Output]
0012 %    none
0013 %
0014 % Copyright (C) 2011, ATR All Rights Reserved.
0015 % License : New BSD License(see VBMEG_LICENSE.txt)
0016 
0017 %
0018 % --- Previous check
0019 %
0020 if nargin ~= 2
0021     error('Please check input arguments.');
0022 end
0023 if exist(fa_niftigz_file, 'file') ~= 2
0024     error('Specified FA image not found.');
0025 end
0026 
0027 %
0028 % --- Main Procedure
0029 %
0030 work_dir = tempname;
0031 mkdir(work_dir);
0032 [p, f, e] = fileparts(fa_niftigz_file);
0033 
0034 % copy FA image to working directory.
0035 fa_file   = fullfile(work_dir, filesep, [f, e]);
0036 copyfile(fa_niftigz_file, fa_file);
0037 
0038 % 1st step (thresholding)
0039 tmp2_file = fullfile(work_dir, filesep, 'tmp2.nii.gz');
0040 cmd = ['fslmaths' ...
0041        ' ', fa_file, ...
0042        ' -thr 0.7', ...
0043        ' -bin ', tmp2_file];
0044 dmri_system(cmd);
0045 
0046 % 2nd step (cluster)
0047 tmp3_file = fullfile(work_dir, filesep, 'tmp3.nii.gz');
0048 cmd = ['cluster', ...
0049        ' -i ', tmp2_file, ...
0050        ' -t 1',...
0051        ' -o ', tmp3_file];
0052 dmri_system(cmd);
0053 
0054 % 3rd step (get cluster value)
0055 tmp4_file = fullfile(work_dir, filesep, 'max_cluster_val');
0056 cmd = ['fslstats', ...
0057        ' ', tmp3_file, ...
0058        ' -R | cut -d '' '' -f 2 > ', tmp4_file];
0059 dmri_system(cmd);
0060 cmd = ['cat ', tmp4_file];
0061 [s, value_str] = system(cmd);
0062 value_str = strrep(value_str, sprintf('\n'), '');
0063 
0064 % 4th step (extract brain area)
0065 output_dir = fileparts(output_niftigz_file);
0066 if exist(output_dir, 'dir') ~= 7
0067     mkdir(output_dir);
0068 end
0069 cmd = ['fslmaths', ...
0070        ' ', tmp3_file, ...
0071        ' -thr ', value_str, ...
0072        ' -uthr ' value_str, ...
0073        ' -bin '  output_niftigz_file];
0074 dmri_system(cmd);
0075 
0076 % copy value file to output_dir
0077 copyfile(tmp4_file, output_dir);
0078 
0079 % remove working directory
0080 rmdir(work_dir, 's');

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