function nb_act_plots(speeds,paths,methods,close_first,save_dir)

% Example Usage:

% make_plots({'walk125';'walk150'},{'JB011613'},{'low100'},1)


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

if close_first == 1
  close all;
end;

%colors = ['y';'b';'r';'k';'m';'g';'c'];

colors = [0 0 1;1 0 0;0 .5 .2; .5 0 1; 1 .6 0; 0 .5 1; .1 .6 0;1 .9 0; 1 0 1;.4 .4 .4];

%colors = [0 0 1; 1 0 0; .1 .6 0; .5 0 1; 0 0 0; 

cnt = 0;

for i = 1:size(speeds,1)
  for j = 1:size(paths,1)
    for k = 1:size(methods,1)
  
      cnt = cnt + 1;
      
      if ischar(speeds) == 0
        speed1  = char(speeds(i));
      else
        speed1  = speeds;
      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 '/' speed1 '.mat']; 

      cmd = ['load ' infile1];
      eval(cmd);
      
      numpts = length(m_aTA);

      figure(1)
      eval(['niceBars(0:(numpts-1),m_aTA,sd_aTA,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aTA,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('TA Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('TA Activation Estimate','fontsize',12);
      figure(2)
      eval(['niceBars(0:(numpts-1),m_aSOL,sd_aSOL,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aSOL,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('SOL Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('SOL Activation Estimate','fontsize',12);
      figure(3)
      eval(['niceBars(0:(numpts-1),m_aGAS,sd_aGAS,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aGAS,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('GAS Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('GAS Activation Estimate','fontsize',12);
      figure(4)
      eval(['niceBars(0:(numpts-1),m_aVAS,sd_aVAS,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aVAS,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('VAS Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('VAS Activation Estimate','fontsize',12);
      figure(5)
      eval(['niceBars(0:(numpts-1),m_aBFSH,sd_aBFSH,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aBFSH,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('BFSH Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('BFSH Activation Estimate','fontsize',12);
      figure(6)
      eval(['niceBars(0:(numpts-1),m_aRF,sd_aRF,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aRF,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']); 
      title('RF Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('RF Activation Estimate','fontsize',12);
      figure(7)
      eval(['niceBars(0:(numpts-1),m_aSMEM,sd_aSMEM,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aSMEM,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('SMEM Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('SMEM Activation Estimate','fontsize',12);
      figure(8)
      eval(['niceBars(0:(numpts-1),m_aBFLH,sd_aBFLH,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aBFLH,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('BFLH Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('BFLH Activation Estimate','fontsize',12);
      figure(9)
      eval(['niceBars(0:(numpts-1),m_aILL,sd_aILL,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aILL,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('ILL Activation Profile','fontsize',12);
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('ILL Activation Estimate','fontsize',12);
      figure(10)
      eval(['niceBars(0:(numpts-1),m_aGLU,sd_aGLU,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
      hold on; grid on;
      eval(['plot(0:(numpts-1),m_aGLU,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
      title('GLU Activation Profile','fontsize',12);                
      xlabel('Percent Gait Cycle','fontsize',12);
      ylabel('GLU Activation Estimate','fontsize',12);
      if exist('m_aGLUU') > 0
        figure(11)
        eval(['niceBars(0:(numpts-1),m_aGLUU,sd_aGLUU,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
        hold on; grid on;
        eval(['plot(0:(numpts-1),m_aGLUU,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
        title('GLU Upp. Activation Profile','fontsize',12);                
        xlabel('Percent Gait Cycle','fontsize',12);
        ylabel('GLU Upp. Activation Estimate','fontsize',12);
      end;
      if exist('m_aGMED') > 0
        figure(12)
        eval(['niceBars(0:(numpts-1),m_aGMED,sd_aMED,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
        hold on; grid on;
        eval(['plot(0:(numpts-1),m_aGMED,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
        title('GMED Activation Profile','fontsize',12);                
        xlabel('Percent Gait Cycle','fontsize',12);
        ylabel('GMED Activation Estimate','fontsize',12);
      end;
      if exist('m_aADDL') > 0
        figure(13)
        eval(['niceBars(0:(numpts-1),m_aADDL,sd_aADDL,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
        hold on; grid on;
        eval(['plot(0:(numpts-1),m_aADDL,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
        title('ADDL Activation Profile','fontsize',12);                
        xlabel('Percent Gait Cycle','fontsize',12);
        ylabel('ADDL Activation Estimate','fontsize',12);
      end;
      if exist('m_aADDM') > 0
        figure(14)
        eval(['niceBars(0:(numpts-1),m_aADDM,sd_aADDM,[' num2str(colors(mod(cnt,10)+1,:)) '],0.5);']);
        hold on; grid on;
        eval(['plot(0:(numpts-1),m_aADDM,''color'',[' num2str(colors(mod(cnt,10)+1,:)) '],''linewidth'',4);']);
        title('ADDM Activation Profile','fontsize',12);                
        xlabel('Percent Gait Cycle','fontsize',12);
        ylabel('ADDM Activation Estimate','fontsize',12);
      end;
    end;   
  end;    
end;

if exist('save_dir');
  figure(1);
  eval(['print -dpng ' save_dir '/nb_actTA.png;']);
  figure(2);
  eval(['print -dpng ' save_dir '/nb_actSOL.png;']);
  figure(3);
  eval(['print -dpng ' save_dir '/nb_actGAS.png;']);
  figure(4);
  eval(['print -dpng ' save_dir '/nb_actVAS.png;']);
  figure(5);
  eval(['print -dpng ' save_dir '/nb_actBFSH.png;']);
  figure(6);
  eval(['print -dpng ' save_dir '/nb_actRF.png;']);
  figure(7);
  eval(['print -dpng ' save_dir '/nb_actSMEM.png;']);
  figure(8);
  eval(['print -dpng ' save_dir '/nb_actBFLH.png;']);
  figure(9);
  eval(['print -dpng ' save_dir '/nb_actILL.png;']);
  figure(10);
  eval(['print -dpng ' save_dir '/nb_actGLU.png;']);
  if exist('m_aGLUU') > 0
    figure(11);
    eval(['print -dpng ' save_dir '/nb_actGLUU.png;']);
  end;
  if exist('m_aGMED') > 0
    figure(12);
    eval(['print -dpng ' save_dir '/nb_actGMED.png;']);
  end;
  if exist('m_aADDL') > 0
    figure(13);
    eval(['print -dpng ' save_dir '/nb_actADDL.png;']);
  end;
  if exist('m_aADDM') > 0
    figure(14);
    eval(['print -dpng ' save_dir '/nb_actADDM.png;']);
  end;  
end;
