% Initialize data
% written by Chris and Dan
% Displacement.m allows you to analyze the data you aquiered with the
% correlation, fitting or mean routine. It only needs the validx and
% validy and can calculate strain from it. Before you start you should
% consider cleaning up the data as described in the guide. After that step
% you can analyze parts of your data, or the full set. Try to use also the
% console command, e.g. if you want to analyze only image 100-110 since
% something really interesting happend there, load validx and validy into
% your workspace and call
% displacement(validx(:,100:110),validy(:,100:110));
% In this case displacement only loads the important images and you can
% clean this part of your data set.
% Changed 3. February 2008
function [validx,validy]=displacement(validx,validy);
%load data in case you did not load it into workspace yet
if exist('validx')==0
[validxname,Pathvalidx] = uigetfile('*.dat','Open validx.dat');
if validxname==0
disp('You did not select a file!')
return
end
cd(Pathvalidx);
validx=importdata(validxname,'\t');
end
if exist('validy')==0
[validyname,Pathvalidy] = uigetfile('*.dat','Open validy.dat');
if validyname==0
disp('You did not select a file!')
return
end
cd(Pathvalidy);
validy=importdata(validyname,'\t');
end
%define the size of the data set
sizevalidx=size(validx);
sizevalidy=size(validy);
looppoints=sizevalidx(1,1);
loopimages=sizevalidx(1,2);
%calculate the displacement relative to the first image in x and y
%direction
clear displx;
validxfirst=zeros(size(validx));
validxfirst=mean(validx(:,1),2)*ones(1,sizevalidx(1,2));
displx=validx-validxfirst;
clear validxfirst
clear disply;
validyfirst=zeros(size(validy));
validyfirst=mean(validy(:,1),2)*ones(1,sizevalidy(1,2));
disply=validy-validyfirst;
clear validyfirst
%Prompt user for type of plotting / visualization
selection10 = menu(sprintf('How do you want to visualize your data?'),'3D Mesh Plot of Displacement'...
,'Full Strain Plots','Strain Measurement between 2 Points','1D Average Strain Measurement',...
'Rotate Orientation (exchange x and y)','Remove badly tracked marker, one by one (Position)',...
'Delete multible markers (Position)','Delete markers from displacement vs. position plot',...
'Delete points moving relative to their neighbours','Select Markers to Analyze ',...
'Save validx and validy','Average a couple of images','Cancel');
% Selection for Cancel - All windows will be closed and you jump back to
% the command line
if selection10==13
close all;
return
end
% This selection will average up a specified number of images to reduce the
% noise of the data set. I would like to point out that you will need to
% average your other sensor data (e.g. load data), too, to match it to your
% strain data.
if selection10==12
prompt = {'How many images would you like to combine as a base image?'};
dlg_title = 'Input number of images:';
num_lines= 1;
def = {'5'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if str2num(cell2mat(answer(1)))==0
disp('Get out, you changed your mind?')
[validx validy]=displacement(validx,validy);
return
else
baseimages = str2num(cell2mat(answer(1)));
if baseimages==[]
disp('Give me a number, will you?')
[validx validy]=displacement(validx,validy);
return
end
if baseimages>loopimages
disp('That is too large?!')
else
baseimagemean=mean(validx(:,1:baseimages),2);
validx(:,1:baseimages-1)=[];
validx(:,1)=baseimagemean;
baseimagemean=mean(validy(:,1:baseimages),2);
validy(:,1:baseimages-1)=[];
validy(:,1)=baseimagemean;
end
end
[validx validy]=displacement(validx,validy);
return
end
% Save validx and validy, very useful if you cleaned up your dataset. Data
% will be saved as -ascii text file. If you send data like this by email
% you can reduce the size tremendously by compressing it. Use ZIP or RAR.
if selection10==11
[FileName,PathName] = uiputfile('validx_corr.dat','Save validx');
if FileName==0
disp('You did not save your file!')
[validx validy]=displacement(validx,validy);
return
else
cd(PathName)
save(FileName,'validx','-ascii')
[FileName,PathName] = uiputfile('validy_corr.dat','Save validy');
if FileName==0
disp('You did not save your file!')
[validx validy]=displacement(validx,validy);
else
cd(PathName)
save(FileName,'validy','-ascii')
end
[validx validy]=displacement(validx,validy);
return
end
end
% Select Points from detailed Analysis
if selection10==10
[validx validy validxbackup validybackup]=ppselection_func(validx,validy);
if validx==0
validx=validxbackup;
validy=validybackup;
end
if validy==0
validx=validxbackup;
validy=validybackup;
end
[validx validy]=displacement(validx,validy);
end
% Remove markers moving relativ to their neighbours
if selection10==9
[validx,validy,displx,disply]=delete_jumpers(validx,validy,displx,disply);
[validx validy]=displacement(validx,validy);
end
% Remove markers from the displacement vs. position plot
if selection10==8
[validx,validy,displx,disply]=removepoints_func(validx,validy,displx,disply);
[validx validy]=displacement(validx,validy);
end
% Remove bad points
if selection10==7
[validx,validy]=removepoints_func2(validx,validy);
[validx validy]=displacement(validx,validy);
end
% Remove bad points
if selection10==6
[validx validy]=removepoints_func3(validx,validy);
[validx validy]=displacement(validx,validy);
end
% Rotate Matrix
if selection10==5
[validx, validy]=rotatematrix(validx,validy);
[validx validy]=displacement(validx,validy);
end
% 1D Strain plot using average strains for ELASTIC STRAIN only
if selection10==4
[validx validy]=strain_1D_average_func(validx, validy,displx,disply);
[validx validy]=displacement(validx,validy);
end
% 1D Strain plot
if selection10==3
[validx, validy,displx,disply]=strain_1D_2Points_func(validx, validy,displx,disply);
[validx validy]=displacement(validx,validy);
end
% Fast plotting, cropping needed for polynomial fit
if selection10==2
[validx, validy,displx,disply]=polyfit3D(validx, validy,displx,disply);
[validx validy]=displacement(validx,validy);
end
% 3D Mesh Plotting
if selection10==1
if sizevalidx(1,1)>2
[validx, validy,displx,disply]=meshplot(validx,validy,displx,disply);
else
disp('You need at least three markers to display the 3D-plot')
msgbox('You need at least three markers to display the 3D-plot','3D-Plot','warn');
end
[validx validy]=displacement(validx,validy);
end
%---------------------------------
function [validx,validy,displx,disply]=delete_jumpers(validx,validy,displx,disply);
% written by Chris
% This is a filter which helps to find jumpy data points which are
% oscillating or stop moving.
% The Filter starts by finding the next 10 datapoint neighbours
% (num_neighbours), calculates their mean position and then plots the
% difference between each data point and its neighbours versus image
% number. If a data point is jumping around it will show up as a spike. But
% be careful, one bad one will also affect his neighbours, therefore its
% worthwhile to use this filter step by step.
% Changed 3. February 2008
num_neighbours=10;
doitonemoretime=1
while doitonemoretime==1
% defining variables
sizevalidx=size(validx);