%
% Play with sampling frequency and range of frequencies of interest
%

display('We will now play with the frequency range of interest');
display('Press return to continue');
pause
%
% Declares default values just in case they have been deleted
%
params.Fs=1000; % inverse of the spacing of the grid onw hcih tapers are computed
figure;
user_continues='y';
while strcmp(user_continues,'y')
  fpassl=input('Give me the lower limit of the frequency range of interest between 0 and 500 ');
  fpassu=input('Give me the upper limit of the frequency range of interest between 0 and 500. Upper limit must be > lower limit ');
  if ~isempty(fpassl) && ~isempty(fpassu);
     if fpassl>fpassu; fpassl=0; display('Lower limit has to smaller than upper limit, using defaults, [0 500]'); end;
     if fpassu>params.Fs/2; fpassu=params.Fs/2;display('Upper limit has to smaller than half the sampling frequency,using defaults, [0 500]'); end;
  else;
     display('User did not specify the frequency range,using default, [0 500]');
     fpassl=0;
     fpassu=500;
  end;
  params.fpass=[fpassl fpassu];
  [S,f]=mtspectrumc(data,params);
  plot_vector(S,f,[],[],'y');
  set(gca,'FontName','Times New Roman','Fontsize', 16);
  xlabel('frequency Hz'); ylabel('Spectrum dB');
  title(['LFP spectrum for 1 trial over a restricted frequency range']);
  position_figure
  user_continues=input('Do you want to continue to play ? Type y for Yes, and n for No ','s');
end