0001 function mov = makeCellMovie(data)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
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