-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSC.m
54 lines (51 loc) · 1.41 KB
/
DSC.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
% Program2
% Dice similarity coefficient
clear
clc
%---------------------------------------------------
DSC=zeros(5,5);
for i=1:5
for j=1:5
if i==j
DSC(i,j)=1;
else
stri=num2str(i);
strj=num2str(j);
filename=['...\' stri 'to' strj '-syn-Genu.nii.gz'];%Deformed label
t=load_nii(filename);
ROI=t.img;
label1=zeros(128,128,64);
[x,y,z]=meshgrid(1:128,1:128,1:64);
for x=1:1:128
for y=1:1:128
for z=1:1:64
if(ROI(x,y,z)~=0)
label1(x,y,z)=1;
end
end
end
end
filename=['...\' strj '-fa-label-Genu.nii.gz'];
t1=load_nii(filename);
ROI1=t1.img;
label=zeros(128,128,64);
[x,y,z]=meshgrid(1:128,1:128,1:64);
for x=1:1:128
for y=1:1:128
for z=1:1:64
if(ROI1(x,y,z)~=0)
label(x,y,z)=1;
end
end
end
end
common=(label&label1);
a=sum(common(:));
b=sum(label1(:));
c=sum(label(:));
DSC_ratio=2*a/(b+c);
DSC(i,j)=DSC_ratio;
end
end
end
save('...\DSC5','DSC')