-
Notifications
You must be signed in to change notification settings - Fork 0
/
SC_CellLevelFeatures.asv
96 lines (80 loc) · 3.61 KB
/
SC_CellLevelFeatures.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
function SC_CellLevelFeatures(method)
%function sc_yeastfeatcalc(har_intbins, downsamplerate,featset)
%SC_YEASTFEATCALC A function for cell/field feature calculation
% 22-Nov-2005 Initial write T. Zhao
% 09-Aug-2006 Modified S.C. Chen
% count = 1
% while license('checkout','statistics_toolbox')==0
% fprintf(1,'The statistics_toolbox is not avaiable... Waiting(%d)...', count); count = count + 1 ;
% pause(30);
% end
imglist = load(method.procfilesmatname);
nprocfiles = length(imglist.procfiles{1});
if method.celllevel == 1
resultdir180feat = [method.resultdir filesep method.thresmethod 'feat_b256_d1'];
resultdir = [method.resultdir filesep method.thresmethod 'feat_b' num2str(method.har_intbins) '_d' num2str(method.downsamplerate)];
segdirpath = [method.resultdir filesep 'handseg'];
else
fprintf(1,'error\n');
end
for n=1:nprocfiles
segImagePath = imglist.procfiles{1}{n};
featFileName = ['Cell' num2str(n) '_features'];
controlDirectory = [resultdir filesep featFileName];
[s,msg] = mkdir(resultdir,featFileName);
%% Check if the job has been taken over
if strfind(msg,'exist')
continue;
end
fprintf(1, 'Processing %dth image(%s)...\n',n,segImagePath);
resultfile = [resultdir filesep featFileName '.mat'];
if ~exist(resultfile,'file') & method.celllevel == 1
if ~exist([segdirpath filesep 'handmask' num2str(n) '_1.mat'],'file')
fprintf(1,'The segmentation file does not exist\n');
continue;
else
% this can be modified to accomodate more than one masks in one image
tmp = load([segdirpath filesep 'handmask' num2str(n) '_1.mat']);
fprintf(1,'Reading segmentation file...\n');
normreg=tz_normreg(tmp.mask_cell);
if sum(tmp.mask_cell(:)) == 0
fprintf(1, 'No feature can be calculated from empty masks\n');
continue;
end
end
dnaimgname = imglist.procfiles{1}{n};
if ~exist(dnaimgname,'file')
fprintf(1,'DNA image %s does not exist. Skip it...\n',dnaimgname);
continue;
else
fprintf(1,'Reading DNA image...\n');
dnaimg=imread(dnaimgname);
end
gfpimgname = imglist.procfiles{2}{n};
if ~exist(gfpimgname,'file')
fprintf(1,'GFP image %s does not exist. Skip it...\n',gfpimgname);
continue;
else
fprintf(1,'Reading GFP image...\n');
gfpimg=imread(gfpimgname);
end
feats = [];
% if method.har_intbins == 256
% keyboard;
[feats,names,slfnames]=sc_regionfeatmat(gfpimg,dnaimg,normreg,'mcell_mor',method.har_intbins,method.downsamplerate,method.thresmethod);
[feats,names,slfnames]=sc_regionfeatmat(gfpimg,dnaimg,normreg,'mcell_mor',method.har_intbins,method.downsamplerate,method.thresmethod);
% else
% resultfile180feat = [resultdir180feat filesep featFileName '.mat'];
% if ~exist(resultfile180feat,'file')
% feats=sc_regionfeatmat(gfpimg,dnaimg,normreg,'all180',method.har_intbins,method.downsamplerate,method.thresmethod);
% else
% harfeats=sc_regionfeatmat(gfpimg,dnaimg,normreg,'har',method.har_intbins,method.downsamplerate,method.thresmethod);
% load(resultfile180feat);
% feats(:,73:85) = harfeats;
% end
% end
save(resultfile,'feats','names','slfnames');
fprintf(1,'%s saved\n\n', resultfile);
unix(['rm -rf ' controlDirectory]);
end
end