*********************************************************************
% Mar 11-13, 2005 -- Individualized sharpening of some units and not others

 cd C:\work\PLModel1\sharpen

% Hold OCTAVES constant = 1 throughout. Parametrically vary HW_orient
% for the units at the target frequency and covering the orientation
% band -30:+30 of the two Gabor targets combined.

 hw=[.7:.1:1.2].*15;Iparams=repmat(PLM_input_params,1,length(hw));HW=repmat(15,7,5);
 for k=1:length(hw) HW(2:6,3)=hw(k);Iparams(k).HW_orient=HW;end;Iparams(1)
ans = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: [7x5 double]     % <-- sic!
      octaves: 1
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]

 Iparams(2).HW_orient
   1.0 c/d   1.4 c/d   2.0 c/d   2.8 c/d   4.0 c/d
%------------------------------------------------- 
   15.0000   15.0000   15.0000   15.0000   15.0000  % -45 deg
   15.0000   15.0000   12.0000   15.0000   15.0000  % -30
   15.0000   15.0000   12.0000   15.0000   15.0000  % -15
   15.0000   15.0000   12.0000   15.0000   15.0000  %   0
   15.0000   15.0000   12.0000   15.0000   15.0000  %  15
   15.0000   15.0000   12.0000   15.0000   15.0000  %  30
   15.0000   15.0000   15.0000   15.0000   15.0000  %  45


 N_runs=1000;for k=1:length(hw) tic;targetHWxOC10{k}=cache_inputs(make_PLFrontend(Iparams(k)),N_runs);toc;save work;end

% save targetHWxOC10.mat       % allHWxOC10.mat contains an earlier cache with  HW_orient=[15 hw hw hw hw hw 15]'  for all spfreq


*********************************************************************
% Mar 14, 2005 -- Sharpen the target spatial frequency

 cd C:\work\PLModel1\sharpen

% Hold HW_ORIENT constant = 15 throughout. Parametrically vary the
% middle element of OCTAVES.  (The middle elt controls the target f=2c/d.)

 oc=[.7:.1:1.2];Iparams=repmat(PLM_input_params,1,length(oc));
 for k=1:length(oc) Iparams(k).octaves=[1 1 oc(k) 1 1];end;Iparams(1)
ans = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 15
      octaves: [1 1 0.7000 1 1]        % <-- sic!
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]

 N_runs=1000;for k=1:length(oc) tic;targetHW15OCy{k}=cache_inputs(make_PLFrontend(Iparams(k)),N_runs);toc;save work;end

% save targetHW15OCy.mat


*********************************************************************
% Mar 15, 2005 -- Sharpen both along the orientaiton and frequency dimensions.

 cd C:\work\PLModel1\sharpen

% Parametrically vary HW_orient for the units at the target frequency and 
% covering the orientation band -30:+30 of the two Gabor targets combined.
% Vary OCTAVES of the target frequency (2 c/d) by the same proportion.

 oc=[.7:.1:1.2];HW=repmat(15,7,5);Iparams=repmat(PLM_input_params,1,length(oc));
 for k=1:length(oc) HW(2:6,3)=oc(k).*15;Iparams(k).HW_orient=HW;Iparams(k).octaves=[1 1 oc(k) 1 1];end;Iparams(1)
ans = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: [7x5 double]        % <-- Sic!
      octaves: [1 1 0.7000 1 1]    % <-- Sic!
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]

 Iparams(2).HW_orient
   1.0 c/d   1.4 c/d   2.0 c/d   2.8 c/d   4.0 c/d
%------------------------------------------------- 
   15.0000   15.0000   15.0000   15.0000   15.0000
   15.0000   15.0000   12.0000   15.0000   15.0000
   15.0000   15.0000   12.0000   15.0000   15.0000
   15.0000   15.0000   12.0000   15.0000   15.0000
   15.0000   15.0000   12.0000   15.0000   15.0000
   15.0000   15.0000   12.0000   15.0000   15.0000
   15.0000   15.0000   15.0000   15.0000   15.0000

 N_runs=1000;for k=1:length(oc) tic;targetHWxOCy{k}=cache_inputs(make_PLFrontend(Iparams(k)),N_runs);toc;save work;end

% save targetHWxCy.mat




*********************************************************************
*********************************************************************
*********************************************************************
Everything below this line was completed before 11 March 2005 with
the old version of PLFrontend.m. That is, the tuning parameters
applied for all representational units across the board.
The program was updated on 11 March 2005 to allow individual tuning
specs for each unit. See in particular PLModel1/frontend/RField_size.m
(ver. 2.1 of 2005/03/11).  These individual-tuning caches are 
generated as summarized above this line.
*********************************************************************
*********************************************************************
*********************************************************************


% 2/22/2005 -- Measure the slope of the tuning function
% See Schoups+etal01 and Teich+Qian03

 PLM_CACHE(1)

ans = 

    arg: [1 1 1]
      N: 5000
    rep: [5000x35 double]

 Idef

Idef = 

     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 15
      octaves: 1
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
      comment: 'E1N1 normalization'
     memo_CRC: 7.3173e+005
       pad_XY: [32 32]

 x=[-45:.1:+45];sigma=Idef.HW_orient*2*Idef.W2sigma

sigma =

   12.7398

 y=exp(-x.^2/(2*sigma^2));plot(x,y);grid on
 d=-x.*y./(sigma^2);
 plot(x,y,'b-',x,d,'r-');grid on
 plot(x,y,'b-',x,10*abs(d),'r-');grid on
 find(x==15)

ans =

   601

 d(601)

ans =

   -0.0462

 2.96/2.19        % From Schoups+etal01: trained/untrained slope

ans =

    1.3516

 (2.96/2.19)*4.62

ans =

    6.2444

 30/(2.96/2.19)

ans =

   22.1959

 sigma1=sigma/(2.96/2.19)

sigma1 =

    9.4258

 y1=exp(-x.^2/(2*sigma1^2));d1=-x.*y1./(sigma1^2);
 plot(x,y,'b-',x,10*abs(d),'b:',x,y1,'r-',x,10*abs(d1),'r:');grid on
 max(abs(d1))

ans =

    0.0643

 sigma1=9.7;y1=exp(-x.^2/(2*sigma1^2));d1=-x.*y1./(sigma1^2);max(abs(d1))

ans =

    0.0625

 plot(x,y,'b-',x,10*abs(d),'b:',x,y1,'r-',x,10*abs(d1),'r:');grid on
 sigma1/(2*Idef.W2sigma)

ans =

   11.4209


*********************************

 pwd

ans = C:\work\PLModel1\sharpen

 Idef=PLM_input_params; Idef.HW_orient=12;

 Idef = make_PLFrontend(Idef)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=12.0 deg, FWf=1.0 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


Idef = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 12
      octaves: 1
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 tic;cacheHW12OC10=cache_inputs(Idef,2000);toc; save cacheHW12

--> 9 hours on Dell OptiPlex


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Feb 23, 2005
 pwd

ans =

C:\work\PLModel1\sharpen

 Idef=PLM_input_params; Idef.octaves=12/15;
 Idef = make_PLFrontend(Idef)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=15.0 deg, FWf=0.8 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


Idef = 

     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 15
      octaves: 0.8000
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 tic;cacheHW15OC08=cache_inputs(Idef,2000);toc; save cacheOC08
-->  8.3 hours on Dell OptiPlex


*********************************************************************
% Feb 24, 2005

 cd C:\work\PLModel1\sharpen
 Idef=PLM_input_params; Idef.HW_orient=12;Idef.octaves=.8;
 Idef = make_PLFrontend(Idef)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=12.0 deg, FWf=0.8 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


Idef = 

     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 12
      octaves: 0.8000
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 tic;cacheHW12OC08=cache_inputs(Idef,2000);toc; save cacheHW12OC08
-->  elapsed time 8.15 hours

*********************************************************************
% Feb 27, 2005

 cd C:\work\PLModel1\sharpen
 IdefHW135OC10=PLM_input_params; IdefHW135OC10.HW_orient=13.5;
 IdefHW135OC10 = make_PLFrontend(IdefHW135OC10)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=13.5 deg, FWf=1.0 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


IdefHW135OC10 = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 13.5000
      octaves: 1
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 IdefHW15OC09=PLM_input_params; IdefHW15OC09.octaves=.9;
 IdefHW15OC09 = make_PLFrontend(IdefHW15OC09)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=15.0 deg, FWf=0.9 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


IdefHW15OC09 = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 15
      octaves: 0.9000
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 IdefHW135OC09=PLM_input_params; IdefHW135OC09.HW_orient=13.5;IdefHW135OC09.octaves=.9;
 IdefHW135OC09 = make_PLFrontend(IdefHW135OC09)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=13.5 deg, FWf=0.9 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


IdefHW135OC09 = 
     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 13.5000
      octaves: 0.9000
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 save Idef

 tic;cacheHW135OC10=cache_inputs(make_PLFrontend(IdefHW135OC10),2000);toc;
--> 7.12 hours

 tic;cacheHW15OC09=cache_inputs(make_PLFrontend(IdefHW15OC09),2000);toc;
--> 7.2 hours

 tic;cacheHW135OC09=cache_inputs(make_PLFrontend(IdefHW135OC09),2000);toc;
--> 7.5 hours


*********************************************************************
% Feb 28, 2005
 
 cd C:\work\PLModel1\sharpen
 15*.7

ans =

   10.5000

 IdefHW105OC07=PLM_input_params; IdefHW105OC07.HW_orient=10.5;IdefHW105OC07.octaves=.7;
 IdefHW105OC07 = make_PLFrontend(IdefHW105OC07)

Front end: 7 orientations by 5 spatial frequencies.
Receptive fields: HWo=10.5 deg, FWf=0.7 octaves.
Contrast gain control via divisive normalization: E1/N1.
Radial Gaussian integration weights: FW=2.0 deg.vis.ang.
Integration centers:  (0.0,0.0) deg.vis.ang.

Global variable FRONTEND_MEMOIZATION updated.


IdefHW1O5C07 = 

     img_size: [64 64]
     FFT_size: [128 128]
     LUT_gray: 128
     LUT_span: 127
      deg_pix: 0.0450
       flipud: 1
     bkgr_idx: 1
     D_orient: [-45 -30 -15 0 15 30 45]
     N_orient: 7
     D_spfreq: [1 1.4142 2 2.8284 4]
     N_spfreq: 5
    HW_orient: 10.5000
      octaves: 0.7000
      W2sigma: 0.4247
    CGC_const: 0
    CGC_Fpool: [5x5 double]
     CGC_mode: 'E1/N1'
    rep_scale: 1
    FW_integr: 2
      centers: [0 0]
     rep_size: [7 5 1]
     memo_CRC: 7.3237e+005
       pad_XY: [32 32]

 tic;cacheHW105OC07=cache_inputs(IdefHW105OC07,2000);toc;clear ans;save cacheHW105OC07


*********************************************************************
% Mar 01, 2005

 cd C:\work\PLModel1\sharpen
 IdefHW15OC07=PLM_input_params; IdefHW15OC07.octaves=.7;
 IdefHW105OC10=PLM_input_params; IdefHW105OC10.HW_orient=10.5;

 tic;cacheHW15OC07=cache_inputs(make_PLFrontend(IdefHW15OC07),2000);toc;
--> 7.2 hours

 tic;cacheHW105OC10=cache_inputs(make_PLFrontend(IdefHW105OC10),2000);toc;
--> 6.7 hours


*********************************************************************
% Mar 07, 2005
%
% Preliminary analyses (see REREPRES_RESULTS.TXT) suggest that the d'
% actually goes DOWN when the tuning curves of the individual units
% are sharpened.  Therefore, it is interesting to see if the d' would
% go UP when the turning becomes less sharp.

 cd C:\work\PLModel1\sharpen
 IdefHW165OC10=PLM_input_params; IdefHW165OC10.HW_orient=16.5;
 IdefHW15OC11=PLM_input_params; IdefHW15OC11.octaves=1.1;
 IdefHW165OC11=PLM_input_params; IdefHW165OC11.HW_orient=16.5;IdefHW165OC11.octaves=1.1;

 tic;cacheHW165OC10=cache_inputs(make_PLFrontend(IdefHW165OC10),2000);toc;
--> 7.1 hours

 tic;cacheHW15OC11=cache_inputs(make_PLFrontend(IdefHW15OC11),2000);toc;
--> 7.2 hours

 tic;cacheHW165OC11=cache_inputs(make_PLFrontend(IdefHW165OC11),2000);toc;
--> 6.8 hours

*********************************************************************
% Mar 08-09, 2005

 cd C:\work\PLModel1\sharpen
 IdefHW18OC10=PLM_input_params; IdefHW18OC10.HW_orient=18;
 IdefHW15OC12=PLM_input_params; IdefHW15OC12.octaves=1.2;
 IdefHW18OC12=PLM_input_params; IdefHW18OC12.HW_orient=18;IdefHW18OC12.octaves=1.2;

 tic;cacheHW18OC10=cache_inputs(make_PLFrontend(IdefHW18OC10),2000);toc;
--> 7.2 hours

 tic;cacheHW15OC12=cache_inputs(make_PLFrontend(IdefHW15OC12),2000);toc;save foo1;
--> 7.2 hours

 tic;cacheHW18OC12=cache_inputs(make_PLFrontend(IdefHW18OC12),2000);toc;save foo;
--> 7.1 hours
