function [output_args] = Analyzedwelltimes4(fname,framerate,numFrames)%,shutteropen) %enter frame rate in 'sec per frame' %AnalyzeDwelltimes4 finds time protein spends on and off Nuc. Outputs these as %onlist and offlist, respectively. %The purpose of this file is to make a list of the amount of time %spent in high and low state from idealized traces outputted from vbFRET file=load(fname) disp("analyzing") FRETpath = file.path; numPaths = size(FRETpath,2) %how many fluorophores? %numFrames = 1200; %how many frames in each movie statematrix = zeros(numFrames,numPaths); FRETmatrix = zeros(numFrames,numPaths); FRETdiff = zeros(numPaths,1); % bind = zeros(3*numPaths,1); release = zeros(3*numPaths,1); numbind = zeros(3*numPaths,1); numrelease = zeros(3*numPaths,1); stitch_state = zeros(3*numPaths,2); %analyze dwelltimes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% find all transition events %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %define bind and release variables %{ bind = zeros(3*numPaths,1); release = zeros(3*numPaths,1); numbind = zeros(3*numPaths,1); numrelease = zeros(3*numPaths,1); stitch_state = zeros(3*numPaths,2); %} %stitch_state is a variable I'm trying out to try to stitch together long %traces to get more information from them m=1; n=1; for k = 1:numPaths; %disp(k); m=1; n=1; disp('path length'); tracesize = size(FRETpath{k},1) a=FRETpath(1,k); %assignin('base','a',a); b=unique(a{1,1}); if b==1; continue; end %tracelength = size(a{1,1}); %something like for legnth of trace count number in high state and low %state highstate = max(b) lowstate = min(b) for i=1:(tracesize-1);%find binding events %disp('analyzing') %disp(i); %disp(tracelength); if ismember(a{1,1}(i),highstate) && ismember(a{1,1}(i+1),lowstate); %disp('into for loop') bind(k,m) = i; m = m+1; %disp('bind!!!!') %disp(i) %save(filename, 'bind', '-ascii', '-double', '-append') assignin('base','bind', bind); end %} end assignin('base','bind',bind); for ii = 1:(tracesize-1) if ismember(a{1,1}(ii),lowstate)&&ismember(a{1,1}(ii+1),highstate); release(k,n) = ii; n=n+1; %disp('release!!!!') %save(filename, 'bind', '-ascii', '-double', '-append') assignin('base','bind',bind); assignin('base','release', release); end end assignin('base','bind',bind) %save('bind_values.mat','bind','-append') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% find number of bind/release events for each trace %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bindrow1 = bind(k,:); release1 = release(k,:); bind_row = bindrow1(find(bindrow1~=0)); bind_release = release1(find(release1~=0)); numbind(k) = length(bind_row); numrelease(k) = length(bind_release); %assignin('base','numbind',numbind); %assignin('base', 'lenrelease', lenrelease); lenbind = length(bind_row); lenrelease = length(bind_release); %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%find dwell times%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%case1: bindFRET: start high, bind(max)>release --> end low %%%%%%%%%%%%%%%% %%%checked 11/6/17 I think this is correct%%%% t=1; r=1; %case1: if bind(k,1)max(release(k,:))&&bind(k,1)~=0&&release(k,1)~=0; stitch_state(k,1) = 2; %trace starts unbound stitch_state(k,2) = 1; %trace ends bound %assignin('base','stitch_state',stitch_state); %disp('starts unbound, ends bound'); x=['num of binding events = ', num2str(length(bind_row))]; y=['num of release events = ',num2str(length(bind_release))]; disp(x); disp(y); z = ['(lenbind,lenrelease)', num2str(lenbind),num2str(lenrelease)]; disp(z); for i = 1:(lenrelease); onmatrix(k,t) = release(k,i)-bind(k,i); t=t+1; assignin('base','onmatrix',onmatrix); end for i = 2:(lenbind); offmatrix(k,r) = bind(k,i) - release(k,i-1); r=r+1; assignin('base','offmatrix',offmatrix); end end %bindvalues = bind(k,:); %releasevalues = release(k,:); %%% starts low (first transition is up), Ends low b/c last transition is %%% binding checked 11/6 think this is also correct r=1; t=1; %case2: if bind(k,1)>release(k,1)&&max(bind(k,:))>max(release(k,:))&&bind(k,1)~=0&&release(k,1)~=0;%&&release(k,1)~=0; stitch_state(k,1) = 1; %trace starts bound stitch_state(k,2) = 1; %trace ends bound %disp('starts bound, ends bound'); x=['num of binding events = ', num2str(length(bind_row))]; y=['num of release events = ',num2str(length(bind_release))]; disp(x); disp(y); for i = 1:(lenbind-1); onmatrix(k,t) = release(k,(i+1))-bind(k,i); t=t+1; assignin('base','onmatrix',onmatrix); end for i = 1:(lenbind); offmatrix(k,r) = bind(k,i)-release(k,i); r=r+1; assignin('base','offmatrix',offmatrix); end end %%%%start high (first event is binding release), end high (last event is a %%%%release) %%10/24 good t=1; r=1; %case3: %first event is a bind, last event is a release if bind(k,1)release(k,1)&&max(bind(k,:))