Home > FMAToolbox > Analyses > CoherenceBands.m

CoherenceBands

PURPOSE ^

CoherenceBands - Determine running coherence in physiological bands.

SYNOPSIS ^

function bands = CoherenceBands(coherogram,frequencies,varargin)

DESCRIPTION ^

CoherenceBands - Determine running coherence in physiological bands.

  USAGE

    bands = CoherenceBands(coherogram,frequencies,<options>)

    coherogram     coherogram obtained using <a href="matlab:help MTCoherogram">MTCoherogram</a>
    frequencies    frequency bins for coherogram
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'smooth'      smoothing for ratio (0 = no smoothing) (default = 2)
     'custom'      set custom band (default= [0 250])
     'delta'       set delta band (default = [0 4])
     'theta'       set theta band (default = [7 10])
     'spindles'    set spindle band (default = [10 20])
     'lowGamma'    set low gamma band (default = [30 80])
     'highGamma'   set high gamma band (default = [80 120])
     'ripples'     set ripple band (default = [100 250])
    =========================================================================

  OUTPUT

    bands.custom     coherence in the custom band
    bands.delta      coherence in the delta band
    bands.theta      coherence in the theta band
    bands.spindles   coherence in the spindle band
    bands.lowGamma   coherence in the low gamma band
    bands.highGamma  coherence in the high gamma band
    bands.ripples    coherence in the ripple band

  SEE

    See also MTCoherogram.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function bands = CoherenceBands(coherogram,frequencies,varargin)
0002 
0003 %CoherenceBands - Determine running coherence in physiological bands.
0004 %
0005 %  USAGE
0006 %
0007 %    bands = CoherenceBands(coherogram,frequencies,<options>)
0008 %
0009 %    coherogram     coherogram obtained using <a href="matlab:help MTCoherogram">MTCoherogram</a>
0010 %    frequencies    frequency bins for coherogram
0011 %    <options>      optional list of property-value pairs (see table below)
0012 %
0013 %    =========================================================================
0014 %     Properties    Values
0015 %    -------------------------------------------------------------------------
0016 %     'smooth'      smoothing for ratio (0 = no smoothing) (default = 2)
0017 %     'custom'      set custom band (default= [0 250])
0018 %     'delta'       set delta band (default = [0 4])
0019 %     'theta'       set theta band (default = [7 10])
0020 %     'spindles'    set spindle band (default = [10 20])
0021 %     'lowGamma'    set low gamma band (default = [30 80])
0022 %     'highGamma'   set high gamma band (default = [80 120])
0023 %     'ripples'     set ripple band (default = [100 250])
0024 %    =========================================================================
0025 %
0026 %  OUTPUT
0027 %
0028 %    bands.custom     coherence in the custom band
0029 %    bands.delta      coherence in the delta band
0030 %    bands.theta      coherence in the theta band
0031 %    bands.spindles   coherence in the spindle band
0032 %    bands.lowGamma   coherence in the low gamma band
0033 %    bands.highGamma  coherence in the high gamma band
0034 %    bands.ripples    coherence in the ripple band
0035 %
0036 %  SEE
0037 %
0038 %    See also MTCoherogram.
0039 
0040 % Copyright (C) 2013 by Gabrielle Girardeau
0041 %
0042 % This program is free software; you can redistribute it and/or modify
0043 % it under the terms of the GNU General Public License as published by
0044 % the Free Software Foundation; either version 3 of the License, or
0045 % (at your option) any later version.
0046 
0047 % Defaults
0048 smooth = 2;
0049 custom = [0 250];
0050 delta = [0 4];
0051 theta = [7 10];
0052 spindles = [10 20];
0053 lowGamma = [30 80];
0054 highGamma = [80 120];
0055 ripples = [100 250];
0056 
0057 % Check number of parameters
0058 if nargin < 2,
0059     error('Incorrect number of parameters (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0060 end
0061 
0062 % Check parameter sizes
0063 if ~isdmatrix(coherogram),
0064     error('Parameter ''coherogram'' is not a matrix (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0065 end
0066 if ~isdvector(frequencies) | length(frequencies) ~= size(coherogram,1),
0067     error('Parameter ''frequencies'' is not a vector or does not match coherogram size (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0068 end
0069 
0070 % Parse options
0071 for i = 1:2:length(varargin),
0072     if ~ischar(varargin{i}),
0073         error(['Parameter ' num2str(i) ' is not a property (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).']);
0074     end
0075     switch(lower(varargin{i})),
0076         case 'smooth',
0077             smooth = varargin{i+1};
0078             if ~isdscalar(smooth,'>=0'),
0079                 error('Incorrect value for property ''smooth'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0080             end
0081         case 'custom',
0082             custom = varargin{i+1};
0083             if ~isdvector(delta,'>=0','<','#2'),
0084                 error('Incorrect value for property ''delta'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0085             end
0086         case 'delta',
0087             delta = varargin{i+1};
0088             if ~isdvector(delta,'>=0','<','#2'),
0089                 error('Incorrect value for property ''delta'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0090             end
0091         case 'theta',
0092             theta = varargin{i+1};
0093             if ~isdvector(theta,'>=0','<','#2'),
0094                 error('Incorrect value for property ''theta'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0095             end
0096         case 'spindles',
0097             spindles = varargin{i+1};
0098             if ~isdvector(spindles,'>=0','<','#2'),
0099                 error('Incorrect value for property ''spindles'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0100             end
0101         case 'lowgamma',
0102             lowGamma = varargin{i+1};
0103             if ~isdvector(lowGamma,'>=0','<','#2'),
0104                 error('Incorrect value for property ''lowGamma'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0105             end
0106         case 'highgamma',
0107             highGamma = varargin{i+1};
0108             if ~isdvector(highGamma,'>=0','<','#2'),
0109                 error('Incorrect value for property ''highGamma'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0110             end
0111         case 'ripples',
0112             ripples = varargin{i+1};
0113             if ~isdvector(ripples,'>=0','<','#2'),
0114                 error('Incorrect value for property ''ripples'' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).');
0115             end
0116         otherwise,
0117             error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SpectrogramBands">SpectrogramBands</a>'' for details).']);
0118     end
0119 end
0120 
0121 % Select relevant frequency bins
0122 customBins = frequencies >= custom(1) & frequencies <= custom(2);
0123 thetaBins = frequencies >= theta(1) & frequencies <= theta(2);
0124 deltaBins = frequencies >= delta(1) & frequencies <= delta(2);
0125 spindleBins = frequencies >= spindles(1) & frequencies <= spindles(2);
0126 lowGammaBins = frequencies >= lowGamma(1) & frequencies <= lowGamma(2);
0127 highGammaBins = frequencies >= highGamma(1) & frequencies <= highGamma(2);
0128 rippleBins = frequencies >= ripples(1) & frequencies <= ripples(2);
0129 
0130 % Compute physiological bands
0131 bands.custom = mean(coherogram(customBins,:))';
0132 bands.theta = mean(coherogram(thetaBins,:))';
0133 bands.delta = mean(coherogram(deltaBins,:))';
0134 bands.spindles = mean(coherogram(spindleBins,:))';
0135 bands.lowGamma = mean(coherogram(lowGammaBins,:))';
0136 bands.highGamma = mean(coherogram(highGammaBins,:))';
0137 bands.ripples = mean(coherogram(rippleBins,:))';
0138

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005