function  Iparams = PLM_input_params(seed_params)

%PLM_INPUT_PARAMS -- Input parameters of the Perceptual Learning Model
%
%  Iparams = PLM_input_params
%  Iparams = PLM_input_params(seed_params)
%
%  SEED_PARAMS is a structure supplying values for one or more of the
%  fields. The rest are filled in with default values.
%
%  IPARAMS is a structure with the following fields:
%    * img_size -- the size of the input image STIM. Default [64 64].
%    * FFT_size -- size of the zero-padded inputs to FFT2, [128 128].
%    * LUT_gray -- the index of the neutral ("gray") level in STIM.
%         Must be coordinated with P.colors.gray (see PLEXP1_PARAMS).
%    * LUT_span -- the half-number of entries in the LUT table used
%         to generate the image STIM (see MAKE_PLE_STIM). Must be
%         coordinated with P.LUT_params.span. Default 127.
%    * deg_pix -- one pixel subtends 0.045 degrees of visual angle.
%    * flipud -- when 1 (the default) the stimulus image is flipped
%         upside down (see FLIPUD and PLM_STIM_ENERGY for details).
%    * bkgr_idx -- STIM(bkgr_idx) is guaranteed to be "background".
%         This pixel thus provides the color for "zero padding".
%    * D_orient -- orientation domain [degrees], default [-45:15:+45].
%    * N_orient -- length(D_orient), default 7.
%    * D_spfreq -- spatial freq domain [cyc/d.v.a], dflt [1 1.4 2 2.8 4]
%    * N_spfreq -- length(D_spfreq), default 5.
%    * HW_orient -- orientation bandwidth [deg] (half width at half H).
%    * octaves -- spatial-frequency bandwidth (log scale, full W half H)
%    * W2sigma -- W-->sigma conversion factor (full W at half H-->std.dev)
%    * CGC_const -- semisaturation constant for divisive normalization.
%    * CGC_Fpool -- weight matrix for pooling across frequency bands.
%         @@Default weight matrix =[.9 .1 0 ; .1 .8 .1 ; 0 .1 .9].
%    * CGC_mode -- comment on the normalization method: 'E1/N1' or 'E1/N2'
%    * rep_scale -- arbitrary scale factor. Default=1.0, which tends to
%         produce max activations of about 2.
%    * FW_integr -- full width at half height of the radial Gaussian
%         kernel that integrates each "channel" over XY space [deg.vis.a]
%         The default is 2.0, which is about twice that of the envelope
%         of the Gabor stimuli used in the experiment. (Exp.sigma=0.4dva,
%         FW=0.942, see PLEXP1_PARAMS and MAKE_PLE_STIM for details).
%    * centers -- [Cx2] matrix of "integration center points" [deg.vis.a]
%    * rep_size -- the length of the row vector produced by PLFRONTEND.
%         Must be N_orient*N_spfreq, default 35=7*5.
%
%  Example: Iparams = PLM_input_params
%    Iparams =
%      img_size: [64 64]   % size of the input stimulus [pix]
%      FFT_size: [64 64]   % image + zero padding
%      LUT_gray: 128       % neutral ("gray") stimulus intensity
%      LUT_span: 127       % half-number of entries in the lookup-table
%       deg_pix: 0.0450    % degrees of visual angle per pixel
%        flipud: 1         % flip the stimulus image upside down
%      bkgr_idx: 1         % points to a guaranteed "background" pixel
%      D_orient: [-45:15:+45]    % orientation domain [degrees]
%      N_orient: 7               % length(D_orient)
%      D_spfreq: [1 1.4 2 2.8 4] % spatial frequency domain [cyc/deg]
%      N_spfreq: 5               % length(D_spfreq)
%     HW_orient: 15.0      % orient. bandwdth [deg] (half W at half H)
%       octaves: 1.0       % spatial freq bandwidth (full W at half H)
%       W2sigma: 0.4247    % W-->sigma conversion factor (full W half H)
% @@  CGC_const: 0         % semisaturation normalization constant
%     CGC_Fpool: [3x3]     % weights for pooling across freq. bands
%      CGC_mode: 'E1/N1'   % comment on the normalization method
%     rep_scale: 1.0       % arbitrary scale factor
%     FW_integr: 2.0       % integration full W at half height [deg.v.a]
%       centers: [0 0]     % center and middle-top integration basins
%      rep_size: [7 5 1]   % representation length (see PLFRONTEND)
%
%  See also PLFRONTEND, MAKE_PLFRONTEND, PLM_PARAMS, PLM_RFIELDS.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 2.2 $  $Date: 2003/05/30 $
%
% Part of the Hebbian Perceptual Learning Model version 1.1 for MATLAB.
% http://alexpetrov.com/proj/plearn/
% Copyright (c) Alexander Petrov 1999-2008, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in PercLearn_license.m

%---  Decipher SPEC
if (nargin==0)         % default
   Iparams = struct('img_size',[64 64]) ;
else
   Iparams = seed_params ;
end

%--- Conversion from W (full width at half height) to sigma (std. dev.)
% See Table 2.1 in Norma Graham's "Visual Pattern Analyzers" (1989, p. 49).
% sigma = W / 2sqrt(2ln2) = 0.425 W ; W = sigma * 2sqrt(2ln2) = 2.35 sigma
W2sigma = 1 / (2*sqrt(2*log(2))) ;

%--- Fill-in missing slots
if (~isfield(Iparams,'img_size'))
   Iparams.img_size = [64 64] ;     % size of the input stimulus
end
if (~isfield(Iparams,'FFT_size'))
   Iparams.FFT_size = [128 128] ;   % stimulus + zero padding
end
if (~isfield(Iparams,'LUT_gray'))
   Iparams.LUT_gray = 128 ;       % =P.colors.gray, where P=PLExp1_params
end
if (~isfield(Iparams,'LUT_span'))
   Iparams.LUT_span = 127 ;       % =P.LUT_params.span
end
if (~isfield(Iparams,'deg_pix'))
   Iparams.deg_pix = 0.0450 ;  % degrees of visual angle per pixel
end
if (~isfield(Iparams,'flipud'))
   Iparams.flipud = 1 ;        % flip the stimulus image upside down
end
if (~isfield(Iparams,'bkgr_idx'))
   Iparams.bkgr_idx = 1 ;      % points to a guaranteed "background" pixel
end
if (~isfield(Iparams,'D_orient'))
   Iparams.D_orient = [-45:15:+45] ;  % orientation domain [degrees]
end
Iparams.N_orient = length(Iparams.D_orient) ;
if (~isfield(Iparams,'D_spfreq'))
%   Iparams.D_spfreq = [1 2 4] ;      % spatial freq domain [cyc/deg]
   Iparams.D_spfreq = 2.^[0:0.5:2] ;  % spatial freq domain [cyc/deg]
end
Iparams.N_spfreq = length(Iparams.D_spfreq) ;
if (~isfield(Iparams,'HW_orient'))
   Iparams.HW_orient = 15.0 ;  % orient. bandwdth [deg] (half W at half H)
end
if (~isfield(Iparams,'octaves'))
   Iparams.octaves = 1.0 ;     % spatial freq bandwidth (full W at half H)
end
if (~isfield(Iparams,'W2sigma'))
   Iparams.W2sigma = W2sigma ; % W-->sigma conversion factor
end
if (~isfield(Iparams,'CGC_const'))
   Iparams.CGC_const = 0 ;     % semisaturation SIGMA^2 in Heeger (1992)
end
if (~isfield(Iparams,'CGC_Fpool'))
   if (Iparams.N_spfreq <= 4)  % one-octave apart: [1 2 4 8] or the like
      default_CGC_Fpool = [.9 .1 0 ; .1 .8 .1 ; 0 .1 .9] ;
   else   % half-octave apart: [1 1.4 2 2.8 4] or the like
      default_CGC_Fpool = [.80 .15 .05 0 0 ; .20 .60 .15 .05 0 ; ...
         .05 .15 .60 .15 .05 ; 0 .05 .15 .60 .20 ; 0 0 .05 .15 .80] ;
   end
   Iparams.CGC_Fpool = default_CGC_Fpool ;
end
if (~isfield(Iparams,'CGC_mode'))
   Iparams.CGC_mode = 'E1/N1' ;
end
if (~isfield(Iparams,'rep_scale'))
   Iparams.rep_scale = 1.0 ;   %  arbitrary scale factor
end
if (~isfield(Iparams,'FW_integr'))
   Iparams.FW_integr = 2.0 ;   %  FWHH of the integration kernel
end
if (~isfield(Iparams,'centers'))
   Iparams.centers = [0 0] ;   % of integration basins [deg.vis.a]
end
N_centers = size(Iparams.centers,1) ;
Iparams.rep_size = [Iparams.N_orient,Iparams.N_spfreq,N_centers] ;

%--- Return IPARAMS
%%%%% End of file PLM_INPUT_PARAMS.M
