Home > SuperSegger > viz > makeCellMovie.m

makeCellMovie

PURPOSE ^

makeCellMovie : creates a movie for a single cell file

SYNOPSIS ^

function mov = makeCellMovie(data)

DESCRIPTION ^

 makeCellMovie : creates a movie for a single cell file
 INPUT : 
       data : a Cell data structure
 OUTPUT : 
       mov : movie file


 Copyright (C) 2016 Wiggins Lab 
 Written by Paul Wiggins.
 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 mov = makeCellMovie(data)
0002 % makeCellMovie : creates a movie for a single cell file
0003 % INPUT :
0004 %       data : a Cell data structure
0005 % OUTPUT :
0006 %       mov : movie file
0007 %
0008 %
0009 % Copyright (C) 2016 Wiggins Lab
0010 % Written by Paul Wiggins.
0011 % University of Washington, 2016
0012 % This file is part of SuperSegger.
0013 %
0014 % SuperSegger is free software: you can redistribute it and/or modify
0015 % it under the terms of the GNU General Public License as published by
0016 % the Free Software Foundation, either version 3 of the License, or
0017 % (at your option) any later version.
0018 %
0019 % SuperSegger is distributed in the hope that it will be useful,
0020 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0021 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0022 % GNU General Public License for more details.
0023 %
0024 % You should have received a copy of the GNU General Public License
0025 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0026 
0027 figure(2);
0028 num_im = numel(data.CellA);
0029 
0030 ss = [0,0];
0031 for ii = 1:num_im
0032     ss_tmp = size(data.CellA{ii}.phase);    
0033     ss(1) = max([ss(1),ss_tmp(1)]);
0034     ss(2) = max([ss(2),ss_tmp(2)]);
0035 end
0036 
0037 
0038 for ii = 1:num_im
0039     figure(2);
0040     clf;
0041     dataA = data.CellA{ii};
0042     back  = ag(dataA.phase);
0043     
0044     if isfield( dataA, 'fluor1' )        
0045         fluo  = ag(dataA.fluor1);
0046     else
0047         fluo = back*0;
0048     end;
0049     
0050     
0051     if isfield( dataA, 'fluor2' )        
0052         fluo2 = ag(dataA.fluor2);
0053     else
0054         fluo2 = fluo*0;
0055     end;
0056     
0057     
0058     mask_ = imdilate(dataA.mask,strel('square',3));
0059     mask  = dataA.mask;
0060     outline= mask_-mask;
0061     maski = ag(outline);
0062     
0063     if exist( 'fluo2', 'var' );
0064         fluo2_thresh = fluo2(logical(mask));
0065         fluo2_thresh = mean(fluo2_thresh);
0066     end
0067     
0068     fluo_thresh = fluo(logical(mask));
0069     fluo_thresh = mean(fluo_thresh);
0070     gChan = fixIm(0.6*ag(double(uint8(fluo-0*fluo_thresh)).*(0.3+double(mask)*0.6))+0.3*back,ss);
0071     [bChan,roffset] = fixIm(0.3*maski+0.3*back,ss);
0072     
0073     if exist( 'fluo2', 'var' );
0074         rChan = fixIm(0.6*ag(double(uint8(fluo2-0*fluo2_thresh)).*(0.3+double(mask)*0.6))+0.3*back,ss);
0075     else
0076         rChan = fixIm(0.3*back,ss);
0077     end
0078     
0079     
0080     imshow( cat(3, rChan, gChan, bChan), [],'InitialMagnification','fit');
0081     hold on;
0082     ro = dataA.r_offset;    
0083     r = dataA.r;
0084     plot( r(1)-ro(1)+1+roffset(1), r(2)-ro(2)+1+roffset(2), 'w.' );
0085 
0086     ll = dataA.length;
0087     llmaj = [ll(1),-ll(1)];
0088     llmin = [ll(2),-ll(2)];    
0089     
0090     xx = llmaj*dataA.coord.e1(1)/2;
0091     yy = llmaj*dataA.coord.e1(2)/2;
0092     plot( r(1)-ro(1)+1+xx+roffset(1), r(2)-ro(2)+1+yy+roffset(2), 'b:' );
0093     
0094     xx =  llmin*dataA.coord.e2(1)/2;
0095     yy = llmin*dataA.coord.e2(2)/2;
0096     plot( r(1)-ro(1)+1+xx+roffset(1), r(2)-ro(2)+1+yy+roffset(2), 'b:' );
0097     
0098     
0099     if isfield(dataA, 'locus1'  )
0100         num_spot = numel( dataA.locus1 );
0101         for jj = 1:num_spot;
0102             r = dataA.locus1(jj).r;
0103             plot( r(1)-ro(1)+1+roffset(1), r(2)-ro(2)+1+roffset(2), 'go' );
0104         end
0105     end
0106     
0107     if isfield(dataA, 'locus2'  )
0108         num_spot = numel(dataA.locus2 );
0109         for jj = 1:num_spot;
0110             r = dataA.locus2(jj).r;
0111             plot( r(1)-ro(1)+1+roffset(1), r(2)-ro(2)+1+roffset(2), 'ro' );
0112         end
0113     end
0114     
0115     drawnow;
0116     mov(ii) = getframe;
0117     
0118 end
0119 
0120 
0121 end
0122 
0123 function [imFix,roffset] = fixIm(im, ss)
0124 ssOld = size(im);
0125 imFix = zeros(ss);
0126 
0127 offset = floor((ss-ssOld)/2)-[1,1];
0128 if offset(1)<0
0129     offset(1) = offset(1) + 1;
0130 end
0131 if offset(2)<0
0132     offset(2) = offset(2) + 1;
0133 end
0134 
0135 try
0136     imFix(offset(1)+(1:ssOld(1)),offset(2)+(1:ssOld(2))) = im;
0137 catch
0138     '';
0139 end
0140 roffset = offset(2:-1:1);
0141 imFix = uint8(imFix);
0142 end

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