%%%%%%%%  April 13, 2003:  Hinton diagrams for the 12 stimuli

%%%%%% Without compressive nonlinearity
%
 load PLM_CACHE; acache=aggreg_cache(PLM_CACHE),a=acache.arg;mnX=acache.mnX;

 Hpar=Hinton_params('hot1');Hpar.axis.xticklabel='-45|||0|||+45';Hpar.colors.colorbar='off'
Hpar = 
      rep_sz: [7 5]
      elt_sz: [5 5]
     canv_sz: [52 71]
    D_orient: [-15 -10 -5 0 5 10 15]
     D_radii: [78 88 98 108 118]
      colors: [1x1 struct]
        axis: [1x1 struct]
     mapping: [35x25 double]

 or='LR';Cp={'.246','.160','.106'};
 idx=[1 3 5,2 4 6 , 7 9 11,8 10 12];   % 4 rows (LL RL LR RR) X 3 columns

 for k=1:12 subplot(4,3,k);s=idx(k);Hinton_diag(mnX(s,:),Hpar,[0 3]);title(['Gab=',or(a(s,1)),'  Bkgr=',or(a(s,3)),'  Cp=',Cp{a(s,2)}]);end


%%%%%%%  Compressive nonlinearity with REP_GAIN=1.5
%
 m=0.5;g=-1.5;   % Mparams.max_act = 0.5 ; Mparams.rep_gain = 1.5 ;
 C=PLM_CACHE;for k=1:12 C(k).rep=m .* (2./(1+exp(g.*C(k).rep))-1);end
 acache1=aggreg_cache(C), mnX1=acache1.mnX;
acache1 = 
    arg: [12x3 double]
      N: [12x1 double]
    mnX: [12x35 double]
    sdX: [12x35 double]

 for k=1:12 subplot(4,3,k);s=idx(k);Hinton_diag(mnX1(s,:),Hpar,[0 m]);title(['Gab=',or(a(s,1)),'  Bkgr=',or(a(s,3)),'  Cp=',Cp{a(s,2)}]);end
% Available as 24-bit color bitmap in 12REPS_G15.BMP.


%%%%%%%  Task analysis (REP_GAIN=1.5), April 14, 2003
%
 M=[mean(mnX1([1 3 5],:));mean(mnX1([7 9 11],:));mean(mnX1([2 4 6],:));mean(mnX1([8 10 12],:))];  % [-L +R +L +R]
 for k=1:4 subplot(2,2,k);Hinton_diag(M(k,:),Hpar,[0 m]);end

 Hpar2=Hinton_params('coldhot2');Hpar2.axis.xticklabel=Hpar.axis.xticklabel
Hpar2 = 
      rep_sz: [7 5]
      elt_sz: [5 5]
     canv_sz: [52 71]
    D_orient: [-15 -10 -5 0 5 10 15]
     D_radii: [78 88 98 108 118]
      colors: [1x1 struct]
        axis: [1x1 struct]
     mapping: [35x25 double]

 T=M([3 4],:)-M([1 2],:);
 subplot(2,1,1);Hinton_diag(T(1,:),Hpar2,[-.35 +.35]);title('Teaching signal, Left context');ylabel('Spatial frequency  [cyc/deg]');xlabel('Orientation  [degrees from vertical]');
 subplot(2,1,2);Hinton_diag(T(2,:),Hpar2,[-.35 +.35]);title('Teaching signal, Right context');ylabel('Spatial frequency  [cyc/deg]');xlabel('Orientation  [degrees from vertical]');

%- Line plots are clearer
 subplot(3,2,1);h=plot(reshape(M(1,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 0 .5]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[0:.1:.5]);ylabel('mean act ;  \theta=-10');grid on;title('Negative background orientation');
 subplot(3,2,2);h=plot(reshape(M(2,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 0 .5]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[0:.1:.5]);ylabel('mean act ;  \theta=-10');grid on;title('Positive background orientation');
 subplot(3,2,3);h=plot(reshape(M(3,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 0 .5]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[0:.1:.5]);ylabel('mean act ;  \theta=+10');grid on;
 subplot(3,2,4);h=plot(reshape(M(4,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 0 .5]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[0:.1:.5]);ylabel('mean act ;  \theta=+10');grid on;

 l={'1.0 c/d','1.4 c/d','2.0 c/d','2.8 c/d','4.0 c/d'};
 subplot(3,2,5);h=plot(reshape(T(1,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 -.35 +.35]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[-.3:.1:.5]);ylabel('mean difference');grid on;h=refline(0,0);set(h,'Color','k','Linestyle','-');title('Negative background orientation');xlabel('Orientation  [degrees from vertical]');legend(l{:},4);
 subplot(3,2,6);h=plot(reshape(T(2,:),7,5),'.-');set(h,'LineWidth',2);axis([.5 7.5 -.35 +.35]);set(gca,'xtick',[1:7],'xticklabel','-45|-30|-15|0|+15|+30|+45','ytick',[-.3:.1:.5]);ylabel('mean difference');grid on;h=refline(0,0);set(h,'Color','k','Linestyle','-');title('Positive background orientation');xlabel('Orientation  [degrees from vertical]');legend(l{:},4);
