Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Integrated min peak intensity into dotfinder, changed z-stack method …

…for CheckDotUpDown. Fixed bug in lsmreader which created offset errors
  • Loading branch information...
commit 8400ff2b7f338fc798db777e2a1da81c4c9554a5 1 parent e17fee1
AlistairMobile AlistairMobile authored
120 CheckDotUpDown.m
View
@@ -24,10 +24,6 @@
% use linear indexing of all dots
tic
-
-% intype = 'uint8';
-
-disp('connecting dots in Z...')
% plotdata = 1; h = hs; w = ws; getpreciseZ =1; ovlap = 2; intype = 'uint16';
% DotData = DotData1; Inds = Inds1; Ints = Ints1; DotLabels = DotLabels1;
% DotData1 = DotData; Inds1 = Inds; Ints1 = Ints; DotLabels1 = DotLabels;
@@ -48,7 +44,7 @@
dotzpos{z} = z*ones(dotsinlayer(z),1);
end
dotC = [cell2mat(DotData'), cell2mat(dotzpos)];
- % clear DotData;
+clear DotData;
NDots = length(dotC); % total number of dots;
@@ -60,7 +56,7 @@
% in 2 different data structures. Could build this guy to start
% with.
-
+%% Troubleshooting plots (3D dot scatter)
% figure(10); clf; plot3(dotC(:,1),dotC(:,2),dotC(:,3),'w.');
% % for n=1:NDots
% % z = dotC(n,3);
@@ -88,7 +84,8 @@
% hold on; plot(DotData{21}(:,1),DotData{21}(:,2),'c.');
% hold on; plot(DotData{22}(:,1),DotData{22}(:,2),'b.');
-
+%%
+disp('connecting dots in Z...')
DotConn = zeros(2*NDots,Zs,'single'); % empty connectivity matrix for all dots; as a uint16 restricts this to 65,536 dots per image.
ConnInt = zeros(2*NDots,Zs,intype);
LayerJoin = false(2*NDots,Zs);
@@ -122,8 +119,6 @@
% Iin_z = imreadfast(im_folder{Z});
% I_test = Iin_z(xp1:xp2,yp1:yp2,mRNAchn+1); imagesc(I_test); colorbar; colormap hot;
% hold on; plot(dotC(indsT,1),dotC(indsT,2),'c+');
-
-
DotConn(2*st1_dot_num+1:2:2*(st1_dot_num + dotsinlayer(Z)),z) = indsT; % STORE in DotConn matrix the indices
ConnInt(2*st1_dot_num+1:2:2*(st1_dot_num + dotsinlayer(Z)),z) = Ints{z}(inds_zin1+1); % Ints{z}(inds_zin1+1); ; % % store actual intensities.
@@ -154,18 +149,6 @@
% liny = dotC(nonzeros(DotConn(n,:)),2) ;
% plot(linx,liny,'w');
% end
-
-% for z=1:Zs
-% text(DotData2{z}(:,1),DotData2{z}(:,2),[num2str(z)],'color','w','FontSize',8);
-% % text(DotData1{z}(:,1),DotData1{z}(:,2),[num2str(z)],'color','m','FontSize',8);
-% end
-%
-
-% % Flag specific points of interest.
-% p1 = (1089+1)/2; p2 = (525);
-% figure(2); hold on; plot(dotC(p1,1),dotC(p1,2),'mo','MarkerSize',15);
-% plot(dotC(p2,1),dotC(p2,2),'m*','MarkerSize',15);
-
@@ -232,8 +215,6 @@
labeled = bwlabel(mask);
R = regionprops(labeled,ConnInt_T,'WeightedCentroid');
tcent = reshape([R.WeightedCentroid],2,length(R))';
-
- % cent = [cent; tcent(:,1),(k-1)*stp + tcent(:,2)];
Cent{k} = [tcent(:,1),(k-1)*stp + tcent(:,2)];
if plotdata == 1;
@@ -246,8 +227,8 @@
title('Cross-Section of all dots');
end
end
-
+ % Final output is just DotConn split up by mask
masked_inds(1+(k-1)*stp:min(k*stp,2*NDots),:) = mask.*DotConn(1+(k-1)*stp:min(k*stp,2*NDots),:) ;
%
@@ -256,6 +237,8 @@
end
end
+% figure(3); clf; imagesc(masked_inds); colormap hot;
+
if plotdata == 1
cent = cell2mat(Cent);
end
@@ -266,42 +249,65 @@
%% Troubleshooting
-% tic
-%
% figure(2); clf;
% imagesc(Imax_dots); hold on;
% plot(dotC(:,1),dotC(:,2),'c+');
%%
+
+%% Free up some Memory
+%clear ConnInt_T DotConn LayerJoin mask ConnInt
+%
+
+%% New method for removing duplicates
+
+% masked inds has continuous blocks of connected dots, such that
+% dotC(masked_inds) gives the the x and y coordinates of of the N
+% associated dots with any given mRNA spot.
+
+% we first pulll out these separate clusters, then we loop through strings
+% of dots, comparing them to all other strings of dots, to remove the ones
+% which occur twice.
+
+tic
+disp('Building unique-spheres from cross-section disks...');
+
Linx = cell(NDots,1); Liny = cell(NDots,1);
for n=1:2:2*NDots
- % text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str( (n+1)/2 )],'color','c','FontSize',8);
- % text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str( dotC((n+1)/2,3) )],'color','c','FontSize',8);
Linx{(n+1)/2} = dotC(nonzeros(masked_inds(n,:)),1);
Liny{(n+1)/2} = dotC(nonzeros(masked_inds(n,:)),2);
% % troubleshooting
- %plot(Linx{(n+1)/2},Liny{(n+1)/2},'c');
+ %plot(Linx{(n+1)/2},Liny{(n+1)/2},'c');
+ % text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
end
+%%
-
-% dup = cell(length(Linx),1);
for j=1:length(Linx); % j =1
+ if isempty(Linx{j})==1;
+ continue;
+ end
for k=1:length(Linx) % k =3
- if j~=k
- if isempty(Linx{k})==0 && isempty(Linx{j})==0
- if length(intersect(Linx{k}, Linx{j})) > 3
- % dup{j} = [dup{j},k];
+ if isempty(Linx{k})==1;
+ continue;
+ end
+ if j~=k
+ if (Linx{k}(1) - Linx{j}(1) + Liny{k}(1) - Liny{j}(1))^2 < .01
+ % length(intersect(Linx{k}, Linx{j})) > 1 % this is the slow step
Linx{k} = [];
- % disp('duplicate removed');
+ % disp('duplicate removed');
end
- end
- end
+ end
end
- % unique_ind(j)median(dup{j})
end
-old_dotC = dotC;
-dotC = old_dotC;
-%%
+
+% Convert string of dots to x-y-z of center dot.
+
+% The median x,y position is taken as the true center since true 3D Gaussian
+% fitting is too slow.
+% the z position is either determined from the precise center of mass
+% fitting of the trace if get-preciseZ is active, otherwise it is chosen as
+% the middle of the stack (position where dot is first detected + half).
+
unique_inds = find(~cellfun('isempty',Linx));
unique_dotX = [Linx(~cellfun('isempty',Linx))];
unique_dotY = [Liny( ~cellfun('isempty',Linx))];
@@ -309,9 +315,9 @@
Ndots = length(unique_dotX);
New_dotC = zeros(Ndots,3);
for k =1:Ndots
- phalf = round(Ndots/2);
- New_dotC(k,1) = unique_dotX{k}(phalf);
- New_dotC(k,2) = unique_dotY{k}(phalf);
+ phalf = round(length(unique_dotX{k}/2));
+ New_dotC(k,1) = median(unique_dotX{k}); % unique_dotX{k}(phalf);
+ New_dotC(k,2) = median(unique_dotY{k}); % unique_dotY{k}(phalf);
if plotdata == 1 && getpreciseZ == 1
New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
@@ -320,23 +326,17 @@
end
end
+disp([num2str(Ndots),' total spheres found']);
+
+toc
+
%
% figure(2); clf;
% imagesc(Imax_dots); hold on;
-% plot(New_dotC(:,1),New_dotC(:,2),'c+');
+% plot(dotC(:,1),dotC(:,2),'c+');
+% plot(New_dotC(:,1),New_dotC(:,2),'w.','MarkerSize',30);
-
-%
-% hold on;
-% for z=1:Zs
-% text(DotData2{z}(:,1),DotData2{z}(:,2),[num2str(z)],'color','w','FontSize',8);
-% % text(DotData1{z}(:,1),DotData1{z}(:,2),[num2str(z)],'color','m','FontSize',8);
-% end
-%
-%
-%
-% toc
@@ -346,10 +346,8 @@
-%%
-%clear ConnInt_T DotConn LayerJoin mask ConnInt
-%
-% %% Remove duplicates
+
+%% Old Method to Remove duplicates
%
% tic
% disp('Building spheres from cross-section disks...');
183 CheckDotUpDown.m~
View
@@ -10,7 +10,7 @@
% if getpreciseZ is off, the first layer in which the dot occurs is used as
% the z postion, rather than the brightest layer
-function dotC = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype)
+function New_dotC = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype)
%% Updates
% Rewritten 03/07/11 to convert more things to uint16 / uint8 to save
@@ -24,15 +24,12 @@ function dotC = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,
% use linear indexing of all dots
tic
-
-% intype = 'uint8';
-
-disp('connecting dots in Z...')
% plotdata = 1; h = hs; w = ws; getpreciseZ =1; ovlap = 2; intype = 'uint16';
% DotData = DotData1; Inds = Inds1; Ints = Ints1; DotLabels = DotLabels1;
% DotData1 = DotData; Inds1 = Inds; Ints1 = Ints; DotLabels1 = DotLabels;
% DotData = DotData(mRNAchn,:); Inds = Inds(mRNAchn,:); Ints = Ints(mRNAchn,:); DotLabels = DotLabels(mRNAchn,:);
-
+ % mRNAchn = 2;
+
comp_onVoff = 0;
hs = yp2 - yp1+1;
ws = xp2 - xp1+1;
@@ -47,7 +44,7 @@ for z = 1:Zs
dotzpos{z} = z*ones(dotsinlayer(z),1);
end
dotC = [cell2mat(DotData'), cell2mat(dotzpos)];
-% clear DotData;
+clear DotData;
NDots = length(dotC); % total number of dots;
@@ -59,7 +56,7 @@ disp(['Total dots = ',num2str(NDots)]);
% in 2 different data structures. Could build this guy to start
% with.
-
+%% Troubleshooting plots (3D dot scatter)
% figure(10); clf; plot3(dotC(:,1),dotC(:,2),dotC(:,3),'w.');
% % for n=1:NDots
% % z = dotC(n,3);
@@ -87,7 +84,8 @@ disp(['Total dots = ',num2str(NDots)]);
% hold on; plot(DotData{21}(:,1),DotData{21}(:,2),'c.');
% hold on; plot(DotData{22}(:,1),DotData{22}(:,2),'b.');
-
+%%
+disp('connecting dots in Z...')
DotConn = zeros(2*NDots,Zs,'single'); % empty connectivity matrix for all dots; as a uint16 restricts this to 65,536 dots per image.
ConnInt = zeros(2*NDots,Zs,intype);
LayerJoin = false(2*NDots,Zs);
@@ -121,8 +119,6 @@ for Z = 1:Zs % The primary layer Z = 8
% Iin_z = imreadfast(im_folder{Z});
% I_test = Iin_z(xp1:xp2,yp1:yp2,mRNAchn+1); imagesc(I_test); colorbar; colormap hot;
% hold on; plot(dotC(indsT,1),dotC(indsT,2),'c+');
-
-
DotConn(2*st1_dot_num+1:2:2*(st1_dot_num + dotsinlayer(Z)),z) = indsT; % STORE in DotConn matrix the indices
ConnInt(2*st1_dot_num+1:2:2*(st1_dot_num + dotsinlayer(Z)),z) = Ints{z}(inds_zin1+1); % Ints{z}(inds_zin1+1); ; % % store actual intensities.
@@ -140,8 +136,8 @@ toc
%% Trouble-shooting: Draw lines between connected dots
-
-
+%
+%
figure(1); clf;
Imax = imread([rawfolder,stackfolder,'max_',fname,'_',emb,'.tif']);
Imax_dots = 3*Imax(xp1:xp2,yp1:yp2,1:3);
@@ -153,18 +149,6 @@ for n=1:2*NDots
liny = dotC(nonzeros(DotConn(n,:)),2) ;
plot(linx,liny,'w');
end
-
-% for z=1:Zs
-% text(DotData2{z}(:,1),DotData2{z}(:,2),[num2str(z)],'color','w','FontSize',8);
-% % text(DotData1{z}(:,1),DotData1{z}(:,2),[num2str(z)],'color','m','FontSize',8);
-% end
-%
-
-% % Flag specific points of interest.
-% p1 = (1089+1)/2; p2 = (525);
-% figure(2); hold on; plot(dotC(p1,1),dotC(p1,2),'mo','MarkerSize',15);
-% plot(dotC(p2,1),dotC(p2,2),'m*','MarkerSize',15);
-
@@ -231,8 +215,6 @@ for k=1:Nsects
labeled = bwlabel(mask);
R = regionprops(labeled,ConnInt_T,'WeightedCentroid');
tcent = reshape([R.WeightedCentroid],2,length(R))';
-
- % cent = [cent; tcent(:,1),(k-1)*stp + tcent(:,2)];
Cent{k} = [tcent(:,1),(k-1)*stp + tcent(:,2)];
if plotdata == 1;
@@ -245,8 +227,8 @@ for k=1:Nsects
title('Cross-Section of all dots');
end
end
-
+ % Final output is just DotConn split up by mask
masked_inds(1+(k-1)*stp:min(k*stp,2*NDots),:) = mask.*DotConn(1+(k-1)*stp:min(k*stp,2*NDots),:) ;
%
@@ -255,6 +237,8 @@ for k=1:Nsects
end
end
+% figure(3); clf; imagesc(masked_inds); colormap hot;
+
if plotdata == 1
cent = cell2mat(Cent);
end
@@ -265,81 +249,94 @@ toc
%% Troubleshooting
-% tic
+% figure(2); clf;
+% imagesc(Imax_dots); hold on;
+% plot(dotC(:,1),dotC(:,2),'c+');
+
+%%
+
+%% Free up some Memory
+%clear ConnInt_T DotConn LayerJoin mask ConnInt
%
-figure(2); clf;
-imagesc(Imax_dots); hold on;
-plot(dotC(:,1),dotC(:,2),'c+');
+%% New method for removing duplicates
-Linx = cell(NDots,1); Liny = cell(NDots,1);
+% masked inds has continuous blocks of connected dots, such that
+% dotC(masked_inds) gives the the x and y coordinates of of the N
+% associated dots with any given mRNA spot.
+
+% we first pulll out these separate clusters, then we loop through strings
+% of dots, comparing them to all other strings of dots, to remove the ones
+% which occur twice.
+
+tic
+disp('Building unique-spheres from cross-section disks...');
+Linx = cell(NDots,1); Liny = cell(NDots,1);
for n=1:2:2*NDots
- % text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str( (n+1)/2 )],'color','c','FontSize',8);
- text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str( dotC((n+1)/2,3) )],'color','c','FontSize',8);
Linx{(n+1)/2} = dotC(nonzeros(masked_inds(n,:)),1);
Liny{(n+1)/2} = dotC(nonzeros(masked_inds(n,:)),2);
% % troubleshooting
- %plot(Linx{(n+1)/2},Liny{(n+1)/2},'c');
+ %plot(Linx{(n+1)/2},Liny{(n+1)/2},'c');
+ % text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
end
-
%%
-% dup = cell(length(Linx),1);
+
for j=1:length(Linx); % j =1
+ if isempty(Linx{j})==1;
+ continue;
+ end
for k=1:length(Linx) % k =3
- if j~=k
- if isempty(Linx{k})==0 && isempty(Linx{j})==0
- if length(intersect(Linx{k}, Linx{j})) > 3
- % dup{j} = [dup{j},k];
+ if isempty(Linx{k})==1;
+ continue;
+ end
+ if j~=k
+ if (Linx{k}(1) - Linx{j}(1) + Liny{k}(1) - Liny{j}(1))^2 < 1
+ % length(intersect(Linx{k}, Linx{j})) > 1 % this is the slow step
Linx{k} = [];
- % disp('duplicate removed');
+ % disp('duplicate removed');
end
- end
- end
+ end
end
- % unique_ind(j)median(dup{j})
end
-old_dotC = dotC;
-dotC = old_dotC;
-%%
+
+% Convert string of dots to x-y-z of center dot.
+
+% The median x,y position is taken as the true center since true 3D Gaussian
+% fitting is too slow.
+% the z position is either determined from the precise center of mass
+% fitting of the trace if get-preciseZ is active, otherwise it is chosen as
+% the middle of the stack (position where dot is first detected + half).
+
unique_inds = find(~cellfun('isempty',Linx));
-unique_dotX = [Linx(~cellfun('isempty',Linx))]
-unique_dotY = [Liny( ~cellfun('isempty',Linx))]
+unique_dotX = [Linx(~cellfun('isempty',Linx))];
+unique_dotY = [Liny( ~cellfun('isempty',Linx))];
Ndots = length(unique_dotX);
-
+New_dotC = zeros(Ndots,3);
for k =1:Ndots
- phalf = round(Ndots/2);
- new_dotC(k,1) = unique_dotX{k}(phalf);
- new_dotC(k,2) = unique_dotY{k}(phalf);
+ phalf = round(length(unique_dotX{k}/2));
+ New_dotC(k,1) = median(unique_dotX{k}); % unique_dotX{k}(phalf);
+ New_dotC(k,2) = median(unique_dotY{k}); % unique_dotY{k}(phalf);
- if getpreciseZ == 1
- zF = cent(cent(:,2) == unique_inds(k),1);
+ if plotdata == 1 && getpreciseZ == 1
+ New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
else
- zF = dotC(unique_inds(k),3) + phalf;
+ New_dotC(k,3) = dotC(unique_inds(k),3) + phalf;
end
-
-%cent(~cellfun('isempty',Linx),1)
-xF = dotC(~cellfun('isempty',Linx),1)
-yF = dotC(~cellfun('isempty',Linx),2)
-dotC(~cellfun('isempty',Linx),3)
+end
+
+disp([num2str(Ndots),' total spheres found']);
+
+toc
+%
figure(2); clf;
imagesc(Imax_dots); hold on;
-plot(xF,yF,'c+');
+plot(dotC(:,1),dotC(:,2),'c+');
+plot(New_dotC(:,1),New_dotC(:,2),'w.','MarkerSize',30);
-
-%
-% hold on;
-% for z=1:Zs
-% text(DotData2{z}(:,1),DotData2{z}(:,2),[num2str(z)],'color','w','FontSize',8);
-% % text(DotData1{z}(:,1),DotData1{z}(:,2),[num2str(z)],'color','m','FontSize',8);
-% end
-%
-%
-%
-% toc
@@ -349,10 +346,8 @@ plot(xF,yF,'c+');
-%%
-%clear ConnInt_T DotConn LayerJoin mask ConnInt
-%
-% %% Remove duplicates
+
+%% Old Method to Remove duplicates
%
% tic
% disp('Building spheres from cross-section disks...');
@@ -433,21 +428,21 @@ plot(xF,yF,'c+');
%%
-%New_dotC = dotC(~remove_dot,:);
-dotC = dotC(~remove_dot,:);
-[N_dots, jnk] = size(dotC);
-%N_dots = NDots - sum(remove_dot) % sum(stacked_dots)
-%N_dots = length(New_dotC);
-disp(['Counted ',num2str(N_dots),' spheres']);
-
-
-
-if comp_onVoff == 1
- figure(7); clf; subplot(2,1,1);
- hist(log(nonzeros(masked_ints(~remove_dot,:)))); title('intensities of kept dots');
- subplot(2,1,2);
- hist(log(nonzeros(masked_ints(logical(remove_dot),:)))); title('intensities of removed dots');
-end
+% %New_dotC = dotC(~remove_dot,:);
+% dotC = dotC(~remove_dot,:);
+% [N_dots, jnk] = size(dotC);
+% %N_dots = NDots - sum(remove_dot) % sum(stacked_dots)
+% %N_dots = length(New_dotC);
+% disp(['Counted ',num2str(N_dots),' spheres']);
+%
+%
+%
+% if comp_onVoff == 1
+% figure(7); clf; subplot(2,1,1);
+% hist(log(nonzeros(masked_ints(~remove_dot,:)))); title('intensities of kept dots');
+% subplot(2,1,2);
+% hist(log(nonzeros(masked_ints(logical(remove_dot),:)))); title('intensities of removed dots');
+% end
53 Unsupervised_DotFinding.m
View
@@ -8,12 +8,12 @@
tot_time = tic;
% Input options
-old_lab = 0; Es = 0; ver = ''; % '_v4'; % '_v3';% '_v2';
+old_lab = 0; Es = 0; ver = '';
folder = '/home/alistair/Documents/Research/Projects/mRNA_counting/Data/2011-05-22/'; %2011-06-20/'; % 2011-04_and_earlier/'; % % 2011-05-22/'; % 2011-06-20/'; % '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/';
rawfolder = '/home/alistair/Documents/Research/Raw_Data_Temp/2011-05-22/'; %2011-06-20/'; % 2011-04_and_earlier/'; %'; % 2011-06-20/'; % '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %% %
-
-stackfolder = 's07_MP08/'; % 's07_MP05Hz/';% 's04_MP10/';% 'MP07Hz/'; % 'MP12Hz/'; % 's05_MP06/';% 's02_MP01/';% 's01_MP09/';% 'sna2.8Hz/' ;%'s06_MP10_sna18/'; %'s21_MP07/';% 'MP07Hz/';% 's11_G4B/' % 's06_MP10_sna18/'; % %'s10_bcd1x/';% 's11_bcd6x/'; %'s14_comp_cntrl/'; % 's12_cntrl_2label/'; %'MP02_22C/'; %'MP01_22C/'; % 'MGa1x/'; % 'MP10_22C/'; %'MP05_22C/'; %'YW_ths_sog/'; % 'MP10_22C/'; % % 'MP09_22C/'; % 'MGa2x/'; % 'MGa1x/'; % 'MGa2x/'; % 'MP10_22C_sna_y_c/'; %
-fname = 'MP08Hz_snaD_22C_b'; % 's07_MP05Hz_22C'; ver = '_v2'; % 'MP10Hz_c'; %'MP07Hz_snaD_22C_b' ; ver = '_v3';% 'MP12Hz_snaD_22C_b'; % 's04_MP10Hz'; % 's05_MP06Hz_b';% 's02_MP01_Hz_22C_b'; % 's01_MP09_Hz_22C_c'; %'sna2.8Hz_snaD_22C'; % 's06_MP10_sna18_b'; % 'MP07het_snaD_22C'; % 'MP07Hz_snaD_22C';%'s11_G4B_LacZ';% 's06_MP10_sna18_b'; % 's05_MP06Hz'; % %'s10_bcd1x';% 's11_bcd6x'; % 's14_comp_cntrl'; Es =1; % 's12_cntrl_2label'; Es = 1; % 'MP09_22C_hb_y_f'; Es = 7; % 'MP02_22C_hb_y'; Es = 9; % 'MP02_22C_hb_y_b'; Es = 10; % % 'MP01_22C_hb_y_f'; Es = 12; % 'MP01_22C_hb_y_c'; Es = 10; % 'MP01_22C_hb_y'; Es = 13; % 'MGa1x_LacZ_b'; Es = 12; % 'MP10_22C_sna_y_e'; Es = 12; % 'MP05_22C_sna_y_c'; Es =7; % 'MP10_22C_sna_y_d3'; Es = 1; %'YW_ths_sog'; Es = 12; % % 'MP09_22C_hb_y_e'; Es = 10; % 'MP09_22C_hb_y_d'; Es=11; % 'MGa2x_LacZ_sna_b'; Es = 10; % 'MP10_22C_sna_y_d'; % 'MGa_LacZ'; %'MGa2x_LacZ_sna'; %'MP10_22C_sna_y_c'; old_lab = 1; % 'MP05_22C_sna_y'; old_lab = 1; %
+rawfolder = '/media/GRAID/Raw_Data/2011-05-22/'
+stackfolder = 's05_MP06/';% 's07_MP08/'; % 's07_MP05Hz/';% 's04_MP10/';% 'MP07Hz/'; % 'MP12Hz/'; % 's02_MP01/';% 's01_MP09/';% 'sna2.8Hz/' ;%'s06_MP10_sna18/'; %'s21_MP07/';% 'MP07Hz/';% 's11_G4B/' % 's06_MP10_sna18/'; % %'s10_bcd1x/';% 's11_bcd6x/'; %'s14_comp_cntrl/'; % 's12_cntrl_2label/'; %'MP02_22C/'; %'MP01_22C/'; % 'MGa1x/'; % 'MP10_22C/'; %'MP05_22C/'; %'YW_ths_sog/'; % 'MP10_22C/'; % % 'MP09_22C/'; % 'MGa2x/'; % 'MGa1x/'; % 'MGa2x/'; % 'MP10_22C_sna_y_c/'; %
+fname = 's05_MP06Hz_b', ver = '_v3'% 'MP08Hz_snaD_22C_b'; % 's07_MP05Hz_22C'; ver = '_v2'; % 'MP10Hz_c'; %'MP07Hz_snaD_22C_b' ; ver = '_v3';% 'MP12Hz_snaD_22C_b'; % 's04_MP10Hz'; % 's02_MP01_Hz_22C_b'; % 's01_MP09_Hz_22C_c'; %'sna2.8Hz_snaD_22C'; % 's06_MP10_sna18_b'; % 'MP07het_snaD_22C'; % 'MP07Hz_snaD_22C';%'s11_G4B_LacZ';% 's06_MP10_sna18_b'; % 's05_MP06Hz'; % %'s10_bcd1x';% 's11_bcd6x'; % 's14_comp_cntrl'; Es =1; % 's12_cntrl_2label'; Es = 1; % 'MP09_22C_hb_y_f'; Es = 7; % 'MP02_22C_hb_y'; Es = 9; % 'MP02_22C_hb_y_b'; Es = 10; % % 'MP01_22C_hb_y_f'; Es = 12; % 'MP01_22C_hb_y_c'; Es = 10; % 'MP01_22C_hb_y'; Es = 13; % 'MGa1x_LacZ_b'; Es = 12; % 'MP10_22C_sna_y_e'; Es = 12; % 'MP05_22C_sna_y_c'; Es =7; % 'MP10_22C_sna_y_d3'; Es = 1; %'YW_ths_sog'; Es = 12; % % 'MP09_22C_hb_y_e'; Es = 10; % 'MP09_22C_hb_y_d'; Es=11; % 'MGa2x_LacZ_sna_b'; Es = 10; % 'MP10_22C_sna_y_d'; % 'MGa_LacZ'; %'MGa2x_LacZ_sna'; %'MP10_22C_sna_y_c'; old_lab = 1; % 'MP05_22C_sna_y'; old_lab = 1; %
mRNA_channels = 2;% 2; % 3; % 1; % total mRNA channels
sname = fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide.
@@ -36,18 +36,18 @@
Es = length(fields(Datas)) - 3; % Number of Stacks
end
% ------- Option: Focus on subset of image: ------------------- %
-% m = 1/2048; % .9;% .7; % .5; .7; % 1/2048; %
-% xp1= floor(h/2*m)+1; xp2 = floor(h/2*(2-m))+1; yp1 = floor(w/2*m)+1; yp2 = floor(w/2*(2-m))+1;
-% hs = yp2-yp1+1; ws = xp2-xp1+1;
+ m = 1/2048; % .7; % .5; .7; % 1/2048; %
+ xp1= floor(h/2*m)+1; xp2 = floor(h/2*(2-m))+1; yp1 = floor(w/2*m)+1; yp2 = floor(w/2*(2-m))+1;
+ hs = yp2-yp1+1; ws = xp2-xp1+1;
-ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
-xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1;
+% ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
+% xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1;
disp(['Coordinates: ', num2str(xp1), ' : ', num2str(xp2), ', ' num2str(yp1), ' : ', num2str(yp2) ] );
% ------------------------------------------------------------- %
% -------------- Graphing and Display Options ------------------ %
- show_projected = 0; % show max-project with all dots and linked dots.
+ show_projected = 1; % show max-project with all dots and linked dots.
plotdata = 0; % CheckDotUpDown display parameter
plotZdata = 0 ;% show z-map of data
showhist = 1; % show histogram of mRNA counts per cell.
@@ -62,14 +62,17 @@
% dotfinder's parameters
sigmaE = 3;% IMPORTANT
sigmaI = 4; % IMPORTANT
- % min_int = 0.04; % 5 ;% .05 % not necessary Fix at Zero
+ min_int = 0.04; % 5 ;% .05 % not necessary Fix at Zero
FiltSize = 30;%
min_size = 30;%
+ min_peak = 600; %
% sphere finding parameters
getpreciseZ = 0;
- % consec_layers = 3;
- ovlap = 4;
+ consec_layers = 3;
+ ovlap = 2;
+ % large ovlap yields confusing dots and then watershed splits these up
+ % in weird dot-distructive ways
%---------------------------------%
@@ -81,7 +84,7 @@
disp('Running DotFinder1');
%%
-for e= 12:Es
+for e= 1:Es
%%
disp('loading data...');
tic
@@ -91,7 +94,7 @@
else
emb = num2str(e);
end
- disp(['analyzing embryo, ',emb,'...']);
+
try load([rawfolder,stackfolder,fname,'_',emb,'_nucdata.mat']);
@@ -114,21 +117,11 @@
end
toc
-
+ disp(['analyzing embryo, ',emb,'...']);
for mRNAchn = 1:mRNA_channels % mRNAchn =2
- if mRNAchn == 1;
- min_int = 0.05; % just for speed
- consec_layers = 3;
- elseif mRNAchn == 2
- min_int = 0.02; %
- consec_layers = 3;
- elseif mRNAchn == 3
- min_int = .01;
- consec_layers = 3;
- end
-
+
DotLabels= cell(1,Zs);
DotData = cell(1,Zs);
Inds = cell(1,Zs);
@@ -140,7 +133,7 @@
im_folder{z} = [rawfolder,stackfolder,fname,'_',emb,'_z',num2str(z),'.tif'];
try
Iin_z = imreadfast(im_folder{z});
- [DotLabels{z},DotData{z},Inds{z},Ints{z}] = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size);
+ [DotLabels{z},DotData{z},Inds{z},Ints{z}] = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size,min_peak);
catch err
disp(err.message);
Zs = z-1;
@@ -174,7 +167,7 @@
Imax_dots = Imax(xp1:xp2,yp1:yp2,mRNAchn);
figure(2);
- Iout = figure(2); clf; imagesc(Imax_dots);
+ Iout = figure(2); clf; imagesc(Imax_dots); colorbar;
colordef black; set(gcf,'color','k');
colormap hot; hold on;
plot( dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
@@ -219,7 +212,7 @@
mRNA_den = zeros(1,Nnucs); % store densities of mRNA per cell
nuc_area = zeros(1,Nnucs);
if showim == 1
- Plot_mRNA = single(NucLabeled);
+ Plot_mRNA = single(NucLabel);
end
for i=1:Nnucs; % i = 4
nn = Nucs_list(i);
57 Unsupervised_DotFinding.m~
View
@@ -8,12 +8,12 @@ clear all;
tot_time = tic;
% Input options
-old_lab = 0; Es = 0; ver = ''; % '_v4'; % '_v3';% '_v2';
-folder = '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/mRNA_counting/Data/2011-05-22/'; %2011-06-20/'; % 2011-04_and_earlier/'; % % 2011-05-22/'; % 2011-06-20/'; % '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/';
-rawfolder = '/Volumes/Data/Lab Data/Raw_Data/2011-06-20/'; % 2011-04_and_earlier/'; %'; % 2011-06-20/'; % '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %% %
-
-stackfolder = 's07_MP08/'; % 's07_MP05Hz/';% 's04_MP10/';% 'MP07Hz/'; % 'MP12Hz/'; % 's05_MP06/';% 's02_MP01/';% 's01_MP09/';% 'sna2.8Hz/' ;%'s06_MP10_sna18/'; %'s21_MP07/';% 'MP07Hz/';% 's11_G4B/' % 's06_MP10_sna18/'; % %'s10_bcd1x/';% 's11_bcd6x/'; %'s14_comp_cntrl/'; % 's12_cntrl_2label/'; %'MP02_22C/'; %'MP01_22C/'; % 'MGa1x/'; % 'MP10_22C/'; %'MP05_22C/'; %'YW_ths_sog/'; % 'MP10_22C/'; % % 'MP09_22C/'; % 'MGa2x/'; % 'MGa1x/'; % 'MGa2x/'; % 'MP10_22C_sna_y_c/'; %
-fname = 'MP08Hz_snaD_22C_b'; % 's07_MP05Hz_22C'; ver = '_v2'; % 'MP10Hz_c'; %'MP07Hz_snaD_22C_b' ; ver = '_v3';% 'MP12Hz_snaD_22C_b'; % 's04_MP10Hz'; % 's05_MP06Hz_b';% 's02_MP01_Hz_22C_b'; % 's01_MP09_Hz_22C_c'; %'sna2.8Hz_snaD_22C'; % 's06_MP10_sna18_b'; % 'MP07het_snaD_22C'; % 'MP07Hz_snaD_22C';%'s11_G4B_LacZ';% 's06_MP10_sna18_b'; % 's05_MP06Hz'; % %'s10_bcd1x';% 's11_bcd6x'; % 's14_comp_cntrl'; Es =1; % 's12_cntrl_2label'; Es = 1; % 'MP09_22C_hb_y_f'; Es = 7; % 'MP02_22C_hb_y'; Es = 9; % 'MP02_22C_hb_y_b'; Es = 10; % % 'MP01_22C_hb_y_f'; Es = 12; % 'MP01_22C_hb_y_c'; Es = 10; % 'MP01_22C_hb_y'; Es = 13; % 'MGa1x_LacZ_b'; Es = 12; % 'MP10_22C_sna_y_e'; Es = 12; % 'MP05_22C_sna_y_c'; Es =7; % 'MP10_22C_sna_y_d3'; Es = 1; %'YW_ths_sog'; Es = 12; % % 'MP09_22C_hb_y_e'; Es = 10; % 'MP09_22C_hb_y_d'; Es=11; % 'MGa2x_LacZ_sna_b'; Es = 10; % 'MP10_22C_sna_y_d'; % 'MGa_LacZ'; %'MGa2x_LacZ_sna'; %'MP10_22C_sna_y_c'; old_lab = 1; % 'MP05_22C_sna_y'; old_lab = 1; %
+old_lab = 0; Es = 0; ver = '';
+folder = '/home/alistair/Documents/Research/Projects/mRNA_counting/Data/2011-05-22/'; %2011-06-20/'; % 2011-04_and_earlier/'; % % 2011-05-22/'; % 2011-06-20/'; % '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/';
+rawfolder = '/home/alistair/Documents/Research/Raw_Data_Temp/2011-05-22/'; %2011-06-20/'; % 2011-04_and_earlier/'; %'; % 2011-06-20/'; % '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %% %
+rawfolder = '/media/GRAID/Raw_Data/2011-05-22/'
+stackfolder = 's05_MP06/';% 's07_MP08/'; % 's07_MP05Hz/';% 's04_MP10/';% 'MP07Hz/'; % 'MP12Hz/'; % 's02_MP01/';% 's01_MP09/';% 'sna2.8Hz/' ;%'s06_MP10_sna18/'; %'s21_MP07/';% 'MP07Hz/';% 's11_G4B/' % 's06_MP10_sna18/'; % %'s10_bcd1x/';% 's11_bcd6x/'; %'s14_comp_cntrl/'; % 's12_cntrl_2label/'; %'MP02_22C/'; %'MP01_22C/'; % 'MGa1x/'; % 'MP10_22C/'; %'MP05_22C/'; %'YW_ths_sog/'; % 'MP10_22C/'; % % 'MP09_22C/'; % 'MGa2x/'; % 'MGa1x/'; % 'MGa2x/'; % 'MP10_22C_sna_y_c/'; %
+fname = 's05_MP06Hz_b', ver = '_v3'% 'MP08Hz_snaD_22C_b'; % 's07_MP05Hz_22C'; ver = '_v2'; % 'MP10Hz_c'; %'MP07Hz_snaD_22C_b' ; ver = '_v3';% 'MP12Hz_snaD_22C_b'; % 's04_MP10Hz'; % 's02_MP01_Hz_22C_b'; % 's01_MP09_Hz_22C_c'; %'sna2.8Hz_snaD_22C'; % 's06_MP10_sna18_b'; % 'MP07het_snaD_22C'; % 'MP07Hz_snaD_22C';%'s11_G4B_LacZ';% 's06_MP10_sna18_b'; % 's05_MP06Hz'; % %'s10_bcd1x';% 's11_bcd6x'; % 's14_comp_cntrl'; Es =1; % 's12_cntrl_2label'; Es = 1; % 'MP09_22C_hb_y_f'; Es = 7; % 'MP02_22C_hb_y'; Es = 9; % 'MP02_22C_hb_y_b'; Es = 10; % % 'MP01_22C_hb_y_f'; Es = 12; % 'MP01_22C_hb_y_c'; Es = 10; % 'MP01_22C_hb_y'; Es = 13; % 'MGa1x_LacZ_b'; Es = 12; % 'MP10_22C_sna_y_e'; Es = 12; % 'MP05_22C_sna_y_c'; Es =7; % 'MP10_22C_sna_y_d3'; Es = 1; %'YW_ths_sog'; Es = 12; % % 'MP09_22C_hb_y_e'; Es = 10; % 'MP09_22C_hb_y_d'; Es=11; % 'MGa2x_LacZ_sna_b'; Es = 10; % 'MP10_22C_sna_y_d'; % 'MGa_LacZ'; %'MGa2x_LacZ_sna'; %'MP10_22C_sna_y_c'; old_lab = 1; % 'MP05_22C_sna_y'; old_lab = 1; %
mRNA_channels = 2;% 2; % 3; % 1; % total mRNA channels
sname = fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide.
@@ -36,18 +36,18 @@ if Es==0
Es = length(fields(Datas)) - 3; % Number of Stacks
end
% ------- Option: Focus on subset of image: ------------------- %
-% m = 1/2048; % .9;% .7; % .5; .7; % 1/2048; %
-% xp1= floor(h/2*m)+1; xp2 = floor(h/2*(2-m))+1; yp1 = floor(w/2*m)+1; yp2 = floor(w/2*(2-m))+1;
-% hs = yp2-yp1+1; ws = xp2-xp1+1;
+ m = .9;% 1/2048; % .7; % .5; .7; % 1/2048; %
+ xp1= floor(h/2*m)+1; xp2 = floor(h/2*(2-m))+1; yp1 = floor(w/2*m)+1; yp2 = floor(w/2*(2-m))+1;
+ hs = yp2-yp1+1; ws = xp2-xp1+1;
-ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
-xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1;
+% ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
+% xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1;
disp(['Coordinates: ', num2str(xp1), ' : ', num2str(xp2), ', ' num2str(yp1), ' : ', num2str(yp2) ] );
% ------------------------------------------------------------- %
% -------------- Graphing and Display Options ------------------ %
- show_projected = 0; % show max-project with all dots and linked dots.
+ show_projected = 1; % show max-project with all dots and linked dots.
plotdata = 0; % CheckDotUpDown display parameter
plotZdata = 0 ;% show z-map of data
showhist = 1; % show histogram of mRNA counts per cell.
@@ -62,14 +62,17 @@ disp(['Coordinates: ', num2str(xp1), ' : ', num2str(xp2), ', ' num2str(yp1),
% dotfinder's parameters
sigmaE = 3;% IMPORTANT
sigmaI = 4; % IMPORTANT
- % min_int = 0.04; % 5 ;% .05 % not necessary Fix at Zero
+ min_int = 0.04; % 5 ;% .05 % not necessary Fix at Zero
FiltSize = 30;%
min_size = 30;%
+ min_peak = 600; %
% sphere finding parameters
getpreciseZ = 0;
- % consec_layers = 3;
- ovlap = 4;
+ consec_layers = 3;
+ ovlap = 2;
+ % large ovlap yields confusing dots and then watershed splits these up
+ % in weird dot-distructive ways
%---------------------------------%
@@ -81,7 +84,7 @@ disp(['Coordinates: ', num2str(xp1), ' : ', num2str(xp2), ', ' num2str(yp1),
disp('Running DotFinder1');
%%
-for e= 12:Es
+for e= 1:Es
%%
disp('loading data...');
tic
@@ -91,7 +94,7 @@ disp('loading data...');
else
emb = num2str(e);
end
- disp(['analyzing embryo, ',emb,'...']);
+
try load([rawfolder,stackfolder,fname,'_',emb,'_nucdata.mat']);
@@ -114,21 +117,11 @@ disp('loading data...');
end
toc
-
+ disp(['analyzing embryo, ',emb,'...']);
for mRNAchn = 1:mRNA_channels % mRNAchn =2
- if mRNAchn == 1;
- min_int = 0.05; % just for speed
- consec_layers = 3;
- elseif mRNAchn == 2
- min_int = 0.02; %
- consec_layers = 3;
- elseif mRNAchn == 3
- min_int = .01;
- consec_layers = 3;
- end
-
+
DotLabels= cell(1,Zs);
DotData = cell(1,Zs);
Inds = cell(1,Zs);
@@ -140,7 +133,7 @@ disp('loading data...');
im_folder{z} = [rawfolder,stackfolder,fname,'_',emb,'_z',num2str(z),'.tif'];
try
Iin_z = imreadfast(im_folder{z});
- [DotLabels{z},DotData{z},Inds{z},Ints{z}] = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size);
+ [DotLabels{z},DotData{z},Inds{z},Ints{z}] = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size,min_peak);
catch err
disp(err.message);
Zs = z-1;
@@ -174,7 +167,7 @@ disp('loading data...');
Imax_dots = Imax(xp1:xp2,yp1:yp2,mRNAchn);
figure(2);
- Iout = figure(2); clf; imagesc(Imax_dots);
+ Iout = figure(2); clf; imagesc(Imax_dots); colorbar;
colordef black; set(gcf,'color','k');
colormap hot; hold on;
plot( dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
@@ -219,7 +212,7 @@ disp('loading data...');
mRNA_den = zeros(1,Nnucs); % store densities of mRNA per cell
nuc_area = zeros(1,Nnucs);
if showim == 1
- Plot_mRNA = single(NucLabeled);
+ Plot_mRNA = single(NucLabel);
end
for i=1:Nnucs; % i = 4
nn = Nucs_list(i);
8 jacquestiffread.m
View
@@ -131,6 +131,8 @@
switch TIF.entry_tag
case 254
TIF.NewSubfiletype = entry.val;
+
+
case 256 % image width - number of column
IMG.width = entry.val;
@@ -212,7 +214,7 @@
Data.LSM_info=LSM_info;
-numberofstacks = round((count-2)/Data.LSM_info.DimensionZ);
+numberofstacks = (count-1)/Data.LSM_info.DimensionZ;
for i =1:numberofstacks
for j=1:Data.LSM_info.DimensionZ
@@ -231,7 +233,7 @@
save(filenameout,'Datas');
disp('data saved');
-fclose(TIF.file)
+fclose(TIF.file);
end
@@ -336,7 +338,7 @@
end
- entry.val(i)= entry.val(i)+TEMPDat.counterr*(2^32-1);
+ entry.val(i)= entry.val(i)+TEMPDat.counterr*(2^32);
TEMPDat.pastposi=entryvaltemp(i);
10 jacquestiffread.m~
View
@@ -131,6 +131,8 @@ while TIF.img_pos ~= 0
switch TIF.entry_tag
case 254
TIF.NewSubfiletype = entry.val;
+
+
case 256 % image width - number of column
IMG.width = entry.val;
@@ -212,7 +214,7 @@ end
Data.LSM_info=LSM_info;
-numberofstacks = round((count-2)/Data.LSM_info.DimensionZ);
+numberofstacks = (count-1)/Data.LSM_info.DimensionZ;
for i =1:numberofstacks
for j=1:Data.LSM_info.DimensionZ
@@ -231,7 +233,7 @@ Datas.TEMPDat = TIF.TEMPDat;
save(filenameout,'Datas');
disp('data saved');
-fclose(TIF.file)
+fclose(TIF.file);
end
@@ -342,9 +344,9 @@ else
end
+ TEMPDat.entryval = entry.val; % Added export for troubleshooting
TIF.TEMPDat=TEMPDat;
- Datas.TEMPDat=TEMPDat;
-
+
else
Please sign in to comment.
Something went wrong with that request. Please try again.