%% manually find all the blebs % Using findBlebs.m, we find all possible connected components that could be blebs. We then can go through and manually delete connected components that are not blebs. % Use arrow keys to loop through the images and use the % number keys to delete the corresponding detected blebs. To save the variables press the zero key. clear %outputfile = 'BLEBS_061010_c1b.mat'; %outputfile = 'BLEBS_agar_2per_4_C1.mat'; outputfile = 'BLEBS_agar_2per_5_C1.mat'; % get bleb data from file or from variable file %load( 'FILE.mat' ) %filedata = struct('filename', '061010_c1b_seg.tif', 'numberofimages', 85, 'outputfilename', 'FILE.mat', 'outputtofile', 0); %filedata = struct('filename', 'agar_2per_4_C1.tif', 'numberofimages', 100, 'outputfilename', 'FILE.mat', 'outputtofile', 0); filedata = struct('filename', 'agar_2per_5_C1.tif', 'numberofimages', 85, 'outputfilename', 'FILE.mat', 'outputtofile', 0); % parameters set so that we do not miss any connected components that maybe blebs parameters = struct('lowerblebsizethreshold', 50, 'upperblebsizethreshold', 50, 'alphathreshold', 0.0); blebdata = findBlebs( parameters , filedata ); % bleb: [560×422×4×88 double] % blebsize: [4×88 double] % cellsize: [1x88 double] % alpha: [4×88 double] % showAllBlebs: [560×422×88 double] % numberofblebs: [1×88 double] % images: struct with (intensities, BW, BW2) actualblebdata = blebdata; notblebdata.blebsize = zeros(size(blebdata.blebsize)); notblebdata.alpha = zeros(size(blebdata.alpha)); % show blebs % this plots the cell at time frame i and i+1, aswell as the difference between the two frames in the binary matrices, the detected blebs using the above parameters. Finally we show the actual blebs based on removing the connected components that are not blebs fig = gcf; text1 = text( 0 , 0 , ''); text2 = text1; text3 = text1; text4 = text1; i = 1; while i <= blebdata.numberofimages - 1 subplotrows = 1; subplotcols = 5; subplot(subplotrows,subplotcols,1), imshow(blebdata.images.intensities(:,:,i)), title([ strcat('Time Frame',{' '},int2str(i)) ]) subplot(subplotrows,subplotcols,2), imshow(blebdata.images.intensities(:,:,i+1)), title([ strcat('Time Frame',{' '},int2str(i+1)) ]) subplot(subplotrows,subplotcols,3), imshowpair(blebdata.images.BW2(:,:,i),blebdata.images.BW2(:,:,i+1),'blend','Scaling','joint'), title([ 'Discretised Difference' ]) subplot(subplotrows,subplotcols,4), imshow(blebdata.showAllBlebs(:,:,i)), title([ 'Detected blebs' ]) delete( text1) ; delete( text2 ); delete( text3 ); delete( text4 ); posx = -500; posx2 = 0; posy = -100; posy2 = -75; [n m numberofblebs k] = size( blebdata.bleb ); str = 'bleb sizes = '; str2 = 'alpha = '; for k = 1 : numberofblebs str = strcat( str, int2str(blebdata.blebsize(k,i)), {', '} ); str2 = strcat( str2, num2str(blebdata.alpha(k,i)), {', '} ); end text1 = text(posx, posy, str ); text2 = text(posx,posy2,str2); subplot(subplotrows,subplotcols,5), imshow(actualblebdata.showAllBlebs(:,:,i)), title([ 'Actual blebs' ]) str = 'bleb sizes = '; str2 = 'alpha = '; for k = 1 : numberofblebs str = strcat( str, int2str(actualblebdata.blebsize(k,i)), {', '} ); str2 = strcat( str2, num2str(actualblebdata.alpha(k,i)), {', '} ); end text3 = text(posx2, posy , str ); text4 = text(posx2,posy2,str2); hold on; was_a_key = waitforbuttonpress; if was_a_key && strcmp(get(fig, 'CurrentKey'), 'rightarrow') if (i == blebdata.numberofimages - 1) i = 1; else i = i + 1; end elseif was_a_key && strcmp(get(fig, 'CurrentKey'), 'leftarrow') if (i == 1) i = blebdata.numberofimages - 1; else i = i - 1; end elseif was_a_key blebindex = str2num(get(fig,'CurrentKey')); [n m j k] = size(blebdata.bleb); if blebindex < j + 1 && blebindex > 0 imageindex = i; B = blebdata.bleb(:,:,blebindex,imageindex); if max(max(B)) == 0 str = 'no bleb detected' else % is there a bleb at blebindex? A = actualblebdata.bleb(:,:,blebindex,imageindex); if max(max(A)) == 0 % no bleb then add it str = 'adding bleb to actual blebs' actualblebdata.showAllBlebs(:,:,imageindex) = max( actualblebdata.showAllBlebs(:,:,imageindex) , blebdata.bleb(:,:,blebindex,imageindex)); actualblebdata.numberofblebs(imageindex) = actualblebdata.numberofblebs(imageindex) + 1; actualblebdata.alpha(blebindex, imageindex) = blebdata.alpha(blebindex, imageindex); actualblebdata.blebsize(blebindex, imageindex) = blebdata.blebsize(blebindex, imageindex); actualblebdata.bleb(:,:,blebindex,imageindex) = blebdata.bleb(:,:,blebindex,imageindex) ; notblebdata.blebsize(blebindex, imageindex) = 0; notblebdata.alpha(blebindex, imageindex) = 0; else % remove a bleb str = 'removing bleb from actual blebs' z = zeros(size(blebdata.bleb(:,:,1,1))); actualblebdata.numberofblebs(imageindex) = actualblebdata.numberofblebs(imageindex) - 1; actualblebdata.alpha(blebindex, imageindex) = 0; actualblebdata.blebsize(blebindex, imageindex) = 0; actualblebdata.bleb(:,:,blebindex,imageindex) = z; actualblebdata.showAllBlebs(:,:,imageindex) = z; for index = 1 : blebdata.numberofblebs(imageindex) actualblebdata.showAllBlebs(:,:,imageindex) = max( actualblebdata.showAllBlebs(:,:,imageindex) , actualblebdata.bleb(:,:,index,imageindex)); end notblebdata.blebsize(blebindex, imageindex) = blebdata.blebsize(blebindex, imageindex); notblebdata.alpha(blebindex, imageindex) = blebdata.alpha(blebindex, imageindex); end end elseif blebindex == 0 str = strcat('saving bleb data as ', outputfile) clearvars -except actualblebdata blebdata outputfile notblebdata save( outputfile ); i = blebdata.numberofimages + 1; else str = "input number between 1 and number of blebs" end end end