function wts = showClassifiers(cv)
%%% wts = showClassifiers(CV.msf)

[nTasks,nTrials] = size(cv.classes);
for ttrial = 1:nTrials
  w = cv.testResults{ttrial}{2}.weights;
  w = w - repmat(mean(w,2),1,nTasks);
  wts{ttrial} = w;
end

figure(1);
'figure 1 has zero meaned weights'
for ttrial = 1:nTrials
  subplot(nTrials,1,ttrial);
  plot(wts{ttrial});
  title(['Test Trial ' num2str(ttrial)]);
end

figure(2);
'figure 2 has zero meaned weights magnitudes averaged over all n tasks'
for ttrial = 1:nTrials
  subplot(nTrials,1,ttrial);
  plot(mean(abs(wts{ttrial}),2));
  title(['Test Trial ' num2str(ttrial)]);
end

figure(3);
'figure 3 has zero meaned weights magnitudes averaged over all n tasks for first test trial'
dm = max(abs(wts{1}),[],2);
plot(dm,'k');
axis tight;
xlabel('Feature Index');
ylabel('Max Magnitude of Linear Discriminant Weights')

figure(4);
['figure 4 has zero meaned weight vars over all tasks for first' ...
      ' test trial']
vm = var(wts{1},0,2);
semilogy(vm,'k');
axis tight;
xlabel('Feature Index');
ylabel('Variance of Linear Discriminant Weights (log scale)')

figure(5);
'figure 5 has zero meaned weights magnitudes averaged over all n tasks for final test trial'
' grouped by electrode'
for ttrial = 1:nTrials
  subplot(nTrials,1,ttrial);
  dm = mean(abs(wts{ttrial}),2);
  dm = reshape(dm,6,length(dm)/6);
%  plot(mean(dm,2),'o-k');
  plot(max(dm,[],2),'o-k');
  title(['Test Trial ' num2str(ttrial)]);
  set(gca,'XTick',1:6);
  set(gca,'XTickLabel',{'C3','C4','P3','P4','O1','O2'});
  ylabel('Max Weight Magnitude');
end

figure(6);
'figure 6 has zero meaned weights magnitudes averaged by electrode for final test trialover all n tasks for final test trial'
for ttrial = 1:nTrials
  subplot(nTrials,1,ttrial);
  mns = [];
  for c = 1:nTasks
    dm = abs(wts{ttrial}(:,c));
    dm = reshape(dm,6,length(dm)/6);
    mns = [mns max(dm,[],2)];
  end
  plot(mns,'o-k');
  title(['Test Trial ' num2str(ttrial)]);
  set(gca,'XTick',1:6);
  set(gca,'XTickLabel',{'C3','C4','P3','P4','O1','O2'});
  ylabel('Max Weight Magnitude');
end

figure(7);
'figure 7 has zero meaned weights magnitudes maxed by electrode for first test trial'
mns = [];
for c = 1:nTasks
dm = wts{1}(:,c);
%  dm = abs(wts{1}(:,c));
  dm = reshape(dm,6,length(dm)/6);
%  mns = [mns max(dm,[],2)];
mns = [mns var(dm,[],2)];
end
plot(mns,'o-k');
set(gca,'XTick',1:6);
set(gca,'XTickLabel',{'C3','C4','P3','P4','O1','O2'});
ylabel('Variance of Weight Magnitudes');
xlabel('Electrode')
childs = get(gca,'Children');
markers = ['o','x','*','s','d'];
dnames = {};
for c=1:nTasks
  set(childs(c),'Marker',markers(c),'MarkerSize',10);
  dnames = {dnames{:} ['Disc for Task ' num2str(c)]};
end
legend(dnames);

