function [Brms, Brmssmooth, Brmsquiet] = winrms(npt, overlap, spectraltime_axis, B_output)
Brms(1) = rms(B_output(1:npt));
for i = 2:round(length(B_output)/(npt-overlap))-1
winstart = (i-1)*(npt-overlap); % start of vector overlaps with previous window
winend = winstart + npt - 1; % end of vector is npt points later

Brms(i) = rms(B_output(winstart:winend)); % extract interval vector for data axis
end
if length(Brms) < length(spectraltime_axis)
Brms(floor(length(B_output)/(npt-overlap))) = rms(B_output(end-npt:end));
end
Brmssmooth = medfilt1(Brms,90);

[Brmsquiet(2) Brmsquiet(1)] = min(Brmssmooth(2:end));
end