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

brain_image_extract

PURPOSE ^

delete non-brain tissues from an image of the whole head by FSL bet command.

SYNOPSIS ^

function brain_image_extract(niftigz_file, threshold)

DESCRIPTION ^

 delete non-brain tissues from an image of the whole head by FSL bet command.

 [Usage]
    brain_image_extract(nifti_gz_file, threshold);

 [Input]
    niftigz_file : gzipped NIfTI Image file(.nii.gz)
       threshold : fractional intensity threshold (0->1); 
                   default=0.5; smaller values give larger brain 
                   outline estimates.
 [Output]
    none

 [Output files]
    extracted brain image file:
       gzipped Nifti file(.nii.gz)
    brain mask file:
       gzipped Nifti file(.nii.gz)
       A single binarised volume in diffusion space containing ones 
       inside the brain and zeroes outside the brain.

 [See also]
    http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET

 [Example]
    brain_image_extract('/home/cbi/data_ecc.nii.gz', 0.18);
      put these files into the same directory.
      (_brain, _brain_mask is added.)
        /home/cbi/data_ecc_brain.nii.gz
        /home/cbi/data_ecc_brain_mask.nii.gz


 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 brain_image_extract(niftigz_file, threshold)
0002 % delete non-brain tissues from an image of the whole head by FSL bet command.
0003 %
0004 % [Usage]
0005 %    brain_image_extract(nifti_gz_file, threshold);
0006 %
0007 % [Input]
0008 %    niftigz_file : gzipped NIfTI Image file(.nii.gz)
0009 %       threshold : fractional intensity threshold (0->1);
0010 %                   default=0.5; smaller values give larger brain
0011 %                   outline estimates.
0012 % [Output]
0013 %    none
0014 %
0015 % [Output files]
0016 %    extracted brain image file:
0017 %       gzipped Nifti file(.nii.gz)
0018 %    brain mask file:
0019 %       gzipped Nifti file(.nii.gz)
0020 %       A single binarised volume in diffusion space containing ones
0021 %       inside the brain and zeroes outside the brain.
0022 %
0023 % [See also]
0024 %    http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET
0025 %
0026 % [Example]
0027 %    brain_image_extract('/home/cbi/data_ecc.nii.gz', 0.18);
0028 %      put these files into the same directory.
0029 %      (_brain, _brain_mask is added.)
0030 %        /home/cbi/data_ecc_brain.nii.gz
0031 %        /home/cbi/data_ecc_brain_mask.nii.gz
0032 %
0033 %
0034 % Copyright (C) 2011, ATR All Rights Reserved.
0035 % License : New BSD License(see VBMEG_LICENSE.txt)
0036 
0037 %
0038 % --- Previous check
0039 %
0040 if ~exist('niftigz_file', 'var')
0041     error('Please check input arguments.');
0042 end
0043 if exist(niftigz_file, 'file') ~= 2
0044     error('Specified niftigz_file not found');
0045 end
0046 if ~exist('threshold', 'var')
0047     threshold = 0.5;
0048 end
0049 
0050 %
0051 % --- Main Procedure
0052 %
0053 fprintf('brain extraction(threshold:%.2f)...', threshold);
0054 [p, f, e] = fileparts(niftigz_file(1:end-7)); % -7 means '.nii.gz'
0055 output_basename = [p, '/', f, '_brain'];
0056 command = ['bet ', niftigz_file, ' ', ...
0057                    output_basename, ...
0058                    ' -m', ...             % -m: generate binary brain mask
0059                    ' -f ', num2str(threshold), ... % -f: fractional intensity
0060                    ' -R '];
0061 [status, cmdout] = dmri_system(command, '-echo');
0062 if status ~= 0
0063     error('Please check input arguments.');
0064 end
0065 fprintf('done.\n');
0066

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