%this script plots all the situations that occurred for landmark removal
%from fishes A3,A5 and C4
%For fish A3. two pairs of trials contained changes one from trial 5 to
%trial 6 when the small triangle was removed (tn=1), second one from trial 7-8
%where both small square and large circle were removed(tn=2). for fish A5
%(tn=3) the home was removed and for fish C4 also.
%For each trial different rows correspond to different units.
clearvars
close all
trials=dir('*_LMRemoveFR.mat');
change_dir=[];
All_pairs=[];
for tn=1:length(trials)
    load(trials(tn).name)
    if tn==1
        plot([1,2],[fr_stp2_pairs(:,1),fr_stp2_pairs(:,2)],'o-')
        change_dir=[change_dir,(fr_stp2_pairs(:,2)-fr_stp2_pairs(:,1))'];
        hold on
        All_pairs=[All_pairs;fr_stp2_pairs]

        clear fr_stp2_pairs
    elseif tn==2
        plot([1,2],[fr_sqp2_pairs(:,1),fr_sqp2_pairs(:,2)],'o-')
        plot([1,2],[fr_lc2_pairs(:,1),fr_lc2_pairs(:,2)],'o-')
        change_dir=[change_dir,(fr_sqp2_pairs(:,2)-fr_sqp2_pairs(:,1))'];
        change_dir=[change_dir,(fr_lc2_pairs(:,2)-fr_lc2_pairs(:,1))']
        All_pairs=[All_pairs;fr_sqp2_pairs]
        All_pairs=[All_pairs;fr_lc2_pairs]

        clear fr_sqp2_pairs
        clear fr_lc2_pairs
    elseif tn==3
        plot([1,2],[fr_hc2_pairs(:,1),fr_hc2_pairs(:,2)],'o-')
        change_dir=[change_dir,(fr_hc2_pairs(:,2)-fr_hc2_pairs(:,1))']
        All_pairs=[All_pairs;fr_hc2_pairs]

        clear fr_hc2_pairs
    else
        plot([1,2],[fr_hc2_pairs(:,1),fr_hc2_pairs(:,2)],'o-')
        change_dir=[change_dir,(fr_hc2_pairs(:,2)-fr_hc2_pairs(:,1))']
        All_pairs=[All_pairs;fr_hc2_pairs]

 
    end
    
end
xlim([0.5,2.5])
diff_bef_aft=(All_pairs(:,2)-All_pairs(:,1))./(All_pairs(:,1));

for i=1:length(All_pairs)
    All_pairs_norm(i,:)=All_pairs(i,:)/max(All_pairs(i,:));
    plot([1,2],[All_pairs_norm(i,1),All_pairs_norm(i,2)],'o-')
    hold on

end
kruskalwallis([All_pairs_norm(:,1);All_pairs_norm(:,2)],[ones(size(All_pairs_norm(:,1)));2*ones(size(All_pairs_norm(:,2)))])

% figure
% plot([ones(size(All_pairs_norm(:,1)));2*ones(size(All_pairs_norm(:,2)))],[All_pairs_norm(:,1);All_pairs_norm(:,2)],'o-')
