SONGETADCCHANNEL reads an ADC (waveform) channel from a SON file.
[DATA {, HEADER}]=SONGETADCCHANNEL(FID, CHAN{, START{, STOP{, OPTIONS}}})
FID is the matlab file handle, CHAN is the channel number (1=max)
[DATA, HEADER]=SONGETADCCHANNEL(FID, 1{, OPTIONS})
reads all the data on channel 1
[DATA, HEADER]=SONGETADCCHANNEL(FID, 1, 10{, OPTIONS})
reads disc block 10 for continuous data or epoch 10 for triggered
data
[DATA, HEADER]=SONGETADCCHANNEL(FID, 1, 10, 20{, OPTIONS})
reads disc blocks 10-20 for continuous data or epochs 10-20
for triggered data
When present, OPTIONS must be the last input argument. Valid options
are:
'ticks', 'microseconds', 'milliseconds' and 'seconds' cause times to
be scaled to the appropriate unit (seconds by default)in HEADER
'scale' - calls SONADCToDouble to apply the channel scale and offset to DATA
which will be cast to double precision
'progress' - causes a progress bar to be displayed during the read.
'mat' - the loaded data will be appended to the MAT-file specified
in the next optional input e.g.:
[d,h]=SONGetADCChannel(fid,1,'progress','mat','myfile.mat');
Returns the signed 16 bit integer ADC values in DATA (scaled, offset and
cast to double if 'scale' is used as an option). If present, HEADER
will be returned with the channel header information from the file.
For continuously sampled data, DATA is a simple vector.
If sampling was triggered, DATA will be 2-dimensional matrix
with each epoch (frame) of data in a separate column.
Examples:
[data, header]=SONGetADCChannel(fid, 1, 'ticks')
reads all data on channel 1 returning an int16 vector or matrix
Times in header will be in clock ticks
options={'progress' 'scale' 'ticks'}
[data, header]=SONGetADCChannel(fid, 1, 200, 399, options{:})
reads epochs 200-399 from channel 1 and displays a progress bar. Data is
returned in double-precision floating point after scaling and applying
the offset stored on disc. If sampling was
continuous, data will be a vector containing data blocks 200-399.
If triggered, data will be a 200 column matrix, each column containing one
data epoch.
HEADER could have the following example field values
FileName: source filename (and path)
system: SON version identifier
FileChannel: Channel number in file
phyChan: Physical (hardware) port.
kind: 1 (or 9 if scaled) - channel type identifier
comment: Channel comment
title: Channel title
sampleinterval: sampling interval in microseconds (Changed in v2.2)
scale: e.g. 200, scaling factor used to convert to 'units'
offset: e.g. 1 offset applied to scaled data
units: Channel units
npoints: e.g. [1x200 double] number of valid data points
in each column of DATA
mode: 'Triggered' or 'Continuous' sampling
start: e.g [1x200 double] start time for each column in data
in 'TimeUnits'
stop: e.g. [1x200 double] end time for each column in data
in 'TimeUnits'
Epochs: a cell array e.g. {[200] [399] 'of' [961] 'epochs'}
lists the blocks or epochs read
TimeUnits: e.g. 'Ticks' the time units
transpose: default 0, a flag, 0 for row-wise and 1 for columnwise
organization of data
min and max fields will also be present if the data are scaled
11/03/06
Memory pre-allocations changed to speed up execution
SONADCToDouble code embedded in function
Memory mapping embedded in function
31/3/06
Use Version 7.0 "zeros" for int16 pre-allocation - include if/else
for backwards compat
20/5/06
Varargin handling tidied
Memory mapping improved. Now uses the ADCARRAY class
12/7/06
Memory mapping removed. Now files data in a Level 5 Version 6
compatible MAT file. Use 'where.m' to map the MAT-file.
20/02/08
Always build header, whether nargout==2 or not
20/01/10
R2010a compatibility changes
Malcolm Lidierth 03/02
Updated 12/06 ML
Copyright © The Author & King's College London 2002-2006