-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpre_process_func.m
60 lines (40 loc) · 2.04 KB
/
pre_process_func.m
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
function [pre_nuclei, pre_vessels, pre_micromet] = pre_process_func(nuclei,vessels,micromets,save_dir,sample_name)
shortfile = sample_name;
display(['Pre-processing ' shortfile])
%Pre-processing of nuclei channel
nuclei_single = single(nuclei);
nuclei_local = nuclei_single./(0.2*max(nuclei_single(:))+(im2mat(gaussf(nuclei_single,size(nuclei_single,1)/10))));
nuclei_loglocal = mat2im(log(nuclei_local+0.1));
nuclei_processed = uint8(stretch(nuclei_loglocal));
pre_nuclei = nuclei_processed;
%Pre-processing of blood vessels channel
vessels_single = single(vessels);
vessels_local = vessels_single./(0.2*max(vessels_single(:))+(im2mat(gaussf(vessels_single,size(vessels_single,1)/10))));
vessels_loglocal = mat2im(log(vessels_local+0.1));
vessels_processed = uint8(stretch(vessels_loglocal));
pre_vessels = vessels_processed;
%Pre-processing of ki67 channel
ki67_single = single(micromets);
ki67_local = ki67_single./(0.2*max(ki67_single(:))+(im2mat(gaussf(ki67_single,size(ki67_single,1)/10))));
ki67_loglocal = mat2im(log(ki67_local+0.1));
ki67_processed = uint8(stretch(ki67_loglocal));
pre_micromet = ki67_processed;
%Write pre-processed files
cd(save_dir)
nuclei_processed_name = strcat(shortfile,'_pre_processed_nuclei.tif');
vessels_processed_name = strcat(shortfile,'_pre_processed_vessels.tif');
ki67_processed_name = strcat(shortfile,'_pre_processed_micromets.tif');
num_slices = size(nuclei,3);
imwrite(uint8(nuclei_processed(:,:,1)),nuclei_processed_name);
for p = 2:num_slices
imwrite(uint8(nuclei_processed(:,:,p)),nuclei_processed_name, 'WriteMode','append');
end
imwrite(uint8(vessels_processed(:,:,1)),vessels_processed_name);
for p = 2:num_slices
imwrite(uint8(vessels_processed(:,:,p)),vessels_processed_name, 'WriteMode','append');
end
imwrite(uint8(ki67_processed(:,:,1)),ki67_processed_name);
for p = 2:num_slices
imwrite(uint8(ki67_processed(:,:,p)),ki67_processed_name, 'WriteMode','append');
end
end