read BDF file [usage] [ChannelLabel, RecordTime, Nch, SampleRate, data_type, ... PhysicalUnit, DAT] = vb_bdffile_get_info(bdf_file) [input] bdf_file : <required> <<file>> BDF file [output] ChannelLabel : {1,Nch} list of channel name RecordTime : [Sec] record time Nch : number of channel SampleRate : [Hz] sample frequency data_type : data type ['float32'] PhysicalUnit : physical unit of data {1 x n_channel} DAT : <<struct>> original data set which includes header (.Head) [note] The detail of header are beyond the scope [history] 2008-03-31 (Sako) initial version 2009-12-25 (Sako) added PhysicalUnit to the return values Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [ChannelLabel, RecordTime, Nch, SampleRate, data_type, ... 0002 PhysicalUnit, DAT] = vb_bdffile_get_info(bdf_file) 0003 % read BDF file 0004 % [usage] 0005 % [ChannelLabel, RecordTime, Nch, SampleRate, data_type, ... 0006 % PhysicalUnit, DAT] = vb_bdffile_get_info(bdf_file) 0007 % [input] 0008 % bdf_file : <required> <<file>> BDF file 0009 % [output] 0010 % ChannelLabel : {1,Nch} list of channel name 0011 % RecordTime : [Sec] record time 0012 % Nch : number of channel 0013 % SampleRate : [Hz] sample frequency 0014 % data_type : data type ['float32'] 0015 % PhysicalUnit : physical unit of data {1 x n_channel} 0016 % DAT : <<struct>> original data set which includes header (.Head) 0017 % [note] 0018 % The detail of header are beyond the scope 0019 % [history] 0020 % 2008-03-31 (Sako) initial version 0021 % 2009-12-25 (Sako) added PhysicalUnit to the return values 0022 % 0023 % Copyright (C) 2011, ATR All Rights Reserved. 0024 % License : New BSD License(see VBMEG_LICENSE.txt) 0025 0026 % --- CHECK ARGUMENTS --- % 0027 if ~exist('bdf_file', 'var'), bdf_file = ''; end 0028 [bdf_file] = inner_check_arguments(bdf_file); 0029 0030 % --- MAIN PROCEDURE --------------------------------------------------------- % 0031 % 0032 vb_define_device; 0033 0034 [DAT,H1] = vb_openbdf(bdf_file); 0035 % --- H1 is not used now 0036 0037 % procedure parameters 0038 header = DAT.Head; 0039 RecordTime = header.NRec; 0040 Nch = header.NS; 0041 SampleRate = max(header.SampleRate); 0042 data_type = STANDARD_BIN_DATA_TYPE; 0043 % data_size = STANDARD_BIN_DATA_SIZE; 0044 0045 ChannelLabel = cell(1,Nch); 0046 PhysicalUnit = cell(1,Nch); 0047 0048 % get channel label for hardware 0049 for ch = 1:Nch 0050 ChannelLabel{ch} = deblank(header.Label(ch,:)); 0051 PhysicalUnit{ch} = deblank(header.PhysDim(ch,:)); 0052 end 0053 return; 0054 % 0055 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0056 0057 % --- INNER FUNCTIONS -------------------------------------------------------- % 0058 % 0059 % --- inner_check_arguments() 0060 % 0061 function [bdf_file] = inner_check_arguments(bdf_file) 0062 func_ = mfilename; 0063 if isempty(bdf_file) 0064 error('(%s)bdf_file is a required parameter', func_); 0065 end 0066 0067 if exist(bdf_file, 'file') ~= 2 0068 error('(%s)cannot find bdf_file: %s', func_, bdf_file); 0069 end 0070 return; 0071 % 0072 % --- end of inner_check_arguments() 0073 % 0074 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0075 0076 %%% END OF FILE %%%