Download this file

147 lines (133 with data), 6.4 kB

  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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
%filename = 'C:\Documents and Settings\akim2\Desktop\IMFILL\new_parsed_xml.csv';
filename = '\\ailab03\NEW_LIDC\LIDC\extract LIDC\new_parsed_xml.csv';
excelSheet = csvread_mod(filename);
count= 1;
for t= 1:size(excelSheet,1)
R = rem(t,18);
if R==0
coor(count,1)=excelSheet(t,1) ;
count = count+1;
end
end
counter =1;
%Take imageSOPs and put them in imageSOP_UIDs matrix
%for t=1:size(excelSheet, 1)
fid = fopen ('nodules_features.txt', 'wt');
fid2 = fopen ('nodules_many_regions.txt', 'wt');
fprintf(fid,'%s,%s,%s,%s,%s,%s,%s,%s,%s \n','ImageName','Circularity','Roughness','Elongation','Compactness','Eccentricity','Solidity','Extent','RadialDistanceSD');
fprintf(fid2,'%s,%s,%s,%s,%s,%s,%s,%s,%s \n','ImageName','Circularity','Roughness','Elongation','Compactness','Eccentricity','Solidity','Extent','RadialDistanceSD');
for i=2:size(excelSheet, 1)
s1 = coor{i,:};
s2 = regexp(s1, '\|', 'split');
s2(:);
for j= 1:size(s2,2)
s3(j) = regexp(s2(j), '\;', 'split');
end
for k=1:size(s2,2)-1
c=s3{k};
y=c{1};
x=c{2};
x=str2num(x);
y=str2num(y);
b(k)=x;
d(k)=y;
a(1,k)=x-287;
a(2,k)=y-87;
end
maxx=0;
maxy=0;
minx=0;
miny=0;
%for c= 1:k
maxx= max(b);
maxy= max(d);
minx= min(b);
miny= min(d);
I= zeros((maxx-minx)+1,(maxy-miny)+1);
%end
for f=1:size(s2,2)-1
x=b(f)-minx;
y=d(f)-miny;
I(x+1,y+1)= 1;
end
I2=im2bw(I);
I3=imfill(I2,'holes');
%figure;
%imshow(I3);
%HERE GOES FEATURE CALCULATION STUFF
count = 0;
%for i = 1:size(files,1)
% fn = sprintf('%s/%s', 'segmented_nodules', char(files(i).name));
% fn2 = sprintf('%s/%s', 'segmented_background', char(files(i).name));
% info = dicominfo(fn);
% info4 = dicominfo(fn2);
% I = dicomread(info);
% I4 = dicomread(info4);
% BW = (I~=-2000);
L = bwlabel(I3);
a = L;
flag = 0;
if (nanmax(a(:)) > 1)
flag = 1;
end
a(a~=0 & a~=1) = 0;
STATS = regionprops (a,'Area', 'Extent', 'Perimeter', 'Centroid', 'ConvexArea', 'ConvexImage', 'Solidity', 'Eccentricity', 'MajorAxisLength', 'EquivDiameter', 'MinorAxisLength');
STATS.ConvexPerimeter = 2 * (sqrt(pi*STATS.ConvexArea));
STATS.Circularity = (4*pi*STATS.Area)/(STATS.ConvexPerimeter .^ 2);
STATS.Elongation = STATS.MajorAxisLength/STATS.MinorAxisLength;
% b = double(I);
% b(b==-2000) = NaN;
% b4 = double(I4);
% b4(b4==-2000) = NaN;
% STATS.MinIntensity = nanmin(b(:));
% STATS.MaxIntensity = nanmax(b(:));
% STATS.MeanIntensity = nanmean(b(:));
% STATS.SDIntensity = nanstd(b(:));
% STATS.MinIntensityBG = nanmin(b4(:));
% STATS.MaxIntensityBG = nanmax(b4(:));
% STATS.SDIntensityBG = nanstd(b4(:));
% STATS.MeanIntensityBG = nanmean(b4(:));
% STATS.IntensityDifference = abs(STATS.MeanIntensity - STATS.MeanIntensityBG);
% fprintf(files(i).name,',',STATS(1).Area,',', STATS(1).Extent,',', STATS(1).Perimeter,'\n');
% count = count+1
% fn2 = sprintf('%s/%s', 'contours', char(files(i).name));
% info2 = dicominfo(fn2);
% I2 = dicomread(info2);
d = NaN;
j = 0;
for r = 1:size(I3,1)
for c = 1:size(I3,2)
if (I2(r,c) == 1)
j = j + 1;
d(j) = sqrt(double((c-(STATS.Centroid(1)^2))+(r-(STATS.Centroid(2)^2))));
end
end
end
STATS.RadialDistanceSD = nanstd(d(:));
STATS.Perimeter = j;
I3 = bwperim(STATS.ConvexImage);
j = 0;
for r = 1:size(I3,1)
for c = 1:size(I3,2)
if (I3(r,c) == 1)
j = j + 1;
end
end
end
STATS.ConvexPerimeter = j;
STATS.Roughness = STATS.ConvexPerimeter/STATS.Perimeter;
STATS.Compactness = STATS.Perimeter^2/(4*pi*STATS.Area);
if (flag == 0)
fprintf(fid,'%s,%f,%f,%f,%f,%f,%f,%f,%f \n',files(i).name,STATS.Circularity,STATS.Roughness,STATS.Elongation,STATS.Compactness,STATS.Eccentricity,STATS.Solidity,STATS.Extent,STATS.RadialDistanceSD);
else
fprintf(fid2,'%s,%f,%f,%f,%f,%f,%f,%f,%f \n',files(i).name,STATS.Circularity,STATS.Roughness,STATS.Elongation,STATS.Compactness,STATS.Eccentricity,STATS.Solidity,STATS.Extent,STATS.RadialDistanceSD);
end
%end
clear I;
clear d;
clear b;
clear I3;
end
fclose(fid);
fclose(fid2);
%end