/usr/share/psychtoolbox-3/PsychCal/FindSpectralPeaks.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | function peaks = FindSpectralPeaks(spectrum,S,noiseLevel)
% peaks = FindSpectralPeaks(spectrum,[S],[noiseLevel])
%
% Find the local peaks in a spectrum.
% Uses the heuristic of requiring increasing
% and decreasing in neighborhood of peak to
% get rid of noise.
%
% Parameter noiseLevel (default 0) causes
% the routine to ignore peaks lower than
% noiseLevel*maxValue where maxValue is the
% largest measurement in the spectrum.
%
% 1/6/96 dhb Wrote it.
% 5/17/99 dhb Added noiseLevel parameter.
if (nargin < 2 || isempty(S))
S = [380 5 81];
end
wls = MakeItWls(S);
if (nargin < 3 || isempty(noiseLevel))
noiseLevel = 0;
end
indices = [];
[nWls,nil] = size(spectrum);
noiseThreshold = noiseLevel*max(spectrum);
for i = 3:nWls-2
if (spectrum(i-2) < spectrum(i-1) & ...
spectrum(i-1) < spectrum(i) & ...
spectrum(i+1) < spectrum(i) & ...
spectrum(i+2) < spectrum(i+1) & ...
spectrum(i) > noiseThreshold)
indices = [indices ; i];
end
end
peaks = indices;
[nPeaks,nil] = size(indices);
for i = 1:nPeaks
peaks(i) = wls(indices(i));
end
|