|
a |
|
b/combinedDeepLearningActiveContour/saveCont_into_txtFile.m |
|
|
1 |
% this program aims to save automatic contours into text files |
|
|
2 |
% to be later used for evaluation and statistical analysis |
|
|
3 |
clear all |
|
|
4 |
close all |
|
|
5 |
clc |
|
|
6 |
addpath('functions') |
|
|
7 |
%imset='training'; |
|
|
8 |
%imset='online'; |
|
|
9 |
imset='validation'; |
|
|
10 |
|
|
|
11 |
%% ED contours |
|
|
12 |
patient=15; |
|
|
13 |
|
|
|
14 |
name1=['results/',imset,'/ED/case',num2str(patient),'.mat']; |
|
|
15 |
load (name1,'LV_seg','Mroi','slice_num','slice_per_patient','t_I',... |
|
|
16 |
't_centers','t_contours','t_LV_cont_names'); |
|
|
17 |
|
|
|
18 |
% convert LV mask to original image size |
|
|
19 |
for k=1:length(slice_num) |
|
|
20 |
display(['processing slice# ',num2str(slice_num(k))]) |
|
|
21 |
I=t_I(:,:,slice_num(k)); |
|
|
22 |
|
|
|
23 |
% center of sub image |
|
|
24 |
cnt_xy=t_centers{slice_num(k)}; |
|
|
25 |
|
|
|
26 |
% resize to original size |
|
|
27 |
LV_seg_Isize(:,:,slice_num(k)) = remap_mask(LV_seg(:,:,slice_num(k)),cnt_xy,I); |
|
|
28 |
|
|
|
29 |
% save into files |
|
|
30 |
fname1=['results/',imset,'/contours-auto/case',num2str(patient),'/']; |
|
|
31 |
if exist(fname1,'dir')==0 |
|
|
32 |
mkdir(fname1); |
|
|
33 |
end |
|
|
34 |
endo_cn=t_LV_cont_names(slice_num(k)).name; |
|
|
35 |
endo_cnm = strrep(endo_cn, 'manual', 'auto'); |
|
|
36 |
|
|
|
37 |
name2=[fname1,endo_cnm]; |
|
|
38 |
save_contours2(LV_seg_Isize(:,:,slice_num(k)),name2); |
|
|
39 |
|
|
|
40 |
% display automatic and manual contorus |
|
|
41 |
subplot(3,ceil(length(slice_num)/3),k) |
|
|
42 |
Cm=t_contours{slice_num(k)}; |
|
|
43 |
showCurveAndPhi(I,Cm,LV_seg_Isize(:,:,slice_num(k))); |
|
|
44 |
|
|
|
45 |
end |
|
|
46 |
%% |
|
|
47 |
% ES contours |
|
|
48 |
name1=['results/',imset,'/ES/case',num2str(patient),'.mat']; |
|
|
49 |
load (name1,'LV_seg','Mroi','slice_num','slice_per_patient','t_I',... |
|
|
50 |
't_centers','t_contours','t_LV_cont_names'); |
|
|
51 |
|
|
|
52 |
figure |
|
|
53 |
% convert LV mask to original image size |
|
|
54 |
for k=1:length(slice_num) |
|
|
55 |
display(['processing slice# ',num2str(slice_num(k))]) |
|
|
56 |
I=t_I(:,:,slice_num(k)); |
|
|
57 |
|
|
|
58 |
% center of sub image |
|
|
59 |
cnt_xy=t_centers{slice_num(k)}; |
|
|
60 |
|
|
|
61 |
% resize to original size |
|
|
62 |
LV_seg_Isize(:,:,slice_num(k)) = remap_mask(LV_seg(:,:,slice_num(k)),cnt_xy,I); |
|
|
63 |
|
|
|
64 |
% save into files |
|
|
65 |
fname1=['results/',imset,'/contours-auto/case',num2str(patient),'/']; |
|
|
66 |
endo_cn=t_LV_cont_names(slice_num(k)).name |
|
|
67 |
endo_cnm = strrep(endo_cn, 'manual', 'auto'); |
|
|
68 |
|
|
|
69 |
name2=[fname1,endo_cnm]; |
|
|
70 |
save_contours2(LV_seg_Isize(:,:,slice_num(k)),name2); |
|
|
71 |
|
|
|
72 |
% display automatic and manual contorus |
|
|
73 |
subplot(3,ceil(length(slice_num)/3),k) |
|
|
74 |
Cm=t_contours{slice_num(k)}; |
|
|
75 |
showCurveAndPhi(I,Cm,LV_seg_Isize(:,:,slice_num(k))); |
|
|
76 |
|
|
|
77 |
end |