


FORMAT flags = prt_check_flag(flags_o,flags)
Function to automatically check the content of a "flag" structure, using
a "default flag structure", adding the missing fields and putting in the
default value if none was provided.
INPUT:
flags_o default or reference structure
flags input flag/option structure that need to be filled for missing
fields with default values
OUPUT:
flags filled flag/option structure
NOTE:
This function was originally named 'crc_check_flag' and was distributed
with the FASST toolbox:
http://www.montefiore.ulg.ac.be/~phillips/FASST.html
__________________________________________________________________________
Copyright (C) 2015 Machine Learning & Neuroimaging Laboratory

0001 function flags = prt_check_flag(flags_o,flags) 0002 0003 % FORMAT flags = prt_check_flag(flags_o,flags) 0004 % 0005 % Function to automatically check the content of a "flag" structure, using 0006 % a "default flag structure", adding the missing fields and putting in the 0007 % default value if none was provided. 0008 % 0009 % INPUT: 0010 % flags_o default or reference structure 0011 % flags input flag/option structure that need to be filled for missing 0012 % fields with default values 0013 % 0014 % OUPUT: 0015 % flags filled flag/option structure 0016 % 0017 % NOTE: 0018 % This function was originally named 'crc_check_flag' and was distributed 0019 % with the FASST toolbox: 0020 % http://www.montefiore.ulg.ac.be/~phillips/FASST.html 0021 %__________________________________________________________________________ 0022 % Copyright (C) 2015 Machine Learning & Neuroimaging Laboratory 0023 0024 % Written by Y. Leclercq & C. Phillips, 2008. 0025 % Cyclotron Research Centre, University of Liege, Belgium 0026 0027 f_names = fieldnames(flags_o); 0028 % list fields in default structure 0029 0030 Nfields = length(f_names); 0031 for ii=1:Nfields 0032 if ~isfield(flags,f_names{ii}) || isempty(getfield(flags,f_names{ii})) %#ok<*GFLD> 0033 flags = setfield(flags,f_names{ii},getfield(flags_o,f_names{ii})); %#ok<*SFLD> 0034 end 0035 end 0036 0037 return