Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 10 files changed
  • 0 comments
  • 1 contributor
92  CheckDotUpDown.m 100755 → 100644
@@ -10,7 +10,7 @@
10 10
 % if getpreciseZ is off, the first layer in which the dot occurs is used as
11 11
 % the z postion, rather than the brightest layer  
12 12
 
13  
-function New_dotC = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype)
  13
+function [New_dotC,Linx,Liny] = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ)
14 14
 
15 15
 %% Updates
16 16
 % Rewritten 03/07/11 to convert more things to uint16 / uint8 to save
@@ -44,7 +44,7 @@
44 44
     dotzpos{z} = z*ones(dotsinlayer(z),1);
45 45
 end
46 46
 dotC = [cell2mat(DotData'), cell2mat(dotzpos)];  
47  
-clear DotData; 
  47
+%clear DotData; 
48 48
 
49 49
 
50 50
 NDots = length(dotC); % total number of dots;
@@ -149,8 +149,8 @@
149 149
 %     liny = dotC(nonzeros(DotConn(n,:)),2) ;  
150 150
 %     plot(linx,liny,'w');
151 151
 % end
152  
-      
153  
-   
  152
+%       
  153
+%    
154 154
 
155 155
 %%
156 156
 
@@ -202,6 +202,7 @@
202 202
     mask = bwareaopen(mask,consec_layers); % figure(3); clf; imagesc(mask);
203 203
  % bwareaopen is very expensive for big images    
204 204
     
  205
+ if watershedZ == 1
205 206
     % Watershed to split dots
206 207
     % W = ConnInt_T.*uint16(mask.*longDots); figure(4); clf; imagesc(W);
207 208
     W = immultiply(ConnInt_T,cast(mask,intype)); 
@@ -210,7 +211,8 @@
210 211
      % figure(3); clf; imagesc(W); colormap lines;
211 212
     mask(W==0) = 0; 
212 213
     % figure(4); clf; imagesc(mask);
213  
-
  214
+ end
  215
+ 
214 216
     if getpreciseZ == 1
215 217
         labeled = bwlabel(mask);
216 218
         R = regionprops(labeled,ConnInt_T,'WeightedCentroid');
@@ -248,9 +250,9 @@
248 250
 toc
249 251
 
250 252
 
251  
-  %% Troubleshooting
  253
+ %% Troubleshooting
252 254
 %  figure(2); clf; 
253  
-%  imagesc(Imax_dots);   hold on;
  255
+%  imagesc(Imax_dots); colormap hot;  hold on;
254 256
 %  plot(dotC(:,1),dotC(:,2),'c+');
255 257
 % for n=1:2:2*NDots  
256 258
 %     linx = dotC(nonzeros(masked_inds(n,:)),1); % trailing zero prevents cellfun error   
@@ -258,7 +260,17 @@
258 260
 %     plot(linx,liny,'c'); 
259 261
 %      text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
260 262
 % end
261  
-%
  263
+% 
  264
+% 
  265
+%  figure(1); clf; 
  266
+%  imagesc(Imax_dots(:,:,mRNAchn)); colormap hot;  hold on;
  267
+% for n=1:2:2*NDots  
  268
+%     linx = dotC(nonzeros(masked_inds(n,:)),1); % trailing zero prevents cellfun error   
  269
+%     liny = dotC(nonzeros(masked_inds(n,:)),2);
  270
+%     plot(linx,liny,'c'); 
  271
+% %     text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
  272
+% end
  273
+
262 274
 
263 275
 %%  Free up some Memory
264 276
 %clear  ConnInt_T DotConn LayerJoin  mask  ConnInt
@@ -279,8 +291,8 @@
279 291
 
280 292
 Linx = cell(NDots,1); Liny = cell(NDots,1); Lind = cell(NDots,1); 
281 293
 for n=1:2:2*NDots  
282  
-    Linx{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),1)',0,0,0]; % trailing zero prevents cellfun error   
283  
-    Liny{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),2)',0,0,0];
  294
+    Linx{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),1)',NaN,NaN,NaN]; % trailing zero prevents cellfun error   
  295
+    Liny{(n+1)/2} = [dotC(nonzeros(masked_inds(n,:)),2)',NaN,NaN,NaN];
284 296
     Lind{(n+1)/2} = (n+1)/2; % [nonzeros(masked_inds(n,:))',0,0,0]; % must be a non-loop way to do this
285 297
 end
286 298
 %
@@ -289,29 +301,37 @@
289 301
  UL = cell2mat(UL);    % this is infact uniform output, not sure why matlab insists we do it this way 
290 302
  
291 303
  if isempty(UL) == 0
292  
-     UL = UL(UL(:,1)>0,:); % remove all empty values
293  
-      unique_inds = UL(:,7); 
294  
-     [~,ui] = unique(sum(UL(:,1:6),2));
295  
-     unique_inds = UL(ui,7); 
296  
-    unique_dotX = Linx(unique_inds);
297  
-    unique_dotY = Liny(unique_inds);
298  
-
299  
-Ndots = length(unique_dotX);
300  
-New_dotC = zeros(Ndots,3); 
301  
-for k =1:Ndots
302  
-    phalf = round(length((unique_dotX{k})-3)/2);
303  
-    %New_dotC(k,1) = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
304  
-    %New_dotC(k,2) =   unique_dotY{k}(phalf); %median(unique_dotY{k}); %
305  
-    
306  
-     New_dotC(k,1) = median(unique_dotX{k}(1:end-3)); %
307  
-    New_dotC(k,2) =   median(unique_dotY{k}(1:end-3)); %
308  
-    
309  
-    if plotdata == 1 && getpreciseZ == 1
310  
-        New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
311  
-    else
312  
-        New_dotC(k,3) = dotC(unique_inds(k),3) + phalf;
  304
+ 
  305
+     UL = UL(~isnan(UL(:,1)),:);  % remove all empty values
  306
+     UL(isnan(UL(:,3)),3) = 0;
  307
+
  308
+     max_clusters = length(UL); 
  309
+     ULcat = [[UL(:,1)+UL(:,4);UL(:,2)+UL(:,5);UL(:,3)+UL(:,6)],[UL(:,7);UL(:,7);UL(:,7)]];
  310
+     [~,ui] = unique(ULcat(:,1)); % find unique values
  311
+     ui = ui(ui<max_clusters);  % only want indices corresponding to original clusters 
  312
+
  313
+     unique_inds = ULcat(ui,2); % take the cluster indices from the set of unique clusters 
  314
+     unique_dotX = Linx(unique_inds);
  315
+     unique_dotY = Liny(unique_inds);
  316
+
  317
+    Ndots = length(unique_dotX);
  318
+    New_dotC = zeros(Ndots,3); 
  319
+    for k =1:Ndots
  320
+        phalf = floor(length((unique_dotX{k})-3)/2);
  321
+        New_dotC(k,1) = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
  322
+       New_dotC(k,2) =   unique_dotY{k}(phalf); %median(unique_dotY{k}); %
  323
+
  324
+    %     [New_dotC(k,1),idx] = mymedian(unique_dotX{k}(1:end-3)); %
  325
+    %    % if isempty(idx)~=0
  326
+    %         New_dotC(k,2) = unique_dotY{k}(idx(1)); %
  327
+    %    % end
  328
+
  329
+        if plotdata == 1 && getpreciseZ == 1
  330
+            New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
  331
+        else
  332
+            New_dotC(k,3) = dotC(unique_inds(k),3) + phalf;
  333
+        end
313 334
     end
314  
-end
315 335
 
316 336
  else
317 337
      Ndots = 0;
@@ -321,14 +341,16 @@
321 341
 disp([num2str(Ndots),' total spheres found']);
322 342
 
323 343
 toc
324  
-
  344
+% 
325 345
 % 
326 346
 % figure(4); clf; 
327 347
 % imagesc(Imax_dots);   hold on;
328 348
 % plot(New_dotC(:,1),New_dotC(:,2),'w.','MarkerSize',30);
329  
-% plot(dotC(:,1),dotC(:,2),'c+');
  349
+% plot(dotC(:,1),dotC(:,2),'m+');
330 350
 % 
331  
-
  351
+%    for k=1:length(Linx)
  352
+%                 plot(Linx{k}(1:end-3),Liny{k}(1:end-3),'c');
  353
+%    end
332 354
 
333 355
 
334 356
 
88  CheckDotUpDown.m~
@@ -10,7 +10,7 @@
10 10
 % if getpreciseZ is off, the first layer in which the dot occurs is used as
11 11
 % the z postion, rather than the brightest layer  
12 12
 
13  
-function New_dotC = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype)
  13
+function [New_dotC,Linx,Liny] = CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ)
14 14
 
15 15
 %% Updates
16 16
 % Rewritten 03/07/11 to convert more things to uint16 / uint8 to save
@@ -44,7 +44,7 @@ for z = 1:Zs
44 44
     dotzpos{z} = z*ones(dotsinlayer(z),1);
45 45
 end
46 46
 dotC = [cell2mat(DotData'), cell2mat(dotzpos)];  
47  
-clear DotData; 
  47
+%clear DotData; 
48 48
 
49 49
 
50 50
 NDots = length(dotC); % total number of dots;
@@ -138,19 +138,19 @@ toc
138 138
 %%  Trouble-shooting: Draw lines between connected dots
139 139
 % 
140 140
 % 
141  
-figure(1); clf; 
142  
-  Imax = imread([rawfolder,stackfolder,'max_',fname,'_',emb,'.tif']); 
143  
-            Imax_dots = 3*Imax(xp1:xp2,yp1:yp2,1:3);  
144  
-            Imax_dots(:,:,3) = .1*Imax_dots(:,:,3);
145  
-            imagesc(Imax_dots);   hold on;
146  
-plot(dotC(:,1),dotC(:,2),'c+');
147  
-for n=1:2*NDots   
148  
-    linx = dotC(nonzeros(DotConn(n,:)),1);
149  
-    liny = dotC(nonzeros(DotConn(n,:)),2) ;  
150  
-    plot(linx,liny,'w');
151  
-end
152  
-      
153  
-   
  141
+% figure(1); clf; 
  142
+%   Imax = imread([rawfolder,stackfolder,'max_',fname,'_',emb,'.tif']); 
  143
+%             Imax_dots = 3*Imax(xp1:xp2,yp1:yp2,1:3);  
  144
+%             Imax_dots(:,:,3) = .1*Imax_dots(:,:,3);
  145
+%             imagesc(Imax_dots);   hold on;
  146
+% plot(dotC(:,1),dotC(:,2),'c+');
  147
+% for n=1:2*NDots   
  148
+%     linx = dotC(nonzeros(DotConn(n,:)),1);
  149
+%     liny = dotC(nonzeros(DotConn(n,:)),2) ;  
  150
+%     plot(linx,liny,'w');
  151
+% end
  152
+%       
  153
+%    
154 154
 
155 155
 %%
156 156
 
@@ -202,6 +202,7 @@ for k=1:Nsects
202 202
     mask = bwareaopen(mask,consec_layers); % figure(3); clf; imagesc(mask);
203 203
  % bwareaopen is very expensive for big images    
204 204
     
  205
+ if watershedZ == 1
205 206
     % Watershed to split dots
206 207
     % W = ConnInt_T.*uint16(mask.*longDots); figure(4); clf; imagesc(W);
207 208
     W = immultiply(ConnInt_T,cast(mask,intype)); 
@@ -210,7 +211,8 @@ for k=1:Nsects
210 211
      % figure(3); clf; imagesc(W); colormap lines;
211 212
     mask(W==0) = 0; 
212 213
     % figure(4); clf; imagesc(mask);
213  
-
  214
+ end
  215
+ 
214 216
     if getpreciseZ == 1
215 217
         labeled = bwlabel(mask);
216 218
         R = regionprops(labeled,ConnInt_T,'WeightedCentroid');
@@ -248,17 +250,27 @@ end
248 250
 toc
249 251
 
250 252
 
251  
-  %% Troubleshooting
252  
- figure(2); clf; 
253  
- imagesc(Imax_dots);   hold on;
254  
- plot(dotC(:,1),dotC(:,2),'c+');
255  
-for n=1:2:2*NDots  
256  
-    linx = dotC(nonzeros(masked_inds(n,:)),1); % trailing zero prevents cellfun error   
257  
-    liny = dotC(nonzeros(masked_inds(n,:)),2);
258  
-    plot(linx,liny,'c'); 
259  
-     text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
260  
-end
261  
-%%
  253
+ %% Troubleshooting
  254
+%  figure(2); clf; 
  255
+%  imagesc(Imax_dots); colormap hot;  hold on;
  256
+%  plot(dotC(:,1),dotC(:,2),'c+');
  257
+% for n=1:2:2*NDots  
  258
+%     linx = dotC(nonzeros(masked_inds(n,:)),1); % trailing zero prevents cellfun error   
  259
+%     liny = dotC(nonzeros(masked_inds(n,:)),2);
  260
+%     plot(linx,liny,'c'); 
  261
+%      text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
  262
+% end
  263
+% 
  264
+% 
  265
+%  figure(1); clf; 
  266
+%  imagesc(Imax_dots(:,:,mRNAchn)); colormap hot;  hold on;
  267
+% for n=1:2:2*NDots  
  268
+%     linx = dotC(nonzeros(masked_inds(n,:)),1); % trailing zero prevents cellfun error   
  269
+%     liny = dotC(nonzeros(masked_inds(n,:)),2);
  270
+%     plot(linx,liny,'c'); 
  271
+% %     text(dotC((n+1)/2,1)+1,dotC((n+1)/2,2),[' ', num2str(dotC((n+1)/2,3) )],'color','c','FontSize',8);
  272
+% end
  273
+
262 274
 
263 275
 %%  Free up some Memory
264 276
 %clear  ConnInt_T DotConn LayerJoin  mask  ConnInt
@@ -288,9 +300,10 @@ end
288 300
  UL = cellfun(@(x,y,z) [x(1:3),y(1:3),z(1)],Linx,Liny,Lind,'UniformOutput',0); % Add index to 
289 301
  UL = cell2mat(UL);    % this is infact uniform output, not sure why matlab insists we do it this way 
290 302
  UL = UL(UL(:,1)>0,:); % remove all empty values
291  
-  unique_inds = UL(:,7); 
292  
-% [~,unique_inds] = unique(sum(UL(:,1:6),2));
293  
- 
  303
+  unique_inds = UL(:,7);
  304
+ [~,ui] = unique([UL(:,1);UL(:,2);UL(:,3)]);
  305
+ ULi = [UL(:,7);UL(:,7);UL(:,7)];
  306
+ unique_inds = ULi(ui,7); 
294 307
 unique_dotX = Linx(unique_inds);
295 308
 unique_dotY = Liny(unique_inds);
296 309
 
@@ -298,8 +311,11 @@ Ndots = length(unique_dotX);
298 311
 New_dotC = zeros(Ndots,3); 
299 312
 for k =1:Ndots
300 313
     phalf = round(length((unique_dotX{k})-3)/2);
301  
-    [New_dotC(k,1)] = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
302  
-    New_dotC(k,2) =   unique_dotY{k}(phalf); %median(unique_dotY{k}); %
  314
+    %New_dotC(k,1) = unique_dotX{k}(phalf); % median(unique_dotX{k}); %
  315
+    %New_dotC(k,2) =   unique_dotY{k}(phalf); %median(unique_dotY{k}); %
  316
+    
  317
+     New_dotC(k,1) = median(unique_dotX{k}(1:end-3)); %
  318
+    New_dotC(k,2) =   median(unique_dotY{k}(1:end-3)); %
303 319
     
304 320
     if plotdata == 1 && getpreciseZ == 1
305 321
         New_dotC(k,3) = cent(cent(:,2) == 2*unique_inds(k)-1,1);
@@ -312,13 +328,15 @@ disp([num2str(Ndots),' total spheres found']);
312 328
 
313 329
 toc
314 330
 
315  
-% 
  331
+
316 332
 figure(4); clf; 
317 333
 imagesc(Imax_dots);   hold on;
318 334
 plot(New_dotC(:,1),New_dotC(:,2),'w.','MarkerSize',30);
319  
-plot(dotC(:,1),dotC(:,2),'c+');
320  
-
  335
+plot(dotC(:,1),dotC(:,2),'m+');
321 336
 
  337
+   for k=1:length(Linx)
  338
+                plot(Linx{k}(1:end-3),Liny{k}(1:end-3),'c');
  339
+   end
322 340
 
323 341
 
324 342
 
13  Unsupervised_DotFinding.m 100755 → 100644
@@ -9,11 +9,13 @@
9 9
 tot_time = tic;
10 10
 % Input options 
11 11
 old_lab = 0;  Es = 0;  ver = '';
  12
+
12 13
 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/'; 
13 14
 %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/'; %%   %
14 15
 rawfolder =  'G:2011-04_and_earlier/'
15 16
 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/'; %
16 17
 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; % 
  18
+
17 19
 mRNA_channels = 2;% 2; %  3; %  1; % total mRNA channels
18 20
 
19 21
 sname =  fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
@@ -37,6 +39,7 @@
37 39
 end
38 40
 % ------- Option: Focus on subset of image: ------------------- %
39 41
      m =   1/2048;  %    .7; % .5; .7; %   1/2048; % 
  42
+
40 43
    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;
41 44
    hs = yp2-yp1+1;     ws = xp2-xp1+1;
42 45
 
@@ -69,8 +72,9 @@
69 72
    
70 73
   % sphere finding parameters
71 74
    getpreciseZ = 0;
72  
-   consec_layers = 3;
  75
+   consec_layers = 2;
73 76
    ovlap = 2;  
  77
+   watershedZ = 1;
74 78
    % large ovlap yields confusing dots and then watershed splits these up
75 79
    % in weird dot-distructive ways
76 80
 %---------------------------------%
@@ -152,7 +156,7 @@
152 156
         %%
153 157
 
154 158
          intype = class(Iin_z);
155  
-         dotC =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype);
  159
+         [dotC,LinX,LinY] =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ);
156 160
          Cents = cell2mat(DotData');
157 161
          
158 162
         % Project all layers
@@ -172,7 +176,10 @@
172 176
             colormap hot; hold on;
173 177
             plot(  dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
174 178
             plot(  Cents(:,1),Cents(:,2),'yo','MarkerSize',4);
175  
-         %   saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
  179
+            for z=1:Zs
  180
+                plot(LinX{z},LinY{z},'c'); 
  181
+            end
  182
+           saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
176 183
         end
177 184
         %%
178 185
         
10  Unsupervised_DotFinding.m~
@@ -9,11 +9,11 @@ clear all;
9 9
 tot_time = tic;
10 10
 % Input options 
11 11
 old_lab = 0;  Es = 0;  ver = '';
12  
-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/'; 
13  
-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/'; %%   %
14  
-%rawfolder =  '/media/GRAID/Raw_Data/2011-05-22/'
  12
+folder = '/home/alistair/Documents/Research/Projects/mRNA_counting/Data/2011-06-20/'; % 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/'; 
  13
+rawfolder = '/home/alistair/Documents/Research/Raw_Data_Temp/2011-06-20/'; % 2011-05-22/'; %  2011-04_and_earlier/'; %'; % 2011-06-20/'; %  '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %%   %
  14
+%rawfolder =  '/media/GRAID/Raw_Data/2011-05-22/';
15 15
 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/'; %
16  
-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; % 
  16
+fname = 'MP10_22C_sna_y_e'; ver = '% 's05_MP06Hz', 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; %   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; % 
17 17
 mRNA_channels = 2;% 2; %  3; %  1; % total mRNA channels
18 18
 
19 19
 sname =  fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
@@ -36,7 +36,7 @@ if Es==0
36 36
     Es = length(fields(Datas)) - 3;   % Number of Stacks
37 37
 end
38 38
 % ------- Option: Focus on subset of image: ------------------- %
39  
-     m =  .95;%  1/2048;  %    .7; % .5; .7; %   1/2048; % 
  39
+     m =  1/2048;  %    .7; % .5; .7; %   1/2048; % 
40 40
    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;
41 41
    hs = yp2-yp1+1;     ws = xp2-xp1+1;
42 42
 
45  Unsupervised_DotFinding2.m 100755 → 100644
... ...
@@ -1,4 +1,4 @@
1  
-%%                      Unsupervised_DotFinding.m
  1
+%%                      Unsupervised_DotFinding2.m
2 2
 %
3 3
 % Alistair Boettiger                                   Date Begun: 03/10/11
4 4
 % Levine Lab                                        Last Modified: 07/07/11
@@ -9,13 +9,14 @@
9 9
 tot_time = tic;
10 10
 % Input options 
11 11
 old_lab = 0;  Es = 0;  ver = '';
12  
-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/'; 
  12
+
  13
+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/'; 
13 14
 %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/'; %%   %
14  
-rawfolder =  'G:2011-04_and_earlier\'%\2011-02-17\';
15  
-stackfolder =  'MP12Hz/';% '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/'; %
16  
-fname =  'MP12Hz_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; % 
  15
+%rawfolder =  'G:\2011-04_and_earlier/'
  16
+rawfolder = 'C:\Users\alistair\Data\2011-11\';%
  17
+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/'; %
  18
+fname ='MP05'; ver = '_v3'% 'MP08_snaD_LacZ647';% '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; % 
17 19
 mRNA_channels = 2;% 2; %  3; %  1; % total mRNA channels
18  
-
19 20
 sname =  fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
20 21
 
21 22
 
@@ -36,7 +37,8 @@
36 37
     Es = length(fields(Datas)) - 3;   % Number of Stacks
37 38
 end
38 39
 % ------- Option: Focus on subset of image: ------------------- %
39  
-     m =   1/2048;  %    .7; % .5; .7; %   1/2048; % 
  40
+     m =  1/2048;  %.7; %   .98; %   .7; % .5; .7; %   1/2048; % 
  41
+
40 42
    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;
41 43
    hs = yp2-yp1+1;     ws = xp2-xp1+1;
42 44
 
@@ -60,17 +62,18 @@
60 62
 
61 63
 %---- Dot Finding Parameters ----- %
62 64
    % dotfinder's parameters 
63  
-    sigmaE = 3;%  IMPORTANT
64  
-    sigmaI = 4; % IMPORTANT
  65
+    sigmaE = 2.5;% 3;%  IMPORTANT
  66
+    sigmaI = 3.5; %4; % IMPORTANT
65 67
     min_int  = 0.04;    %  5    ;% .05 % not necessary Fix at Zero
66 68
     FiltSize = 30;% 
67 69
     min_size = 30;% 
68  
-    min_peak = 2000; %
  70
+    min_peak = 5000% 2000; %
69 71
    
70 72
   % sphere finding parameters
71 73
    getpreciseZ = 0;
72  
-   consec_layers = 3;
73  
-   ovlap = 2;  
  74
+   consec_layers = 2;
  75
+   ovlap = 1;  
  76
+   watershedZ = 1;
74 77
    % large ovlap yields confusing dots and then watershed splits these up
75 78
    % in weird dot-distructive ways
76 79
 %---------------------------------%
@@ -150,9 +153,10 @@
150 153
 
151 154
             
152 155
         %%
  156
+        
153 157
 
154 158
          intype = class(Iin_z);
155  
-         dotC =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype);
  159
+         [dotC,LinX,LinY] =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ);
156 160
          Cents = cell2mat(DotData');
157 161
          
158 162
         % Project all layers
@@ -172,11 +176,14 @@
172 176
             colormap hot; hold on;
173 177
             plot(  dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
174 178
             plot(  Cents(:,1),Cents(:,2),'yo','MarkerSize',4);
175  
-         %   saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
  179
+            Lx = cell2mat(LinX');
  180
+            Ly = cell2mat(LinY');
  181
+            plot(Lx,Ly,'c'); 
  182
+           saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
176 183
         end
177 184
         %%
178 185
         
179  
-    clear Imax Cents DotData DotLabels Inds Ints Iin_z 
  186
+   % clear Imax Cents DotData DotLabels Inds Ints Iin_z 
180 187
         
181 188
         %%
182 189
         
@@ -223,12 +230,12 @@
223 230
             mRNA_den(i) = mRNA_cnt(i)/imdata.Area(i); 
224 231
             nuc_area(i) = length(imdata.PixelID{i});
225 232
             if showim == 1
226  
-                Plot_mRNA(NucLabeled==nn) = single(mRNA_den(i));
  233
+                Plot_mRNA(NucLabel==nn) = single(mRNA_den(i));
227 234
             end
228 235
         end
229 236
         % normalize density to the average cell area
230 237
         mRNA_sadj = mRNA_den*mean(imdata.Area);
231  
-        
  238
+        % figure(3); clf; imagesc(Plot_mRNA); colorbar;
232 239
         % more stats  
233 240
         m_cnt = mean(mRNA_cnt);
234 241
         s_cnt = std(mRNA_cnt);
@@ -268,7 +275,7 @@
268 275
             [on_cnts,off_cnts]= fxn_regionvar(NucLabel,Plot_mRNA,mRNA_sadj,t,spread,Nnucs,Nucs_list);
269 276
             saveas(Fig_regvar,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),'rvar',ver,'.fig']); 
270 277
         end
271  
-    
  278
+    %%
272 279
      clear imdata M C W  mRNA_map Fig_regvar histfig Iout  
273 280
         %
274 281
      %% Export data
@@ -281,7 +288,7 @@
281 288
 Rpars.getpreciseZ = getpreciseZ;
282 289
 Rpars.consec_layers = consec_layers;
283 290
 Rpars.ovlap = ovlap; 
284  
-     
  291
+Rpars.minpeak = min_peak;     
285 292
        save([folder,fname,'_',emb,'_chn',num2str(mRNAchn),'_data',ver,'.mat'],...
286 293
            'nuc_area','dotC','mRNA_cnt','Plot_mRNA','mRNA_sadj','Rpars'); 
287 294
      
165  Unsupervised_DotFinding2.m~
... ...
@@ -1,53 +1,55 @@
1 1
 %%                      Unsupervised_DotFinding2.m
2 2
 %
3 3
 % Alistair Boettiger                                   Date Begun: 03/10/11
4  
-% Levine Lab                                        Last Modified: 06/07/11
  4
+% Levine Lab                                        Last Modified: 07/07/11
5 5
 %
6 6
 
7 7
 clear all;
8 8
 
9 9
 tot_time = tic;
10 10
 % Input options 
11  
-old_lab = 0;  Es = 0; Zs = 0; ver = ''; 
12  
-folder = '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/mRNA_counting/Data/2011-04_and_earlier/';%   2011-06-20/';%  2011-07-12/'; %2011-05-22/'; %2011-06-20/';% 2011-05-22/'; %  2011-06-20/';%  '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/'; 
13  
-rawfolder = '/Volumes/Data/Lab Data/Raw_Data/2011-04_and_earlier/';%    2011-06-20/';%  2011-07-12/'; %2011-05-22/'; %  '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %%   %
  11
+old_lab = 0;  Es = 0;  ver = '';
  12
+folder = '/home/alistair/Documents/Research/Projects/mRNA_counting/Data/'; 
  13
+rawfolder = '/home/alistair/Documents/Research/Raw_Data_Temp/2011-11/'; % 2011-05-22/'; %  2011-04_and_earlier/'; %'; % 2011-06-20/'; %  '/Volumes/Data/Lab Data/Raw_Data/02-17-11/'; %%   %
  14
+%rawfolder =  '/media/GRAID/Raw_Data/2011-05-22/'
  15
+%rawfolder = '/media/HD-HSQ/2011-02-17/';%
  16
+stackfolder =  ''; %'MP10_22C/';% '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/'; %
  17
+fname = 'MP0'MP10_22C_sna_y_e'; ver = '';% 's05_MP06Hz', 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; %   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; % 
  18
+mRNA_channels =  2; %  3; %  1; % total mRNA channels
14 19
 
15  
-stackfolder = 'MP12Hz/'; %'sna2p8het/'; % 'MP07Hz/'; % 's07_MP05Hz/';%'s04_MP10/';%  's05_MP06/';% 's01_MP09/';% 's06_MP10_sna18/'; %'s05_MP06/';%  'sna2.8Hz/';% 's21_MP07/';% 'MP07Hz/';% 's11_G4B/' %    's02_MP01/';% %'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/'; %
16  
-fname = 'MP12Hz_snaD_22C'; ver = '_v3'; % 'sna2p8het_30C'; % 'MP07Hz_snaD_22C_b' ; ver = '_v2'; % 's07_MP05Hz_22C_c'; %  's04_MP10Hz_b';% 's05_MP06Hz_b';% 's01_MP09_cflip';% 's01_MP09_Hz_22C';%  's06_MP10_sna18_b'; %'s05_MP06Hz_b';  Zs = 35;  % 'sna2.8_snaD_22C';%  'MP07het_snaD_22C'; %  'MP07Hz_snaD_22C';%'s11_G4B_LacZ';% 's05_MP06Hz'; % 's04_MP10Hz'; % 's01_MP09_Hz_22C_c'; % 's02_MP01_Hz_22C_b'; %%'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; % 
17  
-mRNA_channels = 2; %  3; %  1; % total mRNA channels
  20
+sname =  fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
18 21
 
19  
-sname =  fname; %'s05_MP06Hz';%  'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
20 22
 
21 23
 % MP10_22C_sna_y_c and MP05_22C all done at 3.5, 4, 0.03, 30, 30
22 24
 % MGa2x and MGa1x all done at 2.5, 3, 0.03, 30, 30
23 25
 
24 26
 
25  
- 
26  
-filename = [rawfolder,stackfolder,'/',fname];     
27  
-load([rawfolder,stackfolder,sname,'.mat'])   
  27
+
  28
+%%
  29
+
  30
+filename = [rawfolder,'/',fname];     
  31
+load([rawfolder,stackfolder,sname,'.mat'])  
  32
+
28 33
 w = Datas.Stack1.Image1.IMG.width;
29 34
 h = Datas.Stack1.Image1.IMG.height; 
30  
-% auotomatically find quantities if not programed.  
31  
-if Es == 0
  35
+ Zs = Datas.LSM_info.DimensionZ; 
  36
+ 
  37
+if Es==0
32 38
     Es = length(fields(Datas)) - 3;   % Number of Stacks
33 39
 end
34  
-if Zs == 0
35  
-    Zs = Datas.LSM_info.DimensionZ; 
36  
-end
37  
-
38 40
 % ------- Option: Focus on subset of image: ------------------- %
39  
-%      m = 1/2048;  % .9;%    .7; % .5; .7; %   1/2048; % 
40  
-%    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;
41  
-%    hs = yp2-yp1+1;     ws = xp2-xp1+1;
  41
+     m =  1/2048;  %    .7; % .5; .7; %   1/2048; % 
  42
+   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;
  43
+   hs = yp2-yp1+1;     ws = xp2-xp1+1;
42 44
 
43  
-ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
44  
-xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1; 
  45
+% ws = 2048; hs = 2048; xp1 = 1; yp1 = 1;
  46
+% xp2 = xp1 + ws -1; yp2 = yp1 + hs - 1; 
45 47
 disp(['Coordinates:  ', num2str(xp1), ' : ', num2str(xp2), ',   ' num2str(yp1), ' : ', num2str(yp2) ] );
46 48
 % ------------------------------------------------------------- %     
47 49
     
48 50
 
49 51
 % -------------- Graphing and Display Options ------------------ %
50  
-   show_projected = 0; % show max-project with all dots and linked dots. 
  52
+   show_projected = 1; % show max-project with all dots and linked dots. 
51 53
    plotdata = 0; % CheckDotUpDown display parameter
52 54
    plotZdata = 0 ;% show z-map of data
53 55
    showhist = 1; % show histogram of mRNA counts per cell. 
@@ -62,14 +64,18 @@ disp(['Coordinates:  ', num2str(xp1), ' : ', num2str(xp2), ',   ' num2str(yp1),
62 64
    % dotfinder's parameters 
63 65
     sigmaE = 3;%  IMPORTANT
64 66
     sigmaI = 4; % IMPORTANT
65  
-    min_int  = 0.03;    %  5    ;% .05 % not necessary Fix at Zero
  67
+    min_int  = 0.04;    %  5    ;% .05 % not necessary Fix at Zero
66 68
     FiltSize = 30;% 
67 69
     min_size = 30;% 
  70
+    min_peak = 5000; %
68 71
    
69 72
   % sphere finding parameters
70 73
    getpreciseZ = 0;
71  
-   consec_layers = 3;  
72  
-   ovlap = 4; 
  74
+   ovlap = 2;  
  75
+   watershedZ = 1; 
  76
+   consec_layers = 2;
  77
+   % large ovlap yields confusing dots and then watershed splits these up
  78
+   % in weird dot-distructive ways
73 79
 %---------------------------------%
74 80
 
75 81
 
@@ -77,19 +83,25 @@ disp(['Coordinates:  ', num2str(xp1), ' : ', num2str(xp2), ',   ' num2str(yp1),
77 83
     % Build the Gaussian Filter   
78 84
     Ex = fspecial('gaussian',FiltSize,sigmaE); % excitatory gaussian
79 85
     Ix = fspecial('gaussian',FiltSize,sigmaI); % inhibitory gaussian
80  
-
  86
+ 
  87
+    disp('Running DotFinder1'); 
  88
+  
81 89
 %%
82  
-for e=  1:Es
  90
+for e= 1:Es
83 91
 %%
  92
+
  93
+
  94
+
  95
+disp('loading data...');
84 96
     tic 
85  
-    disp('Running DotFinder2, loading data...');
  97
+  
86 98
     if e<10
87 99
         emb = ['0',num2str(e)];
88 100
     else
89 101
         emb = num2str(e);
90 102
     end
91  
-    disp(['analyzing embryo, ',emb,'...']);
92  
-    
  103
+  
  104
+   
93 105
     
94 106
     try load([rawfolder,stackfolder,fname,'_',emb,'_nucdata.mat']);
95 107
     
@@ -111,18 +123,15 @@ for e=  1:Es
111 123
     end
112 124
    
113 125
     toc
114  
-    
  126
+      disp(['analyzing embryo, ',emb,'...']);
115 127
     
116 128
     for mRNAchn = 1:mRNA_channels % mRNAchn =2
117  
-        
118  
-         if mRNAchn == 1;
119  
-                  min_int  = 0.05;  % .05 just for speed 
120  
-         elseif mRNAchn == 2
121  
-               min_int  = 0.01; % .028 .01
122  
-         else
123  
-             min_int = 0.2; % .05
124  
-         end
125  
-        
  129
+
  130
+        if mRNAchn == 2
  131
+            min_int = .03;
  132
+            min_peak = 1000;%
  133
+        end        
  134
+           
126 135
             DotLabels= cell(1,Zs); 
127 136
             DotData = cell(1,Zs);    
128 137
             Inds = cell(1,Zs); 
@@ -132,17 +141,28 @@ for e=  1:Es
132 141
             tic; disp('finding dots...'); 
133 142
             for z = 1:Zs % z = 11     
134 143
                  im_folder{z} = [rawfolder,stackfolder,fname,'_',emb,'_z',num2str(z),'.tif'];
  144
+                 try
135 145
                  Iin_z = imreadfast(im_folder{z});       
136  
-                 [DotLabels{z},DotData{z},Inds{z},Ints{z}]  = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size);
137  
-            end     
  146
+                 [DotLabels{z},DotData{z},Inds{z},Ints{z}]  = dotfinder(Iin_z(xp1:xp2,yp1:yp2,mRNAchn),Ex,Ix,min_int,min_size,min_peak);
  147
+                 catch err
  148
+                     disp(err.message); 
  149
+                     Zs = z-1; 
  150
+                    break
  151
+                 end 
  152
+            end
138 153
             toc;
139 154
             
140  
-                     
  155
+            % resize;        
  156
+            DotLabels= DotLabels(1:Zs); 
  157
+            DotData = DotData(1:Zs);    
  158
+            Inds = Inds(1:Zs); 
  159
+            Ints = Ints(1:Zs); 
  160
+
  161
+            
141 162
         %%
142  
- % consec_layers = 4; 
143  
-        
144  
-        intype = class(Iin_z);
145  
-         dotC =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype);
  163
+            
  164
+         intype = class(Iin_z);
  165
+         [dotC,Linx,Liny] =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ);
146 166
          Cents = cell2mat(DotData');
147 167
          
148 168
         % Project all layers
@@ -156,15 +176,26 @@ for e=  1:Es
156 176
             end
157 177
             
158 178
             Imax_dots = Imax(xp1:xp2,yp1:yp2,mRNAchn);  
159  
-            figure(2); 
160  
-            Iout = figure(2);  clf;  imagesc(Imax_dots);
  179
+            figure(4); 
  180
+            Iout = figure(4);  clf;  imagesc(Imax_dots); colorbar;
161 181
             colordef black; set(gcf,'color','k'); 
162 182
             colormap hot; hold on;
163  
-            plot(  dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
164  
-            plot(  Cents(:,1),Cents(:,2),'yo','MarkerSize',4);
165  
-            saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
  183
+             plot(  dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
  184
+             plot(  Cents(:,1),Cents(:,2),'yo','MarkerSize',4);           
  185
+%             figure(5); clf;  imagesc(Imax_dots); colorbar; 
  186
+%              colordef black; set(gcf,'color','k'); 
  187
+%             colormap hot; hold on;
  188
+            for k=1:length(Linx)
  189
+                plot(Linx{k}(1:end-3),Liny{k}(1:end-3),'c');
  190
+            end
  191
+              saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
  192
+          
  193
+            
  194
+            
166 195
         end
167  
-
  196
+        %%
  197
+        
  198
+   % clear Imax Cents DotData DotLabels Inds Ints Iin_z 
168 199
         
169 200
         %%
170 201
         
@@ -200,7 +231,7 @@ for e=  1:Es
200 231
         mRNA_den = zeros(1,Nnucs);  % store densities of mRNA per cell
201 232
         nuc_area = zeros(1,Nnucs); 
202 233
         if showim == 1
203  
-            Plot_mRNA = single(NucLabeled);
  234
+            Plot_mRNA = zeros(hn,'single'); % figure(3); clf; imagesc(Plot_mRNA);
204 235
         end
205 236
         for i=1:Nnucs; % i = 4
206 237
             nn = Nucs_list(i);
@@ -244,8 +275,8 @@ for e=  1:Es
244 275
          end
245 276
 
246 277
          if showim == 1        
247  
-            mRNA_map = figure(3); clf;  colordef black;
248  
-            imagesc(Plot_mRNA*mean(imdata.Area)); colormap('hot'); colorbar; 
  278
+            mRNA_map = figure(3); clf;  colordef black; 
  279
+            imagesc(Plot_mRNA.*mean(imdata.Area)); colormap('hot'); colorbar; 
249 280
             set(gcf,'color','k');  
250 281
             saveas(mRNA_map,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),'rvar',ver,'.jpg'],'jpg'); 
251 282
          end
@@ -257,7 +288,7 @@ for e=  1:Es
257 288
              saveas(Fig_regvar,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),'rvar',ver,'.fig']); 
258 289
         end
259 290
     
260  
-     clear imdata M C W  mRNA_map Fig_regvar histfig Iout  
  291
+  %   clear imdata M C W  mRNA_map Fig_regvar histfig Iout  
261 292
         %
262 293
      %% Export data
263 294
 
@@ -273,20 +304,26 @@ Rpars.ovlap = ovlap;
273 304
        save([folder,fname,'_',emb,'_chn',num2str(mRNAchn),'_data',ver,'.mat'],...
274 305
            'nuc_area','dotC','mRNA_cnt','Plot_mRNA','mRNA_sadj','Rpars'); 
275 306
      
276  
-     clear nuc_area dotC mRNA_cnt mRNA_sadj Plot_mRNA 
  307
+  %   clear nuc_area dotC mRNA_cnt mRNA_sadj Plot_mRNA 
277 308
     
278 309
      toc
279 310
     end % end loop over mNRA channels
280 311
        %  clean up;
281  
-      
  312
+%         clear Iin_z DotData DotMasks I_max cent1 bw dL Cents ...
  313
+%             Nmin imdata imdata2 NucLabel NucLabeled Plot_mRNA M C ...
  314
+%             nuc_area dotC mRNA_cnt mRNA_den mRNA_sadj inds conn_map;
  315
+%             
282 316
     
283 317
 end % end loop over embryos 
284 318
 
285  
-        
286  
-      %save([folder,fname,'_slidedata',ver], 'Data'); 
  319
+
  320
+%       clear Iin_z DotData DotMasks I_max cent1 bw dL Cents ...
  321
+%             Nmin imdata imdata2 NucLabeled Plot_mRNA M C ...
  322
+%             nuc_area dotC mRNA_cnt mRNA_den mRNA_sadj;
  323
+              
  324
+       Tout = toc(tot_time)/(60*60);
  325
+      disp(['elpased time = ',num2str(Tout), ' hours']); 
287 326
       
288  
-      Tout = toc(tot_time)/60;
289  
-      disp(['elpased time = ',num2str(Tout), ' minutes']); 
290 327
       disp('All slide data saved'); 
291 328
       
292 329
         
47  Unsupervised_DotFinding3.m 100755 → 100644
... ...
@@ -1,4 +1,4 @@
1  
-%%                      Unsupervised_DotFinding3.m
  1
+%%                      Unsupervised_DotFinding1.m
2 2
 %
3 3
 % Alistair Boettiger                                   Date Begun: 03/10/11
4 4
 % Levine Lab                                        Last Modified: 07/07/11
@@ -9,13 +9,14 @@
9 9
 tot_time = tic;
10 10
 % Input options 
11 11
 old_lab = 0;  Es = 0;  ver = '';
12  
-folder = 'C:\Users\Alistair\My Documents\Projects\mRNA_counting\Data\2011-02-17\'; %2011-06-20/'; %  2011-04_and_earlier/'; % % 2011-05-22/'; % 2011-06-20/'; %   '/Users/alistair/Documents/Berkeley/Levine_Lab/Projects/Enhancer_Modeling/Data/'; 
  12
+
  13
+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/'; 
13 14
 %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/'; %%   %
14  
-rawfolder =  'G:\2011-02-17\';
15  
-stackfolder =  'MP05_22C/';% '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/'; %
16  
-fname =  'MP05_22C_sna_y_c', 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; % 
  15
+%rawfolder =  'G:\2011-04_and_earlier/'
  16
+rawfolder = 'C:\Users\alistair\Data\2011-11\';%
  17
+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/'; %
  18
+fname = 'MP08_snaD_LacZ647'; ver = '_v3'% '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; % 
17 19
 mRNA_channels = 2;% 2; %  3; %  1; % total mRNA channels
18  
-
19 20
 sname =  fname; % 'MP07het_snaD_22C_1';% '_1'; % additional label on slide. 
20 21
 
21 22
 
@@ -36,7 +37,8 @@
36 37
     Es = length(fields(Datas)) - 3;   % Number of Stacks
37 38
 end
38 39
 % ------- Option: Focus on subset of image: ------------------- %
39  
-     m =   1/2048;  %    .7; % .5; .7; %   1/2048; % 
  40
+     m =  1/2048;  %.7; %   .98; %   .7; % .5; .7; %   1/2048; % 
  41
+
40 42
    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;
41 43
    hs = yp2-yp1+1;     ws = xp2-xp1+1;
42 44
 
@@ -60,17 +62,18 @@
60 62
 
61 63
 %---- Dot Finding Parameters ----- %
62 64
    % dotfinder's parameters 
63  
-    sigmaE = 3;%  IMPORTANT
64  
-    sigmaI = 4; % IMPORTANT
65  
-    min_int  = 0.04;    %  5    ;% .05 % not necessary Fix at Zero
  65
+    sigmaE = 2.5;% 3;%  IMPORTANT
  66
+    sigmaI = 3.5;% 4; % IMPORTANT
  67
+    min_int  = 0.05;    %  5    ;% .05 % not necessary Fix at Zero
66 68
     FiltSize = 30;% 
67 69
     min_size = 30;% 
68  
-    min_peak = 2000; %
  70
+    min_peak = 5000; %
69 71
    
70 72
   % sphere finding parameters
71 73
    getpreciseZ = 0;
72  
-   consec_layers = 3;
73  
-   ovlap = 2;  
  74
+   consec_layers = 2;
  75
+   ovlap = 1;  
  76
+   watershedZ = 1;
74 77
    % large ovlap yields confusing dots and then watershed splits these up
75 78
    % in weird dot-distructive ways
76 79
 %---------------------------------%
@@ -150,9 +153,10 @@
150 153
 
151 154
             
152 155
         %%
  156
+        
153 157
 
154 158
          intype = class(Iin_z);
155  
-         dotC =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype);
  159
+         [dotC,LinX,LinY] =  CheckDotUpDown(DotLabels,DotData,Inds,Ints,plotdata,getpreciseZ,consec_layers,ovlap,xp1,xp2,yp1,yp2,intype,watershedZ);
156 160
          Cents = cell2mat(DotData');
157 161
          
158 162
         % Project all layers
@@ -172,11 +176,14 @@
172 176
             colormap hot; hold on;
173 177
             plot(  dotC(:,1),dotC(:,2),'w+','MarkerSize',14 );
174 178
             plot(  Cents(:,1),Cents(:,2),'yo','MarkerSize',4);
175  
-         %   saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
  179
+            Lx = cell2mat(LinX');
  180
+            Ly = cell2mat(LinY');
  181
+            plot(Lx,Ly,'c'); 
  182
+           saveas(Iout,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),ver,'.fig']); 
176 183
         end
177 184
         %%
178 185
         
179  
-    clear Imax Cents DotData DotLabels Inds Ints Iin_z 
  186
+   % clear Imax Cents DotData DotLabels Inds Ints Iin_z 
180 187
         
181 188
         %%
182 189
         
@@ -223,12 +230,12 @@
223 230
             mRNA_den(i) = mRNA_cnt(i)/imdata.Area(i); 
224 231
             nuc_area(i) = length(imdata.PixelID{i});
225 232
             if showim == 1
226  
-                Plot_mRNA(NucLabeled==nn) = single(mRNA_den(i));
  233
+                Plot_mRNA(NucLabel==nn) = single(mRNA_den(i));
227 234
             end
228 235
         end
229 236
         % normalize density to the average cell area
230 237
         mRNA_sadj = mRNA_den*mean(imdata.Area);
231  
-        
  238
+        % figure(3); clf; imagesc(Plot_mRNA); colorbar;
232 239
         % more stats  
233 240
         m_cnt = mean(mRNA_cnt);
234 241
         s_cnt = std(mRNA_cnt);
@@ -268,7 +275,7 @@
268 275
             [on_cnts,off_cnts]= fxn_regionvar(NucLabel,Plot_mRNA,mRNA_sadj,t,spread,Nnucs,Nucs_list);
269 276
             saveas(Fig_regvar,[folder,fname,'_',emb,'_chn',num2str(mRNAchn),'rvar',ver,'.fig']); 
270 277
         end
271  
-    
  278
+    %%
272 279
      clear imdata M C W  mRNA_map Fig_regvar histfig Iout  
273 280
         %
274 281
      %% Export data
@@ -281,7 +288,7 @@
281 288
 Rpars.getpreciseZ = getpreciseZ;
282 289
 Rpars.consec_layers = consec_layers;
283 290
 Rpars.ovlap = ovlap; 
284  
-     
  291
+Rpars.minpeak = min_peak;     
285 292
        save([folder,fname,'_',emb,'_chn',num2str(mRNAchn),'_data',ver,'.mat'],...
286 293
            'nuc_area','dotC','mRNA_cnt','Plot_mRNA','mRNA_sadj','Rpars'); 
287 294
      
2  imviewer_lsm.m
@@ -22,7 +22,7 @@
22 22
 % 
23 23
 %
24 24
 %
25  
-%% Overview:
  25
+%% Overview:    
26 26
 %
27 27
 %
28 28
 %% Required subroutines
13  imviewer_lsm.m~
@@ -22,7 +22,7 @@
22 22
 % 
23 23
 %
24 24
 %
25  
-%% Overview:
  25
+%% Overview:    
26 26
 %
27 27
 %
28 28
 %% Required subroutines
@@ -177,20 +177,19 @@ function [handles] = projectNsave(hObject, eventdata, handles)
177 177
     % find if data is uint16 or something else; 
178 178
 try
179 179
     inttype =  ['uint',num2str(Datas.Stack1.Image1.IMG.bits)];
  180
+        disp(['data is ',inttype]); 
180 181
      channels =  Datas.Stack1.Image1.TIF.SamplesPerPixel;  
181 182
      w = Datas.Stack1.Image1.IMG.width;
182 183
      h = Datas.Stack1.Image1.IMG.height;
183  
-     disp(['Data contains ', num2str(channels),' channels'])
  184
+        disp(['Data contains ', num2str(channels),' channels']);
184 185
 catch er
185 186
     disp(er.message); 
186  
-   % disp([fsource,'/',froot,'.mat', '   failed to load']);  
187  
-    inttype =  'uint16';
  187
+    disp('data is not an image stack');
188 188
 end
189 189
     
190  
-    disp(['data is ',inttype]); 
  190
+
191 191
      
192  
-; 
193  
-    
  192
+
194 193
       
195 194
     if str_chns{:} == ' '
196 195
         chns = 1:channels;
BIN  imviewer_lsm_pars1.mat
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.