%%
% Imaris excel data to measurements
% Author: Tegy John Vadakkan
% Affiliation: Baylor College of Medicine, Houston
% Date modified: 9/15/2011
%%
% Program description
% Calculates track length, track displacement, and track duration of tracks that are continous in time.
% Tracks whose duration is greater than maxT will be eliminated and the
% output will all be zeros (same holds for discontinuous tracks).
% minT and maxT acts as thresholds in time.
% This program helps to construct a distribution of track lengths, displacements, and
% durations.
%%
% Typical Imaris output file
% Spot Position
%
% Position X Position Y Position Z Unit Time Object Group Index
% 0.986000001 10.11499977 0 um 1 Spot 1453 Group 2 2
% 0.934000015 249.3009949 0 um 1 Spot 1205 Track 40 4
% 25.88400078 67.80599976 0 um 1 Spot 822 Track 25 10
% 45.35100174 182.2610016 0 um 1 Spot 1146 Track 36 14
% 49.98899841 23.62999916 0 um 1 Spot 1013 Track 30 15
% 54.79999924 237.0610046 0 um 1 Spot 1156 Track 37 16
%
% convert the Imaris output file to the format below (create a new excel
% file with the following format (five columns)):
% 0.986000001 10.11499977 Group 2 1
% 0.934000015 249.3009949 Track 40 1
% 25.88400078 67.80599976 Track 25 1
% 45.35100174 182.2610016 Track 36 1
% 49.98899841 23.62999916 Track 30 1
% 54.79999924 237.0610046 Track 37 1
% inputs to the program
% track_xy_excel_file (new excel file in the format mentioned above)
% minT (lower time cutoff)
% maxT (upper time cutoff)
% output_file (output file name)
%%
clear all;
close all;
clc;
%% collect data
indata=inputdlg({'track_xy_excel_file','minT','maxT','output_file'});
[numeric,text] = xlsread(indata{1});
[rows cols] = size(numeric);
maxy = max(numeric(:,4));
xycount = zeros(maxy,1);
for i = 1:rows
if(strcmp('Track',text{i,3}) == 1)
xycount(numeric(i,4)) = xycount(numeric(i,4)) + 1;
xdata(numeric(i,4),xycount(numeric(i,4))) = numeric(i,1);
ydata(numeric(i,4),xycount(numeric(i,4))) = numeric(i,2);
tdata(numeric(i,4),xycount(numeric(i,4))) = numeric(i,5);
trdata(numeric(i,4),xycount(numeric(i,4)))= numeric(i,4);
end
end
%%
for i=1:maxy
plength(i,1) = 0.0;
ptime(i,1) = 1;
flag(i) = 0;
if(xycount(i) > 0)
xycm1 = xycount(i)-1;
for j=1:xycm1
if((tdata(i,j+1)-tdata(i,j)) == 1)
dxx = xdata(i,j+1) - xdata(i,j);
dyy = ydata(i,j+1) - ydata(i,j);
delta = sqrt(power(dxx,2) + power(dyy,2));
plength(i,1) = plength(i,1) + delta;
ptime(i,1) = ptime(i,1) + 1;
end
end
end
end
%%
indx = 0;
minT = str2num(indata{2});
maxT = str2num(indata{3});
for i=1:maxy
dist(i,1) = 0.0;
durn(i,1) = 0.0;
pdisp(i,1) = 0.0;
if(xycount(i) == ptime(i))
if(ptime(i) > minT && ptime(i) <= maxT )
dist(i,1) = plength(i);
durn(i,1) = ptime(i)-1;
dxx = xdata(i,1) - xdata(i,xycount(i));
dyy = ydata(i,1) - ydata(i,xycount(i));
delta = sqrt(power(dxx,2) + power(dyy,2));
pdisp(i,1) = delta;
flag(i) = 1;
end
end
end
%% output data
odata(:,1) = pdisp;
odata(:,2) = dist;
odata(:,3) = durn;
dlmwrite(indata{4},odata);