Skip to content
Browse files

Fixed bug in find unique dots for CheckDotUpDown.m

  • Loading branch information...
1 parent a88c96e commit c9ec920fb79775f633572784f52ed952e9325e46 @AlistairBoettiger committed Nov 29, 2011
Showing with 43 additions and 37 deletions.
  1. +31 −25 CheckDotUpDown.m
  2. +12 −12 Unsupervised_DotFinding3.m
View
56 CheckDotUpDown.m
@@ -291,8 +291,8 @@
Linx = cell(NDots,1); Liny = cell(NDots,1); Lind = cell(NDots,1);
for n=1:2:2*NDots
- Linx{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),1)',0,0,0]; % trailing zero prevents cellfun error
- Liny{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),2)',0,0,0];
+ Linx{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),1)',NaN,NaN,NaN]; % trailing zero prevents cellfun error
+ Liny{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),2)',NaN,NaN,NaN];
Lind{(n+1)/2} = (n+1)/2; % [nonzeros(masked_inds(n,:))',0,0,0]; % must be a non-loop way to do this
end
%
@@ -302,30 +302,36 @@
if isempty(UL) == 0
- UL = UL(UL(:,1)>0,:); % remove all empty values
- % unique_inds = UL(:,7);
- [~,ui] = unique([UL(:,1);UL(:,2);UL(:,3)]);
- ULi = [UL(:,7);UL(:,7);UL(:,7)];
- unique_inds = ULi(ui);
-unique_dotX = Linx(unique_inds);
-unique_dotY = Liny(unique_inds);
-
-Ndots = length(unique_dotX);
-New_dotC = zeros(Ndots,3);
-for k =1:Ndots
- phalf = round(length((unique_dotX{k})-3)/2);
- %New_dotC(k,1) = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
- %New_dotC(k,2) = unique_dotY{k}(phalf); %median(unique_dotY{k}); %
-
- New_dotC(k,1) = median(unique_dotX{k}(1:end-3)); %
- New_dotC(k,2) = median(unique_dotY{k}(1:end-3)); %
-
- if plotdata == 1 && getpreciseZ == 1
- New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
- else
- New_dotC(k,3) = dotC(unique_inds(k),3) + phalf;
+ UL = UL(~isnan(UL(:,1)),:); % remove all empty values
+ UL(isnan(UL(:,3)),3) = 0;
+
+ max_clusters = length(UL);
+ ULcat = [[UL(:,1)+UL(:,4);UL(:,2)+UL(:,5);UL(:,3)+UL(:,6)],[UL(:,7);UL(:,7);UL(:,7)]];
+ [~,ui] = unique(ULcat(:,1)); % find unique values
+ ui = ui(ui<max_clusters); % only want indices corresponding to original clusters
+
+ unique_inds = ULcat(ui,2); % take the cluster indices from the set of unique clusters
+ unique_dotX = Linx(unique_inds);
+ unique_dotY = Liny(unique_inds);
+
+ Ndots = length(unique_dotX);
+ New_dotC = zeros(Ndots,3);
+ for k =1:Ndots
+ phalf = floor(length((unique_dotX{k})-3)/2);
+ New_dotC(k,1) = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
+ New_dotC(k,2) = unique_dotY{k}(phalf); %median(unique_dotY{k}); %
+
+ % [New_dotC(k,1),idx] = mymedian(unique_dotX{k}(1:end-3)); %
+ % % if isempty(idx)~=0
+ % New_dotC(k,2) = unique_dotY{k}(idx(1)); %
+ % % end
+
+ if plotdata == 1 && getpreciseZ == 1
+ New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
+ else
+ New_dotC(k,3) = dotC(unique_inds(k),3) + phalf;
+ end
end
-end
else
Ndots = 0;
View
24 Unsupervised_DotFinding3.m
@@ -10,14 +10,13 @@
% Input options
old_lab = 0; Es = 0; ver = '';
-folder = 'C:\Users\Alistair\My Documents\Projects\mRNA_counting\Data\2011-04_and_earlier/'; %2011-06-20/'; % 2011-04_and_earlier/'; % % 2011-05-22/'; % 2011-06-20/'; % '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/';
+folder = 'C:\Users\Alistair\My Documents\Projects\mRNA_counting\Data\2011-11\';%2011-04_and_earlier/'; %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 = 'G:2011-04_and_earlier/'
-stackfolder = 'MP07Hz/';% '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 = 'MP07Hz_snaD_22C_b', ver = '_vN' % '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; %
-
+%rawfolder = 'G:\2011-04_and_earlier/'
+rawfolder = 'C:\Users\alistair\Data\2011-11\';%
+stackfolder = ''; %'MP07Hz/';% '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 = 'MP05';%'MP07Hz_snaD_22C'; ver = '_vN' % '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.
@@ -38,7 +37,7 @@
Es = length(fields(Datas)) - 3; % Number of Stacks
end
% ------- Option: Focus on subset of image: ------------------- %
- m = 1/2048; % .7; % .5; .7; % 1/2048; %
+ m = 1/2048; % .98; % .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;
@@ -73,7 +72,7 @@
% sphere finding parameters
getpreciseZ = 0;
consec_layers = 2;
- ovlap = 2;
+ ovlap = 1;
watershedZ = 1;
% large ovlap yields confusing dots and then watershed splits these up
% in weird dot-distructive ways
@@ -154,6 +153,7 @@
%%
+
intype = class(Iin_z);
[dotC,LinX,LinY] = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ);
@@ -176,14 +176,14 @@
colormap hot; hold on;
plot( dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
plot( Cents(:,1),Cents(:,2),'yo','MarkerSize',4);
- for z=1:Zs
- plot(LinX{z},LinY{z},'c');
- end
+ Lx = cell2mat(LinX');
+ Ly = cell2mat(LinY');
+ plot(Lx,Ly,'c');
saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']);
end
%%
- clear Imax Cents DotData DotLabels Inds Ints Iin_z
+ % clear Imax Cents DotData DotLabels Inds Ints Iin_z
%%

0 comments on commit c9ec920

Please sign in to comment.
Something went wrong with that request. Please try again.