function [HorizontalLoad,HorizontalPos,Slip,Slip_motor,Time,VerticalLoad] = ReadFile_FC(ind_shift,filename,Fric,Horiz_load_initial,Vert_load_initial)
%Input data
MyData = TDMS_readTDMSFile(filename);
%Names given for each data category in the input file
Cellnames = MyData.chanNames{1,1};

%% - Time 
%Time difference [sec]
xx = find(string(Cellnames) == "TimeDiff");
td = cell2mat(MyData.data(xx+ind_shift));
Time = cumsum(abs(td));

mycolors = zeros(100,3);
mycolors(:,1) = linspace(0,1,100);
mycolors(:,2) = linspace(.75,0,100);
mycolors(:,3) = linspace(.75,0,100);

%% - Force & Pressure data
%Horizontal force [kN]
xx = find(string(Cellnames) == "Horizontal piston load [kN]");
HorizontalLoad = cell2mat(MyData.data(xx+ind_shift)) - Horiz_load_initial;
%Savitzy-Golay filter horiz load
order = 5;
framelen = 251;
HorizontalLoad = sgolayfilt(HorizontalLoad, order, framelen);
%Vertical force [kN]
xx = find(string(Cellnames) == "Vertical piston load [kN]");
VerticalLoad = cell2mat(MyData.data(xx+ind_shift)) - Vert_load_initial;
%Correct for frictionless piece
VerticalLoad = VerticalLoad - Fric*HorizontalLoad;
%Savitzy-Golay filter vert load
% VerticalLoad = sgolayfilt(VerticalLoad, order, framelen);
%Confining pressure [MPa]
xx = find(string(Cellnames) == "Confining pressure (pump) [MPa]");
ConfiningPr = cell2mat(MyData.data(xx+ind_shift));
%Pore pressure left [MPa]
xx = find(string(Cellnames) == "Pore fluid system left pressure [MPa]");
PorePrleft = cell2mat(MyData.data(xx+ind_shift));
%Pore pressure right [MPa]
xx = find(string(Cellnames) == "Pore fluid system right pressure [MPa]");
PorePrright = cell2mat(MyData.data(xx+ind_shift));
%Confining pressure block [MPa]
xx = find(string(Cellnames) == "Confining pressure (block) [MPa]");
ConfiningPrblock = cell2mat(MyData.data(xx+ind_shift));
%Confining pressure chamber [MPa]
xx = find(string(Cellnames) == "Confining pressure (chamber) [MPa]");
ConfiningPrChamber = cell2mat(MyData.data(xx+ind_shift));

%% - Strain gage data
%1st strain gage [-]
xx = find(string(Cellnames) == "Strain 1");
Strain1 = cell2mat(MyData.data(xx+ind_shift));
%2nd strain gage [-]
xx = find(string(Cellnames) == "Strain 2");
Strain2 = cell2mat(MyData.data(xx+ind_shift));
%3rd strain gage [-]
xx = find(string(Cellnames) == "Strain 3");
Strain3 = cell2mat(MyData.data(xx+ind_shift));
%4th strain gage [-]
xx = find(string(Cellnames) == "Strain 4");
Strain4 = cell2mat(MyData.data(xx+ind_shift));

%% - Position data
%Horizontal position [mm]
xx = find(string(Cellnames) == "Horizontal Piston [mm]");
HorizontalPos = cell2mat(MyData.data(xx+ind_shift));
%Vertical position [mm]
xx = find(string(Cellnames) == "Vertical Piston [mm]");
VerticalPos = cell2mat(MyData.data(xx+ind_shift));
%Vertical position motor [mm]
xx = find(string(Cellnames) == "Vertical Piston Motor [mm]");
VPmot = cell2mat(MyData.data(xx+ind_shift));
%Pore fluid position left [mm]
xx = find(string(Cellnames) == "Pore fluid system left [mm]");
PorePosright = cell2mat(MyData.data(xx+ind_shift));
%Pore fluid position right [mm]
xx = find(string(Cellnames) == "Pore fluid system right [mm]");
PorePosleft = cell2mat(MyData.data(xx+ind_shift));
%Confining pressure piston position [mm]
xx = find(string(Cellnames) == "Confining pressure position [mm]");
ConfiningPos = cell2mat(MyData.data(xx+ind_shift));

%% - Temperature data
%Internal pressure 1 [C]
xx = find(string(Cellnames) == "Temperature Internal 1 [°C]");
TempInt1 = cell2mat(MyData.data(xx+ind_shift));
%Internal pressure 2 [C]
xx = find(string(Cellnames) == "Temperature Internal 2 [°C]");
TempInt2 = cell2mat(MyData.data(xx+ind_shift));
%External pressure 1 [C]
xx = find(string(Cellnames) == "Temperature External 1 [°C]");
TempExt1 = cell2mat(MyData.data(xx+ind_shift));
%External pressure 2 [C]
xx = find(string(Cellnames) == "Temperature External 2 [°C]");
TempExt2 = cell2mat(MyData.data(xx+ind_shift));
%External pressure 3 [C]
xx = find(string(Cellnames) == "Temperature External 3 [°C]");
TempExt3 = cell2mat(MyData.data(xx+ind_shift));

%% - Security
%Oil level
xx = find(string(Cellnames) == "Oil level");
Oillevel = cell2mat(MyData.data(xx+ind_shift));
%Oil filter
xx = find(string(Cellnames) == "Oil filter");
OilFilter = cell2mat(MyData.data(xx+ind_shift));
%Vertical piston left limit
xx = find(string(Cellnames) == "Vertical piston left limit");
VertPistLeftLimit = cell2mat(MyData.data(xx+ind_shift));
%Vertical piston right limit
xx = find(string(Cellnames) == "Vertical piston right limit");
VertPistRightLimit = cell2mat(MyData.data(xx+ind_shift));
%Lever in
xx = find(string(Cellnames) == "Lever in");
Leverin = cell2mat(MyData.data(xx+ind_shift));
%Lever out
xx = find(string(Cellnames) == "Lever out");
Leverout = cell2mat(MyData.data(xx+ind_shift));

%% - Correct for stiffness of machine
%Correct horizontal displacement [mm]
CorrectionH = HorizontalLoad/480;
CorrectionH(HorizontalLoad>18) = CorrectionH(HorizontalLoad>18) + HorizontalLoad(HorizontalLoad>18)/491;
CorrectionH(HorizontalLoad>50) = CorrectionH(HorizontalLoad>50) + HorizontalLoad(HorizontalLoad>50)/559;
HorizontalPos = HorizontalPos + CorrectionH;

%Correct vertical displacement [mm]
CorrectionV = VerticalLoad/199;
CorrectionV(VerticalLoad>5) = (VerticalLoad(VerticalLoad>5)+23.3)/1018;
VerticalPos = VerticalPos - CorrectionV;

%Correct motor displacement [mm]
CorrectionM = VerticalLoad/18;
CorrectionM(VerticalLoad>5) = CorrectionM(VerticalLoad>5) + VerticalLoad(VerticalLoad>5)/112;
VPmot = VPmot - CorrectionM;

%% - Calculations
%Total slip from optical encoder (stiffness between oc and sample not removed) [mm]
Slip = abs((VerticalPos-max(VerticalPos)));
%SG filter for slip
% Slip = sgolayfilt(Slip, order, framelen);
%Slip calculated from motors [mm]
Slip_motor = abs((VPmot-max(VPmot)))/7;
end

