function [num_misclassifications,class_val] = test_fisher(data,label,Peakorder,V,decision_threshold,plot_option)

id1 = (label == 1);
id2 = (label == 2);
data1 = data(id1, :);
data2 = data(id2, :);

Peakdata1 = data1(:, Peakorder);
Peakdata2 = data2(:, Peakorder);
PCdata1 = Peakdata1 * V;
PCdata2 = Peakdata2 * V;

% class1_mean = sum(PCdata1(:,3))/size(PCdata1,1);
% class2_mean = sum(PCdata2(:,3))/size(PCdata2,1);
% 
% threshold = (class1_mean+class2_mean)*.5;
threshold = decision_threshold.val;

if(length(PCdata1) == 0) class_val = PCdata2(1,3); point = PCdata2(1,:);
else class_val = PCdata1(1,3); point = PCdata1(1,:);
end

if(plot_option == 1) plot3(point(:, 1), point(:, 2), point(:, 3), 'bo','MarkerSize',8);
end

if(decision_threshold.label== 1) 
    num_misclassifications = length(find(PCdata1(:,3) < threshold)) + length(find(PCdata2(:,3) >  threshold));
else
    num_misclassifications = length(find(PCdata2(:,3) < threshold)) + length(find(PCdata1(:,3) >  threshold));
end
