function make_plots_paper(speed1,paths,methods,close_first,save_it)

% Example Usage:

%make_plots_paper({'walk125'},'JB011613',{'sang_mvc_lo';'low100_mvc_lo'},1,1);

% Makes plots including Perry EMG.

load ~/Documents/MATLAB/data/Perry_muscles/stim_act;

addpath '~/Dropbox/harvard/processMOT/';  

if close_first == 1
  close all;
else
  figure;
end;

%colors = ['k';'b';'r';'m';'g';'c';'y'];
colors = [0 0 1;1 0 0;0 .5 .2; .5 0 1; 1 .6 0; 0 .5 1; 1 .9 0; .1 .6 0;0 0 0; 1 0 1;.4 .4 .4];

cnt = 0;

speed_all = {'walk150','walk133','walk133','walk150','walk150'}

for i = 1:size(speed1,1)
  for j = 1:length(paths)
    for k = 1:size(methods,1)
  
      cnt = cnt + 1;
      
      if ischar(speed1) == 0
        speedc  = char(speed1(i));
      else
        speedc  = speed1;
      end;
      if ischar(paths) == 0
        path1   = char(paths{j});
      else
        path1   = paths;
      end;
      if ischar(methods) == 0
        method1 = char(methods(k));
      else
        method1 = methods;
      end;
     
      infile1 = ['~/Documents/MATLAB/data/' path1 '/processed/EMG/avg_act_thresh'];
      infile1 = [infile1 '/' method1 '/' speedc '.mat']; 

      eval(['load ' infile1]);
      
      numpts = length(m_aTA);
      
      subplot(3,4,1)
      eval(['niceBars(0:(numpts-1),m_aTA,sd_aTA,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aTA,'k','linewidth',4);
      title('TA','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('TA Activation Estimate','fontsize',12);
      subplot(3,4,2)
      eval(['niceBars(0:(numpts-1),m_aSOL,sd_aSOL,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aSOL,'k','linewidth',4);
      title('SOL','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('SOL Activation Estimate','fontsize',12);
      subplot(3,4,3)
      eval(['niceBars(0:(numpts-1),m_aGAS,sd_aGAS,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aGAS,'k','linewidth',4);
      title('GAS','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('GAS Activation Estimate','fontsize',12);
      subplot(3,4,4)
      eval(['niceBars(0:(numpts-1),m_aVAS,sd_aVAS,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aVAS,'k','linewidth',4);
      title('VAS','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('VAS Activation Estimate','fontsize',12);
      subplot(3,4,5)
      eval(['niceBars(0:(numpts-1),m_aBFSH,sd_aBFSH,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aBFSH,'k','linewidth',4);
      title('BFSH','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('BFSH Activation Estimate','fontsize',12);
      subplot(3,4,6)
      eval(['niceBars(0:(numpts-1),m_aRF,sd_aRF,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aRF,'k','linewidth',4); 
      title('RF','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('RF Activation Estimate','fontsize',12);
      subplot(3,4,7)
      eval(['niceBars(0:(numpts-1),m_aHAM,sd_aHAM,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);              
      hold on; 
      %plot(0:(numpts-1),m_aHAM,'k','linewidth',4);
      title('HAM','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('HAM Activation Estimate','fontsize',12);
      subplot(3,4,8)
      eval(['niceBars(0:(numpts-1),m_aILL,sd_aILL,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aILL,'k','linewidth',4);
      title('ILL','fontsize',12);
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('ILL Activation Estimate','fontsize',12);
      subplot(3,4,9)
      eval(['niceBars(0:(numpts-1),m_aGLU,sd_aGLU,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
      hold on; 
      %plot(0:(numpts-1),m_aGLU,'k','linewidth',4);
      title('GLU','fontsize',12);                
      %xlabel('Percent Gait Cycle','fontsize',12);
      %ylabel('GLU Activation Estimate','fontsize',12);
      if exist('m_aHAB') > 0
        subplot(3,4,10)
        eval(['niceBars(0:(numpts-1),m_aHAB,sd_aHAB,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
        hold on; 
        %plot(0:(numpts-1),m_aHAB,'k','linewidth',4);
        title('HAB','fontsize',12);                
        %xlabel('Percent Gait Cycle','fontsize',12);
        %ylabel('HAB Activation Estimate','fontsize',12);
      end;
      if exist('m_aADDL') > 0
        subplot(3,4,11)
        eval(['niceBars(0:(numpts-1),m_aADDL,sd_aADDL,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
        hold on; 
        %plot(0:(numpts-1),m_aADDL,'k','linewidth',4);
        title('ADDL','fontsize',12);                
        %xlabel('Percent Gait Cycle','fontsize',12);
        %ylabel('ADDL Activation Estimate','fontsize',12);
      end;
      if exist('m_aADDM') > 0
        subplot(3,4,12)
        eval(['niceBars(0:(numpts-1),m_aADDM,sd_aADDM,[' num2str(colors(mod(cnt,11)+1,:)) '],0.5);']);
        hold on; 
        %plot(0:(numpts-1),m_aADDM,'k','linewidth',4);
        title('ADDM','fontsize',12);                
        %xlabel('Percent Gait Cycle','fontsize',12);
        %ylabel('ADDM Activation Estimate','fontsize',12);
      end;
    end;  
  end;    
end;

box on
subplot(3,4,1)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,2)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,3)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,4)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,5)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,6)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,7)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,8)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,9)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,10)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,11)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)
subplot(3,4,12)
box on; axis tight;
set(gcf,'Color',[1,1,1])
set(gca,'linewidth',2)

%h_xlabel = get(gca,'XLabel');
%set(h_xlabel,'FontSize',14); 
%h_ylabel = get(gca,'YLabel');
%set(h_ylabel,'FontSize',14); 

addpath ~/Dropbox/export_fig
export_fig ~/Dropbox/inverse_paper/figures/act_all -png -r150


keyboard



subplot(3,4,1)
plot(0:(numpts-1),p_sTA,'k','linewidth',3);
subplot(3,4,2)
plot(0:(numpts-1),p_sSOL,'k','linewidth',3);
subplot(3,4,3)
plot(0:(numpts-1),p_sGAS,'k','linewidth',3);
subplot(3,4,4)
plot(0:(numpts-1),p_sVLAT,'k','linewidth',3);
subplot(3,4,5)
plot(0:(numpts-1),p_sBFSH,'k','linewidth',3);
subplot(3,4,6)
plot(0:(numpts-1),p_sRF,'k','linewidth',3);
subplot(3,4,7)
plot(0:(numpts-1),p_sSMEM,'k','linewidth',3);
subplot(3,4,8)
plot(0:(numpts-1),p_sILL,'k','linewidth',3);
subplot(3,4,9)
plot(0:(numpts-1),p_sGLU_low,'k','linewidth',3);
subplot(3,4,10)
plot(0:(numpts-1),p_sGMED,'k','linewidth',3);
subplot(3,4,11)
plot(0:(numpts-1),p_sAL,'k','linewidth',3);
subplot(3,4,12)
plot(0:(numpts-1),p_sAM,'k','linewidth',3);
subplot(3,4,8)
legend('0.75 m/s','1.00 m/s','1.25 m/s','1.50 m/s','1.75 m/s','2.00 m/s','Perry','location','EastOutside');


if exist('save_it')==1 && save_it==1;
  save_dir = ['~/Documents/MATLAB/data/' char(path1) '/processed/EMG/avg_act_thresh'];
  outfile = [char(path1) '_' char(speed1(1)) '_thresh'];
  eval(['print -dpng ' save_dir '/' outfile '.png;']);
end;
