Home > bml > annot > bml_raw2annot.m

bml_raw2annot

PURPOSE ^

BML_RAW2ANNOT creates an annotation table from a raw

SYNOPSIS ^

function annot = bml_raw2annot(raw)

DESCRIPTION ^

 BML_RAW2ANNOT creates an annotation table from a raw

 raw - FT_DATATYPE_RAW

 returns an ANNOT table with variables
   'id' corresponds to the trial
   'starts' time represented by the trial
     'ends' time represented by the trial
   'duration' in seconds
   's1' double, first sample sync coord
   't1' double, time of first sample sample sync coord
   's2' double, second sample sync coord
   't2' double, time of second sample sample sync coord
   'Fs' double, sampling rate
   'nSamples' double, number of samples in raw

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function annot = bml_raw2annot(raw)
0002 
0003 % BML_RAW2ANNOT creates an annotation table from a raw
0004 %
0005 % raw - FT_DATATYPE_RAW
0006 %
0007 % returns an ANNOT table with variables
0008 %   'id' corresponds to the trial
0009 %   'starts' time represented by the trial
0010 %     'ends' time represented by the trial
0011 %   'duration' in seconds
0012 %   's1' double, first sample sync coord
0013 %   't1' double, time of first sample sample sync coord
0014 %   's2' double, second sample sync coord
0015 %   't2' double, time of second sample sample sync coord
0016 %   'Fs' double, sampling rate
0017 %   'nSamples' double, number of samples in raw
0018 
0019 annot = table();
0020 for i=1:numel(raw.trial)
0021   id = i;
0022   nSamples = size(raw.trial{i},2);
0023   
0024   if ismember('fsample',fields(raw))
0025     Fs = raw.fsample;
0026   else
0027     Fs = round(1/mean(diff(raw.time{i})),9,'significant');
0028   end
0029   
0030 %   if ismember('sampleinfo',fields(raw))
0031 %     s1 = raw.sampleinfo(i,1);
0032 %     s2 = raw.sampleinfo(i,2);
0033 %   else
0034 %     s1 = 1;
0035 %     s2 = nSamples;
0036 %   end
0037   s1 = 1;
0038   s2 = nSamples;     
0039 
0040   t1 = raw.time{i}(1);
0041   t2 = raw.time{i}(end);
0042   
0043   starts = t1 - 0.5/Fs;
0044   ends = t2 + 0.5/Fs;
0045   
0046   annot = [annot; table(id,starts,ends,s1,t1,s2,t2,Fs,nSamples)];
0047   
0048 end
0049 
0050 annot = bml_annot_table(annot,inputname(1));

Generated on Tue 25-Sep-2018 10:08:19 by m2html © 2005