Home > SuperSegger > viz > makeConsensusImage.m

makeConsensusImage

PURPOSE ^

makeConsensusImage : Computes consensus fluorescence localization from cells in a cell files

SYNOPSIS ^

function [ imMosaic, imColor, imBW, imInv, imMosaic10 ] = makeConsensusImage(dataImArray, CONST, skip, mag, disp_flag, fnum, clist)

DESCRIPTION ^

 makeConsensusImage : Computes consensus fluorescence localization from cells in a cell files

 INPUT:
   dataImArray : cell image array made from makeConsensusArray
               or cell directory - then it calls makeConsensusArray and
               creates dataImArray.

 OUPUT:
  imMosaic : Image mosaic of cells that make up the consensus image
   imColor : Color cons image (w/ black background)
      imBW : Grayscale cons image
     imInv : Color cons image (w/ white background)
  imMosaic10 : Image mosaic of first 10 cells that make up the consensus image

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ imMosaic, imColor, imBW, imInv, imMosaic10 ] = makeConsensusImage ...
0002     (dataImArray, CONST, skip, mag, disp_flag, fnum, clist)
0003 % makeConsensusImage : Computes consensus fluorescence localization from cells in a cell files
0004 %
0005 % INPUT:
0006 %   dataImArray : cell image array made from makeConsensusArray
0007 %               or cell directory - then it calls makeConsensusArray and
0008 %               creates dataImArray.
0009 %
0010 % OUPUT:
0011 %  imMosaic : Image mosaic of cells that make up the consensus image
0012 %   imColor : Color cons image (w/ black background)
0013 %      imBW : Grayscale cons image
0014 %     imInv : Color cons image (w/ white background)
0015 %  imMosaic10 : Image mosaic of first 10 cells that make up the consensus image
0016 %
0017 % Copyright (C) 2016 Wiggins Lab
0018 % Written by Paul Wiggins, Stella Stylianidou.
0019 % University of Washington, 2016
0020 % This file is part of SuperSegger.
0021 %
0022 % SuperSegger is free software: you can redistribute it and/or modify
0023 % it under the terms of the GNU General Public License as published by
0024 % the Free Software Foundation, either version 3 of the License, or
0025 % (at your option) any later version.
0026 %
0027 % SuperSegger is distributed in the hope that it will be useful,
0028 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030 % GNU General Public License for more details.
0031 %
0032 % You should have received a copy of the GNU General Public License
0033 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0034 
0035 if ~exist( 'skip', 'var' ) || isempty( skip )
0036     skip = 1;
0037 end
0038 
0039 if ~exist( 'mag', 'var' ) || isempty( mag )
0040     mag = 4;
0041 end
0042 if ~exist( 'disp_flag', 'var' ) || isempty( disp_flag )
0043     disp_flag = 1;
0044 end
0045 
0046 if exist( 'clist', 'var' )
0047     clist = gate( clist );
0048 else
0049     clist = [];
0050 end
0051 
0052 if ~exist( 'fnum', 'var' ) || isempty(fnum)
0053     fnum = 1;
0054 end
0055 
0056 if ~isstruct(dataImArray) && isdir (dataImArray)
0057     cellDir = dataImArray;
0058     [dataImArray] = makeConsensusArray( cellDir, CONST, skip, mag, fnum, clist);
0059 end
0060 
0061 
0062 T0 = numel(dataImArray.imCell); % number of frames
0063 
0064 for jj = 1:T0
0065     ssCell{jj} = size(dataImArray.imCell{jj} );
0066 end
0067 
0068 % merge the cell towers
0069 [ ~, ~, dataImArray.tower, dataImArray.towerMask ] = ...
0070     towerMergeImages( dataImArray.imCell, dataImArray.maskCell, ssCell, 1, skip, mag, CONST );
0071 
0072 % Merge the normalized towers into a single image
0073 [ ~, ~, dataImArray.towerNorm, dataImArray.towerMask ] = ...
0074     towerMergeImages( dataImArray.imCellNorm, dataImArray.maskCell, ssCell, 1, skip, mag, CONST );
0075 
0076 % Merge the normalized weighted towers into a single image
0077 [ ~, ~, dataImArray.towerNormW, dataImArray.towerMask ] = ...
0078         towerMergeImages( dataImArray.imCellNormW, dataImArray.maskCell, ssCell, 1, skip, mag, CONST );
0079 
0080 
0081 numIm = numel( dataImArray.tower );
0082 
0083 if numIm  > 0
0084     % make the color map for the color image
0085     
0086     [ imMosaic, imColor, imBW, imInv, imMosaic10 ] = intDoMakeImage( dataImArray.towerNorm, ...
0087         dataImArray.towerMask, dataImArray.towerCArray, ...
0088         dataImArray.ssTot, dataImArray.cellArrayNum, CONST, disp_flag );
0089     imBWunmasked = dataImArray.towerNorm;
0090     imBWmask     = dataImArray.towerMask;
0091     
0092     
0093 end
0094 
0095 end
0096 
0097 function [ imMosaic, imColor, imBW, imInv, imMosaic10] = ...
0098     intDoMakeImage( imSum, maskSum, cellArray, ssTot, cellArrayNum, ...
0099     CONST, disp_flag )
0100 % intDoMakeImage : internal function that creates the consensus image
0101 % and cell mosaic
0102 %
0103 % INPUT :
0104 %         imSum : Summed up imBW
0105 %         maskSum : Summed up maskCons
0106 %         imCellSum : Summed up imCell
0107 %         cellArray : array of images for each cel
0108 %         ssTot : Im size of tower mosaic of cell contributing to cons
0109 %         cellArrayNum :
0110 %         CONST : segmentation constants
0111 %         disp_flag : 1 to display images
0112 %
0113 % OUTPUT :
0114 %         imMosaic : Mosaic of towers of cells that make up the consensus image
0115 %         imColor : Color cons image (w/ black background)
0116 %          imBW : Grayscale cons image
0117 %         imInv : Color cons image (w/ white background)
0118 
0119 numCells = numel(cellArray);
0120 
0121 % cellArrayPos: location in the image of each panel of the mosaic.
0122 cellArrayPos = cell(1,numCells);
0123 
0124 % make the color map for the color image
0125 persistent colormap_;
0126 if isempty( colormap_ )
0127     colormap_ = jet(256);
0128 end
0129 
0130 
0131 imTmp = 255*doColorMap( ag(imSum, min(imSum( maskSum>.95 )), max(imSum( maskSum>.95 )) ), colormap_ );
0132 mask3 = cat( 3, maskSum, maskSum, maskSum );
0133 imColor = uint8(uint8( double(imTmp).*mask3));
0134 imBW  = uint8( double(ag(imSum, min(imSum( maskSum>.95 )), max(imSum( maskSum>.95 )) )) .* maskSum );
0135 imTmp = 255*doColorMap( ag(imSum, min(imSum( maskSum>.95 )), max(imSum( maskSum>.95 )) ), 1-colormap_ );
0136 mask3 = cat( 3, maskSum, maskSum, maskSum );
0137 imInv = 255-uint8(uint8( double(imTmp).*mask3));
0138 
0139 % plots the consensus image
0140 if disp_flag
0141     figure(5)
0142     clf;
0143     imshow(imColor);
0144     drawnow;
0145 end
0146 
0147 
0148 del = 1;
0149 
0150 % plots a mosaic of single cell towers
0151 if CONST.view.falseColorFlag
0152     imMosaic = uint8(zeros( [ssTot(1), ssTot(2), 3] )) + del*255;
0153 else
0154     imMosaic = uint8(zeros( [ssTot(1), ssTot(2), 3] ));
0155 end
0156 
0157 
0158 colPos = 1;
0159 width10 = 0;
0160 time10  = 0;
0161 
0162 for ii = 1:numCells
0163     ss = size(cellArray{ii});
0164     if ii <= 10
0165         width10 = width10 + ss(2);
0166         time10  = max([ss(1),time10]);
0167     end
0168     
0169     imMosaic(1:ss(1), colPos:(colPos+ss(2)-1), :) = cellArray{ii};
0170     cellArrayPos{ii} = colPos + ss(2)/2;
0171     colPos = colPos + ss(2);
0172     
0173 end
0174 
0175 imMosaic10 = imMosaic( 1:time10, 1:width10, : );
0176 
0177 if disp_flag
0178     figure(1);
0179     clf;
0180     imshow(imMosaic);
0181     title ('Mosaic of towers of single cells');
0182     if CONST.view.falseColorFlag
0183         cc = 'w';
0184     else
0185         cc = 'b';
0186     end
0187     
0188     for ii = 1:numCells
0189         text( cellArrayPos{ii}, 0, num2str(cellArrayNum{ii}), 'Color', cc, ...
0190             'HorizontalAlignment','center' );
0191     end
0192 end
0193 
0194 end
0195

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