check sample information (from, to) [usage] [result, Nsample] = vb_meginfo_check_sample(meginfo, sample_from, sample_to) [input] meginfo : <required> <<struct>> MEG header information sample_from : <required> start sample number sample_to : <required> end sample number [output] result : boolean : true : both sample_from and sample_to are valid : false : out of sample Nsample : number of sample [note] if sample_from or sample_to is out of sample, this function outputs warning message. [history] 2007-06-20 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [result, Nsample] = vb_meginfo_check_sample(meginfo, ... 0002 sample_from, sample_to) 0003 % check sample information (from, to) 0004 % 0005 % [usage] 0006 % [result, Nsample] = vb_meginfo_check_sample(meginfo, sample_from, sample_to) 0007 % 0008 % [input] 0009 % meginfo : <required> <<struct>> MEG header information 0010 % sample_from : <required> start sample number 0011 % sample_to : <required> end sample number 0012 % 0013 % [output] 0014 % result : boolean 0015 % : true : both sample_from and sample_to are valid 0016 % : false : out of sample 0017 % Nsample : number of sample 0018 % 0019 % [note] 0020 % if sample_from or sample_to is out of sample, this function outputs 0021 % warning message. 0022 % 0023 % [history] 0024 % 2007-06-20 (Sako) initial version 0025 % 0026 % Copyright (C) 2011, ATR All Rights Reserved. 0027 % License : New BSD License(see VBMEG_LICENSE.txt) 0028 0029 % --- CHECK ARGUMENTS --- % 0030 if ~exist('meginfo', 'var') meginfo = []; end 0031 if ~exist('sample_from', 'var') sample_from = []; end 0032 if ~exist('sample_to', 'var') sample_to = []; end 0033 [meginfo, sample_from, sample_to] = ... 0034 inner_check_arguments(meginfo, sample_from, sample_to); 0035 0036 % --- MAIN PROCEDURE --------------------------------------------------------- % 0037 % 0038 func_ = 'vb_meginfo_check_sample'; 0039 0040 result = true; 0041 0042 Nsample = vb_meginfo_get_sample_number(meginfo); 0043 0044 % --- check sample_from 0045 if sample_from < 1 || Nsample < sample_from 0046 result = false; 0047 warning('(%s)sample_from is out of sample : %d (Nsample is %d)', ... 0048 func_, sample_from, Nsample); 0049 end 0050 0051 % --- check sample_to 0052 if sample_to < 1 || Nsample < sample_to 0053 result = false; 0054 warning('(%s)sample_to is out of sample : %d (Nsample is %d)', ... 0055 func_, sample_to, Nsample); 0056 end 0057 0058 % --- check sample_from and sample_to 0059 if sample_to < sample_from 0060 result = false; 0061 warning('(%s)sample_to (%d) is smaller than sample_from (%d)', ... 0062 func_, sample_to, sample_from); 0063 end 0064 return; 0065 % 0066 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0067 0068 0069 % --- INNER FUNCTIONS -------------------------------------------------------- % 0070 % 0071 % --- inner_check_arguments() 0072 % 0073 function [meginfo, sample_from, sample_to] = ... 0074 inner_check_arguments(meginfo, sample_from, sample_to) 0075 0076 func_ = 'vb_meginfo_check_sample'; 0077 0078 if isempty(meginfo) 0079 error('(%s)meginfo is a required parameter', func_); 0080 end 0081 0082 if isempty(sample_from) 0083 error('(%s)sample_from is a required parameter', func_); 0084 end 0085 0086 if isempty(sample_to) 0087 error('(%s)sample_to is a required parameter', func_); 0088 end 0089 return; 0090 % 0091 % --- end of inner_check_arguments() 0092 % 0093 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0094 0095 % --- END OF FILE --- %