Switch to unified view

a b/combinedDeepLearningActiveContour/LVseg_largePhi.m
1
% two-dimensional segmenter  combined with Deep Learning
2
clear all   
3
close all
4
clc
5
addpath('functions')
6
%% load the image 
7
disp('Load MRI images');
8
load matFiles/validation_data; 
9
%%
10
slice_num=23;
11
I=t_I(:,:,slice_num);
12
figure(1)
13
maxplots=4;
14
subplot(1,maxplots,1)
15
imagesc(I);
16
colormap(gray)
17
title(['slice number=',num2str(slice_num)]);
18
19
% maximum iteration
20
max_its = 50;
21
intEweight=.5;
22
DLweight=0.2;
23
Dynamic_Window=1;
24
25
% region of interest size
26
Mroi=100;
27
28
%--- run DL to find ROI: LV location detection
29
% load parameters of Deep Learning for ROI
30
%load DL_ROI_params.mat;
31
%yROI=DLN(I,stackedAEOptTheta,inputSize,hiddenSizeL1,hiddenSizeL2,outputSize,netconfig);
32
%subplot(1,maxplots,2)
33
%magesc(yROI);
34
%subplot(1,maxplots,2);hold on; plot(m_cnt(1),m_cnt(2),'r+')
35
36
% cut ROI from the image
37
%[subI,m_cnt]=mask2subImage(I,yROI,Mroi);
38
subI=t_Iroi(:,:,slice_num);
39
m_cnt=t_centers{slice_num};
40
subplot(1,maxplots,3)
41
imagesc(subI);colormap(gray);hold on; plot(50,50,'r+')
42
43
44
% run DL-LV segmentation to get phi_0
45
load DLconfigure/DL_LV_params.mat;
46
mask_LV=DLN(subI,stackedAEOptTheta,inputSize,hiddenSizeL1,hiddenSizeL2,outputSize,netconfig);
47
mask_LV=clean_segs(mask_LV);
48
init_mask = remap_mask(mask_LV,m_cnt,I);
49
50
% run segmentation
51
figure(2)
52
[LV_seg,phi,m_cnt] = region_segLargePhi(I,subI,m_cnt,init_mask,max_its,intEweight,DLweight,Dynamic_Window,1);
53
hold on
54
%imshow(subI,'initialmagnification',200,'displayrange',[0 255]); hold on;
55
contour(init_mask, [0 0], 'y','LineWidth',2);
56
Ct=t_contours{slice_num};
57
plot(Ct(:,1),Ct(:,2),'r','LineWidth',2)
58
legend('auto','auto','initial','mamual');
59
60
61
62