Permalink
Cannot retrieve contributors at this time
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?
mp_cell_tracking/cell_processing_main.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
136 lines (109 sloc)
3.88 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clc; | |
clear; | |
close all; | |
warning('off','all') | |
set(0,'defaultAxesFontSize',10) | |
set(0,'defaultAxesFontName', 'DejaVu Sans') | |
set(0,'defaultTextFontName', 'DejaVu Sans') | |
addpath(genpath('common_codes')); | |
% ========================================================================= | |
raw_data_dir = uigetdir('ADD YOUR FOLDER DIRECTORY CONTAIING THE STACKED TIFF FILES'); | |
disp(['Data directory: ',raw_data_dir]) | |
case_list = dir(fullfile(raw_data_dir,'*.tif')); | |
N_cases = length(case_list); | |
case_set = 1:N_cases; | |
optionProcessing = 1; | |
optionPostprocessing = 0; | |
optionVideo = 1; | |
if optionProcessing | |
plot_dir = 'results'; | |
mkdir(plot_dir) | |
window_range = zeros(N_cases,4); | |
basic_t = zeros(N_cases,1); | |
peak_min = zeros(N_cases,1); | |
area_min = zeros(N_cases,1); | |
area_max = zeros(N_cases,1); | |
time_step = zeros(N_cases,1); | |
d_acc_threshold = zeros(N_cases,1); | |
for i = case_set | |
close all | |
figure('position',[200 100 800 800]) | |
C = strsplit(case_list(i).name,'.'); | |
case_string = strrep(C{1},'_',' '); | |
img_fname = fullfile(case_list(i).folder,case_list(i).name);%fullfile(raw_data_dir,case_list(i).name); | |
img = imread(img_fname, 1); | |
imagesc(img); hold on; | |
axis equal | |
title(['Select region for case: ',case_string]); | |
[x,y] = ginput(2); | |
x0 = min(round(x)); | |
x1 = max(round(x)); | |
y0 = min(round(y)); | |
y1 = max(round(y)); | |
rectangle('Position',[x0 y0 x1-x0 y1-y0],'EdgeColor','r','LineWidth',3,'linestyle','--') | |
print(fullfile(plot_dir,[case_string,'_ROI']),'-dtiff','-r300') | |
window_range(i,:) = [x0 x1 y0 y1]; | |
close all | |
prompt = {'Basic intensity thresholding:',... | |
'Minimum peak intensity:',... | |
'Minimum cell area:',... | |
'Maximum cell area:',... | |
'Time step (min) between frames:',... | |
'd_acc to threshold motile cells:'}; | |
tt = 'Processing parameters'; | |
dims = [1 35]; | |
definput = {'20','25','3','1000','30','50'}; | |
answer = inputdlg(prompt,tt,dims,definput); | |
basic_t(i) = str2double(answer{1}); | |
peak_min(i) = str2double(answer{2}); | |
area_min(i) = str2double(answer{3}); | |
area_max(i) = str2double(answer{4}); | |
time_step(i) = str2double(answer{5}); | |
d_acc_threshold(i) = str2double(answer{6}); | |
end | |
props = []; | |
props.optionFigure = 0; | |
props.downsample_factor = 7; | |
for i = case_set | |
C = strsplit(case_list(i).name,'.'); | |
case_string = C{1}; | |
disp(['Processing case: ',case_string]) | |
props.case_string = case_string; | |
props.window_range = window_range(i,:); | |
props.img_fname = fullfile(case_list(i).folder,case_list(i).name); | |
props.peak_min = peak_min(i); | |
props.basic_t = basic_t(i); | |
props.area_min = area_min(i); | |
props.area_max = area_max(i); | |
props.optionDebug = 0; | |
props.connectivity = 4; | |
cell_downsample_Hessian_segmentation(props); | |
cell_parameterization(props); | |
cell_tracking(case_string); | |
cell_connect_tracks(case_string); | |
end | |
end | |
if optionPostprocessing | |
props = []; | |
props.roseBins = 8; | |
props.plot_UV_max = 10; | |
props.plot_dXdY_max = 200; | |
props.plot_cell_num_max = 1000; | |
for i = case_set | |
close all | |
C = strsplit(case_list(i).name,'.'); | |
props.case_string = C{1}; | |
props.time_step = time_step(i); | |
props.d_acc_threshold = d_acc_threshold(i); | |
cell_postprocessing(props); | |
end | |
end | |
if optionVideo | |
time_step = 1; | |
for i = case_set | |
close all | |
C = strsplit(case_list(i).name,'.'); | |
case_string = C{1}; | |
cell_plot_sequence(case_string,time_step); | |
end | |
end |