Home > SuperSegger > viz > makeFrameStripeMosaic.m

makeFrameStripeMosaic

PURPOSE ^

makeFrameStripeMosaic : Creates a long stripe with all the cell towers.

SYNOPSIS ^

function [imTot] = makeFrameStripeMosaic( dirName, CONST, skip, disp_flag, clist )

DESCRIPTION ^

 makeFrameStripeMosaic :  Creates a long stripe with all the cell towers.

 INPUT :
       dirName : directory with cell files
       CONST : segmentation parameters
       skip : frames to be skipped
       disp_flag : 1 to display image, 0 to not display iamge
 OUTPUT :
       imTot : final image

 Copyright (C) 2016 Wiggins Lab
 University of Washington, 2016
 This file is part of SuperSeggerOpti.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [imTot] = makeFrameStripeMosaic( dirName, CONST, skip, disp_flag, clist )
0002 % makeFrameStripeMosaic :  Creates a long stripe with all the cell towers.
0003 %
0004 % INPUT :
0005 %       dirName : directory with cell files
0006 %       CONST : segmentation parameters
0007 %       skip : frames to be skipped
0008 %       disp_flag : 1 to display image, 0 to not display iamge
0009 % OUTPUT :
0010 %       imTot : final image
0011 %
0012 % Copyright (C) 2016 Wiggins Lab
0013 % University of Washington, 2016
0014 % This file is part of SuperSeggerOpti.
0015 
0016 if ~isfield( CONST.view, 'saveFiles' )
0017     CONST.view.saveFiles = false;
0018 end
0019 
0020 
0021 if ~isfield(CONST.view, 'falseColorFlag' )
0022     CONST.view.falseColorFlag = false;
0023 end
0024 
0025 if ~isfield(CONST.view, 'maxNumCell' )
0026     CONST.view.maxNumCell = 100;
0027 end
0028 
0029 if ~exist( 'skip', 'var' )
0030     skip = [];
0031 end
0032 
0033 
0034 if ~isfield( CONST, 'view') || CONST.view.showFullCellCycleOnly
0035     contents = dir([dirName,filesep,'Cell*.mat']);
0036 else
0037     contents = dir([dirName,filesep,'*ell*.mat']);
0038 end
0039 
0040 numCells = numel(contents);
0041 numCells = min( [numCells, CONST.view.maxNumCell] );
0042 disp( ['Numer of files: ', num2str( numCells ), '.'] );
0043 
0044 cellArray = cell(1,numCells);
0045 cellArrayPos = cell(1,numCells);
0046 cellArrayNum = cell(1,numCells);
0047 ssTot = [0,0];
0048 
0049 if disp_flag
0050     h = waitbar(0, 'Computation' );
0051     cleanup = onCleanup( @()( delete( h ) ) );
0052 end
0053 
0054 for ii = 1:numCells
0055     
0056     if disp_flag
0057         waitbar(ii/numCells,h);
0058     end
0059     
0060     loadname = [dirName,filesep,contents(ii).name];
0061     
0062     data = load( loadname );
0063     
0064     lpos =  find(contents(ii).name == 'l', 1, 'last' );
0065     ppos =  find(contents(ii).name == '.', 1 );
0066     
0067     if isempty( lpos ) || isempty( ppos )
0068         disp('Error in makeFrameStripeMosaic' );
0069         return;
0070     else
0071         cellArrayNum{ii} = floor(str2num(contents(ii).name(lpos+1:ppos-1)));
0072     end
0073     
0074     tmp_im = makeFrameMosaic(data,CONST,1,false, skip );
0075     
0076     if isfield( CONST.view, 'saveFiles' ) && CONST.view.saveFiles
0077         loadname(end-2:end)='png';
0078         imwrite( tmp_im, loadname, 'png' );
0079     else
0080         cellArray{ii} = tmp_im;
0081     end
0082     
0083     ss = size(cellArray{ii});
0084     ssTot = [ max([ssTot(1),ss(1)]), ssTot(2)+ss(2) ];
0085 end
0086 
0087 if disp_flag
0088     close(h);
0089 end
0090 
0091 if ~CONST.view.saveFiles
0092     
0093     if CONST.view.falseColorFlag
0094         
0095         if ~isfield( CONST.view, 'background' );
0096             CONST.view.background = [0,0,0];
0097         end
0098         
0099         tmptmp = zeros( [ssTot(1), ssTot(2)] );
0100         imTot = uint8( cat( 3, tmptmp + CONST.view.background(1),...
0101             tmptmp + CONST.view.background(2),...
0102             tmptmp + CONST.view.background(3)));
0103         
0104     else
0105         del = 0.0;
0106         limTot = uint8(zeros( [ssTot(1), ssTot(2), 3] ));
0107     end
0108     
0109     
0110     colPos = 1;
0111     
0112     for ii = 1:numCells
0113         
0114         ss = size(cellArray{ii});
0115         imTot(1:ss(1), colPos:(colPos+ss(2)-1), :) = cellArray{ii};
0116         cellArrayPos{ii} = colPos + ss(2)/2;
0117         colPos = colPos + ss(2);
0118         
0119     end
0120     
0121     clf;
0122     imshow( imTot );
0123     
0124     if CONST.view.falseColorFlag
0125         cc = 'w';
0126     else
0127         cc = 'b';
0128     end
0129     
0130     
0131     for ii = 1:numCells
0132         text( cellArrayPos{ii}, 0, num2str(cellArrayNum{ii}), 'Color', cc, 'HorizontalAlignment','center' );
0133     end
0134 end
0135 
0136 end

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