

gain=0.2;
bg=98.7;
datadir='Y:\10-10-18\';
PSFsigma=1.3;

%load a data set
data=load([datadir 'BestBilayer1-2010-10-18-18-49.mat'])

%process the sequence for gain and background:
%This results in values that can be interpreted as 'counts' or 'photons'
series=(data.sequence-bg)*gain;

%if you have 'DipImage' installed, you can see this image by typing the
%variable name
series

%cut out a region to analyze
cntr=[122 62]; %[x y]
sz=10 %pixels
st=100 %start frame
en=150 %end frame

cutregion=series( cntr(1)-round(sz/2):cntr(1)-round(sz/2)+sz-1, ...
                cntr(2)-round(sz/2):cntr(2)-round(sz/2)+sz-1,...
                st:en);
                    
%find maximum pixel to use as a starting guess            
crm=single(cutregion); %convert to matlab type varible
clear xmax ymax
for ii=1:size(crm,3)
[xmax(ii) ymax(ii)]=find(crm(:,:,ii)==max(max(crm(:,:,ii))));            
end            

%% Make maximum likelihood estimate of positions




%% Calculate mean square displacement
deltat=data.paraCCD.FrameTime; %seconds
pixelsize=16/150; %microns 


%% Fit MSD to get diffusion constant
