Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
function cell_plot_sequence(case_string,time_step)
case_dir = fullfile('cases',case_string);
% time_step = 1;
% case_string = 'ca1a_n2';
% case_dir = '/home/shannon/b/aether/Projects/Tumor_Microenvironment/Analysis/Brian/Spring_2019/03032019/cases/ca1hFN3_n1_bsubtracted_v1';
img_dir = fullfile(case_dir,'images');
track_dir = fullfile(case_dir,'tracks');
particle_dir = fullfile(case_dir,'particles');
image_list = dir(fullfile(img_dir,'*.tif'));
num_imgs = length(image_list);
particle_list = dir(fullfile(particle_dir,'*.mat'));
load(fullfile(track_dir,'tracks.mat'))
out_dir = 'results';
mkdir(out_dir);
myVideo = VideoWriter(fullfile(out_dir,[case_string,'.avi']));
myVideo.FrameRate = 30; % Default 30
myVideo.Quality = 50; % Default 75
open(myVideo)
num_tracks = size(tracks_order,3);
% colors = distinguishable_colors(num_tracks,'k');
colors = rand(num_tracks,3);
figure('position',[0 0 900 900],'InvertHardCopy', 'off','color','w')
for i = 1: num_imgs - 2
time = (i - 1) * time_step;
file_name = fullfile(img_dir,image_list(i).name);
img_raw = imread(file_name);
img = medfilt2(img_raw,[3 3]);
current_track = reshape(tracks_order(i,:,:),4,num_tracks)';
ind = find(current_track(:,1)~=0);
%[rb(ind) ra(ind) ang(ind) area(ind) I(ind)];
file_name = fullfile(particle_dir,particle_list(i).name);
load(file_name)
pos = particles.pos;
paras = particles.paras;
imshow( img_raw,'initialmagnification','fit'); hold on;
for j = 1:length(ind)
track_ID = ind(j);
track_j = tracks_order(:,:,track_ID);
ind_t = find(track_j(:,1) ~=0);
times = ind_t(1):i+1;
x_t = track_j(times,2);
y_t = track_j(times,3);
ind_t = (x_t.*y_t ~= 0);
x_t = x_t(ind_t);
y_t = y_t(ind_t);
particle_id = current_track(track_ID,1);
plot(x_t(1),y_t(1),'color',colors(track_ID,:),'marker','X','markersize',5,'linewidth',2,'linesmoothing','on'); hold on;
%ellipse(paras(particle_id,1),paras(particle_id,2),paras(particle_id,3),pos(particle_id,1),pos(particle_id,2),colors(track_ID,:),50); hold on;
plot(x_t,y_t,'-','color',colors(track_ID,:),'linewidth',2,'linesmoothing','on'); hold on;
end
hold off;
title(sprintf('Time = %.2f frame',time))
% file_name = [out_dir,sprintf('/t=%.4d.tif',i)];
% print(file_name,'-dtiff','-r100')
% frame = imread(file_name);
set(gca,'nextplot','replacechildren');
frame = getframe(gcf);
writeVideo(myVideo, frame)
end
close(myVideo);