% This script organizes all Excel tracking files exported from Blender in
% one database. 
% Author: Joschka Wiegleb (2021)

%Title: Flow, force, behaviour: Assessment of a prototype hydraulic barrier for
%invasive fish
%Journal: Hydrobiologia
%Article authors: Joschka Wiegleb, Philipp E. Hirsch, Frank Seidel, Georg Rauter,
%Patricia Burkhardt-Holm
%Corresponding Author: Patricia Burkhardt-Holm, Program
%Man-Society-Environment, Department of Environmental Sciences, University of Basel, Vesalgasse 1, 4051 Basel, Switzerland, patricia.holm@unibas.ch




prompt = {'Enter target file path'} %% Target file path is where all marker files of the relating treatment are stored (e.g. V:\A1_Ausbreitungsmechanismen\TP_Grundelsperre\KIT\01_Analysis\00_BlenderFiles_Markers_and_Tracking\Analysis_20190416_KIT_1Slot_Gru_Rep2_sehr starke Str?mung_recovered\data_Tracking);
dlgtitle = 'Input';
answer = inputdlg(prompt,dlgtitle);
ans=char(answer);

a=dir(fullfile(ans));
folder=transpose({a.folder});
name=transpose({a.name});
pathparts = strsplit(ans,filesep);
q=pathparts(1,7)

for i=3:length(name)
    b=fullfile(folder(i,:), name(i,:));
    c=readtable(b{1,1});
    all(i,:)={i c};
end

e=vertcat(all{3:end,2});
endfile=fullfile(ans,'AllTrMarkers.xlsx')

pathparts = strsplit(ans,filesep);
treatment=pathparts(1,7);

e(:,6)=treatment

writetable(e,endfile)

