0001 function [Clevels] = eeg_contour_levels( step, data )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 Clevels = [];
0026
0027
0028 step = abs(step);
0029
0030
0031
0032 minstep = 0;
0033 if min(data) < 0,
0034 while minstep - step > min(data),
0035 minstep = minstep - step;
0036 end
0037 else
0038 while minstep < min(data),
0039 minstep = minstep + step;
0040 end
0041 end
0042
0043
0044 maxstep = 0;
0045 if max(data) > 0
0046 while maxstep + step < max(data),
0047 maxstep = maxstep + step;
0048 end
0049 else
0050 while maxstep > max(data),
0051 maxstep = maxstep - step;
0052 end
0053 end
0054
0055
0056
0057
0058 if (minstep > maxstep),
0059 fprintf('...eeg_contour_levels, minstep > maxstep, revise step.\n');
0060 if minstep > min(data) & minstep < max(data),
0061 Clevels = minstep;
0062 end
0063 if maxstep > min(data) & maxstep < max(data),
0064 Clevels = maxstep;
0065 end
0066 return
0067 end
0068 if and(maxstep == 0, minstep == 0),
0069 fprintf('...eeg_contour_levels, step too large for min/max of data.\n');
0070 return
0071 end
0072
0073
0074
0075
0076
0077 if and(minstep < 0.0, maxstep > 0.0)
0078
0079
0080 nlevels = round( ( 0 - minstep ) / step );
0081
0082 for a = 0:(nlevels -1), Narray(1,a+1) = (-1 * step) - (a * step); end
0083
0084
0085 plevels = round( maxstep / step );
0086
0087 for a = 0:plevels, Parray(1,a+1) = step * a; end
0088
0089 Clevels = [fliplr(Narray), Parray];
0090 return
0091 end
0092
0093 if and(minstep < 0.0, maxstep <= 0.0)
0094
0095
0096 nlevels = round( ( maxstep - minstep ) / step );
0097
0098
0099 for a = 0:nlevels, Narray(1,a+1) = maxstep - (step * a); end
0100
0101 Clevels = fliplr(Narray);
0102 return
0103 end
0104
0105 if and(minstep >= 0.0, maxstep > 0.0)
0106
0107
0108 plevels = round( ( maxstep - minstep ) / step );
0109
0110
0111 for a = 0:plevels, Parray(1,a+1) = minstep + (step * a); end
0112
0113 Clevels = Parray;
0114 return
0115 end