0001 function [data] = vb_load_eeg_ch_data(ch_file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if ~exist('ch_file', 'var') ch_file = []; end
0019 [ch_file] = inner_check_arguments(ch_file);
0020
0021
0022
0023 func_ = mfilename;
0024
0025 [data_type,status_ch] = inner_check_status_channel(ch_file)
0026
0027 file_num = size(ch_file, 2);
0028
0029 for file_cnt = 1:file_num
0030
0031 file_path = ch_file{file_cnt};
0032
0033 if exist(file_path, 'file') ~= 2
0034 error('(%s)cannot find file : %s', func_, file_path);
0035 end
0036
0037 fid = fopen(file_path, 'r');
0038 if fid < 0
0039 error('(%s)cannot open : %s', func_, file_path);
0040 end
0041
0042 this_data = fread(fid, data_type{file_cnt});
0043
0044 if status_ch(file_cnt)
0045 data(file_cnt,:) = this_data';
0046 else
0047 data(file_cnt,:) = this_data;
0048
0049 end
0050
0051 fclose(fid);
0052
0053
0054
0055 end
0056
0057
0058
0059
0060
0061
0062
0063 function [ch_file] = inner_check_arguments(ch_file)
0064 func_ = mfilename;
0065
0066 if isempty(ch_file)
0067 error('(%s)ch_file is required parameter', func_);
0068 end
0069
0070 if ~iscell(ch_file)
0071 warning('(%s)ch_file must be cell array', func_);
0072 ch_file = {ch_file};
0073 end
0074 return;
0075
0076
0077
0078
0079
0080 function [data_type, status_ch] = inner_check_status_channel(ch_file)
0081
0082 func_ = mfilename;
0083
0084 vb_define_device;
0085
0086 file_num = size(ch_file,2);
0087 data_type = cell(1, file_num);
0088 status_ch = zeros(file_num, 1);
0089
0090 for file_cnt = 1:file_num
0091 [fpath,fname,fext] = vb_get_file_parts(ch_file{file_cnt});
0092
0093 if isempty(findstr(fname, STATUS_CH_LABEL))
0094 data_type{file_cnt} = STANDARD_BIN_DATA_TYPE;
0095 status_ch(file_cnt) = 0;
0096 else
0097 data_type{file_cnt} = STATUS_CH_DATA_TYPE;
0098 status_ch(file_cnt) = 1;
0099 end
0100 end
0101
0102 return;
0103
0104
0105
0106
0107