Skip to content

Commit

Permalink
Converted units [dx,dt] from pixels/frames to um./sec
Browse files Browse the repository at this point in the history
  • Loading branch information
Blosberg committed Nov 23, 2018
1 parent e96a8fc commit c1f7829
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 39 deletions.
28 changes: 14 additions & 14 deletions build_xyl_trackmat.m → build_xyl_trackdat.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function [ trackmat_xyl ] = build_xyl_trackmat ( tracks_input, Nframes )
function [ trackdat_xyl ] = build_xyl_trackdat ( tracks_input, px_spacing, Nframes )

Num_comp_tracks = length( tracks_input);

% Loop through each independent track (of length T frames) and figure
% out how many sub-tracks need to be considered for each case:
for ti = 1:Num_comp_tracks

Nsubtracks(ti) = size( tracks_input(ti).tracksCoordAmpCG, 1);
Expand All @@ -12,8 +14,6 @@
comptrack_death_lag = Nframes - max( tracks_input(ti).seqOfEvents(:,1) );
% the number of frames that should be appended to the end of this comptrack to make it to the end of the movie.

% Loop through each independent track (of length T frames) and figure
% out how many sub-tracks need to be considered for each case:
for sti = 1:Nsubtracks( ti )
% Within each sub-track, extract the position and change values
% segment in which the particle could not be located on either side
Expand All @@ -22,26 +22,26 @@
% get birth and death time points for each subtrack _within_ the composite window
obituary = tracks_input(ti).seqOfEvents( tracks_input(ti).seqOfEvents(:,3)==sti, 1 );

xdat_compwindow = tracks_input(ti).tracksCoordAmpCG(sti,1:8:end);
ydat_compwindow = tracks_input(ti).tracksCoordAmpCG(sti,2:8:end);
xdat_compwindow = px_spacing * tracks_input(ti).tracksCoordAmpCG(sti,1:8:end);
ydat_compwindow = px_spacing * tracks_input(ti).tracksCoordAmpCG(sti,2:8:end);
Adat_compwindow = tracks_input(ti).tracksCoordAmpCG(sti,4:8:end);

trackmat_xyl(ti).xpos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), xdat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackmat_xyl(ti).ypos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), ydat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackmat_xyl(ti).Lamp(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), Adat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackdat_xyl(ti).xpos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), xdat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackdat_xyl(ti).ypos(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), ydat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];
trackdat_xyl(ti).Lamp(sti,:) = [ repmat(NaN,[1 , (comptrack_birth-1)]), Adat_compwindow, repmat(NaN,[1 , comptrack_death_lag]) ];

end % terminate forloop through subtracks

if( ~all( size( trackmat_xyl(ti).xpos ) == [ Nsubtracks(ti), Nframes] ) || ~all( size( trackmat_xyl(ti).ypos ) == [ Nsubtracks(ti), Nframes] ) )
disp("unexpected dimension in trackmat_xyl.")
if( ~all( size( trackdat_xyl(ti).xpos ) == [ Nsubtracks(ti), Nframes] ) || ~all( size( trackdat_xyl(ti).ypos ) == [ Nsubtracks(ti), Nframes] ) )
disp("unexpected dimension in trackdat_xyl.")
return
end

trackmat_xyl(ti).dx = diff ( trackmat_xyl(ti).xpos, 1, 2 );
trackmat_xyl(ti).dy = diff ( trackmat_xyl(ti).ypos, 1, 2 );
trackdat_xyl(ti).dx = diff ( trackdat_xyl(ti).xpos, 1, 2 );
trackdat_xyl(ti).dy = diff ( trackdat_xyl(ti).ypos, 1, 2 );

if( ~all ( size( trackmat_xyl(ti).Lamp ) == [ Nsubtracks(ti), Nframes] ) )
disp("unexpected dimension in trackmat_xyl.Lamp.")
if( ~all ( size( trackdat_xyl(ti).Lamp ) == [ Nsubtracks(ti), Nframes] ) )
disp("unexpected dimension in trackdat_xyl.Lamp.")
return
end

Expand Down
3 changes: 1 addition & 2 deletions get_diffdat.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
dout.y = [];
dndnp1 = [];


% -------------------------------------------------
% ---- First collect Diffdat for each polymer state

Expand All @@ -26,7 +25,7 @@

% this is the diffusion constant, using the formula from Eq. 14 (page 022726-7
% from Vestergaard et al, Phys. Rev. E. 89, (2014)
Diffdat{S}.D = (dx2_ave/2*(dt)) + (dxndxnp1_ave/dt)/dt;
Diffdat{S}.D = (dx2_ave/2*(dt)) + (dxndxnp1_ave/dt);
Diffdat{S}.sigma2 = R*(dx2_ave) + (2*R-1)*dxndxnp1_ave;

if( Diffdat{S}.sigma2 <1 )
Expand Down
7 changes: 3 additions & 4 deletions get_state_lifetimes.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
function [ state_lifetime_list ] = get_state_lifetimes ( tracks_input, state_matrices_allti, max_state , Nframes )
% Added on boztower at 21:50 on 25.10.2018
%
function [ state_lifetime_list ] = get_state_lifetimes ( tracks_input, state_matrices_allti, max_state, dt, Nframes )
% Calculations the number of intervening frames within dimerization events.

Num_comp_tracks = length( tracks_input );
for s= 1:max_state
Expand Down Expand Up @@ -74,7 +73,7 @@
index = indices_right_shape(j);
[ state_this_window, excit_duration ] = get_state( state_matrices_allti{ti}(sti,:), Events_this_track(index,:), Events_this_track(index+1,:) );
% ^merger event^ , ^split event^
state_lifetime_list{state_this_window} = [ state_lifetime_list{state_this_window}, excit_duration ] ;
state_lifetime_list{state_this_window} = [ state_lifetime_list{state_this_window}, dt * excit_duration ] ;
end
end
end
Expand Down
32 changes: 25 additions & 7 deletions master.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
load("workspace_just_tracksFinal.mat")
dt = 0.04;
Label = "DATANAME";
% polytracker ---a software package for processing data from TIRF fluorescance
% videos
% Copyright © 2017 Bren Osberg <[email protected]>

R = 1/6
% ---- master file to run the polytracker software. You should be able
% to hit ctrl+Enter through the commands here after loading your tracksFinal data
% structure into the workspace

% import tracksFinal, somehow,
% then run this command:
%% ==========================================================================
%%
% ---- DEFINE VARIABLES RELEVANT TO THIS DATASET

[ life, dens, lumen, Diffdat_p, D_observations] = polytrack( tracksFinal, Label, dt, R);
dt = 0.04; %--- time spacing between frames
px_spacing = 0.01066; %--- pixel spacing (assuming tracksFinal stores position
% coordinates in units of pixels, this factor converts
% the spatial dimension into micrometers.
R = 1/6; %--- the motion blur constant, as defined in Vestergaard et
% al, Phys. Rev. E. 89, (2014). Assuming the camera
% shutter is left on continuously

Label = "DATANAME"; %--- Some descriptive name for your dataset.

Nbin = 100; %--- Resolution (number of bins) for your histograms.

%% ==========================================================================
%% Now run the script:

[ life, dens, lumen, Diffdat_p, D_observations] = polytrack( tracksFinal, Label, dt, px_spacing, R, Nbin);

19 changes: 8 additions & 11 deletions polytrack.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
% take TracksFinal type data structure and dt spacing and some label, and
% output relevant plots

function [ lifetime_list, density, lumen_list, Diffdat_p, D_observations] = polytrack ( tracks_input_RAW, Label, dt , R )
function [ lifetime_list, density, lumen_list, Diffdat_p, D_observations] = polytrack ( tracks_input_RAW, Label, dt, px_spacing, R, Nbin)

RES = 100;
% ===================================================
% dat_in = "E:\NikonTIRF\04-10-18\beta1\141\TrackingPackage\tracks\Channel_1_tracking_result"
% tracksoftware = "C:\u-track\software\plotCompTrack.m"
Expand All @@ -23,7 +22,7 @@
%% ===================================================
% --- get xy-, dxdy-, and lumen data for each subtrack

trackdat_xyl = build_xyl_trackmat ( tracks_input, Nframes );
trackdat_xyl = build_xyl_trackdat ( tracks_input, px_spacing, Nframes );

%% ===================================================
% --- Assign polymer state for each time point along each track:
Expand All @@ -36,9 +35,7 @@
% Lifetime_list{1} is the list of lifetime observations for polymers in the 1 state
% Lifetime_list{2} "" "" in the 2 state, etc.

lifetime_list = get_state_lifetimes ( tracks_input, state_matrices_allti, max_state, Nframes );

%%
lifetime_list = get_state_lifetimes ( tracks_input, state_matrices_allti, max_state, dt, Nframes );

all_lives_matter = [];

Expand All @@ -49,7 +46,7 @@

figure(1)
hist(all_lives_matter, 50)
xlabel("# frames")
xlabel(" lifetime [s]")
ylabel("frequency")
title( strcat('Merger liftime distribution; dataset: ', Label) )

Expand Down Expand Up @@ -95,13 +92,13 @@

figure(6)
subplot(2,1,1);
hist(lumen_list{1}, RES)
hist(lumen_list{1}, Nbin)
xlabel("Intensity")
ylabel("Freq")
title( strcat('spectral distribution of monomers; dataset: ', Label) )

subplot(2,1,2);
hist(lumen_list{2}, RES)
hist(lumen_list{2}, Nbin)
xlabel("Intensity")
ylabel("Freq")
title( strcat('spectral distribution of dimers; dataset: ', Label) )
Expand All @@ -121,14 +118,14 @@
title( strcat('position change -scatter') );

subplot(2,1,2);
hist(dndnp1, 2*RES);
hist(dndnp1, 2*Nbin);
xlim([-5, 5]);
xlabel("dx_n * dx_{n+1}");
ylabel("Freq");
title( strcat('Two-frame drift correlation: ', Label) );

figure(8);
hist(D_observations, 2*RES);
hist(D_observations, 2*Nbin);
xlabel("Observed diffusion constant");
ylabel("Freq");
title( strcat('Diffusion constant calculation (like in PNAS 2013): ', Label) );
Expand Down
2 changes: 1 addition & 1 deletion purge_ephemeral.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@

% (nothing with _RAW should be touched after this point )

end
end

0 comments on commit c1f7829

Please sign in to comment.