Permalink
Browse files

replace nansum

  • Loading branch information...
rharkes committed Apr 25, 2018
1 parent 02f1c7c commit 3ebaa621ece5b31ad38c6cc4cc6d968aff65c522
View
@@ -53,23 +53,23 @@
mstack=mean(allstacks,4,'omitnan');
mstack=mstack-min(mstack(:),[],'omitnan');
mstack=mstack/nansum(mstack(:));
mstack=mstack/sum(mstack(:),'omitnan');
for k=length(beads):-1:1
stackh=(allstacks(:,:,:,k));
stackh=stackh-min(stackh(:),[],'omitnan');
stackh=stackh/nansum(stackh(:));
stackh=stackh/sum(stackh(:),'omitnan');
dstack(k)=sum((stackh(:)-mstack(:)).^2);
end
dstack=dstack/mean(dstack);
if p.isglobalfit
mstack=mean(allstackst,4,'omitnan');
mstack=mstack-min(mstack(:),[],'omitnan');
mstack=mstack/nansum(mstack(:));
mstack=mstack/sum(mstack(:),'omitnan');
for k=length(beads):-1:1
stackh=(allstackst(:,:,:,k));
stackh=stackh-min(stackh(:),[],'omitnan');
stackh=stackh/nansum(stackh(:));
stackh=stackh/sum(stackh(:),'omitnan');
dstackt(k)=sum((stackh(:)-mstack(:)).^2);
end
dstackt=dstackt/mean(dstackt);
@@ -133,7 +133,7 @@
centpsfr=corrPSFr(rangex,rangey,z-1:z+1); %cut out rim from shift
minPSFr=min(centpsfr(:),[],'omitnan');
corrPSFnr=corrPSFr-minPSFr;
intglobalr=mean(nansum(sum(corrPSFnr(rangex,rangey,z-1:z+1),1),2,'omitnan'),'omitnan');
intglobalr=mean(sum(sum(corrPSFnr(rangex,rangey,z-1:z+1),1,'omitnan'),2,'omitnan'),'omitnan');
corrPSFnr=corrPSFnr/intglobalr;
shiftedstack(1:size(allrois,1),:,:,:)=shiftedstack(1:size(allrois,1),:,:,:)/intglobalr;
corrPSFnr(isnan(corrPSFnr))=0;
View
@@ -39,11 +39,11 @@
mstack=mean(allstacks,4,'omitnan');
mstacks=mstack(3:end-2);
mstack=mstack-min(mstacks(:),[],'omitnan');
mstack=mstack/nansum(mstack(:));
mstack=mstack/sum(mstack(:),'omitnan');
for k=length(beads):-1:1
stackh=(allstacks(:,:,:,k));
stackh=stackh-min(stackh(:),[],'omitnan');
stackh=stackh/nansum(stackh(:));
stackh=stackh/sum(stackh(:),'omitnan');
dstack(k)=sum((stackh(:)-mstack(:)).^2);
end
dstack=dstack/mean(dstack);
@@ -261,7 +261,7 @@
zs(:,k)=P(:,5);
% test for the returned photons and photons in the raw image
% phot=P(:,3); bg=P(:,4);
% totsum=squeeze(nansum( nansum(teststack(range,range,:,k),1),2));
% totsum=squeeze(sum( sum(teststack(range,range,:,k),1,'omitnan'),2,'omitnan'));
% totsum=totsum-squeeze(min(min(teststack(range,range,:,k),[],1),[],2))*length(range)^2;
% photsum=phot+0*bg*length(range)^2;
% plot(ax2,z,(photsum-totsum)./totsum,'.')
@@ -104,7 +104,7 @@
% shiftedstack=zeros(simin(1),simin(2),simin(3),numbeads)+NaN;
%
% for k=1:numbeads
% goodframes=squeeze(nansum(nansum(smallim(:,:,:,k),1),2))>0;
% goodframes=squeeze(sum(sum(smallim(:,:,:,k),1,'omitnan'),2,'omitnan'))>0;
% if p.alignz
% [shift(k,:),cc(k)]=get3Dcorrshift(refim(:,:,goodframes),smallim(:,:,goodframes,k));
% else
@@ -197,7 +197,7 @@
for k=1:numbeads
p.status.String=['calculate shift of individual PSFs: ' num2str(k) ' of ' num2str(numbeads)]; drawnow
goodframes=squeeze(nansum(nansum(smallim(:,:,:,k),1),2))>0;
goodframes=squeeze(sum(sum(smallim(:,:,:,k),1,'omitnan'),2,'omitnan'))>0;
if p.alignz
[shift(k,:),cc(k)]=get3Dcorrshift(refim(:,:,goodframes),smallim(:,:,goodframes,k));
else
@@ -103,7 +103,7 @@
% shiftedstack=zeros(simin(1),simin(2),simin(3),numbeads)+NaN;
%
% for k=1:numbeads
% goodframes=squeeze(nansum(nansum(smallim(:,:,:,k),1),2))>0;
% goodframes=squeeze(sum(sum(smallim(:,:,:,k),1,'omitnan'),2,'omitnan'))>0;
% if p.alignz
% [shift(k,:),cc(k)]=get3Dcorrshift(refim(:,:,goodframes),smallim(:,:,goodframes,k));
% else
@@ -252,7 +252,7 @@
for k=1:numbeads
p.status.String=['calculate shift of individual PSFs: ' num2str(k) ' of ' num2str(numbeads)]; drawnow
goodframes=squeeze(nansum(nansum(smallim(:,:,:,k),1),2))>0;
goodframes=squeeze(sum(sum(smallim(:,:,:,k),1,'omitnan'),2,'omitnan'))>0;
if p.alignz
[shift(k,:),cc(k)]=get3Dcorrshift(refim(:,:,goodframes),smallim(:,:,goodframes,k));
else
View
@@ -8,8 +8,8 @@
return;
end
refim=nansum(refim,3);
targetim=nansum(targetim,3);
refim=sum(refim,3,'omitnan');
targetim=sum(targetim,3,'omitnan');
sim=size(targetim);
% if sim(3)==1 %2D
% G = (fftshift(real(ifft2(fft2(refim).*conj(fft2(targetim))))))/...
View
@@ -140,7 +140,7 @@
% standard deviation
goodIdx = sum(isfinite(res2),dim) > 4;
stdSample = NaN(size(goodIdx));
stdSample(goodIdx)=sqrt(nansum(res2(goodIdx),dim)./(nInliers(goodIdx)-4));
stdSample(goodIdx)=sqrt(sum(res2(goodIdx),dim,'omitnan')./(nInliers(goodIdx)-4));
end
%====END LMS=========

0 comments on commit 3ebaa62

Please sign in to comment.