0001 function bands = CoherenceBands(coherogram,frequencies,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
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
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
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
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
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
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