


BML_INFO_RAW return a annot table with OS and header info of each raw file in a folder. Use as tab = bml_info_raw(cfg); 'raw' files are those that can be read by ft_read_header. The first argument cfg is a configuration structure, which can contain the following field: cfg.path - string: path to the folder containing the files. Defauts to '.' cfg.has_channel - cell of strings: channels required Returns a matlab 'table' with the folloing variables: starts - double: time in seconds ends - double: time in seconds name - cell array of char: filename folder - cell array of char: path date - cell array of char: data of file modification bytes - double: Size of the file in bytes isdir - logical: 1 if name is a folder; 0 if name is a file datenum - double: Modification date as serial date number. chantype Fs nSamples nChans nTrials chantype chanunit duration


0001 function info = bml_info_raw(cfg) 0002 0003 % BML_INFO_RAW return a annot table with OS and header info of each raw file in a folder. 0004 % 0005 % Use as 0006 % tab = bml_info_raw(cfg); 0007 % 0008 % 'raw' files are those that can be read by ft_read_header. 0009 % 0010 % The first argument cfg is a configuration structure, which can contain 0011 % the following field: 0012 % cfg.path - string: path to the folder containing the files. Defauts to '.' 0013 % cfg.has_channel - cell of strings: channels required 0014 % 0015 % Returns a matlab 'table' with the folloing variables: 0016 % starts - double: time in seconds 0017 % ends - double: time in seconds 0018 % name - cell array of char: filename 0019 % folder - cell array of char: path 0020 % date - cell array of char: data of file modification 0021 % bytes - double: Size of the file in bytes 0022 % isdir - logical: 1 if name is a folder; 0 if name is a file 0023 % datenum - double: Modification date as serial date number. 0024 % chantype 0025 % Fs 0026 % nSamples 0027 % nChans 0028 % nTrials 0029 % chantype 0030 % chanunit 0031 % duration 0032 0033 chantype = bml_getopt(cfg, 'chantype', {}); 0034 path = bml_getopt(cfg, 'path'); 0035 has_channel = bml_getopt(cfg, 'has_channel'); 0036 0037 info = bml_info_file(cfg); 0038 0039 if isempty(info); return; end 0040 info = info(info.bytes > 0,:); 0041 0042 hdr_vars={'chantype','Fs','nSamples','nChans','nTrials','chanunit'}; 0043 hdr_table = cell2table(cell(height(info),length(hdr_vars))); 0044 hdr_table.Properties.VariableNames = hdr_vars; 0045 0046 for i=1:height(info) 0047 hdr = ft_read_header(fullfile(info.folder{i},info.name{i}),'chantype',chantype); 0048 if ~isempty(has_channel) 0049 if ~all(ismember(has_channel,hdr.label)) 0050 continue 0051 end 0052 end 0053 hdr_table.chantype(i) = {strjoin(unique(hdr.chantype))}; 0054 hdr_table.Fs(i) = {hdr.Fs}; 0055 hdr_table.nSamples(i) = {hdr.nSamples}; 0056 hdr_table.nChans(i) = {hdr.nChans}; 0057 hdr_table.nTrials(i) = {hdr.nTrials}; 0058 hdr_table.chanunit(i) = {strjoin(unique(hdr.chanunit))}; 0059 end 0060 0061 filtvec = ~cellfun(@isempty,hdr_table.nChans); 0062 hdr_table = hdr_table(filtvec,:); 0063 0064 hdr_table.Fs = cell2mat(hdr_table.Fs); 0065 hdr_table.nSamples = cell2mat(hdr_table.nSamples); 0066 hdr_table.nChans = cell2mat(hdr_table.nChans); 0067 hdr_table.nTrials = cell2mat(hdr_table.nTrials); 0068 0069 info = [info(filtvec,:) hdr_table]; 0070 info.duration = info.nSamples ./ info.Fs; 0071 ends=bml_date2sec(info{:,'date'}); 0072 starts = ends-info.duration; 0073 0074 info=[table(starts,ends,'VariableNames',{'starts','ends'}) info]; 0075 % info=sortrows(info,'starts'); 0076 info=bml_annot_table(info,'raw_info'); 0077 0078 0079