Home > SuperSegger > viz > makeKymoMosaic.m

makeKymoMosaic

PURPOSE ^

makeKymoMosaic creates a mosaic kymograph of multiple cells.

SYNOPSIS ^

function [im]= makeKymoMosaic (dirname, CONST)

DESCRIPTION ^

 makeKymoMosaic creates a mosaic kymograph of multiple cells.
 make kymo mosaic is only for fl1 in makeKymograph, which is currently
 set to gfp. A kymograph shows the fluorescence of the cell along the
 long axis of the cell, with time.

 INPUT :
       dirname : directory with cell data files
       CONST : segmentation parameters
 OUTPUT : 
       im : output image of kymo mosaic


 Copyright (C) 2016 Wiggins Lab 
 Written by Paul Wiggins, Stella Stylianidou.
 University of Washington, 2016
 This file is part of SuperSegger.
 
 SuperSegger is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 SuperSegger is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [im]= makeKymoMosaic (dirname, CONST)
0002 % makeKymoMosaic creates a mosaic kymograph of multiple cells.
0003 % make kymo mosaic is only for fl1 in makeKymograph, which is currently
0004 % set to gfp. A kymograph shows the fluorescence of the cell along the
0005 % long axis of the cell, with time.
0006 %
0007 % INPUT :
0008 %       dirname : directory with cell data files
0009 %       CONST : segmentation parameters
0010 % OUTPUT :
0011 %       im : output image of kymo mosaic
0012 %
0013 %
0014 % Copyright (C) 2016 Wiggins Lab
0015 % Written by Paul Wiggins, Stella Stylianidou.
0016 % University of Washington, 2016
0017 % This file is part of SuperSegger.
0018 %
0019 % SuperSegger is free software: you can redistribute it and/or modify
0020 % it under the terms of the GNU General Public License as published by
0021 % the Free Software Foundation, either version 3 of the License, or
0022 % (at your option) any later version.
0023 %
0024 % SuperSegger is distributed in the hope that it will be useful,
0025 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0026 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0027 % GNU General Public License for more details.
0028 %
0029 % You should have received a copy of the GNU General Public License
0030 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0031 
0032 % NOTE: TIME IN HOURS FOR 1 MIN FREQUENCY
0033 TimeStep     = CONST.getLocusTracks.TimeStep/60;
0034 PixelSize    = CONST.getLocusTracks.PixelSize;
0035 
0036 
0037 if ~isfield(CONST.view, 'falseColorFlag' )
0038     CONST.view.falseColorFlag = false;
0039 end
0040 
0041 %figure(1);
0042 persistent colormap_;
0043 if isempty( colormap_ )
0044     colormap_ = colormap( 'jet' );
0045 end
0046 
0047 if ~isfield( CONST, 'view') || CONST.view.showFullCellCycleOnly
0048     dir_list = dir([dirname,filesep,'Cell*.mat']);
0049 else
0050     dir_list = dir([dirname,filesep,'*ell*.mat']);
0051 end
0052 
0053 
0054 num_list_ = numel( dir_list ); % number of cells to be displayed
0055 
0056 if ~isfield(CONST.view, 'maxNumCell' )
0057     CONST.view.maxNumCell = 100;
0058 else
0059     
0060 num_list_ = min( [num_list_, CONST.view.maxNumCell] );
0061 num_list = 0;
0062 
0063 for ii = 1:num_list_   
0064     if (~isempty(dir_list(ii).name))
0065         num_list = num_list + 1;
0066     end
0067 end
0068 
0069 numa = ceil(sqrt(num_list));
0070 numb = ceil( num_list/numa);
0071 
0072 
0073 clf;
0074 max_x = 0;
0075 max_t = 0;
0076 data_A = cell(1,num_list);
0077 del = .1;
0078 ii = 0;
0079 
0080 h = waitbar(0, 'Computation' );
0081 cleanup = onCleanup( @()( delete( h ) ) );
0082 
0083 for jj = 1:num_list_
0084     
0085     if ~isempty(dir_list(jj).name)
0086         
0087         ii = ii + 1;
0088         filename = [dirname,filesep,dir_list(jj).name];
0089         data = load(filename);
0090         [kymo,~,f1mm,~] = makeKymographC(data,0,CONST);
0091         
0092         name(jj) = data.ID;
0093         pole(jj) = getPoleSign( data );
0094         
0095         if CONST.view.falseColorFlag
0096             backer3 = double(cat(3, kymo.b, kymo.b, kymo.b)>1);
0097             im = doColorMap( ag(kymo.g,f1mm(1), f1mm(2)), colormap_ );
0098             data_A{ii} =( im.*backer3+.6*(1-backer3) );
0099         else
0100             data_A{ii} = cat(3,del*ag(1-kymo.b)+ag(kymo.r),...
0101                 del*ag(1-kymo.b)+ag(kymo.g),del*ag(1-kymo.b));
0102         end
0103         
0104         ss = size(data_A{ii});       
0105         max_x = max([max_x,ss(1)]);
0106         max_t = max([max_t,ss(2)]);        
0107     end
0108      waitbar(jj/num_list_,h);
0109 end
0110  close(h);
0111  
0112 max_x = max_x+1;
0113 max_t = max_t+1;
0114 imdim = [ max_x*numa + 1, max_t*numb + 1 ];
0115 
0116 for ii = 1:2
0117     if isnan(imdim(ii))
0118         imdim (ii)= 0;
0119     end
0120 end
0121 
0122 
0123 if CONST.view.falseColorFlag
0124     cc = 'w';
0125     im = (zeros(imdim(1), imdim(2), 3 ));
0126     im(:,:,:) = del*0;
0127     
0128     for ii = 1:num_list
0129         yy = floor((ii-1)/numb);
0130         xx = ii-yy*numb-1;
0131         
0132         ss = size(data_A{ii});
0133         dx = floor((max_x-ss(1))/2);
0134         
0135         im(1+yy*max_x+(1:ss(1))+dx, 1+xx*max_t+(1:ss(2)),:) =  data_A{ii};
0136     end
0137 else
0138     cc = 'w';
0139     im = uint8(zeros(imdim(1), imdim(2), 3 ));
0140     im(:,:,:) = del*255;
0141     
0142     for ii = 1:num_list
0143         yy = floor((ii-1)/numb);
0144         xx = ii-yy*numb-1;
0145         
0146         ss = size(data_A{ii});
0147         dx = floor((max_x-ss(1))/2);
0148         
0149         im(1+yy*max_x+(1:ss(1))+dx, 1+xx*max_t+(1:ss(2)),:) =  data_A{ii};
0150     end
0151 end
0152 
0153 ss = size(im);
0154 
0155 T_ = (1:ss(2))*TimeStep;
0156 X_ = (1:ss(1))*PixelSize;
0157 
0158 inv_flag = 0;
0159 figure;
0160 clf;
0161 if inv_flag
0162     imagesc(T_,X_,255-im);
0163 else
0164     imagesc(T_,X_,im);
0165 end
0166 hold on;
0167 
0168 nx = ceil(sqrt( num_list*max_x/max_t));
0169 ny = ceil(num_list/nx);
0170 
0171 max_T = max(T_);
0172 max_X = max(X_);
0173 
0174 for ii = 1:num_list
0175     yy = floor((ii-1)/numb);
0176     xx = ii-yy*numb-1;
0177     y = yy*(max_X/numa);
0178     x = xx*(max_T/numb);
0179     text( x+max_T/20/numb, y+max_X/20/numa, [num2str(name(ii))],'Color',cc,'FontSize',12,'VerticalAlignment','Top','HorizontalAlignment','Left');
0180 end
0181 
0182 
0183 dd = [1,numa*max_x+1];
0184 for xx = 1:(numb-1)
0185     plot( (0*dd + 1+xx*max_t)*TimeStep, dd*PixelSize,[':',cc]);
0186 end
0187 
0188 dd = [1,numb*max_t+1];
0189 for yy = 1:(numa-1)
0190     plot( (dd)*TimeStep, (0*dd + 1+yy*max_x)*PixelSize, [':',cc]);
0191 end
0192 
0193 xlabel('Time (h)');
0194 ylabel('Long Axis Position (um)');
0195 
0196 end
0197 
0198

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005