wvWelchSpectra
wvWelchSpectra. Workhorse function called by spectral analysis routines.
wvWelchSpectra is intended to be called from wvPowerSpectra but can be
invoked directly.
Examples:
P=wvWelchSpectra(fhandle, PropName1, PropValue1.....)
P=wvWelchSpectra(channels, PropName1, PropValue1.....)
The output P is a N x N cell matrix where N is the number of channels.The
data are contained in the diagonal of the matrix.
wvWelchSpectra returns the Power Spectral Density.
For continuous waveform channels, the Welch periodogram is calculated for
sections of data of length WindowLength seconds. The length of data used
will be truncated, if necessary, to a multiple of WindowLength.
For episodic and frame-based data, only valid data epochs will be used
within the timerange where
channels{x}.tim(:,1) < t <= channels{x}.tim(:,2)
if tim has only 2 columns or
channels{x}.tim(:,2) < t <= channels{x}.tim(:,3)
if it has 3 columns
i.e. only post-trigger data is used if the trigger time is known.
Note that, if WindowLength exceeds the length of the available data,
the WindowLength for all sections will be reduced to that of
the shortest (post-trigger) period.
Valid field/value pairs are:
'channellist' the numbers for the channels to analyze
(scalar or vector list)
'start' the start time for data processing
(scalar, in seconds)
'stop' the stop time for data processing
(scalar, in seconds)'
'windowtype' the window to apply to the data
(string: e.g. 'hamming')
'windowlength' the length of the window and also of the data
sections in seconds (scalar)
'overlap' the overlap to be used between data sections
as a percentage (scalar)
'overlapmode' determines whether overalpping will be
applied.OverlapMode may be set to 'on',
'off' or 'auto':
'auto': This is the default. Continuous waveform
data will be processed in overlapping
sections. Episodic and frame-based data will
not be overlapped.
'off': No overlapping will be performed
regardless of the setting for Overlap.
'on': the overlap will be applied to all
channels including episodic and
frame-based samples. It will rarely
make sense to do this.
'detrend' Logical flag. If true, the linear trend will
each data section be removed from each data
section before taking its FFT
'spectrummode' The type of spectrum to return as a string:
'normalized power spectral density'
'power spectral density'
'linear power spectral density'
'power spectrum'
'linear power spectrum'
'spectrogramflag' Not really a flag but a string. If set to
'contour' or 'surface' the spectrum will be
returned for each data section and plotted
in 3D as a contour or surface. Otherwise,
data will be averaged to produce a 2D
result.
'decimation' decimation factor (zero by default). If non-zero,
the data to be analyzed will be anti-alias
filtered and downsampled by the factor in
decimate. This can be useful with oversampled
data when drawing 3D plots as graphics rendering
may otherwise to too slow
Toolboxes Required: For decimation only, dfilt objects must be available
e.g. via SP Toolbox
-------------------------------------------------------------------------
Author: Malcolm Lidierth 09/07
Copyright © The Author & King's College London 2007
-------------------------------------------------------------------------